@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/dist/react.mjs
CHANGED
|
@@ -8,13 +8,19 @@ var SEARCH_CSS_VARS = {
|
|
|
8
8
|
cardRadius: "--garagem-listing-card-radius",
|
|
9
9
|
cardGap: "--garagem-listing-card-gap",
|
|
10
10
|
priceSize: "--garagem-listing-price-size",
|
|
11
|
-
mediaRatio: "--garagem-listing-media-ratio"
|
|
11
|
+
mediaRatio: "--garagem-listing-media-ratio",
|
|
12
|
+
controlHeight: "--garagem-search-control-height",
|
|
13
|
+
iconSize: "--garagem-search-icon-size",
|
|
14
|
+
skeleton: "--garagem-skeleton"
|
|
12
15
|
};
|
|
13
16
|
var SEARCH_CSS_RECIPE = `:root {
|
|
14
17
|
${SEARCH_CSS_VARS.cardRadius}: 0.75rem;
|
|
15
18
|
${SEARCH_CSS_VARS.cardGap}: 1.5rem;
|
|
16
19
|
${SEARCH_CSS_VARS.priceSize}: 1.125rem;
|
|
17
20
|
${SEARCH_CSS_VARS.mediaRatio}: 4 / 3;
|
|
21
|
+
${SEARCH_CSS_VARS.controlHeight}: 2.75rem;
|
|
22
|
+
${SEARCH_CSS_VARS.iconSize}: 1.25rem;
|
|
23
|
+
${SEARCH_CSS_VARS.skeleton}: var(--muted, #e7e5e4);
|
|
18
24
|
}
|
|
19
25
|
`;
|
|
20
26
|
function formatListingPrice(amount, locale = "pt-BR", currency = "BRL") {
|
|
@@ -119,138 +125,52 @@ function ListingCard({
|
|
|
119
125
|
"article",
|
|
120
126
|
{
|
|
121
127
|
"data-slot": "listing-card",
|
|
122
|
-
className: cn(
|
|
123
|
-
"group overflow-hidden rounded-[var(--garagem-listing-card-radius,0.75rem)] border border-border bg-background",
|
|
124
|
-
className,
|
|
125
|
-
classNames?.root
|
|
126
|
-
),
|
|
128
|
+
className: cn(className, classNames?.root),
|
|
127
129
|
style,
|
|
128
|
-
children: /* @__PURE__ */ jsxs(
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
children: [
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
),
|
|
167
|
-
/* @__PURE__ */ jsxs(
|
|
168
|
-
"div",
|
|
169
|
-
{
|
|
170
|
-
"data-slot": "listing-card-body",
|
|
171
|
-
className: cn("p-4", classNames?.body),
|
|
172
|
-
children: [
|
|
173
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
174
|
-
/* @__PURE__ */ jsx(
|
|
175
|
-
"p",
|
|
176
|
-
{
|
|
177
|
-
"data-slot": "listing-card-price",
|
|
178
|
-
className: cn("font-semibold tracking-tight", classNames?.price),
|
|
179
|
-
style: {
|
|
180
|
-
fontSize: "var(--garagem-listing-price-size, 1.125rem)"
|
|
181
|
-
},
|
|
182
|
-
children: model.priceLabel
|
|
183
|
-
}
|
|
184
|
-
),
|
|
185
|
-
model.pricePeriod ? /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: model.pricePeriod }) : null
|
|
186
|
-
] }),
|
|
187
|
-
/* @__PURE__ */ jsx(
|
|
188
|
-
"h3",
|
|
189
|
-
{
|
|
190
|
-
"data-slot": "listing-card-title",
|
|
191
|
-
className: cn(
|
|
192
|
-
"mt-1 line-clamp-1 text-sm font-medium",
|
|
193
|
-
classNames?.title
|
|
194
|
-
),
|
|
195
|
-
children: model.title
|
|
196
|
-
}
|
|
197
|
-
),
|
|
198
|
-
/* @__PURE__ */ jsx(
|
|
199
|
-
"p",
|
|
200
|
-
{
|
|
201
|
-
"data-slot": "listing-card-location",
|
|
202
|
-
className: cn(
|
|
203
|
-
"mt-0.5 line-clamp-1 text-xs text-muted-foreground",
|
|
204
|
-
classNames?.location
|
|
205
|
-
),
|
|
206
|
-
children: model.locationLabel || model.propertyType || ""
|
|
207
|
-
}
|
|
208
|
-
),
|
|
209
|
-
/* @__PURE__ */ jsxs(
|
|
210
|
-
"ul",
|
|
211
|
-
{
|
|
212
|
-
"data-slot": "listing-card-features",
|
|
213
|
-
className: cn(
|
|
214
|
-
"mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",
|
|
215
|
-
classNames?.features
|
|
216
|
-
),
|
|
217
|
-
children: [
|
|
218
|
-
model.bedrooms != null ? /* @__PURE__ */ jsxs("li", { children: [
|
|
219
|
-
model.bedrooms,
|
|
220
|
-
" quartos"
|
|
221
|
-
] }) : null,
|
|
222
|
-
model.bathrooms != null ? /* @__PURE__ */ jsxs("li", { children: [
|
|
223
|
-
model.bathrooms,
|
|
224
|
-
" banheiros"
|
|
225
|
-
] }) : null,
|
|
226
|
-
model.parkingSpaces != null ? /* @__PURE__ */ jsxs("li", { children: [
|
|
227
|
-
model.parkingSpaces,
|
|
228
|
-
" vagas"
|
|
229
|
-
] }) : null,
|
|
230
|
-
areaLabel ? /* @__PURE__ */ jsx("li", { children: areaLabel }) : null
|
|
231
|
-
]
|
|
232
|
-
}
|
|
233
|
-
),
|
|
234
|
-
slots?.cta ? /* @__PURE__ */ jsx(
|
|
235
|
-
"div",
|
|
236
|
-
{
|
|
237
|
-
"data-slot": "listing-card-cta",
|
|
238
|
-
className: cn("mt-3", classNames?.cta),
|
|
239
|
-
children: slots.cta
|
|
240
|
-
}
|
|
241
|
-
) : null
|
|
242
|
-
]
|
|
243
|
-
}
|
|
244
|
-
)
|
|
245
|
-
]
|
|
246
|
-
}
|
|
247
|
-
)
|
|
130
|
+
children: /* @__PURE__ */ jsxs(Link, { href: target, "data-slot": "listing-card-link", children: [
|
|
131
|
+
/* @__PURE__ */ jsxs("div", { "data-slot": "listing-card-media", className: classNames?.media, children: [
|
|
132
|
+
slots?.media ?? (model.coverSrc ? /* @__PURE__ */ jsx("img", { src: model.coverSrc, alt: model.coverAlt }) : /* @__PURE__ */ jsx("div", { "data-slot": "listing-card-empty", children: "Sem foto" })),
|
|
133
|
+
slots?.badge ?? /* @__PURE__ */ jsx("span", { "data-slot": "listing-card-badge", className: classNames?.badge, children: model.businessLabel })
|
|
134
|
+
] }),
|
|
135
|
+
/* @__PURE__ */ jsxs("div", { "data-slot": "listing-card-body", className: classNames?.body, children: [
|
|
136
|
+
/* @__PURE__ */ jsxs("div", { "data-slot": "listing-card-price-row", children: [
|
|
137
|
+
/* @__PURE__ */ jsx("p", { "data-slot": "listing-card-price", className: classNames?.price, children: model.priceLabel }),
|
|
138
|
+
model.pricePeriod ? /* @__PURE__ */ jsx("span", { "data-slot": "listing-card-period", children: model.pricePeriod }) : null
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ jsx("h3", { "data-slot": "listing-card-title", className: classNames?.title, children: model.title }),
|
|
141
|
+
/* @__PURE__ */ jsx("p", { "data-slot": "listing-card-location", className: classNames?.location, children: model.locationLabel || model.propertyType || "" }),
|
|
142
|
+
/* @__PURE__ */ jsxs(
|
|
143
|
+
"ul",
|
|
144
|
+
{
|
|
145
|
+
"data-slot": "listing-card-features",
|
|
146
|
+
className: classNames?.features,
|
|
147
|
+
children: [
|
|
148
|
+
model.bedrooms != null ? /* @__PURE__ */ jsxs("li", { children: [
|
|
149
|
+
model.bedrooms,
|
|
150
|
+
" quartos"
|
|
151
|
+
] }) : null,
|
|
152
|
+
model.bathrooms != null ? /* @__PURE__ */ jsxs("li", { children: [
|
|
153
|
+
model.bathrooms,
|
|
154
|
+
" banheiros"
|
|
155
|
+
] }) : null,
|
|
156
|
+
model.parkingSpaces != null ? /* @__PURE__ */ jsxs("li", { children: [
|
|
157
|
+
model.parkingSpaces,
|
|
158
|
+
" vagas"
|
|
159
|
+
] }) : null,
|
|
160
|
+
areaLabel ? /* @__PURE__ */ jsx("li", { children: areaLabel }) : null
|
|
161
|
+
]
|
|
162
|
+
}
|
|
163
|
+
),
|
|
164
|
+
slots?.cta ? /* @__PURE__ */ jsx("div", { "data-slot": "listing-card-cta", className: classNames?.cta, children: slots.cta }) : null
|
|
165
|
+
] })
|
|
166
|
+
] })
|
|
248
167
|
}
|
|
249
168
|
);
|
|
250
169
|
}
|
|
251
170
|
|
|
252
171
|
// src/react/search-page.tsx
|
|
253
172
|
import {
|
|
173
|
+
useCallback as useCallback2,
|
|
254
174
|
useEffect as useEffect2,
|
|
255
175
|
useRef as useRef2,
|
|
256
176
|
useState as useState2
|
|
@@ -942,6 +862,54 @@ function countFacetChoices(options) {
|
|
|
942
862
|
}
|
|
943
863
|
return out;
|
|
944
864
|
}
|
|
865
|
+
var FEMININE_HEADING = /(casa|cobertura|kitnet|loja|sala|fazenda|chácara|chacara)s?$/i;
|
|
866
|
+
function pluralizePt(label) {
|
|
867
|
+
const text = label.trim();
|
|
868
|
+
if (!text || /s$/i.test(text)) return text;
|
|
869
|
+
if (/il$/i.test(text)) return `${text.slice(0, -1)}is`;
|
|
870
|
+
if (/m$/i.test(text)) return `${text.slice(0, -1)}ns`;
|
|
871
|
+
return `${text}s`;
|
|
872
|
+
}
|
|
873
|
+
function headingLocationSuffix(location) {
|
|
874
|
+
if (!location) return "";
|
|
875
|
+
if (location.street && location.neighborhood) {
|
|
876
|
+
return `${location.street}, ${location.neighborhood}`;
|
|
877
|
+
}
|
|
878
|
+
if (location.neighborhood && location.city) {
|
|
879
|
+
return `${location.neighborhood}, ${location.city}`;
|
|
880
|
+
}
|
|
881
|
+
if (location.city && location.state) {
|
|
882
|
+
return `${location.city} - ${location.state}`;
|
|
883
|
+
}
|
|
884
|
+
return location.city || location.neighborhood || location.street || location.state || "";
|
|
885
|
+
}
|
|
886
|
+
function searchResultsHeading(pathFilters, dictionary, locationNames) {
|
|
887
|
+
const types = [].concat(pathFilters.propertyType || []).filter(Boolean);
|
|
888
|
+
let noun = "Im\xF3veis";
|
|
889
|
+
let found = "encontrados";
|
|
890
|
+
if (types.length === 1) {
|
|
891
|
+
const id = String(types[0]);
|
|
892
|
+
const option = dictionary?.propertyTypes?.find(
|
|
893
|
+
(entry) => entry.id === id || entry.slug === id
|
|
894
|
+
);
|
|
895
|
+
const label = option?.label;
|
|
896
|
+
if (label) {
|
|
897
|
+
noun = pluralizePt(label.charAt(0).toUpperCase() + label.slice(1));
|
|
898
|
+
if (FEMININE_HEADING.test(id) || FEMININE_HEADING.test(label)) {
|
|
899
|
+
found = "encontradas";
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const place = locationNames ? headingLocationSuffix(
|
|
904
|
+
displayPathLocation(pathFilters.location, locationNames)
|
|
905
|
+
) : "";
|
|
906
|
+
if (place) return `${noun} ${found} em ${place}`;
|
|
907
|
+
return `${noun} ${found}`;
|
|
908
|
+
}
|
|
909
|
+
function hrefWithExplicitPage(href, page) {
|
|
910
|
+
if (page !== 1 || /(?:\?|&)page=/.test(href)) return href;
|
|
911
|
+
return href.includes("?") ? `${href}&page=1` : `${href}?page=1`;
|
|
912
|
+
}
|
|
945
913
|
function paginationPages(currentPage, totalPages, padding) {
|
|
946
914
|
if (totalPages < 1) return [];
|
|
947
915
|
const current = Math.min(Math.max(1, currentPage), totalPages);
|
|
@@ -965,10 +933,9 @@ function RangeFields({
|
|
|
965
933
|
const patch = (side, raw) => {
|
|
966
934
|
onRangePatch(filter.id, side, isPrice ? formatGroupedInteger(raw) : raw);
|
|
967
935
|
};
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
/* @__PURE__ */
|
|
971
|
-
/* @__PURE__ */ jsxs2("div", { className: "flex gap-2", children: [
|
|
936
|
+
return /* @__PURE__ */ jsxs2("fieldset", { "data-slot": "search-filter", children: [
|
|
937
|
+
/* @__PURE__ */ jsx2("legend", { children: filter.label }),
|
|
938
|
+
/* @__PURE__ */ jsxs2("div", { "data-slot": "search-range-row", children: [
|
|
972
939
|
/* @__PURE__ */ jsx2(
|
|
973
940
|
RangeSide,
|
|
974
941
|
{
|
|
@@ -976,9 +943,9 @@ function RangeFields({
|
|
|
976
943
|
label: "M\xEDn",
|
|
977
944
|
isPrice,
|
|
978
945
|
value: draft.min,
|
|
979
|
-
inputClass,
|
|
980
946
|
onPatch: (raw) => patch("min", raw),
|
|
981
|
-
onCommit: () => onRangeCommit(filter.id)
|
|
947
|
+
onCommit: () => onRangeCommit(filter.id, "blur"),
|
|
948
|
+
onEnter: () => onRangeCommit(filter.id, "enter")
|
|
982
949
|
}
|
|
983
950
|
),
|
|
984
951
|
/* @__PURE__ */ jsx2(
|
|
@@ -988,9 +955,18 @@ function RangeFields({
|
|
|
988
955
|
label: "M\xE1x",
|
|
989
956
|
isPrice,
|
|
990
957
|
value: draft.max,
|
|
991
|
-
inputClass,
|
|
992
958
|
onPatch: (raw) => patch("max", raw),
|
|
993
|
-
onCommit: () => onRangeCommit(filter.id)
|
|
959
|
+
onCommit: () => onRangeCommit(filter.id, "blur"),
|
|
960
|
+
onEnter: () => onRangeCommit(filter.id, "enter")
|
|
961
|
+
}
|
|
962
|
+
),
|
|
963
|
+
/* @__PURE__ */ jsx2(
|
|
964
|
+
"button",
|
|
965
|
+
{
|
|
966
|
+
type: "button",
|
|
967
|
+
"data-slot": "search-range-apply",
|
|
968
|
+
onClick: () => onRangeCommit(filter.id, "apply"),
|
|
969
|
+
children: "Atualizar"
|
|
994
970
|
}
|
|
995
971
|
)
|
|
996
972
|
] })
|
|
@@ -1001,9 +977,9 @@ function RangeSide({
|
|
|
1001
977
|
label,
|
|
1002
978
|
isPrice,
|
|
1003
979
|
value,
|
|
1004
|
-
inputClass,
|
|
1005
980
|
onPatch,
|
|
1006
|
-
onCommit
|
|
981
|
+
onCommit,
|
|
982
|
+
onEnter
|
|
1007
983
|
}) {
|
|
1008
984
|
const input = /* @__PURE__ */ jsx2(
|
|
1009
985
|
"input",
|
|
@@ -1018,15 +994,18 @@ function RangeSide({
|
|
|
1018
994
|
onChange: (event) => onPatch(event.target.value),
|
|
1019
995
|
onBlur: onCommit,
|
|
1020
996
|
onKeyDown: (event) => {
|
|
1021
|
-
if (event.key === "Enter")
|
|
997
|
+
if (event.key === "Enter") {
|
|
998
|
+
event.preventDefault();
|
|
999
|
+
onEnter();
|
|
1000
|
+
}
|
|
1022
1001
|
},
|
|
1023
|
-
|
|
1002
|
+
"data-slot": "search-range-input"
|
|
1024
1003
|
}
|
|
1025
1004
|
);
|
|
1026
|
-
return /* @__PURE__ */ jsxs2("label", {
|
|
1027
|
-
/* @__PURE__ */ jsx2("span", {
|
|
1028
|
-
isPrice ? /* @__PURE__ */ jsxs2("span", {
|
|
1029
|
-
/* @__PURE__ */ jsx2("span", {
|
|
1005
|
+
return /* @__PURE__ */ jsxs2("label", { "data-slot": "search-range-side", htmlFor: id, children: [
|
|
1006
|
+
/* @__PURE__ */ jsx2("span", { children: label }),
|
|
1007
|
+
isPrice ? /* @__PURE__ */ jsxs2("span", { "data-slot": "search-range-affix", children: [
|
|
1008
|
+
/* @__PURE__ */ jsx2("span", { "data-slot": "search-range-prefix", children: "R$" }),
|
|
1030
1009
|
input
|
|
1031
1010
|
] }) : input
|
|
1032
1011
|
] });
|
|
@@ -1038,17 +1017,15 @@ function CountFields({
|
|
|
1038
1017
|
}) {
|
|
1039
1018
|
const selected = pathFilterValue(pathFilters, filter.id);
|
|
1040
1019
|
const choices = countFacetChoices(filter.options);
|
|
1041
|
-
return /* @__PURE__ */ jsxs2("fieldset", {
|
|
1042
|
-
/* @__PURE__ */ jsx2("legend", {
|
|
1043
|
-
/* @__PURE__ */ jsx2("div", {
|
|
1020
|
+
return /* @__PURE__ */ jsxs2("fieldset", { "data-slot": "search-filter", children: [
|
|
1021
|
+
/* @__PURE__ */ jsx2("legend", { children: filter.label }),
|
|
1022
|
+
/* @__PURE__ */ jsx2("div", { "data-slot": "search-count-group", role: "group", children: choices.map((choice) => /* @__PURE__ */ jsx2(
|
|
1044
1023
|
"button",
|
|
1045
1024
|
{
|
|
1046
1025
|
type: "button",
|
|
1026
|
+
"data-slot": "search-count-choice",
|
|
1027
|
+
"data-selected": selected === choice.id ? "true" : void 0,
|
|
1047
1028
|
onClick: () => onChange(filter.id, Number(choice.id)),
|
|
1048
|
-
className: cn(
|
|
1049
|
-
"min-h-10 cursor-pointer rounded-lg border px-3 text-sm hover:bg-muted",
|
|
1050
|
-
selected === choice.id && "border-primary bg-primary/10"
|
|
1051
|
-
),
|
|
1052
1029
|
children: choice.label
|
|
1053
1030
|
},
|
|
1054
1031
|
choice.id
|
|
@@ -1062,36 +1039,20 @@ function EnumFields({
|
|
|
1062
1039
|
}) {
|
|
1063
1040
|
const options = filter.options || [];
|
|
1064
1041
|
const scroll = options.length > 8;
|
|
1065
|
-
return /* @__PURE__ */ jsxs2("fieldset", {
|
|
1066
|
-
/* @__PURE__ */ jsx2("legend", {
|
|
1067
|
-
/* @__PURE__ */ jsx2(
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
/* @__PURE__ */ jsx2(
|
|
1080
|
-
"input",
|
|
1081
|
-
{
|
|
1082
|
-
type: "checkbox",
|
|
1083
|
-
checked: pathFilterHasOption(pathFilters, filter.id, option.id),
|
|
1084
|
-
onChange: () => onChange(filter.id, option.id),
|
|
1085
|
-
className: "cursor-pointer"
|
|
1086
|
-
}
|
|
1087
|
-
),
|
|
1088
|
-
/* @__PURE__ */ jsx2("span", { children: option.label })
|
|
1089
|
-
]
|
|
1090
|
-
},
|
|
1091
|
-
option.id
|
|
1092
|
-
))
|
|
1093
|
-
}
|
|
1094
|
-
)
|
|
1042
|
+
return /* @__PURE__ */ jsxs2("fieldset", { "data-slot": "search-filter", children: [
|
|
1043
|
+
/* @__PURE__ */ jsx2("legend", { children: filter.label }),
|
|
1044
|
+
/* @__PURE__ */ jsx2("div", { "data-slot": scroll ? "search-scroll" : "search-enum-list", children: options.map((option) => /* @__PURE__ */ jsxs2("label", { "data-slot": "search-enum-option", children: [
|
|
1045
|
+
/* @__PURE__ */ jsx2(
|
|
1046
|
+
"input",
|
|
1047
|
+
{
|
|
1048
|
+
type: "checkbox",
|
|
1049
|
+
"data-slot": "search-checkbox",
|
|
1050
|
+
checked: pathFilterHasOption(pathFilters, filter.id, option.id),
|
|
1051
|
+
onChange: () => onChange(filter.id, option.id)
|
|
1052
|
+
}
|
|
1053
|
+
),
|
|
1054
|
+
/* @__PURE__ */ jsx2("span", { children: option.label })
|
|
1055
|
+
] }, option.id)) })
|
|
1095
1056
|
] });
|
|
1096
1057
|
}
|
|
1097
1058
|
function FilterPanel({
|
|
@@ -1102,7 +1063,7 @@ function FilterPanel({
|
|
|
1102
1063
|
onRangePatch,
|
|
1103
1064
|
onRangeCommit
|
|
1104
1065
|
}) {
|
|
1105
|
-
return /* @__PURE__ */ jsx2("div", {
|
|
1066
|
+
return /* @__PURE__ */ jsx2("div", { "data-slot": "search-filters", children: filters.map((filter) => {
|
|
1106
1067
|
if (filter.type === "range") {
|
|
1107
1068
|
return /* @__PURE__ */ jsx2(
|
|
1108
1069
|
RangeFields,
|
|
@@ -1152,8 +1113,19 @@ function rangeDraftFromPath(pathFilters) {
|
|
|
1152
1113
|
};
|
|
1153
1114
|
}
|
|
1154
1115
|
|
|
1116
|
+
// src/react/styles/search-chrome-css.generated.ts
|
|
1117
|
+
var SEARCH_CHROME_CSS_VERSION = "0.4.1";
|
|
1118
|
+
var SEARCH_CHROME_CSS = `:root{--garagem-listing-card-radius:0.75rem;--garagem-listing-card-gap:1.5rem;--garagem-listing-price-size:1.125rem;--garagem-listing-media-ratio:4 / 3;--garagem-search-control-height:2.75rem;--garagem-search-icon-size:1.25rem;--garagem-search-radius:var(--radius,0.75rem);--garagem-skeleton:var(--muted,#e7e5e4)}[data-slot="search-page"]{margin-inline:auto;max-width:80rem;padding:3rem 1.5rem}[data-slot="search-heading"]{display:flex;min-width:0;align-items:baseline;gap:0.375rem;font-size:1.25rem;font-weight:600}[data-slot="search-heading-count"]{flex-shrink:0}[data-slot="search-heading-title"]{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:inherit;font-weight:inherit}[data-slot="search-query-sort"]{display:flex;flex-direction:column;gap:1rem}@media (min-width:1024px){[data-slot="search-query-sort"]{flex-direction:row;align-items:flex-end}}[data-slot="search-query"]{flex:1;min-width:0}[data-slot="search-query-input"],[data-slot="search-sort-trigger"],[data-slot="search-toolbar-trigger"],[data-slot="search-filters-trigger"]{min-height:var(--garagem-search-control-height)}[data-slot="search-query-field"]{position:relative}[data-slot="search-query-input"]{width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 5.5rem 0.5rem 1rem;outline:none}[data-slot="search-query-actions"]{position:absolute;top:50%;right:0.35rem;display:flex;transform:translateY(-50%);align-items:center;gap:0.15rem}[data-slot="search-icon-button"]{display:inline-flex;height:2.25rem;width:2.25rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:999px;background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot="search-icon-button"][data-kind="clear"]{background:transparent;color:var(--muted-foreground,#737373)}[data-slot="search-icon"]{width:var(--garagem-search-icon-size);height:var(--garagem-search-icon-size);display:block}[data-slot="search-sort"]{display:flex;flex-direction:column;gap:0.25rem}[data-slot="search-sort-trigger"]{appearance:none;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 2.25rem 0.5rem 0.75rem;background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23737373' stroke-width='2' viewBox='0 0 24 24'><path d='m6 9 6 6 6-6'/></svg>");background-repeat:no-repeat;background-position:right 0.65rem center}[data-slot="search-toolbar"]{display:flex;flex-wrap:wrap;align-items:flex-end;gap:0.5rem}[data-slot="search-toolbar-trigger"],[data-slot="search-filters-trigger"]{cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0.5rem 0.75rem;font-size:0.875rem}[data-slot="search-popover"]{position:absolute;z-index:30;margin-top:0.5rem;width:18rem;border-radius:0.75rem;border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:1rem;box-shadow:0 10px 30px rgb(0 0 0 / 0.12);animation:garagem-search-in 140ms ease-out}[data-slot="search-grid"],[data-slot="search-skeleton"]{display:grid;grid-template-columns:1fr;gap:var(--garagem-listing-card-gap)}@media (min-width:640px){[data-slot="search-grid"],[data-slot="search-skeleton"]{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width:1024px){[data-slot="search-grid"],[data-slot="search-skeleton"]{grid-template-columns:repeat(3,minmax(0,1fr))}}[data-slot="listing-card"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7);background:var(--card,var(--background,#fff))}[data-slot="listing-card-price-row"]{display:inline-flex;align-items:baseline;gap:0.25rem}[data-slot="listing-card-price"]{font-size:var(--garagem-listing-price-size);font-weight:600}[data-slot="listing-card-period"]{font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-checkbox"]{appearance:none;width:1.15rem;height:1.15rem;flex-shrink:0;cursor:pointer;border:1px solid var(--primary,#111);border-radius:0.25rem;background:var(--background,#fff)}[data-slot="search-checkbox"]:checked{background-color:var(--primary,#111);background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'><path d='M5 12l5 5L20 7'/></svg>");background-repeat:no-repeat;background-position:center;background-size:0.8rem}[data-slot="search-scroll"]{max-height:12rem;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--muted-foreground,#a1a1aa) transparent}[data-slot="search-range-apply"]{display:inline-flex;min-height:2.5rem;cursor:pointer;align-items:center;justify-content:center;border:0;border-radius:var(--garagem-search-radius);background:var(--primary,#111);color:var(--primary-foreground,#fff);padding:0 0.75rem;font-size:0.75rem;font-weight:600}[data-slot="search-sheet"]{position:fixed;inset:0;z-index:40}[data-slot="search-sheet-overlay"]{position:absolute;inset:0;border:0;cursor:pointer;background:rgb(0 0 0 / 0.4);animation:garagem-search-fade 160ms ease-out}[data-slot="search-sheet-panel"]{position:absolute;top:0;right:0;display:flex;height:100dvh;width:min(22rem,100%);flex-direction:column;background:var(--background,#fff);animation:garagem-search-sheet 180ms ease-out}[data-slot="search-sheet-body"]{min-height:0;flex:1;overflow:auto;padding:1.5rem 1.5rem 0;scrollbar-width:thin}[data-slot="search-sheet-footer"]{display:flex;gap:0.5rem;border-top:1px solid var(--border,#e4e4e7);padding:1rem 1.5rem}[data-slot="search-apply-bar"]{display:flex;width:100%;gap:0.5rem}[data-slot="search-apply-bar"] > button{min-height:2.5rem;flex:1;cursor:pointer;border-radius:var(--garagem-search-radius);padding:0 1rem}[data-slot="search-apply-bar"] > button[data-kind="clear"]{border:1px solid var(--border,#e4e4e7);background:transparent}[data-slot="search-apply-bar"] > button[data-kind="apply"]{border:0;background:var(--primary,#111);color:var(--primary-foreground,#fff);font-weight:600}[data-slot="search-pagination"]{margin-top:2.5rem;display:flex;justify-content:center}[data-slot="search-pagination"] ul{display:flex;flex-wrap:wrap;justify-content:center;gap:0.25rem;padding:0;margin:0;list-style:none}[data-slot="search-pagination-item"]{display:inline-flex;width:2.25rem;height:2.25rem;align-items:center;justify-content:center;border:1px solid var(--border,#e4e4e7);border-radius:0.375rem;font-size:0.75rem;font-weight:500}@media (min-width:768px){[data-slot="search-pagination-item"]{width:2.5rem;height:2.5rem}}[data-slot="search-pagination-item"] a,[data-slot="search-pagination-item"] span{display:flex;width:100%;height:100%;align-items:center;justify-content:center;color:inherit;text-decoration:none}[data-slot="search-pagination-item"][data-current="true"]{background:var(--primary,#111);color:var(--primary-foreground,#fff)}[data-slot="search-pagination-item"][data-disabled="true"]{cursor:not-allowed;color:var(--muted-foreground,#737373)}[data-slot="search-toolbar-item"]{position:relative}[data-slot="search-body"]{margin-top:2rem;display:flex;flex-direction:column;gap:1.5rem}[data-slot="search-label"]{margin-bottom:0.25rem;display:block;font-size:0.875rem;color:var(--muted-foreground,#737373)}[data-slot="search-sheet-title"]{padding:1.5rem 1.5rem 0;font-size:1.125rem;font-weight:600}[data-slot="search-layout"]{display:grid;gap:2rem}[data-slot="search-sidebar"]{display:none}[data-slot="search-layout"] > div > [data-slot="search-filters-trigger"]{margin-bottom:1rem}@media (min-width:1024px){[data-slot="search-layout"]{grid-template-columns:280px minmax(0,1fr)}[data-slot="search-sidebar"]{display:block;position:sticky;top:1.5rem;align-self:start}[data-slot="search-layout"] > div > [data-slot="search-filters-trigger"]{display:none}}[data-slot="listing-card-link"]{display:block;color:inherit;text-decoration:none;cursor:pointer}[data-slot="listing-card-media"]{position:relative;width:100%;overflow:hidden;background:var(--muted,#f5f5f4);aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot="listing-card-media"] img{height:100%;width:100%;object-fit:cover;transition:transform 0.3s}[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img{transform:scale(1.05)}@media (prefers-reduced-motion:reduce){[data-slot="listing-card-media"] img{transition:none}[data-slot="listing-card"]:hover [data-slot="listing-card-media"] img{transform:none}}[data-slot="listing-card-empty"]{display:flex;height:100%;width:100%;align-items:center;justify-content:center;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="listing-card-cta"]{margin-top:0.75rem}[data-slot="search-filters"]{display:flex;flex-direction:column;gap:1.25rem}[data-slot="search-filter"]{margin:0;padding:0;border:0;font-size:0.875rem}[data-slot="search-filter"] legend{margin-bottom:0.5rem;padding:0;color:var(--muted-foreground,#737373)}[data-slot="search-range-row"]{display:flex;align-items:flex-end;gap:0.5rem}[data-slot="search-range-side"]{min-width:0;flex:1}[data-slot="search-range-side"] > span:first-child{margin-bottom:0.25rem;display:block;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-range-affix"]{position:relative;display:block}[data-slot="search-range-prefix"]{pointer-events:none;position:absolute;inset-block:0;left:0;display:flex;align-items:center;padding-left:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-range-input"]{min-height:2.5rem;width:100%;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem}[data-slot="search-range-affix"] [data-slot="search-range-input"]{padding-left:2.5rem}[data-slot="search-count-group"]{display:flex;flex-wrap:wrap;gap:0.375rem}[data-slot="search-count-choice"]{min-height:2.5rem;cursor:pointer;border-radius:var(--garagem-search-radius);border:1px solid var(--border,#e4e4e7);background:var(--background,#fff);padding:0 0.75rem;font-size:0.875rem}[data-slot="search-count-choice"][data-selected="true"]{border-color:var(--primary,#111);background:color-mix(in srgb,var(--primary,#111) 10%,transparent)}[data-slot="search-enum-list"],[data-slot="search-scroll"]{display:flex;flex-direction:column;gap:0.375rem}[data-slot="search-enum-option"]{display:flex;cursor:pointer;align-items:center;gap:0.5rem}[data-slot="listing-card-badge"]{position:absolute;left:0.75rem;top:0.75rem;border-radius:999px;background:color-mix(in srgb,var(--background,#fff) 90%,transparent);padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500}[data-slot="listing-card-body"]{padding:1rem}[data-slot="listing-card-title"]{display:-webkit-box;margin-top:0.25rem;overflow:hidden;-webkit-box-orient:vertical;-webkit-line-clamp:1;font-size:0.875rem;font-weight:500}[data-slot="listing-card-location"]{margin-top:0.125rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="listing-card-features"]{display:flex;flex-wrap:wrap;margin-top:0.75rem;gap:0.25rem 1rem;padding:0;list-style:none;font-size:0.75rem;color:var(--muted-foreground,#737373)}[data-slot="search-skeleton-block"]{animation:garagem-search-pulse 1.2s ease-in-out infinite;background:var(--garagem-skeleton);border-radius:0.375rem}[data-slot="search-skeleton-card"]{overflow:hidden;border-radius:var(--garagem-listing-card-radius);border:1px solid var(--border,#e4e4e7)}[data-slot="search-skeleton-body"]{display:flex;flex-direction:column;gap:0.5rem;padding:1rem}[data-slot="search-skeleton-block"][data-kind="media"]{aspect-ratio:var(--garagem-listing-media-ratio)}[data-slot="search-skeleton-block"][data-kind="line-lg"]{height:1.25rem;width:50%}[data-slot="search-skeleton-block"][data-kind="line-md"]{height:1rem;width:75%}[data-slot="search-skeleton-block"][data-kind="line-sm"]{height:0.75rem;width:66.666667%}[data-slot="search-skeleton-block"][data-kind="detail-media"]{max-width:45rem;aspect-ratio:4 / 3}[data-slot="search-skeleton-block"][data-kind="detail-title"]{width:66.666667%;height:2rem;margin-top:1.5rem}@media (prefers-reduced-motion:reduce){[data-slot="search-popover"],[data-slot="search-sheet-overlay"],[data-slot="search-sheet-panel"],[data-slot="search-skeleton-block"]{animation:none}}@keyframes garagem-search-in{from{opacity:0;transform:translateY(-4px) scale(0.98)}to{opacity:1;transform:none}}@keyframes garagem-search-fade{from{opacity:0}to{opacity:1}}@keyframes garagem-search-sheet{from{transform:translateX(100%)}to{transform:none}}@keyframes garagem-search-pulse{50%{opacity:0.55}}`;
|
|
1119
|
+
|
|
1120
|
+
// src/react/styles/search-chrome-styles.tsx
|
|
1121
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1122
|
+
var STYLE_ID = `garagem-search-chrome-${SEARCH_CHROME_CSS_VERSION}`;
|
|
1123
|
+
function SearchChromeStyles() {
|
|
1124
|
+
return /* @__PURE__ */ jsx3("style", { id: STYLE_ID, children: SEARCH_CHROME_CSS });
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1155
1127
|
// src/react/search-chrome.tsx
|
|
1156
|
-
import { jsx as
|
|
1128
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1157
1129
|
function SearchSortSelect({
|
|
1158
1130
|
value,
|
|
1159
1131
|
onChange,
|
|
@@ -1161,16 +1133,16 @@ function SearchSortSelect({
|
|
|
1161
1133
|
className
|
|
1162
1134
|
}) {
|
|
1163
1135
|
const options = searchSortOptions(sorts);
|
|
1164
|
-
return /* @__PURE__ */ jsxs3("label", {
|
|
1165
|
-
/* @__PURE__ */
|
|
1166
|
-
/* @__PURE__ */
|
|
1136
|
+
return /* @__PURE__ */ jsxs3("label", { "data-slot": "search-sort", className, children: [
|
|
1137
|
+
/* @__PURE__ */ jsx4("span", { "data-slot": "search-label", children: "Ordenar" }),
|
|
1138
|
+
/* @__PURE__ */ jsx4(
|
|
1167
1139
|
"select",
|
|
1168
1140
|
{
|
|
1169
1141
|
id: "garagem-search-sort",
|
|
1142
|
+
"data-slot": "search-sort-trigger",
|
|
1170
1143
|
value,
|
|
1171
1144
|
onChange: (event) => onChange(event.target.value || null),
|
|
1172
|
-
|
|
1173
|
-
children: options.map((sort) => /* @__PURE__ */ jsx3("option", { value: sort.id, children: sort.label }, sort.id || "relevance"))
|
|
1145
|
+
children: options.map((sort) => /* @__PURE__ */ jsx4("option", { value: sort.id, children: sort.label }, sort.id || "relevance"))
|
|
1174
1146
|
}
|
|
1175
1147
|
)
|
|
1176
1148
|
] });
|
|
@@ -1178,127 +1150,118 @@ function SearchSortSelect({
|
|
|
1178
1150
|
function ResultsSkeleton({
|
|
1179
1151
|
className
|
|
1180
1152
|
}) {
|
|
1181
|
-
return /* @__PURE__ */
|
|
1182
|
-
"div",
|
|
1183
|
-
{
|
|
1184
|
-
"data-slot": "search-skeleton",
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
className: "animate-pulse bg-muted",
|
|
1198
|
-
style: { aspectRatio: "4 / 3" }
|
|
1199
|
-
}
|
|
1200
|
-
),
|
|
1201
|
-
/* @__PURE__ */ jsxs3("div", { className: "space-y-2 p-4", children: [
|
|
1202
|
-
/* @__PURE__ */ jsx3("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
|
|
1203
|
-
/* @__PURE__ */ jsx3("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
|
|
1204
|
-
/* @__PURE__ */ jsx3("div", { className: "h-3 w-2/3 animate-pulse rounded bg-muted" })
|
|
1205
|
-
] })
|
|
1206
|
-
]
|
|
1207
|
-
},
|
|
1208
|
-
i
|
|
1209
|
-
))
|
|
1210
|
-
}
|
|
1211
|
-
);
|
|
1153
|
+
return /* @__PURE__ */ jsx4("div", { "data-slot": "search-skeleton", className, children: Array.from({ length: 6 }, (_, i) => /* @__PURE__ */ jsxs3("div", { "data-slot": "search-skeleton-card", children: [
|
|
1154
|
+
/* @__PURE__ */ jsx4("div", { "data-slot": "search-skeleton-block", "data-kind": "media" }),
|
|
1155
|
+
/* @__PURE__ */ jsxs3("div", { "data-slot": "search-skeleton-body", children: [
|
|
1156
|
+
/* @__PURE__ */ jsx4("div", { "data-slot": "search-skeleton-block", "data-kind": "line-lg" }),
|
|
1157
|
+
/* @__PURE__ */ jsx4("div", { "data-slot": "search-skeleton-block", "data-kind": "line-md" }),
|
|
1158
|
+
/* @__PURE__ */ jsx4("div", { "data-slot": "search-skeleton-block", "data-kind": "line-sm" })
|
|
1159
|
+
] })
|
|
1160
|
+
] }, i)) });
|
|
1161
|
+
}
|
|
1162
|
+
function SearchPageFallback({
|
|
1163
|
+
className
|
|
1164
|
+
}) {
|
|
1165
|
+
return /* @__PURE__ */ jsxs3("main", { "data-slot": "search-page", children: [
|
|
1166
|
+
/* @__PURE__ */ jsx4(SearchChromeStyles, {}),
|
|
1167
|
+
/* @__PURE__ */ jsx4(ResultsSkeleton, { className })
|
|
1168
|
+
] });
|
|
1212
1169
|
}
|
|
1213
1170
|
|
|
1214
1171
|
// src/react/search-pagination.tsx
|
|
1215
1172
|
import Link2 from "next/link";
|
|
1216
|
-
import { jsx as
|
|
1173
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1217
1174
|
function NavItem({
|
|
1218
1175
|
href,
|
|
1219
1176
|
label,
|
|
1220
1177
|
disabled,
|
|
1221
1178
|
current,
|
|
1222
|
-
|
|
1179
|
+
onNavigate
|
|
1223
1180
|
}) {
|
|
1224
|
-
const itemClass = cn(
|
|
1225
|
-
"inline-flex size-8 cursor-pointer items-center justify-center rounded-md border text-xs font-medium md:size-9",
|
|
1226
|
-
current && "bg-primary text-primary-foreground",
|
|
1227
|
-
disabled && "cursor-not-allowed text-muted-foreground",
|
|
1228
|
-
className
|
|
1229
|
-
);
|
|
1230
1181
|
if (disabled || !href || current) {
|
|
1231
|
-
return /* @__PURE__ */
|
|
1182
|
+
return /* @__PURE__ */ jsx5(
|
|
1183
|
+
"li",
|
|
1184
|
+
{
|
|
1185
|
+
"data-slot": "search-pagination-item",
|
|
1186
|
+
"data-current": current ? "true" : void 0,
|
|
1187
|
+
"data-disabled": disabled ? "true" : void 0,
|
|
1188
|
+
children: /* @__PURE__ */ jsx5("span", { children: label })
|
|
1189
|
+
}
|
|
1190
|
+
);
|
|
1232
1191
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
{
|
|
1236
|
-
|
|
1237
|
-
className: "flex size-full items-center justify-center",
|
|
1238
|
-
"aria-label": label,
|
|
1239
|
-
children: label
|
|
1192
|
+
function handleClick(event) {
|
|
1193
|
+
if (!onNavigate || !href) return;
|
|
1194
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) {
|
|
1195
|
+
return;
|
|
1240
1196
|
}
|
|
1241
|
-
|
|
1197
|
+
event.preventDefault();
|
|
1198
|
+
onNavigate(href);
|
|
1199
|
+
}
|
|
1200
|
+
return /* @__PURE__ */ jsx5("li", { "data-slot": "search-pagination-item", children: /* @__PURE__ */ jsx5(Link2, { href, onClick: handleClick, "aria-label": label, children: label }) });
|
|
1242
1201
|
}
|
|
1243
1202
|
function SearchPagination({
|
|
1244
1203
|
page,
|
|
1245
1204
|
totalPages,
|
|
1246
1205
|
hrefForPage,
|
|
1206
|
+
onNavigate,
|
|
1247
1207
|
className
|
|
1248
1208
|
}) {
|
|
1249
1209
|
if (totalPages <= 1) return null;
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1252
|
-
return /* @__PURE__ */ jsx4(
|
|
1210
|
+
const pages = paginationPages(page, totalPages, 2);
|
|
1211
|
+
return /* @__PURE__ */ jsx5(
|
|
1253
1212
|
"nav",
|
|
1254
1213
|
{
|
|
1255
1214
|
"data-slot": "search-pagination",
|
|
1256
|
-
className
|
|
1215
|
+
className,
|
|
1257
1216
|
"aria-label": "Pagina\xE7\xE3o",
|
|
1258
|
-
children: /* @__PURE__ */ jsxs4("ul", {
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
-
/* @__PURE__ */ jsx4(
|
|
1217
|
+
children: /* @__PURE__ */ jsxs4("ul", { children: [
|
|
1218
|
+
/* @__PURE__ */ jsx5(
|
|
1261
1219
|
NavItem,
|
|
1262
1220
|
{
|
|
1263
|
-
href: hrefForPage(
|
|
1264
|
-
label: "\u2039",
|
|
1265
|
-
disabled: page <= 1
|
|
1221
|
+
href: hrefWithExplicitPage(hrefForPage(1), 1),
|
|
1222
|
+
label: "\u2039\u2039",
|
|
1223
|
+
disabled: page <= 1,
|
|
1224
|
+
onNavigate
|
|
1266
1225
|
}
|
|
1267
1226
|
),
|
|
1268
|
-
|
|
1227
|
+
/* @__PURE__ */ jsx5(
|
|
1269
1228
|
NavItem,
|
|
1270
1229
|
{
|
|
1271
|
-
href:
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1230
|
+
href: hrefWithExplicitPage(
|
|
1231
|
+
hrefForPage(Math.max(1, page - 1)),
|
|
1232
|
+
Math.max(1, page - 1)
|
|
1233
|
+
),
|
|
1234
|
+
label: "\u2039",
|
|
1235
|
+
disabled: page <= 1,
|
|
1236
|
+
onNavigate
|
|
1237
|
+
}
|
|
1238
|
+
),
|
|
1239
|
+
pages.map((n) => /* @__PURE__ */ jsx5(
|
|
1279
1240
|
NavItem,
|
|
1280
1241
|
{
|
|
1281
|
-
href: hrefForPage(n),
|
|
1242
|
+
href: hrefWithExplicitPage(hrefForPage(n), n),
|
|
1282
1243
|
label: String(n),
|
|
1283
1244
|
current: n === page,
|
|
1284
|
-
|
|
1245
|
+
onNavigate
|
|
1285
1246
|
},
|
|
1286
|
-
|
|
1247
|
+
n
|
|
1287
1248
|
)),
|
|
1288
|
-
/* @__PURE__ */
|
|
1249
|
+
/* @__PURE__ */ jsx5(
|
|
1289
1250
|
NavItem,
|
|
1290
1251
|
{
|
|
1291
1252
|
href: hrefForPage(Math.min(totalPages, page + 1)),
|
|
1292
1253
|
label: "\u203A",
|
|
1293
|
-
disabled: page >= totalPages
|
|
1254
|
+
disabled: page >= totalPages,
|
|
1255
|
+
onNavigate
|
|
1294
1256
|
}
|
|
1295
1257
|
),
|
|
1296
|
-
/* @__PURE__ */
|
|
1258
|
+
/* @__PURE__ */ jsx5(
|
|
1297
1259
|
NavItem,
|
|
1298
1260
|
{
|
|
1299
1261
|
href: hrefForPage(totalPages),
|
|
1300
1262
|
label: "\u203A\u203A",
|
|
1301
|
-
disabled: page >= totalPages
|
|
1263
|
+
disabled: page >= totalPages,
|
|
1264
|
+
onNavigate
|
|
1302
1265
|
}
|
|
1303
1266
|
)
|
|
1304
1267
|
] })
|
|
@@ -1306,73 +1269,102 @@ function SearchPagination({
|
|
|
1306
1269
|
);
|
|
1307
1270
|
}
|
|
1308
1271
|
|
|
1272
|
+
// src/react/icons.tsx
|
|
1273
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1274
|
+
function Icon({ children, ...props }) {
|
|
1275
|
+
return /* @__PURE__ */ jsx6(
|
|
1276
|
+
"svg",
|
|
1277
|
+
{
|
|
1278
|
+
viewBox: "0 0 24 24",
|
|
1279
|
+
fill: "none",
|
|
1280
|
+
stroke: "currentColor",
|
|
1281
|
+
strokeWidth: 2,
|
|
1282
|
+
strokeLinecap: "round",
|
|
1283
|
+
strokeLinejoin: "round",
|
|
1284
|
+
"aria-hidden": true,
|
|
1285
|
+
"data-slot": "search-icon",
|
|
1286
|
+
...props,
|
|
1287
|
+
children
|
|
1288
|
+
}
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
function SearchLensIcon(props) {
|
|
1292
|
+
return /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
1293
|
+
/* @__PURE__ */ jsx6("circle", { cx: "11", cy: "11", r: "7" }),
|
|
1294
|
+
/* @__PURE__ */ jsx6("path", { d: "M20 20l-3.5-3.5" })
|
|
1295
|
+
] });
|
|
1296
|
+
}
|
|
1297
|
+
function SearchClearIcon(props) {
|
|
1298
|
+
return /* @__PURE__ */ jsx6(Icon, { ...props, children: /* @__PURE__ */ jsx6("path", { d: "M6 6l12 12M18 6L6 18" }) });
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1309
1301
|
// src/react/search-query-form.tsx
|
|
1310
|
-
import { jsx as
|
|
1302
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1311
1303
|
function SearchQueryForm({
|
|
1312
1304
|
value,
|
|
1313
1305
|
onChange,
|
|
1314
1306
|
onSubmit,
|
|
1315
1307
|
onClear,
|
|
1316
|
-
className
|
|
1308
|
+
className,
|
|
1309
|
+
iconClassName,
|
|
1310
|
+
searchIcon,
|
|
1311
|
+
clearIcon
|
|
1317
1312
|
}) {
|
|
1318
1313
|
function handleSubmit(event) {
|
|
1319
1314
|
event.preventDefault();
|
|
1320
1315
|
onSubmit();
|
|
1321
1316
|
}
|
|
1322
|
-
return /* @__PURE__ */
|
|
1317
|
+
return /* @__PURE__ */ jsxs6(
|
|
1323
1318
|
"form",
|
|
1324
1319
|
{
|
|
1325
1320
|
role: "search",
|
|
1326
1321
|
"data-slot": "search-query",
|
|
1327
1322
|
onSubmit: handleSubmit,
|
|
1328
|
-
className
|
|
1329
|
-
children:
|
|
1330
|
-
/* @__PURE__ */
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
htmlFor: "garagem-search-q",
|
|
1334
|
-
className: "mb-1 block text-sm text-muted-foreground",
|
|
1335
|
-
children: "Busca"
|
|
1336
|
-
}
|
|
1337
|
-
),
|
|
1338
|
-
/* @__PURE__ */ jsxs5("div", { className: "relative", children: [
|
|
1339
|
-
/* @__PURE__ */ jsx5(
|
|
1323
|
+
className,
|
|
1324
|
+
children: [
|
|
1325
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: "garagem-search-q", "data-slot": "search-label", children: "Busca" }),
|
|
1326
|
+
/* @__PURE__ */ jsxs6("div", { "data-slot": "search-query-field", children: [
|
|
1327
|
+
/* @__PURE__ */ jsx7(
|
|
1340
1328
|
"input",
|
|
1341
1329
|
{
|
|
1342
1330
|
id: "garagem-search-q",
|
|
1343
1331
|
name: "q",
|
|
1344
|
-
type: "
|
|
1332
|
+
type: "text",
|
|
1333
|
+
inputMode: "search",
|
|
1345
1334
|
autoComplete: "off",
|
|
1346
1335
|
enterKeyHint: "search",
|
|
1347
1336
|
value,
|
|
1348
1337
|
onChange: (event) => onChange(event.target.value),
|
|
1349
1338
|
placeholder: "Busque por bairro, rua ou c\xF3digo",
|
|
1350
|
-
|
|
1339
|
+
"data-slot": "search-query-input"
|
|
1351
1340
|
}
|
|
1352
1341
|
),
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1342
|
+
/* @__PURE__ */ jsxs6("div", { "data-slot": "search-query-actions", children: [
|
|
1343
|
+
value ? /* @__PURE__ */ jsx7(
|
|
1344
|
+
"button",
|
|
1345
|
+
{
|
|
1346
|
+
type: "button",
|
|
1347
|
+
title: "Limpar busca",
|
|
1348
|
+
"aria-label": "Limpar busca",
|
|
1349
|
+
onClick: onClear,
|
|
1350
|
+
"data-slot": "search-icon-button",
|
|
1351
|
+
"data-kind": "clear",
|
|
1352
|
+
children: clearIcon ?? /* @__PURE__ */ jsx7(SearchClearIcon, { className: iconClassName })
|
|
1353
|
+
}
|
|
1354
|
+
) : null,
|
|
1355
|
+
/* @__PURE__ */ jsx7(
|
|
1356
|
+
"button",
|
|
1357
|
+
{
|
|
1358
|
+
type: "submit",
|
|
1359
|
+
title: "Buscar",
|
|
1360
|
+
"aria-label": "Buscar",
|
|
1361
|
+
"data-slot": "search-icon-button",
|
|
1362
|
+
children: searchIcon ?? /* @__PURE__ */ jsx7(SearchLensIcon, { className: iconClassName })
|
|
1363
|
+
}
|
|
1364
|
+
)
|
|
1365
|
+
] })
|
|
1374
1366
|
] })
|
|
1375
|
-
]
|
|
1367
|
+
]
|
|
1376
1368
|
}
|
|
1377
1369
|
);
|
|
1378
1370
|
}
|
|
@@ -1476,6 +1468,9 @@ function usePublicSearch(options) {
|
|
|
1476
1468
|
const [loading, setLoading] = useState(true);
|
|
1477
1469
|
const [qDraft, setQDraft] = useState("");
|
|
1478
1470
|
const [staged, setStaged] = useState({});
|
|
1471
|
+
const [locationNames, setLocationNames] = useState(
|
|
1472
|
+
null
|
|
1473
|
+
);
|
|
1479
1474
|
const parsed = useMemo(
|
|
1480
1475
|
() => readPublicSearch(pathname, search, schema?.dictionary),
|
|
1481
1476
|
[pathname, search, schema?.dictionary]
|
|
@@ -1519,6 +1514,7 @@ function usePublicSearch(options) {
|
|
|
1519
1514
|
const id = catalogId;
|
|
1520
1515
|
let active = true;
|
|
1521
1516
|
locationsRef.current = null;
|
|
1517
|
+
setLocationNames(null);
|
|
1522
1518
|
setSchema(null);
|
|
1523
1519
|
setListings([]);
|
|
1524
1520
|
setLoading(true);
|
|
@@ -1541,10 +1537,12 @@ function usePublicSearch(options) {
|
|
|
1541
1537
|
}
|
|
1542
1538
|
if (!active) return;
|
|
1543
1539
|
locationsRef.current = locations;
|
|
1540
|
+
setLocationNames(locations);
|
|
1544
1541
|
setSchema(nextSchema);
|
|
1545
1542
|
} catch {
|
|
1546
1543
|
if (active) {
|
|
1547
1544
|
locationsRef.current = null;
|
|
1545
|
+
setLocationNames(null);
|
|
1548
1546
|
setSchema(null);
|
|
1549
1547
|
setLoading(false);
|
|
1550
1548
|
}
|
|
@@ -1694,44 +1692,75 @@ function usePublicSearch(options) {
|
|
|
1694
1692
|
clearQuery,
|
|
1695
1693
|
setSort,
|
|
1696
1694
|
hrefForPage,
|
|
1697
|
-
go
|
|
1695
|
+
go,
|
|
1696
|
+
locationNames
|
|
1698
1697
|
};
|
|
1699
1698
|
}
|
|
1700
1699
|
|
|
1701
1700
|
// src/react/search-page.tsx
|
|
1702
|
-
import { Fragment, jsx as
|
|
1701
|
+
import { Fragment, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1703
1702
|
function ToolbarPopover({
|
|
1703
|
+
id,
|
|
1704
1704
|
label,
|
|
1705
|
+
open,
|
|
1706
|
+
onOpenChange,
|
|
1707
|
+
triggerClassName,
|
|
1708
|
+
popoverClassName,
|
|
1705
1709
|
children
|
|
1706
1710
|
}) {
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
|
|
1711
|
+
const rootRef = useRef2(null);
|
|
1712
|
+
useEffect2(() => {
|
|
1713
|
+
if (!open) return;
|
|
1714
|
+
function onPointer(event) {
|
|
1715
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
1716
|
+
onOpenChange(null);
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
function onKey(event) {
|
|
1720
|
+
if (event.key === "Escape") onOpenChange(null);
|
|
1721
|
+
}
|
|
1722
|
+
document.addEventListener("mousedown", onPointer);
|
|
1723
|
+
document.addEventListener("keydown", onKey);
|
|
1724
|
+
return () => {
|
|
1725
|
+
document.removeEventListener("mousedown", onPointer);
|
|
1726
|
+
document.removeEventListener("keydown", onKey);
|
|
1727
|
+
};
|
|
1728
|
+
}, [open, onOpenChange]);
|
|
1729
|
+
return /* @__PURE__ */ jsxs7("div", { "data-slot": "search-toolbar-item", ref: rootRef, children: [
|
|
1730
|
+
/* @__PURE__ */ jsx8(
|
|
1710
1731
|
"button",
|
|
1711
1732
|
{
|
|
1712
1733
|
type: "button",
|
|
1713
|
-
|
|
1714
|
-
className:
|
|
1734
|
+
"data-slot": "search-toolbar-trigger",
|
|
1735
|
+
className: triggerClassName,
|
|
1736
|
+
"aria-expanded": open,
|
|
1737
|
+
onClick: () => onOpenChange(open ? null : id),
|
|
1715
1738
|
children: label
|
|
1716
1739
|
}
|
|
1717
1740
|
),
|
|
1718
|
-
open ? /* @__PURE__ */
|
|
1741
|
+
open ? /* @__PURE__ */ jsx8(
|
|
1742
|
+
"div",
|
|
1743
|
+
{
|
|
1744
|
+
"data-slot": "search-popover",
|
|
1745
|
+
className: popoverClassName,
|
|
1746
|
+
role: "dialog",
|
|
1747
|
+
children
|
|
1748
|
+
}
|
|
1749
|
+
) : null
|
|
1719
1750
|
] });
|
|
1720
1751
|
}
|
|
1721
1752
|
function FiltersTrigger({
|
|
1722
1753
|
onClick,
|
|
1723
1754
|
className
|
|
1724
1755
|
}) {
|
|
1725
|
-
return /* @__PURE__ */
|
|
1756
|
+
return /* @__PURE__ */ jsx8(
|
|
1726
1757
|
"button",
|
|
1727
1758
|
{
|
|
1728
1759
|
type: "button",
|
|
1729
1760
|
title: "Filtros",
|
|
1761
|
+
"data-slot": "search-filters-trigger",
|
|
1730
1762
|
onClick,
|
|
1731
|
-
className
|
|
1732
|
-
"min-h-10 cursor-pointer rounded-lg border border-border px-3 text-sm hover:bg-muted",
|
|
1733
|
-
className
|
|
1734
|
-
),
|
|
1763
|
+
className,
|
|
1735
1764
|
children: "Filtros"
|
|
1736
1765
|
}
|
|
1737
1766
|
);
|
|
@@ -1741,27 +1770,82 @@ function ApplyBar({
|
|
|
1741
1770
|
onApply,
|
|
1742
1771
|
className
|
|
1743
1772
|
}) {
|
|
1744
|
-
return /* @__PURE__ */
|
|
1745
|
-
/* @__PURE__ */
|
|
1773
|
+
return /* @__PURE__ */ jsxs7("div", { "data-slot": "search-apply-bar", className, children: [
|
|
1774
|
+
/* @__PURE__ */ jsx8("button", { type: "button", "data-kind": "clear", onClick: onClear, children: "Limpar" }),
|
|
1775
|
+
/* @__PURE__ */ jsx8("button", { type: "button", "data-kind": "apply", onClick: onApply, children: "Ver resultados" })
|
|
1776
|
+
] });
|
|
1777
|
+
}
|
|
1778
|
+
function FilterSheet({
|
|
1779
|
+
open,
|
|
1780
|
+
title,
|
|
1781
|
+
onClose,
|
|
1782
|
+
overlayClassName,
|
|
1783
|
+
panelClassName,
|
|
1784
|
+
children,
|
|
1785
|
+
footer
|
|
1786
|
+
}) {
|
|
1787
|
+
const onCloseRef = useRef2(onClose);
|
|
1788
|
+
onCloseRef.current = onClose;
|
|
1789
|
+
useEffect2(() => {
|
|
1790
|
+
if (!open) return;
|
|
1791
|
+
function onKey(event) {
|
|
1792
|
+
if (event.key === "Escape") onCloseRef.current();
|
|
1793
|
+
}
|
|
1794
|
+
document.addEventListener("keydown", onKey);
|
|
1795
|
+
const previous = document.body.style.overflow;
|
|
1796
|
+
document.body.style.overflow = "hidden";
|
|
1797
|
+
return () => {
|
|
1798
|
+
document.removeEventListener("keydown", onKey);
|
|
1799
|
+
document.body.style.overflow = previous;
|
|
1800
|
+
};
|
|
1801
|
+
}, [open]);
|
|
1802
|
+
if (!open) return null;
|
|
1803
|
+
return /* @__PURE__ */ jsxs7("div", { "data-slot": "search-sheet", children: [
|
|
1804
|
+
/* @__PURE__ */ jsx8(
|
|
1746
1805
|
"button",
|
|
1747
1806
|
{
|
|
1748
1807
|
type: "button",
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1808
|
+
"aria-label": "Fechar filtros",
|
|
1809
|
+
"data-slot": "search-sheet-overlay",
|
|
1810
|
+
className: overlayClassName,
|
|
1811
|
+
onClick: onClose
|
|
1752
1812
|
}
|
|
1753
1813
|
),
|
|
1754
|
-
/* @__PURE__ */
|
|
1755
|
-
"
|
|
1814
|
+
/* @__PURE__ */ jsxs7(
|
|
1815
|
+
"div",
|
|
1756
1816
|
{
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1817
|
+
"data-slot": "search-sheet-panel",
|
|
1818
|
+
className: panelClassName,
|
|
1819
|
+
role: "dialog",
|
|
1820
|
+
"aria-modal": "true",
|
|
1821
|
+
"aria-label": title,
|
|
1822
|
+
children: [
|
|
1823
|
+
/* @__PURE__ */ jsx8("p", { "data-slot": "search-sheet-title", children: title }),
|
|
1824
|
+
/* @__PURE__ */ jsx8("div", { "data-slot": "search-sheet-body", children }),
|
|
1825
|
+
/* @__PURE__ */ jsx8("div", { "data-slot": "search-sheet-footer", children: footer })
|
|
1826
|
+
]
|
|
1761
1827
|
}
|
|
1762
1828
|
)
|
|
1763
1829
|
] });
|
|
1764
1830
|
}
|
|
1831
|
+
function SearchHeading({
|
|
1832
|
+
total,
|
|
1833
|
+
title,
|
|
1834
|
+
classNames,
|
|
1835
|
+
loading
|
|
1836
|
+
}) {
|
|
1837
|
+
return /* @__PURE__ */ jsxs7("div", { "data-slot": "search-heading", className: classNames?.heading, children: [
|
|
1838
|
+
!loading ? /* @__PURE__ */ jsx8(
|
|
1839
|
+
"span",
|
|
1840
|
+
{
|
|
1841
|
+
"data-slot": "search-heading-count",
|
|
1842
|
+
className: classNames?.headingCount,
|
|
1843
|
+
children: total.toLocaleString("pt-BR")
|
|
1844
|
+
}
|
|
1845
|
+
) : null,
|
|
1846
|
+
/* @__PURE__ */ jsx8("h1", { "data-slot": "search-heading-title", className: classNames?.headingTitle, children: title })
|
|
1847
|
+
] });
|
|
1848
|
+
}
|
|
1765
1849
|
function SearchPage({
|
|
1766
1850
|
siteId,
|
|
1767
1851
|
baseUrl,
|
|
@@ -1769,11 +1853,12 @@ function SearchPage({
|
|
|
1769
1853
|
className,
|
|
1770
1854
|
classNames,
|
|
1771
1855
|
heading,
|
|
1856
|
+
icons,
|
|
1772
1857
|
listingCard: Card = ListingCard
|
|
1773
1858
|
}) {
|
|
1774
1859
|
const search = usePublicSearch({ siteId, baseUrl });
|
|
1775
|
-
const
|
|
1776
|
-
const [
|
|
1860
|
+
const [sheetOpen, setSheetOpen] = useState2(false);
|
|
1861
|
+
const [openToolbar, setOpenToolbar] = useState2(null);
|
|
1777
1862
|
const [rangeDraft, setRangeDraft] = useState2(
|
|
1778
1863
|
() => rangeDraftFromPath(search.pathFilters)
|
|
1779
1864
|
);
|
|
@@ -1784,6 +1869,11 @@ function SearchPage({
|
|
|
1784
1869
|
const toolbarIds = new Set(toolbarFilterIds(search.schema));
|
|
1785
1870
|
const toolbarFilters = filters.filter((filter) => toolbarIds.has(filter.id));
|
|
1786
1871
|
const extraFilters = filters.filter((filter) => !toolbarIds.has(filter.id));
|
|
1872
|
+
const headingTitle = searchResultsHeading(
|
|
1873
|
+
search.pathFilters,
|
|
1874
|
+
search.schema?.dictionary,
|
|
1875
|
+
search.locationNames
|
|
1876
|
+
);
|
|
1787
1877
|
function patchRange(filterId, side, value) {
|
|
1788
1878
|
setRangeDraft((prev) => ({
|
|
1789
1879
|
...prev,
|
|
@@ -1802,9 +1892,12 @@ function SearchPage({
|
|
|
1802
1892
|
function openStagedFilters() {
|
|
1803
1893
|
search.resetStagedFromUrl();
|
|
1804
1894
|
setRangeDraft(rangeDraftFromPath(search.pathFilters));
|
|
1805
|
-
|
|
1806
|
-
|
|
1895
|
+
setOpenToolbar(null);
|
|
1896
|
+
setSheetOpen(true);
|
|
1807
1897
|
}
|
|
1898
|
+
const closeSheet = useCallback2(() => {
|
|
1899
|
+
setSheetOpen(false);
|
|
1900
|
+
}, []);
|
|
1808
1901
|
function clearStagedFilters() {
|
|
1809
1902
|
const keepIds = variant === "toolbar" ? [...toolbarIds] : [];
|
|
1810
1903
|
const source = variant === "toolbar" ? search.pathFilters : search.staged;
|
|
@@ -1822,68 +1915,62 @@ function SearchPage({
|
|
|
1822
1915
|
}
|
|
1823
1916
|
function applyStagedAndClose() {
|
|
1824
1917
|
search.applyStaged();
|
|
1825
|
-
|
|
1826
|
-
setMobileFiltersOpen(false);
|
|
1918
|
+
closeSheet();
|
|
1827
1919
|
}
|
|
1828
|
-
const results = search.loading ? /* @__PURE__ */
|
|
1829
|
-
/* @__PURE__ */
|
|
1830
|
-
|
|
1831
|
-
" ",
|
|
1832
|
-
search.total === 1 ? "im\xF3vel encontrado" : "im\xF3veis encontrados"
|
|
1833
|
-
] }),
|
|
1834
|
-
/* @__PURE__ */ jsx6(
|
|
1835
|
-
"div",
|
|
1920
|
+
const results = search.loading ? /* @__PURE__ */ jsx8(ResultsSkeleton, { className: classNames?.skeleton ?? classNames?.grid }) : /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1921
|
+
/* @__PURE__ */ jsx8("div", { "data-slot": "search-grid", className: classNames?.grid, children: search.listings.map((listing) => /* @__PURE__ */ jsx8(
|
|
1922
|
+
Card,
|
|
1836
1923
|
{
|
|
1837
|
-
|
|
1838
|
-
className:
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
Card,
|
|
1844
|
-
{
|
|
1845
|
-
listing,
|
|
1846
|
-
className: classNames?.card
|
|
1847
|
-
},
|
|
1848
|
-
listing.id
|
|
1849
|
-
))
|
|
1850
|
-
}
|
|
1851
|
-
),
|
|
1852
|
-
/* @__PURE__ */ jsx6(
|
|
1924
|
+
listing,
|
|
1925
|
+
className: classNames?.card
|
|
1926
|
+
},
|
|
1927
|
+
listing.id
|
|
1928
|
+
)) }),
|
|
1929
|
+
/* @__PURE__ */ jsx8(
|
|
1853
1930
|
SearchPagination,
|
|
1854
1931
|
{
|
|
1855
1932
|
page: search.page,
|
|
1856
1933
|
totalPages: search.totalPages,
|
|
1857
1934
|
hrefForPage: search.hrefForPage,
|
|
1935
|
+
onNavigate: search.go,
|
|
1858
1936
|
className: classNames?.pagination
|
|
1859
1937
|
}
|
|
1860
1938
|
)
|
|
1861
1939
|
] });
|
|
1862
|
-
const queryAndSort = /* @__PURE__ */
|
|
1863
|
-
/* @__PURE__ */
|
|
1940
|
+
const queryAndSort = /* @__PURE__ */ jsxs7("div", { "data-slot": "search-query-sort", children: [
|
|
1941
|
+
/* @__PURE__ */ jsx8(
|
|
1864
1942
|
SearchQueryForm,
|
|
1865
1943
|
{
|
|
1866
1944
|
value: search.qDraft,
|
|
1867
1945
|
onChange: search.setQDraft,
|
|
1868
1946
|
onSubmit: search.submitQuery,
|
|
1869
1947
|
onClear: search.clearQuery,
|
|
1870
|
-
className:
|
|
1948
|
+
className: classNames?.query,
|
|
1949
|
+
iconClassName: classNames?.icon,
|
|
1950
|
+
searchIcon: icons?.search,
|
|
1951
|
+
clearIcon: icons?.clear
|
|
1871
1952
|
}
|
|
1872
1953
|
),
|
|
1873
|
-
/* @__PURE__ */
|
|
1954
|
+
/* @__PURE__ */ jsx8(
|
|
1874
1955
|
SearchSortSelect,
|
|
1875
1956
|
{
|
|
1876
1957
|
value: search.applied.sort || "",
|
|
1877
1958
|
onChange: search.setSort,
|
|
1878
|
-
sorts: search.schema?.sorts
|
|
1959
|
+
sorts: search.schema?.sorts,
|
|
1960
|
+
className: classNames?.sort
|
|
1879
1961
|
}
|
|
1880
1962
|
)
|
|
1881
1963
|
] });
|
|
1882
|
-
const header = heading ?? /* @__PURE__ */
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1964
|
+
const header = heading ?? /* @__PURE__ */ jsx8(
|
|
1965
|
+
SearchHeading,
|
|
1966
|
+
{
|
|
1967
|
+
total: search.total,
|
|
1968
|
+
title: headingTitle,
|
|
1969
|
+
classNames,
|
|
1970
|
+
loading: search.loading
|
|
1971
|
+
}
|
|
1972
|
+
);
|
|
1973
|
+
const stagedPanel = (items) => /* @__PURE__ */ jsx8(
|
|
1887
1974
|
FilterPanel,
|
|
1888
1975
|
{
|
|
1889
1976
|
filters: items,
|
|
@@ -1894,124 +1981,88 @@ function SearchPage({
|
|
|
1894
1981
|
onRangeCommit: (id) => commitRange(id, false)
|
|
1895
1982
|
}
|
|
1896
1983
|
);
|
|
1897
|
-
|
|
1984
|
+
const sheet = /* @__PURE__ */ jsx8(
|
|
1985
|
+
FilterSheet,
|
|
1986
|
+
{
|
|
1987
|
+
open: sheetOpen,
|
|
1988
|
+
title: "Filtros",
|
|
1989
|
+
onClose: closeSheet,
|
|
1990
|
+
overlayClassName: classNames?.dialogOverlay,
|
|
1991
|
+
panelClassName: cn(classNames?.dialog, classNames?.dialogPanel),
|
|
1992
|
+
footer: /* @__PURE__ */ jsx8(
|
|
1993
|
+
ApplyBar,
|
|
1994
|
+
{
|
|
1995
|
+
onClear: clearStagedFilters,
|
|
1996
|
+
onApply: applyStagedAndClose,
|
|
1997
|
+
className: classNames?.applyBar
|
|
1998
|
+
}
|
|
1999
|
+
),
|
|
2000
|
+
children: stagedPanel(variant === "toolbar" ? extraFilters : filters)
|
|
2001
|
+
}
|
|
2002
|
+
);
|
|
2003
|
+
return /* @__PURE__ */ jsxs7(
|
|
1898
2004
|
"main",
|
|
1899
2005
|
{
|
|
1900
2006
|
"data-slot": "search-page",
|
|
1901
2007
|
"data-variant": variant,
|
|
1902
|
-
className: cn(
|
|
1903
|
-
"mx-auto max-w-7xl px-6 py-12",
|
|
1904
|
-
className,
|
|
1905
|
-
classNames?.root
|
|
1906
|
-
),
|
|
2008
|
+
className: cn(className, classNames?.root),
|
|
1907
2009
|
children: [
|
|
1908
|
-
/* @__PURE__ */
|
|
1909
|
-
/* @__PURE__ */
|
|
2010
|
+
/* @__PURE__ */ jsx8(SearchChromeStyles, {}),
|
|
2011
|
+
/* @__PURE__ */ jsx8("div", { className: classNames?.header, children: header }),
|
|
2012
|
+
/* @__PURE__ */ jsxs7("div", { "data-slot": "search-body", children: [
|
|
1910
2013
|
queryAndSort,
|
|
1911
|
-
variant === "toolbar" ? /* @__PURE__ */
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2014
|
+
variant === "toolbar" ? /* @__PURE__ */ jsxs7("div", { "data-slot": "search-toolbar", className: classNames?.toolbar, children: [
|
|
2015
|
+
toolbarFilters.map((filter) => /* @__PURE__ */ jsx8(
|
|
2016
|
+
ToolbarPopover,
|
|
2017
|
+
{
|
|
2018
|
+
id: filter.id,
|
|
2019
|
+
label: filter.label,
|
|
2020
|
+
open: openToolbar === filter.id,
|
|
2021
|
+
onOpenChange: setOpenToolbar,
|
|
2022
|
+
triggerClassName: classNames?.toolbarTrigger,
|
|
2023
|
+
popoverClassName: classNames?.popover,
|
|
2024
|
+
children: /* @__PURE__ */ jsx8(
|
|
1921
2025
|
FilterPanel,
|
|
1922
2026
|
{
|
|
1923
2027
|
filters: [filter],
|
|
1924
2028
|
pathFilters: search.pathFilters,
|
|
1925
|
-
onChange:
|
|
2029
|
+
onChange: (id, value) => {
|
|
2030
|
+
search.applyFilter(id, value);
|
|
2031
|
+
if (filter.type !== "range") setOpenToolbar(null);
|
|
2032
|
+
},
|
|
1926
2033
|
rangeDraft,
|
|
1927
2034
|
onRangePatch: patchRange,
|
|
1928
|
-
onRangeCommit: (id) =>
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
extraFilters.length > 0 ? /* @__PURE__ */ jsx6(FiltersTrigger, { onClick: openStagedFilters }) : null
|
|
1932
|
-
]
|
|
1933
|
-
}
|
|
1934
|
-
) : null,
|
|
1935
|
-
variant === "dialog" ? /* @__PURE__ */ jsx6(FiltersTrigger, { onClick: openStagedFilters }) : null,
|
|
1936
|
-
variant === "sidebar" ? /* @__PURE__ */ jsxs6("div", { className: "grid gap-8 lg:grid-cols-[280px_minmax(0,1fr)]", children: [
|
|
1937
|
-
/* @__PURE__ */ jsxs6(
|
|
1938
|
-
"aside",
|
|
1939
|
-
{
|
|
1940
|
-
"data-slot": "search-sidebar",
|
|
1941
|
-
className: cn(
|
|
1942
|
-
"hidden lg:sticky lg:top-6 lg:block lg:self-start",
|
|
1943
|
-
classNames?.sidebar
|
|
1944
|
-
),
|
|
1945
|
-
children: [
|
|
1946
|
-
stagedPanel(filters),
|
|
1947
|
-
/* @__PURE__ */ jsx6(
|
|
1948
|
-
ApplyBar,
|
|
1949
|
-
{
|
|
1950
|
-
onClear: clearStagedFilters,
|
|
1951
|
-
onApply: search.applyStaged,
|
|
1952
|
-
className: classNames?.applyBar
|
|
2035
|
+
onRangeCommit: (id, source) => {
|
|
2036
|
+
commitRange(id, true);
|
|
2037
|
+
if (source === "apply") setOpenToolbar(null);
|
|
1953
2038
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
}
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
results
|
|
1967
|
-
] })
|
|
1968
|
-
] }) : results
|
|
1969
|
-
] }),
|
|
1970
|
-
variant !== "sidebar" ? /* @__PURE__ */ jsxs6(
|
|
1971
|
-
"dialog",
|
|
1972
|
-
{
|
|
1973
|
-
ref: dialogRef,
|
|
1974
|
-
className: cn(
|
|
1975
|
-
"w-[min(32rem,calc(100%-2rem))] rounded-2xl border border-border bg-background p-6 shadow-xl",
|
|
1976
|
-
classNames?.dialog
|
|
1977
|
-
),
|
|
1978
|
-
children: [
|
|
1979
|
-
/* @__PURE__ */ jsx6("p", { className: "mb-4 text-lg font-semibold", children: "Filtros" }),
|
|
1980
|
-
stagedPanel(variant === "toolbar" ? extraFilters : filters),
|
|
1981
|
-
/* @__PURE__ */ jsx6(
|
|
2039
|
+
}
|
|
2040
|
+
)
|
|
2041
|
+
},
|
|
2042
|
+
filter.id
|
|
2043
|
+
)),
|
|
2044
|
+
extraFilters.length > 0 ? /* @__PURE__ */ jsx8(FiltersTrigger, { onClick: openStagedFilters }) : null
|
|
2045
|
+
] }) : null,
|
|
2046
|
+
variant === "dialog" ? /* @__PURE__ */ jsx8(FiltersTrigger, { onClick: openStagedFilters }) : null,
|
|
2047
|
+
variant === "sidebar" ? /* @__PURE__ */ jsxs7("div", { "data-slot": "search-layout", children: [
|
|
2048
|
+
/* @__PURE__ */ jsxs7("aside", { "data-slot": "search-sidebar", className: classNames?.sidebar, children: [
|
|
2049
|
+
stagedPanel(filters),
|
|
2050
|
+
/* @__PURE__ */ jsx8(
|
|
1982
2051
|
ApplyBar,
|
|
1983
2052
|
{
|
|
1984
2053
|
onClear: clearStagedFilters,
|
|
1985
|
-
onApply:
|
|
2054
|
+
onApply: search.applyStaged,
|
|
1986
2055
|
className: classNames?.applyBar
|
|
1987
2056
|
}
|
|
1988
2057
|
)
|
|
1989
|
-
]
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
"aria-label": "Fechar filtros",
|
|
1998
|
-
className: "absolute inset-0 bg-black/40",
|
|
1999
|
-
onClick: () => setMobileFiltersOpen(false)
|
|
2000
|
-
}
|
|
2001
|
-
),
|
|
2002
|
-
/* @__PURE__ */ jsxs6("div", { className: "absolute inset-y-0 right-0 w-[min(22rem,100%)] overflow-y-auto bg-background p-6", children: [
|
|
2003
|
-
/* @__PURE__ */ jsx6("p", { className: "mb-4 text-lg font-semibold", children: "Filtros" }),
|
|
2004
|
-
stagedPanel(filters),
|
|
2005
|
-
/* @__PURE__ */ jsx6(
|
|
2006
|
-
ApplyBar,
|
|
2007
|
-
{
|
|
2008
|
-
onClear: clearStagedFilters,
|
|
2009
|
-
onApply: applyStagedAndClose,
|
|
2010
|
-
className: classNames?.applyBar
|
|
2011
|
-
}
|
|
2012
|
-
)
|
|
2013
|
-
] })
|
|
2014
|
-
] }) : null
|
|
2058
|
+
] }),
|
|
2059
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
2060
|
+
/* @__PURE__ */ jsx8(FiltersTrigger, { onClick: openStagedFilters }),
|
|
2061
|
+
results
|
|
2062
|
+
] })
|
|
2063
|
+
] }) : results
|
|
2064
|
+
] }),
|
|
2065
|
+
sheet
|
|
2015
2066
|
]
|
|
2016
2067
|
}
|
|
2017
2068
|
);
|
|
@@ -2020,7 +2071,9 @@ export {
|
|
|
2020
2071
|
FilterPanel,
|
|
2021
2072
|
ListingCard,
|
|
2022
2073
|
ResultsSkeleton,
|
|
2074
|
+
SearchChromeStyles,
|
|
2023
2075
|
SearchPage,
|
|
2076
|
+
SearchPageFallback,
|
|
2024
2077
|
SearchPagination,
|
|
2025
2078
|
SearchQueryForm,
|
|
2026
2079
|
SearchSortSelect,
|