@mapfirst.ai/react 0.1.1 → 0.1.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/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +168 -145
- package/dist/index.mjs +121 -100
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
CloseIcon: () => CloseIcon,
|
|
35
35
|
EditIcon: () => EditIcon,
|
|
36
36
|
FilterChips: () => FilterChips,
|
|
37
|
+
IconsProvider: () => IconsProvider,
|
|
37
38
|
LeafletAdapter: () => import_core2.LeafletAdapter,
|
|
38
39
|
MapFirstCore: () => import_core2.MapFirstCore,
|
|
39
40
|
MinRatingFilterChip: () => MinRatingFilterChip,
|
|
@@ -55,21 +56,25 @@ __export(index_exports, {
|
|
|
55
56
|
processApiFilters: () => import_core2.processApiFilters,
|
|
56
57
|
renderStars: () => renderStars,
|
|
57
58
|
useFilterScroll: () => useFilterScroll,
|
|
59
|
+
useIcons: () => useIcons,
|
|
58
60
|
useMapFirst: () => useMapFirst,
|
|
59
61
|
useTranslation: () => useTranslation
|
|
60
62
|
});
|
|
61
63
|
module.exports = __toCommonJS(index_exports);
|
|
62
|
-
var
|
|
64
|
+
var import_react11 = __toESM(require("react"));
|
|
63
65
|
var import_core = require("@mapfirst.ai/core");
|
|
64
66
|
var import_core2 = require("@mapfirst.ai/core");
|
|
65
67
|
|
|
66
68
|
// src/components/SmartFilter.tsx
|
|
67
|
-
var
|
|
69
|
+
var import_react10 = require("react");
|
|
68
70
|
|
|
69
71
|
// src/components/smart-filter/FilterChips.tsx
|
|
70
|
-
var
|
|
72
|
+
var import_react9 = __toESM(require("react"));
|
|
71
73
|
|
|
72
74
|
// src/components/smart-filter/CloseButton.tsx
|
|
75
|
+
var import_react2 = __toESM(require("react"));
|
|
76
|
+
|
|
77
|
+
// src/context/IconsContext.tsx
|
|
73
78
|
var import_react = __toESM(require("react"));
|
|
74
79
|
|
|
75
80
|
// src/components/Icons.tsx
|
|
@@ -164,8 +169,20 @@ var StarIcon = ({
|
|
|
164
169
|
}
|
|
165
170
|
);
|
|
166
171
|
|
|
167
|
-
// src/
|
|
172
|
+
// src/context/IconsContext.tsx
|
|
168
173
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
174
|
+
var defaultIcons = {
|
|
175
|
+
CloseIcon,
|
|
176
|
+
EditIcon,
|
|
177
|
+
NextIcon,
|
|
178
|
+
SearchIcon
|
|
179
|
+
};
|
|
180
|
+
var IconsContext = import_react.default.createContext(defaultIcons);
|
|
181
|
+
var IconsProvider = ({ value, children }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(IconsContext.Provider, { value: value ? { ...defaultIcons, ...value } : defaultIcons, children });
|
|
182
|
+
var useIcons = () => import_react.default.useContext(IconsContext);
|
|
183
|
+
|
|
184
|
+
// src/components/smart-filter/CloseButton.tsx
|
|
185
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
169
186
|
var closeButtonStyles = {
|
|
170
187
|
position: "absolute",
|
|
171
188
|
top: "-8px",
|
|
@@ -185,8 +202,9 @@ var iconStyles = {
|
|
|
185
202
|
height: "17px"
|
|
186
203
|
};
|
|
187
204
|
var CloseButton = ({ onClick, style }) => {
|
|
188
|
-
const [isHovering, setIsHovering] =
|
|
189
|
-
|
|
205
|
+
const [isHovering, setIsHovering] = import_react2.default.useState(false);
|
|
206
|
+
const { CloseIcon: CloseIcon2 } = useIcons();
|
|
207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
190
208
|
"button",
|
|
191
209
|
{
|
|
192
210
|
style: {
|
|
@@ -198,13 +216,13 @@ var CloseButton = ({ onClick, style }) => {
|
|
|
198
216
|
onMouseEnter: () => setIsHovering(true),
|
|
199
217
|
onMouseLeave: () => setIsHovering(false),
|
|
200
218
|
"aria-label": "Remove filter",
|
|
201
|
-
children: /* @__PURE__ */ (0,
|
|
219
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CloseIcon2, { style: iconStyles })
|
|
202
220
|
}
|
|
203
221
|
);
|
|
204
222
|
};
|
|
205
223
|
|
|
206
224
|
// src/components/smart-filter/Chip.tsx
|
|
207
|
-
var
|
|
225
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
208
226
|
var chipStyles = {
|
|
209
227
|
position: "relative",
|
|
210
228
|
backgroundColor: "white",
|
|
@@ -221,25 +239,25 @@ var chipStyles = {
|
|
|
221
239
|
height: "34px"
|
|
222
240
|
};
|
|
223
241
|
var Chip = ({ label, icon, remove, style }) => {
|
|
224
|
-
return /* @__PURE__ */ (0,
|
|
225
|
-
icon && /* @__PURE__ */ (0,
|
|
226
|
-
/* @__PURE__ */ (0,
|
|
227
|
-
/* @__PURE__ */ (0,
|
|
242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { ...chipStyles, ...style }, children: [
|
|
243
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { display: "flex", alignItems: "center" }, children: icon }),
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: { whiteSpace: "nowrap" }, children: label }),
|
|
245
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CloseButton, { onClick: remove })
|
|
228
246
|
] });
|
|
229
247
|
};
|
|
230
248
|
|
|
231
249
|
// src/components/smart-filter/MinRatingFilterChip.tsx
|
|
232
|
-
var
|
|
250
|
+
var import_react5 = require("react");
|
|
233
251
|
|
|
234
252
|
// src/hooks/useTranslation.ts
|
|
235
|
-
var
|
|
253
|
+
var import_react4 = require("react");
|
|
236
254
|
|
|
237
255
|
// src/context/TranslationContext.tsx
|
|
238
|
-
var
|
|
239
|
-
var
|
|
240
|
-
var TranslationContext =
|
|
241
|
-
var TranslationProvider = ({ value, children }) => /* @__PURE__ */ (0,
|
|
242
|
-
var useCustomTranslationsContext = () =>
|
|
256
|
+
var import_react3 = __toESM(require("react"));
|
|
257
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
258
|
+
var TranslationContext = import_react3.default.createContext(void 0);
|
|
259
|
+
var TranslationProvider = ({ value, children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TranslationContext.Provider, { value, children });
|
|
260
|
+
var useCustomTranslationsContext = () => import_react3.default.useContext(TranslationContext);
|
|
243
261
|
|
|
244
262
|
// src/hooks/useTranslation.ts
|
|
245
263
|
var defaultTranslations = {
|
|
@@ -275,12 +293,12 @@ var formatCurrencyDefault = (value, currency = "USD") => {
|
|
|
275
293
|
var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
276
294
|
const contextTranslations = useCustomTranslationsContext();
|
|
277
295
|
const merged = customTranslations != null ? customTranslations : contextTranslations;
|
|
278
|
-
const [locale, setLocale] = (0,
|
|
279
|
-
const translations = (0,
|
|
296
|
+
const [locale, setLocale] = (0, import_react4.useState)("en");
|
|
297
|
+
const translations = (0, import_react4.useMemo)(
|
|
280
298
|
() => ({ ...defaultTranslations, ...merged }),
|
|
281
299
|
[merged]
|
|
282
300
|
);
|
|
283
|
-
const t = (0,
|
|
301
|
+
const t = (0, import_react4.useCallback)(
|
|
284
302
|
(key, params) => {
|
|
285
303
|
let translation = translations[key] || key;
|
|
286
304
|
if (params) {
|
|
@@ -295,7 +313,7 @@ var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
|
295
313
|
},
|
|
296
314
|
[translations]
|
|
297
315
|
);
|
|
298
|
-
const formatCurrency = (0,
|
|
316
|
+
const formatCurrency = (0, import_react4.useCallback)(
|
|
299
317
|
(value, currency) => {
|
|
300
318
|
if (customFormatCurrency) {
|
|
301
319
|
return customFormatCurrency(value, currency);
|
|
@@ -313,7 +331,7 @@ var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
|
313
331
|
};
|
|
314
332
|
|
|
315
333
|
// src/components/smart-filter/utils.tsx
|
|
316
|
-
var
|
|
334
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
317
335
|
var STAR_BASE_STYLES = {
|
|
318
336
|
display: "block",
|
|
319
337
|
width: "12px",
|
|
@@ -345,19 +363,19 @@ var renderStars = (rating) => {
|
|
|
345
363
|
const fullStars = Math.floor(rating);
|
|
346
364
|
const hasHalfStar = rating % 1 !== 0;
|
|
347
365
|
for (let i = 0; i < fullStars; i += 1) {
|
|
348
|
-
stars.push(/* @__PURE__ */ (0,
|
|
366
|
+
stars.push(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: STAR_FULL_STYLES }, `full-${i}`));
|
|
349
367
|
}
|
|
350
368
|
if (hasHalfStar) {
|
|
351
|
-
stars.push(/* @__PURE__ */ (0,
|
|
369
|
+
stars.push(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: STAR_HALF_STYLES }, "half"));
|
|
352
370
|
}
|
|
353
371
|
const remainingStars = Math.max(0, 5 - Math.ceil(rating));
|
|
354
372
|
for (let i = 0; i < remainingStars; i += 1) {
|
|
355
|
-
stars.push(/* @__PURE__ */ (0,
|
|
373
|
+
stars.push(/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: STAR_BASE_STYLES }, `empty-${i}`));
|
|
356
374
|
}
|
|
357
375
|
return stars;
|
|
358
376
|
};
|
|
359
|
-
var createMinRatingFilterLabel = (rating, suffix) => /* @__PURE__ */ (0,
|
|
360
|
-
/* @__PURE__ */ (0,
|
|
377
|
+
var createMinRatingFilterLabel = (rating, suffix) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { style: MIN_RATING_LABEL_STYLES, children: [
|
|
378
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: MIN_RATING_STARS_WRAPPER_STYLES, children: renderStars(rating) }),
|
|
361
379
|
" ",
|
|
362
380
|
suffix
|
|
363
381
|
] });
|
|
@@ -368,7 +386,7 @@ var createPriceRangeFilterLabel = (min, max, currency, formatCurrencyFn) => `${f
|
|
|
368
386
|
)}`;
|
|
369
387
|
|
|
370
388
|
// src/components/smart-filter/MinRatingFilterChip.tsx
|
|
371
|
-
var
|
|
389
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
372
390
|
var chipContainerStyles = {
|
|
373
391
|
position: "relative",
|
|
374
392
|
backgroundColor: "white",
|
|
@@ -408,7 +426,7 @@ var buttonBaseStyles = {
|
|
|
408
426
|
padding: 0
|
|
409
427
|
};
|
|
410
428
|
var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style }) => {
|
|
411
|
-
const [hoverRating, setHoverRating] = (0,
|
|
429
|
+
const [hoverRating, setHoverRating] = (0, import_react5.useState)(null);
|
|
412
430
|
const { t } = useTranslation();
|
|
413
431
|
const displayRating = hoverRating != null ? hoverRating : rating;
|
|
414
432
|
const formatLabel = (value) => star && value ? value.toString() : t("smartFilter.minRating.label", { value: formatRatingValue(value) });
|
|
@@ -438,19 +456,19 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
438
456
|
setHoverRating(null);
|
|
439
457
|
}
|
|
440
458
|
};
|
|
441
|
-
return /* @__PURE__ */ (0,
|
|
442
|
-
/* @__PURE__ */ (0,
|
|
459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { ...chipContainerStyles, ...style }, "data-min-rating-chip": true, children: [
|
|
460
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
443
461
|
"div",
|
|
444
462
|
{
|
|
445
463
|
style: { display: "flex", alignItems: "center", gap: "4px" },
|
|
446
464
|
onMouseLeave: () => setHoverRating(null),
|
|
447
465
|
children: [
|
|
448
|
-
/* @__PURE__ */ (0,
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: starContainerStyles, children: Array.from({ length: 5 }).map((_, index) => {
|
|
449
467
|
const fillState = getFillForStar(index);
|
|
450
468
|
const starNumber = index + 1;
|
|
451
469
|
const halfValue = starNumber - 0.5;
|
|
452
470
|
if (star) {
|
|
453
|
-
return /* @__PURE__ */ (0,
|
|
471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
454
472
|
"div",
|
|
455
473
|
{
|
|
456
474
|
style: {
|
|
@@ -459,7 +477,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
459
477
|
height: "16px"
|
|
460
478
|
},
|
|
461
479
|
children: [
|
|
462
|
-
/* @__PURE__ */ (0,
|
|
480
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
463
481
|
"svg",
|
|
464
482
|
{
|
|
465
483
|
viewBox: "0 0 24 24",
|
|
@@ -470,15 +488,15 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
470
488
|
},
|
|
471
489
|
xmlns: "http://www.w3.org/2000/svg",
|
|
472
490
|
children: [
|
|
473
|
-
/* @__PURE__ */ (0,
|
|
474
|
-
/* @__PURE__ */ (0,
|
|
491
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("linearGradient", { id: `star-gradient-${index}`, children: [
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
475
493
|
"stop",
|
|
476
494
|
{
|
|
477
495
|
offset: fillState === "half" ? "50%" : "0%",
|
|
478
496
|
stopColor: "#03852e"
|
|
479
497
|
}
|
|
480
498
|
),
|
|
481
|
-
/* @__PURE__ */ (0,
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
482
500
|
"stop",
|
|
483
501
|
{
|
|
484
502
|
offset: fillState === "half" ? "50%" : "0%",
|
|
@@ -486,7 +504,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
486
504
|
}
|
|
487
505
|
)
|
|
488
506
|
] }) }),
|
|
489
|
-
/* @__PURE__ */ (0,
|
|
507
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
490
508
|
"path",
|
|
491
509
|
{
|
|
492
510
|
d: "M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z",
|
|
@@ -498,7 +516,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
498
516
|
]
|
|
499
517
|
}
|
|
500
518
|
),
|
|
501
|
-
/* @__PURE__ */ (0,
|
|
519
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
502
520
|
"button",
|
|
503
521
|
{
|
|
504
522
|
type: "button",
|
|
@@ -516,7 +534,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
516
534
|
title: formatLabel(halfValue)
|
|
517
535
|
}
|
|
518
536
|
),
|
|
519
|
-
/* @__PURE__ */ (0,
|
|
537
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
520
538
|
"button",
|
|
521
539
|
{
|
|
522
540
|
type: "button",
|
|
@@ -544,18 +562,18 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
544
562
|
...circleBaseStyles,
|
|
545
563
|
background: "linear-gradient(90deg, #03852e 50%, transparent 50%)"
|
|
546
564
|
};
|
|
547
|
-
return /* @__PURE__ */ (0,
|
|
565
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
548
566
|
"div",
|
|
549
567
|
{
|
|
550
568
|
style: { position: "relative", width: "12px", height: "12px" },
|
|
551
569
|
children: [
|
|
552
|
-
/* @__PURE__ */ (0,
|
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
553
571
|
"span",
|
|
554
572
|
{
|
|
555
573
|
style: fillState === "half" ? halfCircleStyles : circleStyles
|
|
556
574
|
}
|
|
557
575
|
),
|
|
558
|
-
/* @__PURE__ */ (0,
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
559
577
|
"button",
|
|
560
578
|
{
|
|
561
579
|
type: "button",
|
|
@@ -575,7 +593,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
575
593
|
title: formatLabel(halfValue)
|
|
576
594
|
}
|
|
577
595
|
),
|
|
578
|
-
/* @__PURE__ */ (0,
|
|
596
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
579
597
|
"button",
|
|
580
598
|
{
|
|
581
599
|
type: "button",
|
|
@@ -600,17 +618,17 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
600
618
|
index
|
|
601
619
|
);
|
|
602
620
|
}) }),
|
|
603
|
-
/* @__PURE__ */ (0,
|
|
621
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: { whiteSpace: "nowrap" }, children: formatLabel(displayRating) })
|
|
604
622
|
]
|
|
605
623
|
}
|
|
606
624
|
),
|
|
607
|
-
/* @__PURE__ */ (0,
|
|
625
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CloseButton, { onClick: onRemove })
|
|
608
626
|
] });
|
|
609
627
|
};
|
|
610
628
|
|
|
611
629
|
// src/components/smart-filter/PriceRangeFilterChip.tsx
|
|
612
|
-
var
|
|
613
|
-
var
|
|
630
|
+
var import_react6 = require("react");
|
|
631
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
614
632
|
var chipStyles2 = {
|
|
615
633
|
position: "relative",
|
|
616
634
|
backgroundColor: "white",
|
|
@@ -660,13 +678,13 @@ var PriceBoundaryChip = ({
|
|
|
660
678
|
onRemove,
|
|
661
679
|
style
|
|
662
680
|
}) => {
|
|
663
|
-
const [draft, setDraft] = (0,
|
|
681
|
+
const [draft, setDraft] = (0, import_react6.useState)(
|
|
664
682
|
value !== void 0 ? String(value) : ""
|
|
665
683
|
);
|
|
666
|
-
const [isEditing, setIsEditing] = (0,
|
|
667
|
-
const [editHover, setEditHover] = (0,
|
|
684
|
+
const [isEditing, setIsEditing] = (0, import_react6.useState)(false);
|
|
685
|
+
const [editHover, setEditHover] = (0, import_react6.useState)(false);
|
|
668
686
|
const hasValue = value !== void 0;
|
|
669
|
-
(0,
|
|
687
|
+
(0, import_react6.useEffect)(() => {
|
|
670
688
|
setDraft(value !== void 0 ? String(value) : "");
|
|
671
689
|
setIsEditing(false);
|
|
672
690
|
}, [value]);
|
|
@@ -718,8 +736,8 @@ var PriceBoundaryChip = ({
|
|
|
718
736
|
event.preventDefault();
|
|
719
737
|
}
|
|
720
738
|
};
|
|
721
|
-
return /* @__PURE__ */ (0,
|
|
722
|
-
/* @__PURE__ */ (0,
|
|
739
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { ...chipStyles2, ...style }, children: [
|
|
740
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
723
741
|
"span",
|
|
724
742
|
{
|
|
725
743
|
style: {
|
|
@@ -731,7 +749,7 @@ var PriceBoundaryChip = ({
|
|
|
731
749
|
children: label
|
|
732
750
|
}
|
|
733
751
|
),
|
|
734
|
-
isEditing ? /* @__PURE__ */ (0,
|
|
752
|
+
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
735
753
|
"input",
|
|
736
754
|
{
|
|
737
755
|
value: draft,
|
|
@@ -748,13 +766,13 @@ var PriceBoundaryChip = ({
|
|
|
748
766
|
style: inputStyles,
|
|
749
767
|
autoFocus: true
|
|
750
768
|
}
|
|
751
|
-
) : hasValue ? /* @__PURE__ */ (0,
|
|
769
|
+
) : hasValue ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
752
770
|
"span",
|
|
753
771
|
{
|
|
754
772
|
style: { fontSize: "16px", fontWeight: 600, textAlign: "center" },
|
|
755
773
|
children: value
|
|
756
774
|
}
|
|
757
|
-
) : showAddWhenEmpty ? /* @__PURE__ */ (0,
|
|
775
|
+
) : showAddWhenEmpty ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
758
776
|
"button",
|
|
759
777
|
{
|
|
760
778
|
type: "button",
|
|
@@ -770,8 +788,8 @@ var PriceBoundaryChip = ({
|
|
|
770
788
|
"aria-label": editLabel,
|
|
771
789
|
children: "+"
|
|
772
790
|
}
|
|
773
|
-
) : /* @__PURE__ */ (0,
|
|
774
|
-
(!showAddWhenEmpty || showAddWhenEmpty && isEditing) && /* @__PURE__ */ (0,
|
|
791
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: { fontSize: "16px", color: "#737373" }, children: "-" }),
|
|
792
|
+
(!showAddWhenEmpty || showAddWhenEmpty && isEditing) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
775
793
|
"span",
|
|
776
794
|
{
|
|
777
795
|
style: {
|
|
@@ -783,7 +801,7 @@ var PriceBoundaryChip = ({
|
|
|
783
801
|
children: currency
|
|
784
802
|
}
|
|
785
803
|
),
|
|
786
|
-
!isEditing && (!showAddWhenEmpty || hasValue) && /* @__PURE__ */ (0,
|
|
804
|
+
!isEditing && (!showAddWhenEmpty || hasValue) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
787
805
|
"button",
|
|
788
806
|
{
|
|
789
807
|
type: "button",
|
|
@@ -796,10 +814,10 @@ var PriceBoundaryChip = ({
|
|
|
796
814
|
onClick: () => setIsEditing(true),
|
|
797
815
|
onMouseEnter: () => setEditHover(true),
|
|
798
816
|
onMouseLeave: () => setEditHover(false),
|
|
799
|
-
children: /* @__PURE__ */ (0,
|
|
817
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(EditIcon, {})
|
|
800
818
|
}
|
|
801
819
|
),
|
|
802
|
-
showRemoveButton && /* @__PURE__ */ (0,
|
|
820
|
+
showRemoveButton && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CloseButton, { onClick: onRemove })
|
|
803
821
|
] });
|
|
804
822
|
};
|
|
805
823
|
var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style }) => {
|
|
@@ -827,8 +845,8 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style })
|
|
|
827
845
|
onChange(nextRange);
|
|
828
846
|
}
|
|
829
847
|
};
|
|
830
|
-
return /* @__PURE__ */ (0,
|
|
831
|
-
/* @__PURE__ */ (0,
|
|
848
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
832
850
|
PriceBoundaryChip,
|
|
833
851
|
{
|
|
834
852
|
label: minLabel,
|
|
@@ -841,7 +859,7 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style })
|
|
|
841
859
|
style
|
|
842
860
|
}
|
|
843
861
|
),
|
|
844
|
-
/* @__PURE__ */ (0,
|
|
862
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
845
863
|
PriceBoundaryChip,
|
|
846
864
|
{
|
|
847
865
|
label: maxChipLabel,
|
|
@@ -860,7 +878,7 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style })
|
|
|
860
878
|
};
|
|
861
879
|
|
|
862
880
|
// src/components/smart-filter/RestaurantPriceLevelChip.tsx
|
|
863
|
-
var
|
|
881
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
864
882
|
var chipStyles3 = {
|
|
865
883
|
position: "relative",
|
|
866
884
|
backgroundColor: "white",
|
|
@@ -900,8 +918,8 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
900
918
|
).map((option) => option.value);
|
|
901
919
|
onChange(orderedSelection);
|
|
902
920
|
};
|
|
903
|
-
return /* @__PURE__ */ (0,
|
|
904
|
-
/* @__PURE__ */ (0,
|
|
921
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { ...chipStyles3, ...style }, children: [
|
|
922
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
905
923
|
"div",
|
|
906
924
|
{
|
|
907
925
|
style: {
|
|
@@ -911,7 +929,7 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
911
929
|
flexWrap: "wrap"
|
|
912
930
|
},
|
|
913
931
|
children: [
|
|
914
|
-
/* @__PURE__ */ (0,
|
|
932
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
915
933
|
"span",
|
|
916
934
|
{
|
|
917
935
|
style: {
|
|
@@ -923,13 +941,13 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
923
941
|
children: label
|
|
924
942
|
}
|
|
925
943
|
),
|
|
926
|
-
/* @__PURE__ */ (0,
|
|
944
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", gap: "12px" }, children: [
|
|
927
945
|
PRICE_LEVEL_OPTIONS.map((option) => {
|
|
928
946
|
const optionLabel = t(
|
|
929
947
|
`smartFilter.restaurantPriceLevel.options.${option.key}`
|
|
930
948
|
);
|
|
931
949
|
const checkboxId = `price-level-${option.key}`;
|
|
932
|
-
return /* @__PURE__ */ (0,
|
|
950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
933
951
|
"label",
|
|
934
952
|
{
|
|
935
953
|
htmlFor: checkboxId,
|
|
@@ -941,7 +959,7 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
941
959
|
cursor: "pointer"
|
|
942
960
|
},
|
|
943
961
|
children: [
|
|
944
|
-
/* @__PURE__ */ (0,
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
945
963
|
"input",
|
|
946
964
|
{
|
|
947
965
|
id: checkboxId,
|
|
@@ -952,24 +970,24 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
952
970
|
style: { accentColor: "#03852e", cursor: "pointer" }
|
|
953
971
|
}
|
|
954
972
|
),
|
|
955
|
-
/* @__PURE__ */ (0,
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: optionLabel })
|
|
956
974
|
]
|
|
957
975
|
},
|
|
958
976
|
option.value
|
|
959
977
|
);
|
|
960
978
|
}),
|
|
961
|
-
values.length === 0 && /* @__PURE__ */ (0,
|
|
979
|
+
values.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: { fontSize: "12px", color: "#737373" }, children: noneSelectedLabel })
|
|
962
980
|
] })
|
|
963
981
|
]
|
|
964
982
|
}
|
|
965
983
|
),
|
|
966
|
-
/* @__PURE__ */ (0,
|
|
984
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { onClick: onRemove })
|
|
967
985
|
] });
|
|
968
986
|
};
|
|
969
987
|
|
|
970
988
|
// src/components/smart-filter/TransformedQueryChip.tsx
|
|
971
|
-
var
|
|
972
|
-
var
|
|
989
|
+
var import_react7 = require("react");
|
|
990
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
973
991
|
var chipStyles4 = {
|
|
974
992
|
position: "relative",
|
|
975
993
|
backgroundColor: "white",
|
|
@@ -1008,14 +1026,15 @@ var editButtonStyles2 = {
|
|
|
1008
1026
|
justifyContent: "center"
|
|
1009
1027
|
};
|
|
1010
1028
|
var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
1011
|
-
const inputRef = (0,
|
|
1012
|
-
const [draft, setDraft] = (0,
|
|
1013
|
-
const [isEditing, setIsEditing] = (0,
|
|
1014
|
-
const [editHover, setEditHover] = (0,
|
|
1029
|
+
const inputRef = (0, import_react7.useRef)(null);
|
|
1030
|
+
const [draft, setDraft] = (0, import_react7.useState)(value);
|
|
1031
|
+
const [isEditing, setIsEditing] = (0, import_react7.useState)(false);
|
|
1032
|
+
const [editHover, setEditHover] = (0, import_react7.useState)(false);
|
|
1015
1033
|
const { t } = useTranslation();
|
|
1034
|
+
const { SearchIcon: SearchIcon2, EditIcon: EditIcon2 } = useIcons();
|
|
1016
1035
|
const removeLabel = t("smartFilter.transformedQuery.remove");
|
|
1017
1036
|
const editLabel = t("smartFilter.transformedQuery.edit");
|
|
1018
|
-
(0,
|
|
1037
|
+
(0, import_react7.useEffect)(() => {
|
|
1019
1038
|
setDraft(value);
|
|
1020
1039
|
setIsEditing(false);
|
|
1021
1040
|
}, [value]);
|
|
@@ -1046,9 +1065,9 @@ var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
|
1046
1065
|
return;
|
|
1047
1066
|
}
|
|
1048
1067
|
};
|
|
1049
|
-
return /* @__PURE__ */ (0,
|
|
1050
|
-
/* @__PURE__ */ (0,
|
|
1051
|
-
isEditing ? /* @__PURE__ */ (0,
|
|
1068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: { ...chipStyles4, ...style }, children: [
|
|
1069
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SearchIcon2, { style: { width: "16px", height: "16px", color: "#03852e" } }),
|
|
1070
|
+
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1052
1071
|
"input",
|
|
1053
1072
|
{
|
|
1054
1073
|
ref: inputRef,
|
|
@@ -1063,8 +1082,8 @@ var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
|
1063
1082
|
style: inputStyles2,
|
|
1064
1083
|
autoFocus: true
|
|
1065
1084
|
}
|
|
1066
|
-
) : /* @__PURE__ */ (0,
|
|
1067
|
-
!isEditing && /* @__PURE__ */ (0,
|
|
1085
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { style: { fontSize: "16px" }, children: value }),
|
|
1086
|
+
!isEditing && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1068
1087
|
"button",
|
|
1069
1088
|
{
|
|
1070
1089
|
type: "button",
|
|
@@ -1077,20 +1096,20 @@ var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
|
1077
1096
|
onClick: () => setIsEditing(true),
|
|
1078
1097
|
onMouseEnter: () => setEditHover(true),
|
|
1079
1098
|
onMouseLeave: () => setEditHover(false),
|
|
1080
|
-
children: /* @__PURE__ */ (0,
|
|
1099
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(EditIcon2, {})
|
|
1081
1100
|
}
|
|
1082
1101
|
),
|
|
1083
|
-
/* @__PURE__ */ (0,
|
|
1102
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CloseButton, { onClick: onRemove })
|
|
1084
1103
|
] });
|
|
1085
1104
|
};
|
|
1086
1105
|
|
|
1087
1106
|
// src/hooks/useFilterScroll.ts
|
|
1088
|
-
var
|
|
1107
|
+
var import_react8 = require("react");
|
|
1089
1108
|
var useFilterScroll = (dependency) => {
|
|
1090
|
-
const scrollerRef = (0,
|
|
1091
|
-
const [atStart, setAtStart] = (0,
|
|
1092
|
-
const [atEnd, setAtEnd] = (0,
|
|
1093
|
-
const updateScrollButtons = (0,
|
|
1109
|
+
const scrollerRef = (0, import_react8.useRef)(null);
|
|
1110
|
+
const [atStart, setAtStart] = (0, import_react8.useState)(true);
|
|
1111
|
+
const [atEnd, setAtEnd] = (0, import_react8.useState)(true);
|
|
1112
|
+
const updateScrollButtons = (0, import_react8.useCallback)(() => {
|
|
1094
1113
|
const el = scrollerRef.current;
|
|
1095
1114
|
if (!el) {
|
|
1096
1115
|
setAtStart(true);
|
|
@@ -1101,7 +1120,7 @@ var useFilterScroll = (dependency) => {
|
|
|
1101
1120
|
setAtStart(scrollLeft <= 0);
|
|
1102
1121
|
setAtEnd(scrollLeft + clientWidth >= scrollWidth - 1);
|
|
1103
1122
|
}, []);
|
|
1104
|
-
(0,
|
|
1123
|
+
(0, import_react8.useEffect)(() => {
|
|
1105
1124
|
const el = scrollerRef.current;
|
|
1106
1125
|
updateScrollButtons();
|
|
1107
1126
|
if (!el) {
|
|
@@ -1115,7 +1134,7 @@ var useFilterScroll = (dependency) => {
|
|
|
1115
1134
|
window.removeEventListener("resize", updateScrollButtons);
|
|
1116
1135
|
};
|
|
1117
1136
|
}, [dependency, updateScrollButtons]);
|
|
1118
|
-
const scrollByDir = (0,
|
|
1137
|
+
const scrollByDir = (0, import_react8.useCallback)((dir) => {
|
|
1119
1138
|
const el = scrollerRef.current;
|
|
1120
1139
|
if (!el) {
|
|
1121
1140
|
return;
|
|
@@ -1135,7 +1154,7 @@ var useFilterScroll = (dependency) => {
|
|
|
1135
1154
|
};
|
|
1136
1155
|
|
|
1137
1156
|
// src/components/smart-filter/FilterChips.tsx
|
|
1138
|
-
var
|
|
1157
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1139
1158
|
var containerStyles = {
|
|
1140
1159
|
position: "relative",
|
|
1141
1160
|
width: "100%"
|
|
@@ -1188,15 +1207,16 @@ var FilterChips = ({
|
|
|
1188
1207
|
const { scrollerRef, atStart, atEnd, scrollByDir } = useFilterScroll(
|
|
1189
1208
|
filters.length
|
|
1190
1209
|
);
|
|
1191
|
-
const
|
|
1192
|
-
const [
|
|
1193
|
-
const
|
|
1210
|
+
const { NextIcon: NextIcon2 } = useIcons();
|
|
1211
|
+
const [navHover, setNavHover] = import_react9.default.useState(null);
|
|
1212
|
+
const [clearHover, setClearHover] = import_react9.default.useState(false);
|
|
1213
|
+
const removeFilter = import_react9.default.useCallback(
|
|
1194
1214
|
(filterId) => {
|
|
1195
1215
|
void onFilterChange(filters.filter((f) => f.id !== filterId));
|
|
1196
1216
|
},
|
|
1197
1217
|
[filters, onFilterChange]
|
|
1198
1218
|
);
|
|
1199
|
-
const patchFilter =
|
|
1219
|
+
const patchFilter = import_react9.default.useCallback(
|
|
1200
1220
|
(filterId, patch) => {
|
|
1201
1221
|
const nextFilters = filters.map(
|
|
1202
1222
|
(f) => f.id === filterId ? { ...f, ...patch } : f
|
|
@@ -1205,8 +1225,8 @@ var FilterChips = ({
|
|
|
1205
1225
|
},
|
|
1206
1226
|
[filters, onFilterChange]
|
|
1207
1227
|
);
|
|
1208
|
-
return /* @__PURE__ */ (0,
|
|
1209
|
-
/* @__PURE__ */ (0,
|
|
1228
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { style: containerStyles, children: [
|
|
1229
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1210
1230
|
"div",
|
|
1211
1231
|
{
|
|
1212
1232
|
ref: scrollerRef,
|
|
@@ -1217,7 +1237,7 @@ var FilterChips = ({
|
|
|
1217
1237
|
...styles == null ? void 0 : styles.scrollContainer
|
|
1218
1238
|
},
|
|
1219
1239
|
children: [
|
|
1220
|
-
/* @__PURE__ */ (0,
|
|
1240
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("style", { children: `
|
|
1221
1241
|
div::-webkit-scrollbar {
|
|
1222
1242
|
display: none;
|
|
1223
1243
|
}
|
|
@@ -1225,7 +1245,7 @@ var FilterChips = ({
|
|
|
1225
1245
|
beforeContent,
|
|
1226
1246
|
filters.map((filter) => {
|
|
1227
1247
|
var _a, _b;
|
|
1228
|
-
const renderStandardChip = () => /* @__PURE__ */ (0,
|
|
1248
|
+
const renderStandardChip = () => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1229
1249
|
Chip,
|
|
1230
1250
|
{
|
|
1231
1251
|
label: filter.label,
|
|
@@ -1240,7 +1260,7 @@ var FilterChips = ({
|
|
|
1240
1260
|
if (!Number.isFinite(currentRating)) {
|
|
1241
1261
|
return renderStandardChip();
|
|
1242
1262
|
}
|
|
1243
|
-
return /* @__PURE__ */ (0,
|
|
1263
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1244
1264
|
MinRatingFilterChip,
|
|
1245
1265
|
{
|
|
1246
1266
|
star: filter.type === "starRating",
|
|
@@ -1258,7 +1278,7 @@ var FilterChips = ({
|
|
|
1258
1278
|
);
|
|
1259
1279
|
}
|
|
1260
1280
|
if (filter.type === "priceRange" && filter.priceRange) {
|
|
1261
|
-
return /* @__PURE__ */ (0,
|
|
1281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1262
1282
|
PriceRangeFilterChip,
|
|
1263
1283
|
{
|
|
1264
1284
|
priceRange: filter.priceRange,
|
|
@@ -1273,7 +1293,7 @@ var FilterChips = ({
|
|
|
1273
1293
|
);
|
|
1274
1294
|
}
|
|
1275
1295
|
if (filter.type === "transformed_query") {
|
|
1276
|
-
return /* @__PURE__ */ (0,
|
|
1296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1277
1297
|
TransformedQueryChip,
|
|
1278
1298
|
{
|
|
1279
1299
|
value: filter.value,
|
|
@@ -1287,7 +1307,7 @@ var FilterChips = ({
|
|
|
1287
1307
|
);
|
|
1288
1308
|
}
|
|
1289
1309
|
if (filter.type === "selected_restaurant_price_levels") {
|
|
1290
|
-
return /* @__PURE__ */ (0,
|
|
1310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1291
1311
|
RestaurantPriceLevelChip,
|
|
1292
1312
|
{
|
|
1293
1313
|
values: (_b = filter.priceLevels) != null ? _b : [],
|
|
@@ -1302,7 +1322,7 @@ var FilterChips = ({
|
|
|
1302
1322
|
}
|
|
1303
1323
|
return renderStandardChip();
|
|
1304
1324
|
}),
|
|
1305
|
-
/* @__PURE__ */ (0,
|
|
1325
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1306
1326
|
"button",
|
|
1307
1327
|
{
|
|
1308
1328
|
className: "mapfirst-clear-all-button",
|
|
@@ -1327,7 +1347,7 @@ var FilterChips = ({
|
|
|
1327
1347
|
]
|
|
1328
1348
|
}
|
|
1329
1349
|
),
|
|
1330
|
-
!atStart && /* @__PURE__ */ (0,
|
|
1350
|
+
!atStart && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1331
1351
|
"div",
|
|
1332
1352
|
{
|
|
1333
1353
|
"aria-hidden": "true",
|
|
@@ -1338,7 +1358,7 @@ var FilterChips = ({
|
|
|
1338
1358
|
}
|
|
1339
1359
|
}
|
|
1340
1360
|
),
|
|
1341
|
-
!atEnd && /* @__PURE__ */ (0,
|
|
1361
|
+
!atEnd && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1342
1362
|
"div",
|
|
1343
1363
|
{
|
|
1344
1364
|
"aria-hidden": "true",
|
|
@@ -1349,7 +1369,7 @@ var FilterChips = ({
|
|
|
1349
1369
|
}
|
|
1350
1370
|
}
|
|
1351
1371
|
),
|
|
1352
|
-
!atStart && /* @__PURE__ */ (0,
|
|
1372
|
+
!atStart && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1353
1373
|
"button",
|
|
1354
1374
|
{
|
|
1355
1375
|
type: "button",
|
|
@@ -1364,10 +1384,10 @@ var FilterChips = ({
|
|
|
1364
1384
|
onClick: () => scrollByDir("prev"),
|
|
1365
1385
|
onMouseEnter: () => setNavHover("prev"),
|
|
1366
1386
|
onMouseLeave: () => setNavHover(null),
|
|
1367
|
-
children: /* @__PURE__ */ (0,
|
|
1387
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NextIcon2, { style: { width: "20px", height: "20px" } })
|
|
1368
1388
|
}
|
|
1369
1389
|
),
|
|
1370
|
-
!atEnd && /* @__PURE__ */ (0,
|
|
1390
|
+
!atEnd && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1371
1391
|
"button",
|
|
1372
1392
|
{
|
|
1373
1393
|
type: "button",
|
|
@@ -1381,14 +1401,14 @@ var FilterChips = ({
|
|
|
1381
1401
|
onClick: () => scrollByDir("next"),
|
|
1382
1402
|
onMouseEnter: () => setNavHover("next"),
|
|
1383
1403
|
onMouseLeave: () => setNavHover(null),
|
|
1384
|
-
children: /* @__PURE__ */ (0,
|
|
1404
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NextIcon2, { style: { width: "20px", height: "20px" } })
|
|
1385
1405
|
}
|
|
1386
1406
|
)
|
|
1387
1407
|
] });
|
|
1388
1408
|
};
|
|
1389
1409
|
|
|
1390
1410
|
// src/components/SmartFilter.tsx
|
|
1391
|
-
var
|
|
1411
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1392
1412
|
var containerStyles2 = {
|
|
1393
1413
|
position: "relative",
|
|
1394
1414
|
display: "flex",
|
|
@@ -1404,6 +1424,7 @@ var SmartFilter = ({
|
|
|
1404
1424
|
currency = "USD",
|
|
1405
1425
|
beforeContent,
|
|
1406
1426
|
styles,
|
|
1427
|
+
customIcons,
|
|
1407
1428
|
containerStyle,
|
|
1408
1429
|
style
|
|
1409
1430
|
}) => {
|
|
@@ -1412,7 +1433,7 @@ var SmartFilter = ({
|
|
|
1412
1433
|
const previousFiltersLabel = t("smartFilter.nav.previous");
|
|
1413
1434
|
const nextFiltersLabel = t("smartFilter.nav.next");
|
|
1414
1435
|
const clearAllLabel = t("smartFilter.clearAll");
|
|
1415
|
-
const handleFilterChange = (0,
|
|
1436
|
+
const handleFilterChange = (0, import_react10.useCallback)(
|
|
1416
1437
|
async (nextFilters, clearAll) => {
|
|
1417
1438
|
if (isSearching) {
|
|
1418
1439
|
return;
|
|
@@ -1425,13 +1446,13 @@ var SmartFilter = ({
|
|
|
1425
1446
|
},
|
|
1426
1447
|
[isSearching, onFilterChange]
|
|
1427
1448
|
);
|
|
1428
|
-
const resetFilters = (0,
|
|
1449
|
+
const resetFilters = (0, import_react10.useCallback)(() => {
|
|
1429
1450
|
void handleFilterChange([]);
|
|
1430
1451
|
}, [handleFilterChange]);
|
|
1431
|
-
const clearAllFilters = (0,
|
|
1452
|
+
const clearAllFilters = (0, import_react10.useCallback)(() => {
|
|
1432
1453
|
void handleFilterChange([], true);
|
|
1433
1454
|
}, [handleFilterChange]);
|
|
1434
|
-
return /* @__PURE__ */ (0,
|
|
1455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(IconsProvider, { value: customIcons, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(TranslationProvider, { value: customTranslations, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1435
1456
|
"div",
|
|
1436
1457
|
{
|
|
1437
1458
|
style: {
|
|
@@ -1440,7 +1461,7 @@ var SmartFilter = ({
|
|
|
1440
1461
|
...containerStyle,
|
|
1441
1462
|
...style
|
|
1442
1463
|
},
|
|
1443
|
-
children: filters.length > 0 && /* @__PURE__ */ (0,
|
|
1464
|
+
children: filters.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1444
1465
|
FilterChips,
|
|
1445
1466
|
{
|
|
1446
1467
|
filters,
|
|
@@ -1458,7 +1479,7 @@ var SmartFilter = ({
|
|
|
1458
1479
|
}
|
|
1459
1480
|
)
|
|
1460
1481
|
}
|
|
1461
|
-
) });
|
|
1482
|
+
) }) });
|
|
1462
1483
|
};
|
|
1463
1484
|
|
|
1464
1485
|
// src/index.tsx
|
|
@@ -1475,12 +1496,12 @@ function attachMapOnce(instanceRef, attachedRef, map, config) {
|
|
|
1475
1496
|
attachedRef.current = true;
|
|
1476
1497
|
}
|
|
1477
1498
|
function useMapFirst(options) {
|
|
1478
|
-
const optionsRef =
|
|
1479
|
-
|
|
1499
|
+
const optionsRef = import_react11.default.useRef(options);
|
|
1500
|
+
import_react11.default.useEffect(() => {
|
|
1480
1501
|
optionsRef.current = options;
|
|
1481
1502
|
});
|
|
1482
|
-
const callbacksRef =
|
|
1483
|
-
const instanceRef =
|
|
1503
|
+
const callbacksRef = import_react11.default.useRef({});
|
|
1504
|
+
const instanceRef = import_react11.default.useRef(null);
|
|
1484
1505
|
if (instanceRef.current === null) {
|
|
1485
1506
|
instanceRef.current = new import_core.MapFirstCore({
|
|
1486
1507
|
adapter: null,
|
|
@@ -1488,10 +1509,10 @@ function useMapFirst(options) {
|
|
|
1488
1509
|
callbacks: callbacksRef.current
|
|
1489
1510
|
});
|
|
1490
1511
|
}
|
|
1491
|
-
const [state, setState] =
|
|
1512
|
+
const [state, setState] = import_react11.default.useState(
|
|
1492
1513
|
() => instanceRef.current.getState()
|
|
1493
1514
|
);
|
|
1494
|
-
|
|
1515
|
+
import_react11.default.useEffect(() => {
|
|
1495
1516
|
if (!instanceRef.current) {
|
|
1496
1517
|
callbacksRef.current = {};
|
|
1497
1518
|
instanceRef.current = new import_core.MapFirstCore({
|
|
@@ -1570,17 +1591,17 @@ function useMapFirst(options) {
|
|
|
1570
1591
|
instanceRef.current = null;
|
|
1571
1592
|
};
|
|
1572
1593
|
}, []);
|
|
1573
|
-
const setPrimaryType =
|
|
1594
|
+
const setPrimaryType = import_react11.default.useCallback((type) => {
|
|
1574
1595
|
if (instanceRef.current) {
|
|
1575
1596
|
instanceRef.current.setPrimaryType(type);
|
|
1576
1597
|
}
|
|
1577
1598
|
}, []);
|
|
1578
|
-
const setSelectedMarker =
|
|
1599
|
+
const setSelectedMarker = import_react11.default.useCallback((id) => {
|
|
1579
1600
|
if (instanceRef.current) {
|
|
1580
1601
|
instanceRef.current.setSelectedMarker(id);
|
|
1581
1602
|
}
|
|
1582
1603
|
}, []);
|
|
1583
|
-
const setUseApi =
|
|
1604
|
+
const setUseApi = import_react11.default.useCallback(
|
|
1584
1605
|
(useApi, autoLoad = true) => {
|
|
1585
1606
|
if (instanceRef.current) {
|
|
1586
1607
|
instanceRef.current.setUseApi(useApi, autoLoad);
|
|
@@ -1588,7 +1609,7 @@ function useMapFirst(options) {
|
|
|
1588
1609
|
},
|
|
1589
1610
|
[]
|
|
1590
1611
|
);
|
|
1591
|
-
const propertiesSearch =
|
|
1612
|
+
const propertiesSearch = import_react11.default.useCallback(
|
|
1592
1613
|
async (options2) => {
|
|
1593
1614
|
if (!instanceRef.current) {
|
|
1594
1615
|
throw new Error("MapFirst instance not available");
|
|
@@ -1597,7 +1618,7 @@ function useMapFirst(options) {
|
|
|
1597
1618
|
},
|
|
1598
1619
|
[]
|
|
1599
1620
|
);
|
|
1600
|
-
const smartFilterSearch =
|
|
1621
|
+
const smartFilterSearch = import_react11.default.useCallback(
|
|
1601
1622
|
async (options2) => {
|
|
1602
1623
|
if (!instanceRef.current) {
|
|
1603
1624
|
throw new Error("MapFirst instance not available");
|
|
@@ -1606,14 +1627,14 @@ function useMapFirst(options) {
|
|
|
1606
1627
|
},
|
|
1607
1628
|
[]
|
|
1608
1629
|
);
|
|
1609
|
-
const boundsSearch =
|
|
1630
|
+
const boundsSearch = import_react11.default.useCallback(async () => {
|
|
1610
1631
|
if (!instanceRef.current) {
|
|
1611
1632
|
return null;
|
|
1612
1633
|
}
|
|
1613
1634
|
return await instanceRef.current.performBoundsSearch();
|
|
1614
1635
|
}, []);
|
|
1615
|
-
const mapLibreAttachedRef =
|
|
1616
|
-
const attachMapLibre =
|
|
1636
|
+
const mapLibreAttachedRef = import_react11.default.useRef(false);
|
|
1637
|
+
const attachMapLibre = import_react11.default.useCallback(
|
|
1617
1638
|
(map, maplibregl, options2) => {
|
|
1618
1639
|
attachMapOnce(instanceRef, mapLibreAttachedRef, map, {
|
|
1619
1640
|
platform: "maplibre",
|
|
@@ -1624,8 +1645,8 @@ function useMapFirst(options) {
|
|
|
1624
1645
|
},
|
|
1625
1646
|
[]
|
|
1626
1647
|
);
|
|
1627
|
-
const googleMapsAttachedRef =
|
|
1628
|
-
const attachGoogle =
|
|
1648
|
+
const googleMapsAttachedRef = import_react11.default.useRef(false);
|
|
1649
|
+
const attachGoogle = import_react11.default.useCallback(
|
|
1629
1650
|
(map, google, options2) => {
|
|
1630
1651
|
attachMapOnce(instanceRef, googleMapsAttachedRef, map, {
|
|
1631
1652
|
platform: "google",
|
|
@@ -1636,8 +1657,8 @@ function useMapFirst(options) {
|
|
|
1636
1657
|
},
|
|
1637
1658
|
[]
|
|
1638
1659
|
);
|
|
1639
|
-
const mapboxAttachedRef =
|
|
1640
|
-
const attachMapbox =
|
|
1660
|
+
const mapboxAttachedRef = import_react11.default.useRef(false);
|
|
1661
|
+
const attachMapbox = import_react11.default.useCallback(
|
|
1641
1662
|
(map, mapboxgl, options2) => {
|
|
1642
1663
|
attachMapOnce(instanceRef, mapboxAttachedRef, map, {
|
|
1643
1664
|
platform: "mapbox",
|
|
@@ -1648,8 +1669,8 @@ function useMapFirst(options) {
|
|
|
1648
1669
|
},
|
|
1649
1670
|
[]
|
|
1650
1671
|
);
|
|
1651
|
-
const leafletAttachedRef =
|
|
1652
|
-
const attachLeaflet =
|
|
1672
|
+
const leafletAttachedRef = import_react11.default.useRef(false);
|
|
1673
|
+
const attachLeaflet = import_react11.default.useCallback(
|
|
1653
1674
|
(map, leaflet, options2) => {
|
|
1654
1675
|
if (!instanceRef.current || !map || leafletAttachedRef.current) return;
|
|
1655
1676
|
const adapter = new import_core.LeafletAdapter(map);
|
|
@@ -1711,6 +1732,7 @@ function useMapFirst(options) {
|
|
|
1711
1732
|
CloseIcon,
|
|
1712
1733
|
EditIcon,
|
|
1713
1734
|
FilterChips,
|
|
1735
|
+
IconsProvider,
|
|
1714
1736
|
LeafletAdapter,
|
|
1715
1737
|
MapFirstCore,
|
|
1716
1738
|
MinRatingFilterChip,
|
|
@@ -1732,6 +1754,7 @@ function useMapFirst(options) {
|
|
|
1732
1754
|
processApiFilters,
|
|
1733
1755
|
renderStars,
|
|
1734
1756
|
useFilterScroll,
|
|
1757
|
+
useIcons,
|
|
1735
1758
|
useMapFirst,
|
|
1736
1759
|
useTranslation
|
|
1737
1760
|
});
|