@mapfirst.ai/react 0.0.6 → 0.0.8
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/EXAMPLES.md +308 -0
- package/README.md +157 -1
- package/dist/index.d.mts +293 -4
- package/dist/index.d.ts +293 -4
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,205 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import * as _mapfirst_ai_core from '@mapfirst.ai/core';
|
|
3
|
+
import { PropertyType, PriceLevel, MapFirstCore, BaseMapFirstOptions, MapState, Property, MapLibreNamespace, GoogleMapsNamespace, MapboxNamespace, MapFirstOptions } from '@mapfirst.ai/core';
|
|
4
|
+
import * as React$1 from 'react';
|
|
5
|
+
import React__default, { FunctionComponent, CSSProperties, ReactNode } from 'react';
|
|
4
6
|
|
|
7
|
+
type Filter = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string | React.ReactNode;
|
|
10
|
+
type: "amenity" | "hotelStyle" | "priceRange" | "minRating" | "starRating" | "primary_type" | "transformed_query" | "selected_restaurant_price_levels";
|
|
11
|
+
value: string;
|
|
12
|
+
numericValue?: number;
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
priceRange?: PriceRangeValue;
|
|
15
|
+
propertyType?: PropertyType;
|
|
16
|
+
priceLevels?: PriceLevel[];
|
|
17
|
+
};
|
|
18
|
+
type PriceRangeValue = {
|
|
19
|
+
min?: number;
|
|
20
|
+
max?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
interface SmartFilterProps {
|
|
24
|
+
mapFirst: MapFirstCore | null;
|
|
25
|
+
filters: Filter[];
|
|
26
|
+
value?: string;
|
|
27
|
+
isSearching?: boolean;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
onSearch: (query: string, filters?: Filter[]) => Promise<void> | void;
|
|
30
|
+
onFilterChange: (filters: Filter[]) => Promise<void> | void;
|
|
31
|
+
onValueChange?: (value: string) => void;
|
|
32
|
+
showTypingPrompt?: boolean;
|
|
33
|
+
customTranslations?: Record<string, string>;
|
|
34
|
+
currency?: string;
|
|
35
|
+
style?: CSSProperties;
|
|
36
|
+
inputStyle?: CSSProperties;
|
|
37
|
+
containerStyle?: CSSProperties;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* SmartFilter component for AI-powered search with filter chips.
|
|
41
|
+
* Provides a search input with smart filtering capabilities.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const { mapFirst, state } = useMapFirstCore({ ... });
|
|
46
|
+
* const [filters, setFilters] = useState<Filter[]>([]);
|
|
47
|
+
* const [searchValue, setSearchValue] = useState("");
|
|
48
|
+
*
|
|
49
|
+
* const handleSearch = async (query: string, currentFilters?: Filter[]) => {
|
|
50
|
+
* // Perform search using mapFirst.runSmartFilterSearch
|
|
51
|
+
* const result = await mapFirst.runSmartFilterSearch({
|
|
52
|
+
* query,
|
|
53
|
+
* filters: currentFilters
|
|
54
|
+
* });
|
|
55
|
+
* // Update filters based on response
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* return (
|
|
59
|
+
* <SmartFilter
|
|
60
|
+
* mapFirst={mapFirst}
|
|
61
|
+
* filters={filters}
|
|
62
|
+
* value={searchValue}
|
|
63
|
+
* isSearching={state?.isSearching}
|
|
64
|
+
* onSearch={handleSearch}
|
|
65
|
+
* onFilterChange={setFilters}
|
|
66
|
+
* onValueChange={setSearchValue}
|
|
67
|
+
* />
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare const SmartFilter$1: FunctionComponent<SmartFilterProps>;
|
|
72
|
+
|
|
73
|
+
interface IconProps {
|
|
74
|
+
className?: string;
|
|
75
|
+
style?: CSSProperties;
|
|
76
|
+
}
|
|
77
|
+
declare const SearchIcon: React__default.FC<IconProps>;
|
|
78
|
+
declare const CloseIcon: React__default.FC<IconProps>;
|
|
79
|
+
declare const EditIcon: React__default.FC<IconProps>;
|
|
80
|
+
declare const NextIcon: React__default.FC<IconProps>;
|
|
81
|
+
declare const AiIcon: React__default.FC<IconProps>;
|
|
82
|
+
declare const StarIcon: React__default.FC<IconProps & {
|
|
83
|
+
fill?: string;
|
|
84
|
+
}>;
|
|
85
|
+
|
|
86
|
+
interface ChipProps {
|
|
87
|
+
label: string | ReactNode;
|
|
88
|
+
icon?: ReactNode;
|
|
89
|
+
remove: () => void;
|
|
90
|
+
style?: CSSProperties;
|
|
91
|
+
}
|
|
92
|
+
declare const Chip: React__default.FC<ChipProps>;
|
|
93
|
+
|
|
94
|
+
interface FilterChipsProps {
|
|
95
|
+
filters: Filter[];
|
|
96
|
+
isPortrait: boolean;
|
|
97
|
+
currency: string;
|
|
98
|
+
minRatingSuffix: string;
|
|
99
|
+
clearAllLabel: string;
|
|
100
|
+
previousFiltersLabel: string;
|
|
101
|
+
nextFiltersLabel: string;
|
|
102
|
+
formatCurrency: (value: number, currency?: string) => string;
|
|
103
|
+
onFilterChange: (filters: Filter[], clearAll?: boolean) => void | Promise<void>;
|
|
104
|
+
onResetFilters: () => void;
|
|
105
|
+
onClearAll: () => void;
|
|
106
|
+
}
|
|
107
|
+
declare const FilterChips: FunctionComponent<FilterChipsProps>;
|
|
108
|
+
|
|
109
|
+
declare const MinRatingFilterChip: FunctionComponent<{
|
|
110
|
+
star?: boolean;
|
|
111
|
+
rating: number;
|
|
112
|
+
onChange: (rating: number) => void;
|
|
113
|
+
onRemove: () => void;
|
|
114
|
+
}>;
|
|
115
|
+
|
|
116
|
+
declare const PriceRangeFilterChip: FunctionComponent<{
|
|
117
|
+
priceRange: PriceRangeValue;
|
|
118
|
+
currency: string;
|
|
119
|
+
onChange: (range: PriceRangeValue) => void;
|
|
120
|
+
onRemove: () => void;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
interface RestaurantPriceLevelChipProps {
|
|
124
|
+
values: PriceLevel[];
|
|
125
|
+
onChange: (values: PriceLevel[]) => void;
|
|
126
|
+
onRemove: () => void;
|
|
127
|
+
}
|
|
128
|
+
declare const RestaurantPriceLevelChip: FunctionComponent<RestaurantPriceLevelChipProps>;
|
|
129
|
+
|
|
130
|
+
interface TransformedQueryChipProps {
|
|
131
|
+
value: string;
|
|
132
|
+
onChange: (nextValue: string) => void;
|
|
133
|
+
onRemove: () => void;
|
|
134
|
+
}
|
|
135
|
+
declare const TransformedQueryChip: FunctionComponent<TransformedQueryChipProps>;
|
|
136
|
+
|
|
137
|
+
declare const renderStars: (rating: number) => ReactNode[];
|
|
138
|
+
declare const createMinRatingFilterLabel: (rating: number, suffix?: string) => ReactNode;
|
|
139
|
+
declare const formatRatingValue: (rating: number) => string;
|
|
140
|
+
declare const createPriceRangeFilterLabel: (min: number, max: number | undefined, currency: string | undefined, formatCurrencyFn: (value: number, currency?: string) => string) => string;
|
|
141
|
+
|
|
142
|
+
declare const useFilterScroll: (dependency: number) => {
|
|
143
|
+
scrollerRef: React$1.RefObject<HTMLDivElement | null>;
|
|
144
|
+
atStart: boolean;
|
|
145
|
+
atEnd: boolean;
|
|
146
|
+
scrollByDir: (dir: "prev" | "next") => void;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hook to detect if the viewport is in portrait orientation.
|
|
151
|
+
* Updates on window resize.
|
|
152
|
+
*/
|
|
153
|
+
declare const useIsPortrait: () => boolean;
|
|
154
|
+
|
|
155
|
+
type Locale = "en" | "es" | "de" | "fr" | "it" | "pt";
|
|
156
|
+
type TranslationFunction = (key: string, params?: Record<string, any>) => string;
|
|
157
|
+
type FormatCurrencyFunction = (value: number, currency?: string) => string;
|
|
158
|
+
/**
|
|
159
|
+
* Simple translation hook with default English translations.
|
|
160
|
+
* Can be extended with custom translations and locales.
|
|
161
|
+
*/
|
|
162
|
+
declare const useTranslation: (customTranslations?: Record<string, string>, customFormatCurrency?: FormatCurrencyFunction) => {
|
|
163
|
+
t: TranslationFunction;
|
|
164
|
+
locale: Locale;
|
|
165
|
+
setLocale: React$1.Dispatch<React$1.SetStateAction<Locale>>;
|
|
166
|
+
formatCurrency: (value: number, currency?: string) => string;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
type InitialRequestBody = {
|
|
170
|
+
initial?: boolean;
|
|
171
|
+
query?: string;
|
|
172
|
+
bounds?: {
|
|
173
|
+
sw: {
|
|
174
|
+
lat: number;
|
|
175
|
+
lng: number;
|
|
176
|
+
};
|
|
177
|
+
ne: {
|
|
178
|
+
lat: number;
|
|
179
|
+
lng: number;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
filters?: any;
|
|
183
|
+
city?: string;
|
|
184
|
+
country?: string;
|
|
185
|
+
location_id?: number;
|
|
186
|
+
longitude?: number;
|
|
187
|
+
latitude?: number;
|
|
188
|
+
radius?: number;
|
|
189
|
+
};
|
|
190
|
+
type SmartFilter = {
|
|
191
|
+
id: string;
|
|
192
|
+
label: string;
|
|
193
|
+
type: "amenity" | "hotelStyle" | "priceRange" | "minRating" | "starRating" | "primary_type" | "transformed_query" | "selected_restaurant_price_levels";
|
|
194
|
+
value: string;
|
|
195
|
+
numericValue?: number;
|
|
196
|
+
priceRange?: {
|
|
197
|
+
min: number;
|
|
198
|
+
max?: number;
|
|
199
|
+
};
|
|
200
|
+
propertyType?: PropertyType;
|
|
201
|
+
priceLevels?: any[];
|
|
202
|
+
};
|
|
5
203
|
/**
|
|
6
204
|
* Hook that creates a MapFirstCore instance that can be initialized before maps are ready.
|
|
7
205
|
* Supports two-phase initialization: create SDK first, attach map later.
|
|
@@ -187,7 +385,98 @@ declare function useMapboxAttachment({ mapFirst, map, mapboxgl, onMarkerClick, }
|
|
|
187
385
|
*
|
|
188
386
|
* @deprecated Use useMapFirstCore and platform-specific attachment hooks instead
|
|
189
387
|
*/
|
|
190
|
-
declare function useMapFirst(options: MapFirstOptions | null):
|
|
388
|
+
declare function useMapFirst(options: MapFirstOptions | null): React__default.RefObject<MapFirstCore | null>;
|
|
389
|
+
/**
|
|
390
|
+
* Hook to run properties search with the MapFirst SDK.
|
|
391
|
+
* Returns a function to trigger the search and loading state.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```tsx
|
|
395
|
+
* const { mapFirst } = useMapFirstCore({ ... });
|
|
396
|
+
* const { search, isLoading, error } = usePropertiesSearch(mapFirst);
|
|
397
|
+
*
|
|
398
|
+
* const handleSearch = async () => {
|
|
399
|
+
* await search({
|
|
400
|
+
* body: {
|
|
401
|
+
* city: "Paris",
|
|
402
|
+
* country: "France",
|
|
403
|
+
* filters: {
|
|
404
|
+
* checkIn: new Date(),
|
|
405
|
+
* checkOut: new Date(Date.now() + 86400000),
|
|
406
|
+
* numAdults: 2,
|
|
407
|
+
* numRooms: 1
|
|
408
|
+
* }
|
|
409
|
+
* }
|
|
410
|
+
* });
|
|
411
|
+
* };
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
declare function usePropertiesSearch(mapFirst: MapFirstCore | null): {
|
|
415
|
+
search: (options: {
|
|
416
|
+
body: InitialRequestBody;
|
|
417
|
+
beforeApplyProperties?: (data: any) => {
|
|
418
|
+
price?: any;
|
|
419
|
+
limit?: number;
|
|
420
|
+
};
|
|
421
|
+
smartFiltersClearable?: boolean;
|
|
422
|
+
}) => Promise<{
|
|
423
|
+
location_id?: number;
|
|
424
|
+
filters: _mapfirst_ai_core.FilterSchema;
|
|
425
|
+
properties: Property[];
|
|
426
|
+
isComplete: boolean | undefined;
|
|
427
|
+
pollingLink: string | undefined;
|
|
428
|
+
durationSeconds: number;
|
|
429
|
+
} | null>;
|
|
430
|
+
isLoading: boolean;
|
|
431
|
+
error: Error | null;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Hook to run smart filter search with the MapFirst SDK.
|
|
435
|
+
* Returns a function to trigger the search and loading state.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```tsx
|
|
439
|
+
* const { mapFirst } = useMapFirstCore({ ... });
|
|
440
|
+
* const { search, isLoading, error } = useSmartFilterSearch(mapFirst);
|
|
441
|
+
*
|
|
442
|
+
* const handleSearch = async () => {
|
|
443
|
+
* await search({
|
|
444
|
+
* query: "hotels near beach with pool"
|
|
445
|
+
* });
|
|
446
|
+
* };
|
|
447
|
+
*
|
|
448
|
+
* // Or with filters
|
|
449
|
+
* const handleFilterSearch = async () => {
|
|
450
|
+
* await search({
|
|
451
|
+
* filters: [
|
|
452
|
+
* { id: "pool", label: "Pool", type: "amenity", value: "pool" },
|
|
453
|
+
* { id: "4star", label: "4 Star", type: "starRating", value: "4", numericValue: 4 }
|
|
454
|
+
* ]
|
|
455
|
+
* });
|
|
456
|
+
* };
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
declare function useSmartFilterSearch(mapFirst: MapFirstCore | null): {
|
|
460
|
+
search: (options: {
|
|
461
|
+
query?: string;
|
|
462
|
+
filters?: SmartFilter[];
|
|
463
|
+
onProcessFilters?: (filters: any, location_id?: number) => {
|
|
464
|
+
smartFilters?: SmartFilter[];
|
|
465
|
+
price?: any;
|
|
466
|
+
limit?: number;
|
|
467
|
+
language?: string;
|
|
468
|
+
};
|
|
469
|
+
}) => Promise<{
|
|
470
|
+
location_id?: number;
|
|
471
|
+
filters: _mapfirst_ai_core.FilterSchema;
|
|
472
|
+
properties: Property[];
|
|
473
|
+
isComplete: boolean | undefined;
|
|
474
|
+
pollingLink: string | undefined;
|
|
475
|
+
durationSeconds: number;
|
|
476
|
+
} | null>;
|
|
477
|
+
isLoading: boolean;
|
|
478
|
+
error: Error | null;
|
|
479
|
+
};
|
|
191
480
|
/**
|
|
192
481
|
* Helper component that simply renders the markers it receives so non-React environments
|
|
193
482
|
* can verify data flows before wiring the SDK into a map.
|
|
@@ -196,4 +485,4 @@ declare function MarkerDebugList({ markers }: {
|
|
|
196
485
|
markers: Property[];
|
|
197
486
|
}): react_jsx_runtime.JSX.Element;
|
|
198
487
|
|
|
199
|
-
export { MarkerDebugList, useGoogleMapsAttachment, useMapFirst, useMapFirstCore, useMapFirstProperties, useMapFirstSelectedProperty, useMapLibreAttachment, useMapboxAttachment, usePrimaryType, useSelectedMarker };
|
|
488
|
+
export { AiIcon, Chip, type ChipProps, CloseIcon, EditIcon, type Filter, FilterChips, type FilterChipsProps, type IconProps, type Locale, MarkerDebugList, MinRatingFilterChip, NextIcon, PriceRangeFilterChip, type PriceRangeValue, RestaurantPriceLevelChip, type RestaurantPriceLevelChipProps, SearchIcon, SmartFilter$1 as SmartFilter, type SmartFilterProps, StarIcon, TransformedQueryChip, type TransformedQueryChipProps, createMinRatingFilterLabel, createPriceRangeFilterLabel, formatRatingValue, renderStars, useFilterScroll, useGoogleMapsAttachment, useIsPortrait, useMapFirst, useMapFirstCore, useMapFirstProperties, useMapFirstSelectedProperty, useMapLibreAttachment, useMapboxAttachment, usePrimaryType, usePropertiesSearch, useSelectedMarker, useSmartFilterSearch, useTranslation };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,205 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import * as _mapfirst_ai_core from '@mapfirst.ai/core';
|
|
3
|
+
import { PropertyType, PriceLevel, MapFirstCore, BaseMapFirstOptions, MapState, Property, MapLibreNamespace, GoogleMapsNamespace, MapboxNamespace, MapFirstOptions } from '@mapfirst.ai/core';
|
|
4
|
+
import * as React$1 from 'react';
|
|
5
|
+
import React__default, { FunctionComponent, CSSProperties, ReactNode } from 'react';
|
|
4
6
|
|
|
7
|
+
type Filter = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string | React.ReactNode;
|
|
10
|
+
type: "amenity" | "hotelStyle" | "priceRange" | "minRating" | "starRating" | "primary_type" | "transformed_query" | "selected_restaurant_price_levels";
|
|
11
|
+
value: string;
|
|
12
|
+
numericValue?: number;
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
priceRange?: PriceRangeValue;
|
|
15
|
+
propertyType?: PropertyType;
|
|
16
|
+
priceLevels?: PriceLevel[];
|
|
17
|
+
};
|
|
18
|
+
type PriceRangeValue = {
|
|
19
|
+
min?: number;
|
|
20
|
+
max?: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
interface SmartFilterProps {
|
|
24
|
+
mapFirst: MapFirstCore | null;
|
|
25
|
+
filters: Filter[];
|
|
26
|
+
value?: string;
|
|
27
|
+
isSearching?: boolean;
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
onSearch: (query: string, filters?: Filter[]) => Promise<void> | void;
|
|
30
|
+
onFilterChange: (filters: Filter[]) => Promise<void> | void;
|
|
31
|
+
onValueChange?: (value: string) => void;
|
|
32
|
+
showTypingPrompt?: boolean;
|
|
33
|
+
customTranslations?: Record<string, string>;
|
|
34
|
+
currency?: string;
|
|
35
|
+
style?: CSSProperties;
|
|
36
|
+
inputStyle?: CSSProperties;
|
|
37
|
+
containerStyle?: CSSProperties;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* SmartFilter component for AI-powered search with filter chips.
|
|
41
|
+
* Provides a search input with smart filtering capabilities.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* const { mapFirst, state } = useMapFirstCore({ ... });
|
|
46
|
+
* const [filters, setFilters] = useState<Filter[]>([]);
|
|
47
|
+
* const [searchValue, setSearchValue] = useState("");
|
|
48
|
+
*
|
|
49
|
+
* const handleSearch = async (query: string, currentFilters?: Filter[]) => {
|
|
50
|
+
* // Perform search using mapFirst.runSmartFilterSearch
|
|
51
|
+
* const result = await mapFirst.runSmartFilterSearch({
|
|
52
|
+
* query,
|
|
53
|
+
* filters: currentFilters
|
|
54
|
+
* });
|
|
55
|
+
* // Update filters based on response
|
|
56
|
+
* };
|
|
57
|
+
*
|
|
58
|
+
* return (
|
|
59
|
+
* <SmartFilter
|
|
60
|
+
* mapFirst={mapFirst}
|
|
61
|
+
* filters={filters}
|
|
62
|
+
* value={searchValue}
|
|
63
|
+
* isSearching={state?.isSearching}
|
|
64
|
+
* onSearch={handleSearch}
|
|
65
|
+
* onFilterChange={setFilters}
|
|
66
|
+
* onValueChange={setSearchValue}
|
|
67
|
+
* />
|
|
68
|
+
* );
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare const SmartFilter$1: FunctionComponent<SmartFilterProps>;
|
|
72
|
+
|
|
73
|
+
interface IconProps {
|
|
74
|
+
className?: string;
|
|
75
|
+
style?: CSSProperties;
|
|
76
|
+
}
|
|
77
|
+
declare const SearchIcon: React__default.FC<IconProps>;
|
|
78
|
+
declare const CloseIcon: React__default.FC<IconProps>;
|
|
79
|
+
declare const EditIcon: React__default.FC<IconProps>;
|
|
80
|
+
declare const NextIcon: React__default.FC<IconProps>;
|
|
81
|
+
declare const AiIcon: React__default.FC<IconProps>;
|
|
82
|
+
declare const StarIcon: React__default.FC<IconProps & {
|
|
83
|
+
fill?: string;
|
|
84
|
+
}>;
|
|
85
|
+
|
|
86
|
+
interface ChipProps {
|
|
87
|
+
label: string | ReactNode;
|
|
88
|
+
icon?: ReactNode;
|
|
89
|
+
remove: () => void;
|
|
90
|
+
style?: CSSProperties;
|
|
91
|
+
}
|
|
92
|
+
declare const Chip: React__default.FC<ChipProps>;
|
|
93
|
+
|
|
94
|
+
interface FilterChipsProps {
|
|
95
|
+
filters: Filter[];
|
|
96
|
+
isPortrait: boolean;
|
|
97
|
+
currency: string;
|
|
98
|
+
minRatingSuffix: string;
|
|
99
|
+
clearAllLabel: string;
|
|
100
|
+
previousFiltersLabel: string;
|
|
101
|
+
nextFiltersLabel: string;
|
|
102
|
+
formatCurrency: (value: number, currency?: string) => string;
|
|
103
|
+
onFilterChange: (filters: Filter[], clearAll?: boolean) => void | Promise<void>;
|
|
104
|
+
onResetFilters: () => void;
|
|
105
|
+
onClearAll: () => void;
|
|
106
|
+
}
|
|
107
|
+
declare const FilterChips: FunctionComponent<FilterChipsProps>;
|
|
108
|
+
|
|
109
|
+
declare const MinRatingFilterChip: FunctionComponent<{
|
|
110
|
+
star?: boolean;
|
|
111
|
+
rating: number;
|
|
112
|
+
onChange: (rating: number) => void;
|
|
113
|
+
onRemove: () => void;
|
|
114
|
+
}>;
|
|
115
|
+
|
|
116
|
+
declare const PriceRangeFilterChip: FunctionComponent<{
|
|
117
|
+
priceRange: PriceRangeValue;
|
|
118
|
+
currency: string;
|
|
119
|
+
onChange: (range: PriceRangeValue) => void;
|
|
120
|
+
onRemove: () => void;
|
|
121
|
+
}>;
|
|
122
|
+
|
|
123
|
+
interface RestaurantPriceLevelChipProps {
|
|
124
|
+
values: PriceLevel[];
|
|
125
|
+
onChange: (values: PriceLevel[]) => void;
|
|
126
|
+
onRemove: () => void;
|
|
127
|
+
}
|
|
128
|
+
declare const RestaurantPriceLevelChip: FunctionComponent<RestaurantPriceLevelChipProps>;
|
|
129
|
+
|
|
130
|
+
interface TransformedQueryChipProps {
|
|
131
|
+
value: string;
|
|
132
|
+
onChange: (nextValue: string) => void;
|
|
133
|
+
onRemove: () => void;
|
|
134
|
+
}
|
|
135
|
+
declare const TransformedQueryChip: FunctionComponent<TransformedQueryChipProps>;
|
|
136
|
+
|
|
137
|
+
declare const renderStars: (rating: number) => ReactNode[];
|
|
138
|
+
declare const createMinRatingFilterLabel: (rating: number, suffix?: string) => ReactNode;
|
|
139
|
+
declare const formatRatingValue: (rating: number) => string;
|
|
140
|
+
declare const createPriceRangeFilterLabel: (min: number, max: number | undefined, currency: string | undefined, formatCurrencyFn: (value: number, currency?: string) => string) => string;
|
|
141
|
+
|
|
142
|
+
declare const useFilterScroll: (dependency: number) => {
|
|
143
|
+
scrollerRef: React$1.RefObject<HTMLDivElement | null>;
|
|
144
|
+
atStart: boolean;
|
|
145
|
+
atEnd: boolean;
|
|
146
|
+
scrollByDir: (dir: "prev" | "next") => void;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Hook to detect if the viewport is in portrait orientation.
|
|
151
|
+
* Updates on window resize.
|
|
152
|
+
*/
|
|
153
|
+
declare const useIsPortrait: () => boolean;
|
|
154
|
+
|
|
155
|
+
type Locale = "en" | "es" | "de" | "fr" | "it" | "pt";
|
|
156
|
+
type TranslationFunction = (key: string, params?: Record<string, any>) => string;
|
|
157
|
+
type FormatCurrencyFunction = (value: number, currency?: string) => string;
|
|
158
|
+
/**
|
|
159
|
+
* Simple translation hook with default English translations.
|
|
160
|
+
* Can be extended with custom translations and locales.
|
|
161
|
+
*/
|
|
162
|
+
declare const useTranslation: (customTranslations?: Record<string, string>, customFormatCurrency?: FormatCurrencyFunction) => {
|
|
163
|
+
t: TranslationFunction;
|
|
164
|
+
locale: Locale;
|
|
165
|
+
setLocale: React$1.Dispatch<React$1.SetStateAction<Locale>>;
|
|
166
|
+
formatCurrency: (value: number, currency?: string) => string;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
type InitialRequestBody = {
|
|
170
|
+
initial?: boolean;
|
|
171
|
+
query?: string;
|
|
172
|
+
bounds?: {
|
|
173
|
+
sw: {
|
|
174
|
+
lat: number;
|
|
175
|
+
lng: number;
|
|
176
|
+
};
|
|
177
|
+
ne: {
|
|
178
|
+
lat: number;
|
|
179
|
+
lng: number;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
filters?: any;
|
|
183
|
+
city?: string;
|
|
184
|
+
country?: string;
|
|
185
|
+
location_id?: number;
|
|
186
|
+
longitude?: number;
|
|
187
|
+
latitude?: number;
|
|
188
|
+
radius?: number;
|
|
189
|
+
};
|
|
190
|
+
type SmartFilter = {
|
|
191
|
+
id: string;
|
|
192
|
+
label: string;
|
|
193
|
+
type: "amenity" | "hotelStyle" | "priceRange" | "minRating" | "starRating" | "primary_type" | "transformed_query" | "selected_restaurant_price_levels";
|
|
194
|
+
value: string;
|
|
195
|
+
numericValue?: number;
|
|
196
|
+
priceRange?: {
|
|
197
|
+
min: number;
|
|
198
|
+
max?: number;
|
|
199
|
+
};
|
|
200
|
+
propertyType?: PropertyType;
|
|
201
|
+
priceLevels?: any[];
|
|
202
|
+
};
|
|
5
203
|
/**
|
|
6
204
|
* Hook that creates a MapFirstCore instance that can be initialized before maps are ready.
|
|
7
205
|
* Supports two-phase initialization: create SDK first, attach map later.
|
|
@@ -187,7 +385,98 @@ declare function useMapboxAttachment({ mapFirst, map, mapboxgl, onMarkerClick, }
|
|
|
187
385
|
*
|
|
188
386
|
* @deprecated Use useMapFirstCore and platform-specific attachment hooks instead
|
|
189
387
|
*/
|
|
190
|
-
declare function useMapFirst(options: MapFirstOptions | null):
|
|
388
|
+
declare function useMapFirst(options: MapFirstOptions | null): React__default.RefObject<MapFirstCore | null>;
|
|
389
|
+
/**
|
|
390
|
+
* Hook to run properties search with the MapFirst SDK.
|
|
391
|
+
* Returns a function to trigger the search and loading state.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```tsx
|
|
395
|
+
* const { mapFirst } = useMapFirstCore({ ... });
|
|
396
|
+
* const { search, isLoading, error } = usePropertiesSearch(mapFirst);
|
|
397
|
+
*
|
|
398
|
+
* const handleSearch = async () => {
|
|
399
|
+
* await search({
|
|
400
|
+
* body: {
|
|
401
|
+
* city: "Paris",
|
|
402
|
+
* country: "France",
|
|
403
|
+
* filters: {
|
|
404
|
+
* checkIn: new Date(),
|
|
405
|
+
* checkOut: new Date(Date.now() + 86400000),
|
|
406
|
+
* numAdults: 2,
|
|
407
|
+
* numRooms: 1
|
|
408
|
+
* }
|
|
409
|
+
* }
|
|
410
|
+
* });
|
|
411
|
+
* };
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
declare function usePropertiesSearch(mapFirst: MapFirstCore | null): {
|
|
415
|
+
search: (options: {
|
|
416
|
+
body: InitialRequestBody;
|
|
417
|
+
beforeApplyProperties?: (data: any) => {
|
|
418
|
+
price?: any;
|
|
419
|
+
limit?: number;
|
|
420
|
+
};
|
|
421
|
+
smartFiltersClearable?: boolean;
|
|
422
|
+
}) => Promise<{
|
|
423
|
+
location_id?: number;
|
|
424
|
+
filters: _mapfirst_ai_core.FilterSchema;
|
|
425
|
+
properties: Property[];
|
|
426
|
+
isComplete: boolean | undefined;
|
|
427
|
+
pollingLink: string | undefined;
|
|
428
|
+
durationSeconds: number;
|
|
429
|
+
} | null>;
|
|
430
|
+
isLoading: boolean;
|
|
431
|
+
error: Error | null;
|
|
432
|
+
};
|
|
433
|
+
/**
|
|
434
|
+
* Hook to run smart filter search with the MapFirst SDK.
|
|
435
|
+
* Returns a function to trigger the search and loading state.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```tsx
|
|
439
|
+
* const { mapFirst } = useMapFirstCore({ ... });
|
|
440
|
+
* const { search, isLoading, error } = useSmartFilterSearch(mapFirst);
|
|
441
|
+
*
|
|
442
|
+
* const handleSearch = async () => {
|
|
443
|
+
* await search({
|
|
444
|
+
* query: "hotels near beach with pool"
|
|
445
|
+
* });
|
|
446
|
+
* };
|
|
447
|
+
*
|
|
448
|
+
* // Or with filters
|
|
449
|
+
* const handleFilterSearch = async () => {
|
|
450
|
+
* await search({
|
|
451
|
+
* filters: [
|
|
452
|
+
* { id: "pool", label: "Pool", type: "amenity", value: "pool" },
|
|
453
|
+
* { id: "4star", label: "4 Star", type: "starRating", value: "4", numericValue: 4 }
|
|
454
|
+
* ]
|
|
455
|
+
* });
|
|
456
|
+
* };
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
declare function useSmartFilterSearch(mapFirst: MapFirstCore | null): {
|
|
460
|
+
search: (options: {
|
|
461
|
+
query?: string;
|
|
462
|
+
filters?: SmartFilter[];
|
|
463
|
+
onProcessFilters?: (filters: any, location_id?: number) => {
|
|
464
|
+
smartFilters?: SmartFilter[];
|
|
465
|
+
price?: any;
|
|
466
|
+
limit?: number;
|
|
467
|
+
language?: string;
|
|
468
|
+
};
|
|
469
|
+
}) => Promise<{
|
|
470
|
+
location_id?: number;
|
|
471
|
+
filters: _mapfirst_ai_core.FilterSchema;
|
|
472
|
+
properties: Property[];
|
|
473
|
+
isComplete: boolean | undefined;
|
|
474
|
+
pollingLink: string | undefined;
|
|
475
|
+
durationSeconds: number;
|
|
476
|
+
} | null>;
|
|
477
|
+
isLoading: boolean;
|
|
478
|
+
error: Error | null;
|
|
479
|
+
};
|
|
191
480
|
/**
|
|
192
481
|
* Helper component that simply renders the markers it receives so non-React environments
|
|
193
482
|
* can verify data flows before wiring the SDK into a map.
|
|
@@ -196,4 +485,4 @@ declare function MarkerDebugList({ markers }: {
|
|
|
196
485
|
markers: Property[];
|
|
197
486
|
}): react_jsx_runtime.JSX.Element;
|
|
198
487
|
|
|
199
|
-
export { MarkerDebugList, useGoogleMapsAttachment, useMapFirst, useMapFirstCore, useMapFirstProperties, useMapFirstSelectedProperty, useMapLibreAttachment, useMapboxAttachment, usePrimaryType, useSelectedMarker };
|
|
488
|
+
export { AiIcon, Chip, type ChipProps, CloseIcon, EditIcon, type Filter, FilterChips, type FilterChipsProps, type IconProps, type Locale, MarkerDebugList, MinRatingFilterChip, NextIcon, PriceRangeFilterChip, type PriceRangeValue, RestaurantPriceLevelChip, type RestaurantPriceLevelChipProps, SearchIcon, SmartFilter$1 as SmartFilter, type SmartFilterProps, StarIcon, TransformedQueryChip, type TransformedQueryChipProps, createMinRatingFilterLabel, createPriceRangeFilterLabel, formatRatingValue, renderStars, useFilterScroll, useGoogleMapsAttachment, useIsPortrait, useMapFirst, useMapFirstCore, useMapFirstProperties, useMapFirstSelectedProperty, useMapLibreAttachment, useMapboxAttachment, usePrimaryType, usePropertiesSearch, useSelectedMarker, useSmartFilterSearch, useTranslation };
|