@garagem-ai/site-sdk 0.4.0 → 0.4.2
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 +29 -9
- package/dist/index.d.mts +57 -58
- package/dist/index.d.ts +57 -58
- package/dist/index.js +187 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +176 -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 +573 -486
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +542 -456
- 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 +15 -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 +61 -106
- package/src/react/search-chrome.tsx +30 -27
- 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 +31 -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/src/studio-contract.ts +138 -0
|
@@ -7,6 +7,7 @@ import { formatAreaM2 } from "../presentation";
|
|
|
7
7
|
import { toListingCardModel } from "../listing-card-model";
|
|
8
8
|
import type { Listing } from "../types";
|
|
9
9
|
import { cn } from "./cn";
|
|
10
|
+
import { SearchChromeStyles } from "./styles";
|
|
10
11
|
import type { ListingCardProps } from "./types";
|
|
11
12
|
|
|
12
13
|
function isListing(value: ListingCardProps["listing"]): value is Listing {
|
|
@@ -26,118 +27,72 @@ export function ListingCard({
|
|
|
26
27
|
const model = isListing(listing) ? toListingCardModel(listing) : listing;
|
|
27
28
|
const target = href ?? model.href;
|
|
28
29
|
const areaLabel = formatAreaM2(model.areaM2);
|
|
29
|
-
|
|
30
30
|
return (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
className,
|
|
36
|
-
|
|
37
|
-
)}
|
|
38
|
-
style={style}
|
|
39
|
-
>
|
|
40
|
-
<Link
|
|
41
|
-
href={target}
|
|
42
|
-
className="block cursor-pointer"
|
|
43
|
-
data-slot="listing-card-link"
|
|
31
|
+
<>
|
|
32
|
+
<SearchChromeStyles />
|
|
33
|
+
<article
|
|
34
|
+
data-slot="listing-card"
|
|
35
|
+
className={cn(className, classNames?.root)}
|
|
36
|
+
style={style}
|
|
44
37
|
>
|
|
45
|
-
<
|
|
46
|
-
data-slot="listing-card-media"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</span>
|
|
75
|
-
)}
|
|
76
|
-
</div>
|
|
77
|
-
<div
|
|
78
|
-
data-slot="listing-card-body"
|
|
79
|
-
className={cn("p-4", classNames?.body)}
|
|
80
|
-
>
|
|
81
|
-
<div className="flex items-baseline justify-between gap-2">
|
|
38
|
+
<Link href={target} data-slot="listing-card-link">
|
|
39
|
+
<div data-slot="listing-card-media" className={classNames?.media}>
|
|
40
|
+
{slots?.media ??
|
|
41
|
+
(model.coverSrc ? (
|
|
42
|
+
<img src={model.coverSrc} alt={model.coverAlt} />
|
|
43
|
+
) : (
|
|
44
|
+
<div data-slot="listing-card-empty">Sem foto</div>
|
|
45
|
+
))}
|
|
46
|
+
{slots?.badge ?? (
|
|
47
|
+
<span
|
|
48
|
+
data-slot="listing-card-badge"
|
|
49
|
+
className={classNames?.badge}
|
|
50
|
+
>
|
|
51
|
+
{model.businessLabel}
|
|
52
|
+
</span>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
<div data-slot="listing-card-body" className={classNames?.body}>
|
|
56
|
+
<div data-slot="listing-card-price-row">
|
|
57
|
+
<p data-slot="listing-card-price" className={classNames?.price}>
|
|
58
|
+
{model.priceLabel}
|
|
59
|
+
</p>
|
|
60
|
+
{model.pricePeriod ? (
|
|
61
|
+
<span data-slot="listing-card-period">{model.pricePeriod}</span>
|
|
62
|
+
) : null}
|
|
63
|
+
</div>
|
|
64
|
+
<h3 data-slot="listing-card-title" className={classNames?.title}>
|
|
65
|
+
{model.title}
|
|
66
|
+
</h3>
|
|
82
67
|
<p
|
|
83
|
-
data-slot="listing-card-
|
|
84
|
-
className={
|
|
85
|
-
style={{
|
|
86
|
-
fontSize: "var(--garagem-listing-price-size, 1.125rem)",
|
|
87
|
-
}}
|
|
68
|
+
data-slot="listing-card-location"
|
|
69
|
+
className={classNames?.location}
|
|
88
70
|
>
|
|
89
|
-
{model.
|
|
71
|
+
{model.locationLabel || model.propertyType || ""}
|
|
90
72
|
</p>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
73
|
+
<ul
|
|
74
|
+
data-slot="listing-card-features"
|
|
75
|
+
className={classNames?.features}
|
|
76
|
+
>
|
|
77
|
+
{model.bedrooms != null ? (
|
|
78
|
+
<li>{model.bedrooms} quartos</li>
|
|
79
|
+
) : null}
|
|
80
|
+
{model.bathrooms != null ? (
|
|
81
|
+
<li>{model.bathrooms} banheiros</li>
|
|
82
|
+
) : null}
|
|
83
|
+
{model.parkingSpaces != null ? (
|
|
84
|
+
<li>{model.parkingSpaces} vagas</li>
|
|
85
|
+
) : null}
|
|
86
|
+
{areaLabel ? <li>{areaLabel}</li> : null}
|
|
87
|
+
</ul>
|
|
88
|
+
{slots?.cta ? (
|
|
89
|
+
<div data-slot="listing-card-cta" className={classNames?.cta}>
|
|
90
|
+
{slots.cta}
|
|
91
|
+
</div>
|
|
95
92
|
) : null}
|
|
96
93
|
</div>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
"mt-1 line-clamp-1 text-sm font-medium",
|
|
101
|
-
classNames?.title
|
|
102
|
-
)}
|
|
103
|
-
>
|
|
104
|
-
{model.title}
|
|
105
|
-
</h3>
|
|
106
|
-
<p
|
|
107
|
-
data-slot="listing-card-location"
|
|
108
|
-
className={cn(
|
|
109
|
-
"mt-0.5 line-clamp-1 text-xs text-muted-foreground",
|
|
110
|
-
classNames?.location
|
|
111
|
-
)}
|
|
112
|
-
>
|
|
113
|
-
{model.locationLabel || model.propertyType || ""}
|
|
114
|
-
</p>
|
|
115
|
-
<ul
|
|
116
|
-
data-slot="listing-card-features"
|
|
117
|
-
className={cn(
|
|
118
|
-
"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",
|
|
119
|
-
classNames?.features
|
|
120
|
-
)}
|
|
121
|
-
>
|
|
122
|
-
{model.bedrooms != null ? <li>{model.bedrooms} quartos</li> : null}
|
|
123
|
-
{model.bathrooms != null ? (
|
|
124
|
-
<li>{model.bathrooms} banheiros</li>
|
|
125
|
-
) : null}
|
|
126
|
-
{model.parkingSpaces != null ? (
|
|
127
|
-
<li>{model.parkingSpaces} vagas</li>
|
|
128
|
-
) : null}
|
|
129
|
-
{areaLabel ? <li>{areaLabel}</li> : null}
|
|
130
|
-
</ul>
|
|
131
|
-
{slots?.cta ? (
|
|
132
|
-
<div
|
|
133
|
-
data-slot="listing-card-cta"
|
|
134
|
-
className={cn("mt-3", classNames?.cta)}
|
|
135
|
-
>
|
|
136
|
-
{slots.cta}
|
|
137
|
-
</div>
|
|
138
|
-
) : null}
|
|
139
|
-
</div>
|
|
140
|
-
</Link>
|
|
141
|
-
</article>
|
|
94
|
+
</Link>
|
|
95
|
+
</article>
|
|
96
|
+
</>
|
|
142
97
|
);
|
|
143
98
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import type { ReactElement } from "react";
|
|
4
4
|
|
|
5
5
|
import { searchSortOptions } from "../search-engine";
|
|
6
|
-
import {
|
|
6
|
+
import { SearchChromeStyles } from "./styles";
|
|
7
7
|
|
|
8
8
|
export type SearchSortSelectProps = {
|
|
9
9
|
value: string;
|
|
@@ -20,13 +20,13 @@ export function SearchSortSelect({
|
|
|
20
20
|
}: SearchSortSelectProps): ReactElement {
|
|
21
21
|
const options = searchSortOptions(sorts);
|
|
22
22
|
return (
|
|
23
|
-
<label
|
|
24
|
-
<span
|
|
23
|
+
<label data-slot="search-sort" className={className}>
|
|
24
|
+
<span data-slot="search-label">Ordenar</span>
|
|
25
25
|
<select
|
|
26
26
|
id="garagem-search-sort"
|
|
27
|
+
data-slot="search-sort-trigger"
|
|
27
28
|
value={value}
|
|
28
29
|
onChange={(event) => onChange(event.target.value || null)}
|
|
29
|
-
className="min-h-10 cursor-pointer rounded-lg border border-border bg-background px-3"
|
|
30
30
|
>
|
|
31
31
|
{options.map((sort) => (
|
|
32
32
|
<option key={sort.id || "relevance"} value={sort.id}>
|
|
@@ -44,29 +44,32 @@ export function ResultsSkeleton({
|
|
|
44
44
|
className?: string;
|
|
45
45
|
}): ReactElement {
|
|
46
46
|
return (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
className={
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
>
|
|
59
|
-
<div
|
|
60
|
-
className="animate-pulse bg-muted"
|
|
61
|
-
style={{ aspectRatio: "4 / 3" }}
|
|
62
|
-
/>
|
|
63
|
-
<div className="space-y-2 p-4">
|
|
64
|
-
<div className="h-5 w-1/2 animate-pulse rounded bg-muted" />
|
|
65
|
-
<div className="h-4 w-3/4 animate-pulse rounded bg-muted" />
|
|
66
|
-
<div className="h-3 w-2/3 animate-pulse rounded bg-muted" />
|
|
47
|
+
<>
|
|
48
|
+
<SearchChromeStyles />
|
|
49
|
+
<div data-slot="search-skeleton" className={className}>
|
|
50
|
+
{Array.from({ length: 6 }, (_, i) => (
|
|
51
|
+
<div key={i} data-slot="search-skeleton-card">
|
|
52
|
+
<div data-slot="search-skeleton-block" data-kind="media" />
|
|
53
|
+
<div data-slot="search-skeleton-body">
|
|
54
|
+
<div data-slot="search-skeleton-block" data-kind="line-lg" />
|
|
55
|
+
<div data-slot="search-skeleton-block" data-kind="line-md" />
|
|
56
|
+
<div data-slot="search-skeleton-block" data-kind="line-sm" />
|
|
57
|
+
</div>
|
|
67
58
|
</div>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
))}
|
|
60
|
+
</div>
|
|
61
|
+
</>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function SearchPageFallback({
|
|
66
|
+
className,
|
|
67
|
+
}: {
|
|
68
|
+
className?: string;
|
|
69
|
+
}): ReactElement {
|
|
70
|
+
return (
|
|
71
|
+
<main data-slot="search-page">
|
|
72
|
+
<ResultsSkeleton className={className} />
|
|
73
|
+
</main>
|
|
71
74
|
);
|
|
72
75
|
}
|