@garagem-ai/site-sdk 0.4.0 → 0.4.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.
- package/README.md +41 -8
- package/dist/index.d.mts +7 -58
- package/dist/index.d.ts +7 -58
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +57 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +33 -6
- package/dist/react.d.ts +33 -6
- package/dist/react.js +517 -463
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +515 -462
- package/dist/react.mjs.map +1 -1
- package/dist/{listing-card-model-D7iR4asd.d.mts → search-engine-D4EZkNrQ.d.mts} +67 -1
- package/dist/{listing-card-model-D7iR4asd.d.ts → search-engine-D4EZkNrQ.d.ts} +67 -1
- package/package.json +9 -4
- package/src/index.ts +2 -0
- package/src/presentation.ts +7 -0
- package/src/react/filter-panel.tsx +39 -42
- package/src/react/icons.tsx +46 -0
- package/src/react/index.ts +7 -1
- package/src/react/listing-card.tsx +14 -71
- package/src/react/search-chrome.tsx +24 -23
- package/src/react/search-page.tsx +210 -111
- package/src/react/search-pagination.tsx +50 -40
- package/src/react/search-query-form.tsx +31 -26
- package/src/react/search.css +717 -0
- package/src/react/styles/index.ts +1 -0
- package/src/react/styles/search-chrome-css.generated.ts +5 -0
- package/src/react/styles/search-chrome-styles.tsx +12 -0
- package/src/react/types.ts +18 -0
- package/src/react/use-public-search.ts +7 -0
- package/src/search-engine.ts +79 -0
package/README.md
CHANGED
|
@@ -247,23 +247,56 @@ Headless URL/search helpers live on the main entry (`readPublicSearch`,
|
|
|
247
247
|
`hrefForPathFilters`, `toListingCardModel`, …). The React adapter is a
|
|
248
248
|
separate subpath — peer `react` + `next`:
|
|
249
249
|
|
|
250
|
+
```tsx
|
|
251
|
+
import { SearchChromeStyles } from "@garagem-ai/site-sdk/react";
|
|
252
|
+
|
|
253
|
+
export default function RootLayout({
|
|
254
|
+
children,
|
|
255
|
+
}: {
|
|
256
|
+
children: React.ReactNode;
|
|
257
|
+
}) {
|
|
258
|
+
return (
|
|
259
|
+
<html lang="pt-BR">
|
|
260
|
+
<body>
|
|
261
|
+
<SearchChromeStyles />
|
|
262
|
+
{children}
|
|
263
|
+
</body>
|
|
264
|
+
</html>
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
250
269
|
```tsx
|
|
251
270
|
"use client";
|
|
252
|
-
import {
|
|
271
|
+
import { Suspense } from "react";
|
|
272
|
+
import { SearchPage, SearchPageFallback } from "@garagem-ai/site-sdk/react";
|
|
253
273
|
|
|
254
274
|
export default function ImoveisPage() {
|
|
255
275
|
return (
|
|
256
|
-
<
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
276
|
+
<Suspense fallback={<SearchPageFallback />}>
|
|
277
|
+
<SearchPage
|
|
278
|
+
siteId={process.env.NEXT_PUBLIC_GARAGEM_SITE_ID!}
|
|
279
|
+
variant="toolbar"
|
|
280
|
+
/>
|
|
281
|
+
</Suspense>
|
|
260
282
|
);
|
|
261
283
|
}
|
|
262
284
|
```
|
|
263
285
|
|
|
264
|
-
`variant` is `toolbar` (default), `dialog`, or `sidebar`.
|
|
265
|
-
|
|
266
|
-
|
|
286
|
+
`variant` is `toolbar` (default), `dialog`, or `sidebar`. Studio and v0
|
|
287
|
+
preview must use `SearchChromeStyles` (a JS module that emits a `<style>`
|
|
288
|
+
tag). Do not `import "@garagem-ai/site-sdk/react/search.css"` in generated
|
|
289
|
+
Studio apps — the preview ESM CDN cannot load npm CSS. That file export
|
|
290
|
+
remains for plain Next consumers who prefer a CSS import.
|
|
291
|
+
|
|
292
|
+
`SearchPage` and `SearchPageFallback` also emit the sheet if the layout
|
|
293
|
+
omits `SearchChromeStyles`. Home listing cards still need the layout tag
|
|
294
|
+
(or a parent that renders it). Customize with CSS variables
|
|
295
|
+
(`SEARCH_CSS_VARS` / `SEARCH_CSS_RECIPE` in `globals.css`), `classNames`,
|
|
296
|
+
`icons`, and `data-slot`. Home and search should share `ListingCard`.
|
|
297
|
+
The search H1 is SEO stable: hit count is a sibling `<span>`, not inside
|
|
298
|
+
`<h1>`. Presentation tokens stay framework-free on the main entry so
|
|
299
|
+
other adapters can reuse them.
|
|
267
300
|
|
|
268
301
|
## What's NOT in this release
|
|
269
302
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters, k as SearchUiDictionary, l as QueryListingsFilters, A as AppliedSearchQuery, m as AppliedSearchChange } from './search-engine-D4EZkNrQ.mjs';
|
|
2
|
+
export { n as CmsEntryStatus, o as CmsFieldDefinition, p as CmsFieldType, q as CmsSeoData, F as FORBIDDEN_SEARCH_QUERY_KEYS, r as Listing, s as ListingBusinessType, t as ListingCardModel, u as ListingLocation, v as ListingMedia, w as ListingPriceVisibility, x as ListingPropertySummary, y as LocationNameTables, z as QueryListingsLocation, B as SEARCH_SORT_RELEVANCE, D as SearchPathLocation, E as SearchUiFilter, G as SearchUiOption, T as TOOLBAR_PRIMARY_FILTER_IDS, H as applyPathFilter, I as buildQueryListingsParams, J as canonicalizeSearchHref, K as clearStagedPathFilters, M as countFacetChoices, N as countOptionLabel, O as displayPathLocation, P as hrefForAppliedChange, U as hrefForPathFilters, V as hrefWithExplicitPage, W as isListingDetailPath, X as listingLocationLabel, Y as paginationPages, Z as pathFilterHasOption, _ as pathFilterValue, $ as publicSearchHref, a0 as readPublicSearch, a1 as searchHrefUsesLegacyFilterQuery, a2 as searchResultsHeading, a3 as searchSortOptions, a4 as toListingCardModel, a5 as toolbarFilterIds, a6 as visibleSearchFilters } from './search-engine-D4EZkNrQ.mjs';
|
|
3
3
|
|
|
4
4
|
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
5
5
|
type FetchLike = typeof fetch;
|
|
@@ -165,7 +165,11 @@ declare const SEARCH_CSS_VARS: {
|
|
|
165
165
|
readonly cardGap: "--garagem-listing-card-gap";
|
|
166
166
|
readonly priceSize: "--garagem-listing-price-size";
|
|
167
167
|
readonly mediaRatio: "--garagem-listing-media-ratio";
|
|
168
|
+
readonly controlHeight: "--garagem-search-control-height";
|
|
169
|
+
readonly iconSize: "--garagem-search-icon-size";
|
|
170
|
+
readonly skeleton: "--garagem-skeleton";
|
|
168
171
|
};
|
|
172
|
+
/** Paste into generated `globals.css` to override tokens. Layout lives in the chrome artifact. */
|
|
169
173
|
declare const SEARCH_CSS_RECIPE: string;
|
|
170
174
|
declare function formatListingPrice(amount: number | null | undefined, locale?: string, currency?: string): string;
|
|
171
175
|
/** Input mask: `499000` → `"499.000"` (no currency symbol). */
|
|
@@ -175,61 +179,6 @@ declare function parseGroupedInteger(value: unknown): number | undefined;
|
|
|
175
179
|
declare function formatAreaM2(area: number | null | undefined): string | null;
|
|
176
180
|
declare function listingBusinessLabel(businessType: string | undefined): string;
|
|
177
181
|
|
|
178
|
-
/** Query keys that must never encode filters (Editor/Studio path contract). */
|
|
179
|
-
declare const FORBIDDEN_SEARCH_QUERY_KEYS: readonly ["tipo", "quartos", "tipo-imovel", "banheiros", "vagas"];
|
|
180
|
-
/** Default option: omit `ordenar` (API has no relevance token). */
|
|
181
|
-
declare const SEARCH_SORT_RELEVANCE: {
|
|
182
|
-
readonly id: "";
|
|
183
|
-
readonly label: "Mais relevantes";
|
|
184
|
-
};
|
|
185
|
-
declare function searchSortOptions(sorts: Array<{
|
|
186
|
-
id: string;
|
|
187
|
-
label: string;
|
|
188
|
-
}> | undefined): Array<{
|
|
189
|
-
id: string;
|
|
190
|
-
label: string;
|
|
191
|
-
}>;
|
|
192
|
-
/** Toolbar: price + bedrooms first and required when the schema has them. */
|
|
193
|
-
declare const TOOLBAR_PRIMARY_FILTER_IDS: readonly ["price", "property_bedrooms"];
|
|
194
|
-
declare function isListingDetailPath(pathname: string): boolean;
|
|
195
|
-
declare function readPublicSearch(pathname: string, search: string, dictionary?: SearchUiDictionary): {
|
|
196
|
-
pathFilters: SearchPathFilters;
|
|
197
|
-
applied: AppliedSearchQuery;
|
|
198
|
-
};
|
|
199
|
-
type LocationNameTables = {
|
|
200
|
-
states?: Record<string, string>;
|
|
201
|
-
cities?: Record<string, string>;
|
|
202
|
-
neighborhoods?: Record<string, string>;
|
|
203
|
-
streets?: Record<string, string>;
|
|
204
|
-
};
|
|
205
|
-
declare function displayPathLocation(location: SearchPathFilters["location"], values?: LocationNameTables | null): SearchPathFilters["location"] | null;
|
|
206
|
-
declare function buildQueryListingsParams(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, schema: Pick<SearchUi, "defaultLimit"> | {
|
|
207
|
-
defaultLimit?: number;
|
|
208
|
-
} | null, locationValues?: LocationNameTables | null): QueryListingsParams;
|
|
209
|
-
declare function applyPathFilter(pathFilters: SearchPathFilters, filterId: string, value: unknown): SearchPathFilters;
|
|
210
|
-
declare function pathFilterValue(pathFilters: SearchPathFilters | undefined, filterId: string): string;
|
|
211
|
-
declare function pathFilterHasOption(pathFilters: SearchPathFilters | undefined, filterId: string, optionId: string): boolean;
|
|
212
|
-
declare function publicSearchHref(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, dictionary?: SearchUiDictionary, existingSearch?: string): string;
|
|
213
|
-
declare function hrefForPathFilters(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, nextPathFilters: SearchPathFilters): string;
|
|
214
|
-
declare function hrefForAppliedChange(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, change: AppliedSearchChange): string;
|
|
215
|
-
/** Canonical href if the current URL is out of generation order; otherwise null. */
|
|
216
|
-
declare function canonicalizeSearchHref(pathname: string, search: string, dictionary?: SearchUiDictionary): string | null;
|
|
217
|
-
declare function searchHrefUsesLegacyFilterQuery(href: string): boolean;
|
|
218
|
-
/**
|
|
219
|
-
* Drop staged filters. Location always stays until apply.
|
|
220
|
-
* `keepFilterIds` keeps toolbar-primary filters (price, bedrooms) so Limpar
|
|
221
|
-
* in the extra-filters dialog does not wipe values already on the toolbar.
|
|
222
|
-
*/
|
|
223
|
-
declare function clearStagedPathFilters(current: SearchPathFilters, keepFilterIds?: readonly string[]): SearchPathFilters;
|
|
224
|
-
declare function visibleSearchFilters(schema: SearchUi | null): SearchUiFilter[];
|
|
225
|
-
declare function toolbarFilterIds(schema: SearchUi | null): string[];
|
|
226
|
-
declare function countOptionLabel(option: Pick<SearchUiOption, "label">): string;
|
|
227
|
-
declare function countFacetChoices(options: SearchUiOption[] | undefined): Array<{
|
|
228
|
-
id: string;
|
|
229
|
-
label: string;
|
|
230
|
-
}>;
|
|
231
|
-
declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
|
|
232
|
-
|
|
233
182
|
declare function composeSearchPublicPath(filters: SearchPathFilters, dictionary?: SearchUiDictionary): string;
|
|
234
183
|
declare function parseSearchPublicPath(pathname: string, dictionary?: SearchUiDictionary): SearchPathFilters | null;
|
|
235
184
|
/**
|
|
@@ -378,4 +327,4 @@ interface GaragemClient {
|
|
|
378
327
|
*/
|
|
379
328
|
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
380
329
|
|
|
381
|
-
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions,
|
|
330
|
+
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RequestNextOptions, L as ListingFilters, Q as QueryListingsParams, S as SearchListingsParams, C as CmsCollection, a as CmsEntriesResult, b as CmsEntry, c as ListingDetail, d as ListingsResult, e as SearchUi, f as SimilarListingsResult, g as Site, h as QueryListingsResult, i as SearchListingsResult, j as SearchPathFilters, k as SearchUiDictionary, l as QueryListingsFilters, A as AppliedSearchQuery, m as AppliedSearchChange } from './search-engine-D4EZkNrQ.js';
|
|
2
|
+
export { n as CmsEntryStatus, o as CmsFieldDefinition, p as CmsFieldType, q as CmsSeoData, F as FORBIDDEN_SEARCH_QUERY_KEYS, r as Listing, s as ListingBusinessType, t as ListingCardModel, u as ListingLocation, v as ListingMedia, w as ListingPriceVisibility, x as ListingPropertySummary, y as LocationNameTables, z as QueryListingsLocation, B as SEARCH_SORT_RELEVANCE, D as SearchPathLocation, E as SearchUiFilter, G as SearchUiOption, T as TOOLBAR_PRIMARY_FILTER_IDS, H as applyPathFilter, I as buildQueryListingsParams, J as canonicalizeSearchHref, K as clearStagedPathFilters, M as countFacetChoices, N as countOptionLabel, O as displayPathLocation, P as hrefForAppliedChange, U as hrefForPathFilters, V as hrefWithExplicitPage, W as isListingDetailPath, X as listingLocationLabel, Y as paginationPages, Z as pathFilterHasOption, _ as pathFilterValue, $ as publicSearchHref, a0 as readPublicSearch, a1 as searchHrefUsesLegacyFilterQuery, a2 as searchResultsHeading, a3 as searchSortOptions, a4 as toListingCardModel, a5 as toolbarFilterIds, a6 as visibleSearchFilters } from './search-engine-D4EZkNrQ.js';
|
|
3
3
|
|
|
4
4
|
/** Custom fetch implementation. Defaults to the global `fetch`. */
|
|
5
5
|
type FetchLike = typeof fetch;
|
|
@@ -165,7 +165,11 @@ declare const SEARCH_CSS_VARS: {
|
|
|
165
165
|
readonly cardGap: "--garagem-listing-card-gap";
|
|
166
166
|
readonly priceSize: "--garagem-listing-price-size";
|
|
167
167
|
readonly mediaRatio: "--garagem-listing-media-ratio";
|
|
168
|
+
readonly controlHeight: "--garagem-search-control-height";
|
|
169
|
+
readonly iconSize: "--garagem-search-icon-size";
|
|
170
|
+
readonly skeleton: "--garagem-skeleton";
|
|
168
171
|
};
|
|
172
|
+
/** Paste into generated `globals.css` to override tokens. Layout lives in the chrome artifact. */
|
|
169
173
|
declare const SEARCH_CSS_RECIPE: string;
|
|
170
174
|
declare function formatListingPrice(amount: number | null | undefined, locale?: string, currency?: string): string;
|
|
171
175
|
/** Input mask: `499000` → `"499.000"` (no currency symbol). */
|
|
@@ -175,61 +179,6 @@ declare function parseGroupedInteger(value: unknown): number | undefined;
|
|
|
175
179
|
declare function formatAreaM2(area: number | null | undefined): string | null;
|
|
176
180
|
declare function listingBusinessLabel(businessType: string | undefined): string;
|
|
177
181
|
|
|
178
|
-
/** Query keys that must never encode filters (Editor/Studio path contract). */
|
|
179
|
-
declare const FORBIDDEN_SEARCH_QUERY_KEYS: readonly ["tipo", "quartos", "tipo-imovel", "banheiros", "vagas"];
|
|
180
|
-
/** Default option: omit `ordenar` (API has no relevance token). */
|
|
181
|
-
declare const SEARCH_SORT_RELEVANCE: {
|
|
182
|
-
readonly id: "";
|
|
183
|
-
readonly label: "Mais relevantes";
|
|
184
|
-
};
|
|
185
|
-
declare function searchSortOptions(sorts: Array<{
|
|
186
|
-
id: string;
|
|
187
|
-
label: string;
|
|
188
|
-
}> | undefined): Array<{
|
|
189
|
-
id: string;
|
|
190
|
-
label: string;
|
|
191
|
-
}>;
|
|
192
|
-
/** Toolbar: price + bedrooms first and required when the schema has them. */
|
|
193
|
-
declare const TOOLBAR_PRIMARY_FILTER_IDS: readonly ["price", "property_bedrooms"];
|
|
194
|
-
declare function isListingDetailPath(pathname: string): boolean;
|
|
195
|
-
declare function readPublicSearch(pathname: string, search: string, dictionary?: SearchUiDictionary): {
|
|
196
|
-
pathFilters: SearchPathFilters;
|
|
197
|
-
applied: AppliedSearchQuery;
|
|
198
|
-
};
|
|
199
|
-
type LocationNameTables = {
|
|
200
|
-
states?: Record<string, string>;
|
|
201
|
-
cities?: Record<string, string>;
|
|
202
|
-
neighborhoods?: Record<string, string>;
|
|
203
|
-
streets?: Record<string, string>;
|
|
204
|
-
};
|
|
205
|
-
declare function displayPathLocation(location: SearchPathFilters["location"], values?: LocationNameTables | null): SearchPathFilters["location"] | null;
|
|
206
|
-
declare function buildQueryListingsParams(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, schema: Pick<SearchUi, "defaultLimit"> | {
|
|
207
|
-
defaultLimit?: number;
|
|
208
|
-
} | null, locationValues?: LocationNameTables | null): QueryListingsParams;
|
|
209
|
-
declare function applyPathFilter(pathFilters: SearchPathFilters, filterId: string, value: unknown): SearchPathFilters;
|
|
210
|
-
declare function pathFilterValue(pathFilters: SearchPathFilters | undefined, filterId: string): string;
|
|
211
|
-
declare function pathFilterHasOption(pathFilters: SearchPathFilters | undefined, filterId: string, optionId: string): boolean;
|
|
212
|
-
declare function publicSearchHref(pathFilters: SearchPathFilters, applied: AppliedSearchQuery, dictionary?: SearchUiDictionary, existingSearch?: string): string;
|
|
213
|
-
declare function hrefForPathFilters(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, nextPathFilters: SearchPathFilters): string;
|
|
214
|
-
declare function hrefForAppliedChange(pathname: string, search: string, dictionary: SearchUiDictionary | undefined, change: AppliedSearchChange): string;
|
|
215
|
-
/** Canonical href if the current URL is out of generation order; otherwise null. */
|
|
216
|
-
declare function canonicalizeSearchHref(pathname: string, search: string, dictionary?: SearchUiDictionary): string | null;
|
|
217
|
-
declare function searchHrefUsesLegacyFilterQuery(href: string): boolean;
|
|
218
|
-
/**
|
|
219
|
-
* Drop staged filters. Location always stays until apply.
|
|
220
|
-
* `keepFilterIds` keeps toolbar-primary filters (price, bedrooms) so Limpar
|
|
221
|
-
* in the extra-filters dialog does not wipe values already on the toolbar.
|
|
222
|
-
*/
|
|
223
|
-
declare function clearStagedPathFilters(current: SearchPathFilters, keepFilterIds?: readonly string[]): SearchPathFilters;
|
|
224
|
-
declare function visibleSearchFilters(schema: SearchUi | null): SearchUiFilter[];
|
|
225
|
-
declare function toolbarFilterIds(schema: SearchUi | null): string[];
|
|
226
|
-
declare function countOptionLabel(option: Pick<SearchUiOption, "label">): string;
|
|
227
|
-
declare function countFacetChoices(options: SearchUiOption[] | undefined): Array<{
|
|
228
|
-
id: string;
|
|
229
|
-
label: string;
|
|
230
|
-
}>;
|
|
231
|
-
declare function paginationPages(currentPage: number, totalPages: number, padding: number): number[];
|
|
232
|
-
|
|
233
182
|
declare function composeSearchPublicPath(filters: SearchPathFilters, dictionary?: SearchUiDictionary): string;
|
|
234
183
|
declare function parseSearchPublicPath(pathname: string, dictionary?: SearchUiDictionary): SearchPathFilters | null;
|
|
235
184
|
/**
|
|
@@ -378,4 +327,4 @@ interface GaragemClient {
|
|
|
378
327
|
*/
|
|
379
328
|
declare function createGaragemClient(options?: CreateGaragemClientOptions): GaragemClient;
|
|
380
329
|
|
|
381
|
-
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions,
|
|
330
|
+
export { AppliedSearchChange, AppliedSearchQuery, CmsCollection, CmsEntriesResult, CmsEntry, type CreateGaragemClientOptions, type FetchLike, type GaragemClient, GaragemSdkError, type GetCmsCollectionOptions, type GetCmsCollectionsOptions, type GetCmsEntriesOptions, type GetCmsEntryOptions, type GetListingOptions, type GetListingsOptions, type GetSearchUiOptions, type GetSimilarListingsOptions, type GetSiteOptions, ListingDetail, ListingFilters, ListingsResult, type LocationFilterInput, QueryListingsFilters, type QueryListingsOptions, QueryListingsParams, QueryListingsResult, RequestNextOptions, type ResolvePublicSiteIdOptions, SEARCH_CSS_RECIPE, SEARCH_CSS_VARS, type SearchListingsOptions, SearchListingsParams, SearchListingsResult, SearchPathFilters, SearchUi, SearchUiDictionary, SimilarListingsResult, Site, composeSearchPublicHref, composeSearchPublicPath, createGaragemClient, formatAreaM2, formatGroupedInteger, formatListingPrice, getCmsCollection, getCmsCollections, getCmsEntries, getCmsEntry, getListing, getListings, getSearchUi, getSimilarListings, getSite, isStudioPreviewHost, listingBusinessLabel, listingLookupKey, listingPublicPath, mergeAppliedSearchQueryIntoSearch, parseAppliedSearchQuery, parseGroupedInteger, parseSearchPublicPath, pathFiltersToQueryFilters, pathLocationToFilterInput, queryListings, reduceAppliedSearchQuery, resolvePublicSiteId, searchListings, serializeAppliedSearchQuery };
|
package/dist/index.js
CHANGED
|
@@ -50,6 +50,7 @@ __export(src_exports, {
|
|
|
50
50
|
getSite: () => getSite,
|
|
51
51
|
hrefForAppliedChange: () => hrefForAppliedChange,
|
|
52
52
|
hrefForPathFilters: () => hrefForPathFilters,
|
|
53
|
+
hrefWithExplicitPage: () => hrefWithExplicitPage,
|
|
53
54
|
isListingDetailPath: () => isListingDetailPath,
|
|
54
55
|
isStudioPreviewHost: () => isStudioPreviewHost,
|
|
55
56
|
listingBusinessLabel: () => listingBusinessLabel,
|
|
@@ -72,6 +73,7 @@ __export(src_exports, {
|
|
|
72
73
|
resolvePublicSiteId: () => resolvePublicSiteId,
|
|
73
74
|
searchHrefUsesLegacyFilterQuery: () => searchHrefUsesLegacyFilterQuery,
|
|
74
75
|
searchListings: () => searchListings,
|
|
76
|
+
searchResultsHeading: () => searchResultsHeading,
|
|
75
77
|
searchSortOptions: () => searchSortOptions,
|
|
76
78
|
serializeAppliedSearchQuery: () => serializeAppliedSearchQuery2,
|
|
77
79
|
toListingCardModel: () => toListingCardModel,
|
|
@@ -401,13 +403,19 @@ var SEARCH_CSS_VARS = {
|
|
|
401
403
|
cardRadius: "--garagem-listing-card-radius",
|
|
402
404
|
cardGap: "--garagem-listing-card-gap",
|
|
403
405
|
priceSize: "--garagem-listing-price-size",
|
|
404
|
-
mediaRatio: "--garagem-listing-media-ratio"
|
|
406
|
+
mediaRatio: "--garagem-listing-media-ratio",
|
|
407
|
+
controlHeight: "--garagem-search-control-height",
|
|
408
|
+
iconSize: "--garagem-search-icon-size",
|
|
409
|
+
skeleton: "--garagem-skeleton"
|
|
405
410
|
};
|
|
406
411
|
var SEARCH_CSS_RECIPE = `:root {
|
|
407
412
|
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
408
413
|
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
409
414
|
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
410
415
|
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
416
|
+
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
417
|
+
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
418
|
+
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
411
419
|
}
|
|
412
420
|
`;
|
|
413
421
|
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
@@ -1185,6 +1193,54 @@ function countFacetChoices(options) {
|
|
|
1185
1193
|
}
|
|
1186
1194
|
return out;
|
|
1187
1195
|
}
|
|
1196
|
+
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
1197
|
+
function pluralizePt(label) {
|
|
1198
|
+
const text = label.trim();
|
|
1199
|
+
if (!text || /s$/i.test(text)) return text;
|
|
1200
|
+
if (/il$/i.test(text)) return `${text.slice(0, -1)}is`;
|
|
1201
|
+
if (/m$/i.test(text)) return `${text.slice(0, -1)}ns`;
|
|
1202
|
+
return `${text}s`;
|
|
1203
|
+
}
|
|
1204
|
+
function headingLocationSuffix(location) {
|
|
1205
|
+
if (!location) return "";
|
|
1206
|
+
if (location.street && location.neighborhood) {
|
|
1207
|
+
return `${location.street}, ${location.neighborhood}`;
|
|
1208
|
+
}
|
|
1209
|
+
if (location.neighborhood && location.city) {
|
|
1210
|
+
return `${location.neighborhood}, ${location.city}`;
|
|
1211
|
+
}
|
|
1212
|
+
if (location.city && location.state) {
|
|
1213
|
+
return `${location.city} - ${location.state}`;
|
|
1214
|
+
}
|
|
1215
|
+
return location.city || location.neighborhood || location.street || location.state || "";
|
|
1216
|
+
}
|
|
1217
|
+
function searchResultsHeading(pathFilters, dictionary, locationNames) {
|
|
1218
|
+
const types = [].concat(pathFilters.propertyType || []).filter(Boolean);
|
|
1219
|
+
let noun = "Im\xF3veis";
|
|
1220
|
+
let found = "encontrados";
|
|
1221
|
+
if (types.length === 1) {
|
|
1222
|
+
const id = String(types[0]);
|
|
1223
|
+
const option = dictionary?.propertyTypes?.find(
|
|
1224
|
+
(entry) => entry.id === id || entry.slug === id
|
|
1225
|
+
);
|
|
1226
|
+
const label = option?.label;
|
|
1227
|
+
if (label) {
|
|
1228
|
+
noun = pluralizePt(label.charAt(0).toUpperCase() + label.slice(1));
|
|
1229
|
+
if (FEMININE_HEADING.test(id) || FEMININE_HEADING.test(label)) {
|
|
1230
|
+
found = "encontradas";
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
const place = locationNames ? headingLocationSuffix(
|
|
1235
|
+
displayPathLocation(pathFilters.location, locationNames)
|
|
1236
|
+
) : "";
|
|
1237
|
+
if (place) return `${noun} ${found} em ${place}`;
|
|
1238
|
+
return `${noun} ${found}`;
|
|
1239
|
+
}
|
|
1240
|
+
function hrefWithExplicitPage(href, page) {
|
|
1241
|
+
if (page !== 1 || /(?:\?|&)page=/.test(href)) return href;
|
|
1242
|
+
return href.includes("?") ? `${href}&page=1` : `${href}?page=1`;
|
|
1243
|
+
}
|
|
1188
1244
|
function paginationPages(currentPage, totalPages, padding) {
|
|
1189
1245
|
if (totalPages < 1) return [];
|
|
1190
1246
|
const current = Math.min(Math.max(1, currentPage), totalPages);
|
|
@@ -1390,6 +1446,7 @@ function createGaragemClient(options = {}) {
|
|
|
1390
1446
|
getSite,
|
|
1391
1447
|
hrefForAppliedChange,
|
|
1392
1448
|
hrefForPathFilters,
|
|
1449
|
+
hrefWithExplicitPage,
|
|
1393
1450
|
isListingDetailPath,
|
|
1394
1451
|
isStudioPreviewHost,
|
|
1395
1452
|
listingBusinessLabel,
|
|
@@ -1412,6 +1469,7 @@ function createGaragemClient(options = {}) {
|
|
|
1412
1469
|
resolvePublicSiteId,
|
|
1413
1470
|
searchHrefUsesLegacyFilterQuery,
|
|
1414
1471
|
searchListings,
|
|
1472
|
+
searchResultsHeading,
|
|
1415
1473
|
searchSortOptions,
|
|
1416
1474
|
serializeAppliedSearchQuery,
|
|
1417
1475
|
toListingCardModel,
|