@mapfirst.ai/react 0.0.94 → 0.0.97
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 +41 -34
- package/dist/index.d.ts +41 -34
- package/dist/index.js +201 -160
- package/dist/index.mjs +165 -122
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -59,15 +59,15 @@ __export(index_exports, {
|
|
|
59
59
|
useTranslation: () => useTranslation
|
|
60
60
|
});
|
|
61
61
|
module.exports = __toCommonJS(index_exports);
|
|
62
|
-
var
|
|
62
|
+
var import_react10 = __toESM(require("react"));
|
|
63
63
|
var import_core = require("@mapfirst.ai/core");
|
|
64
64
|
var import_core2 = require("@mapfirst.ai/core");
|
|
65
65
|
|
|
66
66
|
// src/components/SmartFilter.tsx
|
|
67
|
-
var
|
|
67
|
+
var import_react9 = require("react");
|
|
68
68
|
|
|
69
69
|
// src/components/smart-filter/FilterChips.tsx
|
|
70
|
-
var
|
|
70
|
+
var import_react8 = __toESM(require("react"));
|
|
71
71
|
|
|
72
72
|
// src/components/smart-filter/CloseButton.tsx
|
|
73
73
|
var import_react = __toESM(require("react"));
|
|
@@ -228,18 +228,27 @@ var Chip = ({ label, icon, remove, style }) => {
|
|
|
228
228
|
};
|
|
229
229
|
|
|
230
230
|
// src/components/smart-filter/MinRatingFilterChip.tsx
|
|
231
|
+
var import_react4 = require("react");
|
|
232
|
+
|
|
233
|
+
// src/hooks/useTranslation.ts
|
|
231
234
|
var import_react3 = require("react");
|
|
232
235
|
|
|
236
|
+
// src/context/TranslationContext.tsx
|
|
237
|
+
var import_react2 = __toESM(require("react"));
|
|
238
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
239
|
+
var TranslationContext = import_react2.default.createContext(void 0);
|
|
240
|
+
var TranslationProvider = ({ value, children }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TranslationContext.Provider, { value, children });
|
|
241
|
+
var useCustomTranslationsContext = () => import_react2.default.useContext(TranslationContext);
|
|
242
|
+
|
|
233
243
|
// src/hooks/useTranslation.ts
|
|
234
|
-
var import_react2 = require("react");
|
|
235
244
|
var defaultTranslations = {
|
|
236
245
|
"smartFilter.typingPrompt": "Search for hotels, restaurants, or attractions...",
|
|
237
246
|
"smartFilter.nav.previous": "Previous filters",
|
|
238
247
|
"smartFilter.nav.next": "Next filters",
|
|
239
248
|
"smartFilter.toast.locationRequired": "Please select a location first",
|
|
240
249
|
"smartFilter.clearAll": "Clear all",
|
|
241
|
-
"smartFilter.minRating.suffix": "
|
|
242
|
-
"smartFilter.minRating.label": "{{value}}
|
|
250
|
+
"smartFilter.minRating.suffix": "& up",
|
|
251
|
+
"smartFilter.minRating.label": "{{value}} & up",
|
|
243
252
|
"smartFilter.minRating.remove": "Remove rating filter",
|
|
244
253
|
"smartFilter.minRating.setTo": "Set rating to {{rating}}",
|
|
245
254
|
"smartFilter.priceRange.label": "Price Range",
|
|
@@ -263,12 +272,14 @@ var formatCurrencyDefault = (value, currency = "USD") => {
|
|
|
263
272
|
}).format(value);
|
|
264
273
|
};
|
|
265
274
|
var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
|
|
269
|
-
|
|
275
|
+
const contextTranslations = useCustomTranslationsContext();
|
|
276
|
+
const merged = customTranslations != null ? customTranslations : contextTranslations;
|
|
277
|
+
const [locale, setLocale] = (0, import_react3.useState)("en");
|
|
278
|
+
const translations = (0, import_react3.useMemo)(
|
|
279
|
+
() => ({ ...defaultTranslations, ...merged }),
|
|
280
|
+
[merged]
|
|
270
281
|
);
|
|
271
|
-
const t = (0,
|
|
282
|
+
const t = (0, import_react3.useCallback)(
|
|
272
283
|
(key, params) => {
|
|
273
284
|
let translation = translations[key] || key;
|
|
274
285
|
if (params) {
|
|
@@ -283,7 +294,7 @@ var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
|
283
294
|
},
|
|
284
295
|
[translations]
|
|
285
296
|
);
|
|
286
|
-
const formatCurrency = (0,
|
|
297
|
+
const formatCurrency = (0, import_react3.useCallback)(
|
|
287
298
|
(value, currency) => {
|
|
288
299
|
if (customFormatCurrency) {
|
|
289
300
|
return customFormatCurrency(value, currency);
|
|
@@ -301,7 +312,7 @@ var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
|
301
312
|
};
|
|
302
313
|
|
|
303
314
|
// src/components/smart-filter/utils.tsx
|
|
304
|
-
var
|
|
315
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
305
316
|
var STAR_BASE_STYLES = {
|
|
306
317
|
display: "block",
|
|
307
318
|
width: "12px",
|
|
@@ -333,19 +344,19 @@ var renderStars = (rating) => {
|
|
|
333
344
|
const fullStars = Math.floor(rating);
|
|
334
345
|
const hasHalfStar = rating % 1 !== 0;
|
|
335
346
|
for (let i = 0; i < fullStars; i += 1) {
|
|
336
|
-
stars.push(/* @__PURE__ */ (0,
|
|
347
|
+
stars.push(/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: STAR_FULL_STYLES }, `full-${i}`));
|
|
337
348
|
}
|
|
338
349
|
if (hasHalfStar) {
|
|
339
|
-
stars.push(/* @__PURE__ */ (0,
|
|
350
|
+
stars.push(/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: STAR_HALF_STYLES }, "half"));
|
|
340
351
|
}
|
|
341
352
|
const remainingStars = Math.max(0, 5 - Math.ceil(rating));
|
|
342
353
|
for (let i = 0; i < remainingStars; i += 1) {
|
|
343
|
-
stars.push(/* @__PURE__ */ (0,
|
|
354
|
+
stars.push(/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: STAR_BASE_STYLES }, `empty-${i}`));
|
|
344
355
|
}
|
|
345
356
|
return stars;
|
|
346
357
|
};
|
|
347
|
-
var createMinRatingFilterLabel = (rating, suffix) => /* @__PURE__ */ (0,
|
|
348
|
-
/* @__PURE__ */ (0,
|
|
358
|
+
var createMinRatingFilterLabel = (rating, suffix) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { style: MIN_RATING_LABEL_STYLES, children: [
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: MIN_RATING_STARS_WRAPPER_STYLES, children: renderStars(rating) }),
|
|
349
360
|
" ",
|
|
350
361
|
suffix
|
|
351
362
|
] });
|
|
@@ -356,7 +367,7 @@ var createPriceRangeFilterLabel = (min, max, currency, formatCurrencyFn) => `${f
|
|
|
356
367
|
)}`;
|
|
357
368
|
|
|
358
369
|
// src/components/smart-filter/MinRatingFilterChip.tsx
|
|
359
|
-
var
|
|
370
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
360
371
|
var chipContainerStyles = {
|
|
361
372
|
position: "relative",
|
|
362
373
|
backgroundColor: "white",
|
|
@@ -395,8 +406,8 @@ var buttonBaseStyles = {
|
|
|
395
406
|
border: "none",
|
|
396
407
|
padding: 0
|
|
397
408
|
};
|
|
398
|
-
var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
399
|
-
const [hoverRating, setHoverRating] = (0,
|
|
409
|
+
var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style }) => {
|
|
410
|
+
const [hoverRating, setHoverRating] = (0, import_react4.useState)(null);
|
|
400
411
|
const { t } = useTranslation();
|
|
401
412
|
const displayRating = hoverRating != null ? hoverRating : rating;
|
|
402
413
|
const formatLabel = (value) => star && value ? value.toString() : t("smartFilter.minRating.label", { value: formatRatingValue(value) });
|
|
@@ -426,19 +437,19 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
426
437
|
setHoverRating(null);
|
|
427
438
|
}
|
|
428
439
|
};
|
|
429
|
-
return /* @__PURE__ */ (0,
|
|
430
|
-
/* @__PURE__ */ (0,
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { ...chipContainerStyles, ...style }, "data-min-rating-chip": true, children: [
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
431
442
|
"div",
|
|
432
443
|
{
|
|
433
444
|
style: { display: "flex", alignItems: "center", gap: "4px" },
|
|
434
445
|
onMouseLeave: () => setHoverRating(null),
|
|
435
446
|
children: [
|
|
436
|
-
/* @__PURE__ */ (0,
|
|
447
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: starContainerStyles, children: Array.from({ length: 5 }).map((_, index) => {
|
|
437
448
|
const fillState = getFillForStar(index);
|
|
438
449
|
const starNumber = index + 1;
|
|
439
450
|
const halfValue = starNumber - 0.5;
|
|
440
451
|
if (star) {
|
|
441
|
-
return /* @__PURE__ */ (0,
|
|
452
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
442
453
|
"div",
|
|
443
454
|
{
|
|
444
455
|
style: {
|
|
@@ -447,7 +458,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
447
458
|
height: "16px"
|
|
448
459
|
},
|
|
449
460
|
children: [
|
|
450
|
-
/* @__PURE__ */ (0,
|
|
461
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
451
462
|
"svg",
|
|
452
463
|
{
|
|
453
464
|
viewBox: "0 0 24 24",
|
|
@@ -458,15 +469,15 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
458
469
|
},
|
|
459
470
|
xmlns: "http://www.w3.org/2000/svg",
|
|
460
471
|
children: [
|
|
461
|
-
/* @__PURE__ */ (0,
|
|
462
|
-
/* @__PURE__ */ (0,
|
|
472
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("linearGradient", { id: `star-gradient-${index}`, children: [
|
|
473
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
463
474
|
"stop",
|
|
464
475
|
{
|
|
465
476
|
offset: fillState === "half" ? "50%" : "0%",
|
|
466
477
|
stopColor: "#03852e"
|
|
467
478
|
}
|
|
468
479
|
),
|
|
469
|
-
/* @__PURE__ */ (0,
|
|
480
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
470
481
|
"stop",
|
|
471
482
|
{
|
|
472
483
|
offset: fillState === "half" ? "50%" : "0%",
|
|
@@ -474,7 +485,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
474
485
|
}
|
|
475
486
|
)
|
|
476
487
|
] }) }),
|
|
477
|
-
/* @__PURE__ */ (0,
|
|
488
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
478
489
|
"path",
|
|
479
490
|
{
|
|
480
491
|
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",
|
|
@@ -486,7 +497,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
486
497
|
]
|
|
487
498
|
}
|
|
488
499
|
),
|
|
489
|
-
/* @__PURE__ */ (0,
|
|
500
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
490
501
|
"button",
|
|
491
502
|
{
|
|
492
503
|
type: "button",
|
|
@@ -504,7 +515,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
504
515
|
title: formatLabel(halfValue)
|
|
505
516
|
}
|
|
506
517
|
),
|
|
507
|
-
/* @__PURE__ */ (0,
|
|
518
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
508
519
|
"button",
|
|
509
520
|
{
|
|
510
521
|
type: "button",
|
|
@@ -532,18 +543,18 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
532
543
|
...circleBaseStyles,
|
|
533
544
|
background: "linear-gradient(90deg, #03852e 50%, transparent 50%)"
|
|
534
545
|
};
|
|
535
|
-
return /* @__PURE__ */ (0,
|
|
546
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
536
547
|
"div",
|
|
537
548
|
{
|
|
538
549
|
style: { position: "relative", width: "12px", height: "12px" },
|
|
539
550
|
children: [
|
|
540
|
-
/* @__PURE__ */ (0,
|
|
551
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
541
552
|
"span",
|
|
542
553
|
{
|
|
543
554
|
style: fillState === "half" ? halfCircleStyles : circleStyles
|
|
544
555
|
}
|
|
545
556
|
),
|
|
546
|
-
/* @__PURE__ */ (0,
|
|
557
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
547
558
|
"button",
|
|
548
559
|
{
|
|
549
560
|
type: "button",
|
|
@@ -563,7 +574,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
563
574
|
title: formatLabel(halfValue)
|
|
564
575
|
}
|
|
565
576
|
),
|
|
566
|
-
/* @__PURE__ */ (0,
|
|
577
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
567
578
|
"button",
|
|
568
579
|
{
|
|
569
580
|
type: "button",
|
|
@@ -588,17 +599,17 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false }) => {
|
|
|
588
599
|
index
|
|
589
600
|
);
|
|
590
601
|
}) }),
|
|
591
|
-
/* @__PURE__ */ (0,
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: { whiteSpace: "nowrap" }, children: formatLabel(displayRating) })
|
|
592
603
|
]
|
|
593
604
|
}
|
|
594
605
|
),
|
|
595
|
-
/* @__PURE__ */ (0,
|
|
606
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CloseButton, { onClick: onRemove })
|
|
596
607
|
] });
|
|
597
608
|
};
|
|
598
609
|
|
|
599
610
|
// src/components/smart-filter/PriceRangeFilterChip.tsx
|
|
600
|
-
var
|
|
601
|
-
var
|
|
611
|
+
var import_react5 = require("react");
|
|
612
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
602
613
|
var chipStyles2 = {
|
|
603
614
|
position: "relative",
|
|
604
615
|
backgroundColor: "white",
|
|
@@ -645,15 +656,16 @@ var PriceBoundaryChip = ({
|
|
|
645
656
|
editLabel,
|
|
646
657
|
showAddWhenEmpty = false,
|
|
647
658
|
onCommit,
|
|
648
|
-
onRemove
|
|
659
|
+
onRemove,
|
|
660
|
+
style
|
|
649
661
|
}) => {
|
|
650
|
-
const [draft, setDraft] = (0,
|
|
662
|
+
const [draft, setDraft] = (0, import_react5.useState)(
|
|
651
663
|
value !== void 0 ? String(value) : ""
|
|
652
664
|
);
|
|
653
|
-
const [isEditing, setIsEditing] = (0,
|
|
654
|
-
const [editHover, setEditHover] = (0,
|
|
665
|
+
const [isEditing, setIsEditing] = (0, import_react5.useState)(false);
|
|
666
|
+
const [editHover, setEditHover] = (0, import_react5.useState)(false);
|
|
655
667
|
const hasValue = value !== void 0;
|
|
656
|
-
(0,
|
|
668
|
+
(0, import_react5.useEffect)(() => {
|
|
657
669
|
setDraft(value !== void 0 ? String(value) : "");
|
|
658
670
|
setIsEditing(false);
|
|
659
671
|
}, [value]);
|
|
@@ -705,8 +717,8 @@ var PriceBoundaryChip = ({
|
|
|
705
717
|
event.preventDefault();
|
|
706
718
|
}
|
|
707
719
|
};
|
|
708
|
-
return /* @__PURE__ */ (0,
|
|
709
|
-
/* @__PURE__ */ (0,
|
|
720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { ...chipStyles2, ...style }, children: [
|
|
721
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
710
722
|
"span",
|
|
711
723
|
{
|
|
712
724
|
style: {
|
|
@@ -718,7 +730,7 @@ var PriceBoundaryChip = ({
|
|
|
718
730
|
children: label
|
|
719
731
|
}
|
|
720
732
|
),
|
|
721
|
-
isEditing ? /* @__PURE__ */ (0,
|
|
733
|
+
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
722
734
|
"input",
|
|
723
735
|
{
|
|
724
736
|
value: draft,
|
|
@@ -735,13 +747,13 @@ var PriceBoundaryChip = ({
|
|
|
735
747
|
style: inputStyles,
|
|
736
748
|
autoFocus: true
|
|
737
749
|
}
|
|
738
|
-
) : hasValue ? /* @__PURE__ */ (0,
|
|
750
|
+
) : hasValue ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
739
751
|
"span",
|
|
740
752
|
{
|
|
741
753
|
style: { fontSize: "16px", fontWeight: 600, textAlign: "center" },
|
|
742
754
|
children: value
|
|
743
755
|
}
|
|
744
|
-
) : showAddWhenEmpty ? /* @__PURE__ */ (0,
|
|
756
|
+
) : showAddWhenEmpty ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
745
757
|
"button",
|
|
746
758
|
{
|
|
747
759
|
type: "button",
|
|
@@ -757,8 +769,8 @@ var PriceBoundaryChip = ({
|
|
|
757
769
|
"aria-label": editLabel,
|
|
758
770
|
children: "+"
|
|
759
771
|
}
|
|
760
|
-
) : /* @__PURE__ */ (0,
|
|
761
|
-
(!showAddWhenEmpty || showAddWhenEmpty && isEditing) && /* @__PURE__ */ (0,
|
|
772
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: { fontSize: "16px", color: "#737373" }, children: "-" }),
|
|
773
|
+
(!showAddWhenEmpty || showAddWhenEmpty && isEditing) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
762
774
|
"span",
|
|
763
775
|
{
|
|
764
776
|
style: {
|
|
@@ -770,7 +782,7 @@ var PriceBoundaryChip = ({
|
|
|
770
782
|
children: currency
|
|
771
783
|
}
|
|
772
784
|
),
|
|
773
|
-
!isEditing && (!showAddWhenEmpty || hasValue) && /* @__PURE__ */ (0,
|
|
785
|
+
!isEditing && (!showAddWhenEmpty || hasValue) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
774
786
|
"button",
|
|
775
787
|
{
|
|
776
788
|
type: "button",
|
|
@@ -783,13 +795,13 @@ var PriceBoundaryChip = ({
|
|
|
783
795
|
onClick: () => setIsEditing(true),
|
|
784
796
|
onMouseEnter: () => setEditHover(true),
|
|
785
797
|
onMouseLeave: () => setEditHover(false),
|
|
786
|
-
children: /* @__PURE__ */ (0,
|
|
798
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(EditIcon, {})
|
|
787
799
|
}
|
|
788
800
|
),
|
|
789
|
-
showRemoveButton && /* @__PURE__ */ (0,
|
|
801
|
+
showRemoveButton && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CloseButton, { onClick: onRemove })
|
|
790
802
|
] });
|
|
791
803
|
};
|
|
792
|
-
var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove }) => {
|
|
804
|
+
var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style }) => {
|
|
793
805
|
const { t } = useTranslation();
|
|
794
806
|
const minLabel = "Min";
|
|
795
807
|
const maxChipLabel = "Max";
|
|
@@ -814,8 +826,8 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove }) => {
|
|
|
814
826
|
onChange(nextRange);
|
|
815
827
|
}
|
|
816
828
|
};
|
|
817
|
-
return /* @__PURE__ */ (0,
|
|
818
|
-
/* @__PURE__ */ (0,
|
|
829
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
819
831
|
PriceBoundaryChip,
|
|
820
832
|
{
|
|
821
833
|
label: minLabel,
|
|
@@ -824,10 +836,11 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove }) => {
|
|
|
824
836
|
editLabel,
|
|
825
837
|
showRemoveButton: priceRange.min !== void 0 && priceRange.min !== 0,
|
|
826
838
|
onCommit: (value) => handleBoundaryCommit("min", value),
|
|
827
|
-
onRemove
|
|
839
|
+
onRemove,
|
|
840
|
+
style
|
|
828
841
|
}
|
|
829
842
|
),
|
|
830
|
-
/* @__PURE__ */ (0,
|
|
843
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
831
844
|
PriceBoundaryChip,
|
|
832
845
|
{
|
|
833
846
|
label: maxChipLabel,
|
|
@@ -838,14 +851,15 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove }) => {
|
|
|
838
851
|
editLabel,
|
|
839
852
|
showAddWhenEmpty: true,
|
|
840
853
|
onCommit: (value) => handleBoundaryCommit("max", value),
|
|
841
|
-
onRemove
|
|
854
|
+
onRemove,
|
|
855
|
+
style
|
|
842
856
|
}
|
|
843
857
|
)
|
|
844
858
|
] });
|
|
845
859
|
};
|
|
846
860
|
|
|
847
861
|
// src/components/smart-filter/RestaurantPriceLevelChip.tsx
|
|
848
|
-
var
|
|
862
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
849
863
|
var chipStyles3 = {
|
|
850
864
|
position: "relative",
|
|
851
865
|
backgroundColor: "white",
|
|
@@ -866,7 +880,7 @@ var PRICE_LEVEL_OPTIONS = [
|
|
|
866
880
|
{ value: "Mid Range", key: "midRange" },
|
|
867
881
|
{ value: "Fine Dining", key: "fineDining" }
|
|
868
882
|
];
|
|
869
|
-
var RestaurantPriceLevelChip = ({ values, onChange, onRemove }) => {
|
|
883
|
+
var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
870
884
|
const { t } = useTranslation();
|
|
871
885
|
const label = t("smartFilter.restaurantPriceLevel.label");
|
|
872
886
|
const removeLabel = t("smartFilter.restaurantPriceLevel.remove");
|
|
@@ -885,8 +899,8 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove }) => {
|
|
|
885
899
|
).map((option) => option.value);
|
|
886
900
|
onChange(orderedSelection);
|
|
887
901
|
};
|
|
888
|
-
return /* @__PURE__ */ (0,
|
|
889
|
-
/* @__PURE__ */ (0,
|
|
902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { ...chipStyles3, ...style }, children: [
|
|
903
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
890
904
|
"div",
|
|
891
905
|
{
|
|
892
906
|
style: {
|
|
@@ -896,7 +910,7 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove }) => {
|
|
|
896
910
|
flexWrap: "wrap"
|
|
897
911
|
},
|
|
898
912
|
children: [
|
|
899
|
-
/* @__PURE__ */ (0,
|
|
913
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
900
914
|
"span",
|
|
901
915
|
{
|
|
902
916
|
style: {
|
|
@@ -908,13 +922,13 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove }) => {
|
|
|
908
922
|
children: label
|
|
909
923
|
}
|
|
910
924
|
),
|
|
911
|
-
/* @__PURE__ */ (0,
|
|
925
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "flex", gap: "12px" }, children: [
|
|
912
926
|
PRICE_LEVEL_OPTIONS.map((option) => {
|
|
913
927
|
const optionLabel = t(
|
|
914
928
|
`smartFilter.restaurantPriceLevel.options.${option.key}`
|
|
915
929
|
);
|
|
916
930
|
const checkboxId = `price-level-${option.key}`;
|
|
917
|
-
return /* @__PURE__ */ (0,
|
|
931
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
918
932
|
"label",
|
|
919
933
|
{
|
|
920
934
|
htmlFor: checkboxId,
|
|
@@ -926,7 +940,7 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove }) => {
|
|
|
926
940
|
cursor: "pointer"
|
|
927
941
|
},
|
|
928
942
|
children: [
|
|
929
|
-
/* @__PURE__ */ (0,
|
|
943
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
930
944
|
"input",
|
|
931
945
|
{
|
|
932
946
|
id: checkboxId,
|
|
@@ -937,24 +951,24 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove }) => {
|
|
|
937
951
|
style: { accentColor: "#03852e", cursor: "pointer" }
|
|
938
952
|
}
|
|
939
953
|
),
|
|
940
|
-
/* @__PURE__ */ (0,
|
|
954
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: optionLabel })
|
|
941
955
|
]
|
|
942
956
|
},
|
|
943
957
|
option.value
|
|
944
958
|
);
|
|
945
959
|
}),
|
|
946
|
-
values.length === 0 && /* @__PURE__ */ (0,
|
|
960
|
+
values.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: { fontSize: "12px", color: "#737373" }, children: noneSelectedLabel })
|
|
947
961
|
] })
|
|
948
962
|
]
|
|
949
963
|
}
|
|
950
964
|
),
|
|
951
|
-
/* @__PURE__ */ (0,
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CloseButton, { onClick: onRemove })
|
|
952
966
|
] });
|
|
953
967
|
};
|
|
954
968
|
|
|
955
969
|
// src/components/smart-filter/TransformedQueryChip.tsx
|
|
956
|
-
var
|
|
957
|
-
var
|
|
970
|
+
var import_react6 = require("react");
|
|
971
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
958
972
|
var chipStyles4 = {
|
|
959
973
|
position: "relative",
|
|
960
974
|
backgroundColor: "white",
|
|
@@ -992,15 +1006,15 @@ var editButtonStyles2 = {
|
|
|
992
1006
|
alignItems: "center",
|
|
993
1007
|
justifyContent: "center"
|
|
994
1008
|
};
|
|
995
|
-
var TransformedQueryChip = ({ value, onChange, onRemove }) => {
|
|
996
|
-
const inputRef = (0,
|
|
997
|
-
const [draft, setDraft] = (0,
|
|
998
|
-
const [isEditing, setIsEditing] = (0,
|
|
999
|
-
const [editHover, setEditHover] = (0,
|
|
1009
|
+
var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
1010
|
+
const inputRef = (0, import_react6.useRef)(null);
|
|
1011
|
+
const [draft, setDraft] = (0, import_react6.useState)(value);
|
|
1012
|
+
const [isEditing, setIsEditing] = (0, import_react6.useState)(false);
|
|
1013
|
+
const [editHover, setEditHover] = (0, import_react6.useState)(false);
|
|
1000
1014
|
const { t } = useTranslation();
|
|
1001
1015
|
const removeLabel = t("smartFilter.transformedQuery.remove");
|
|
1002
1016
|
const editLabel = t("smartFilter.transformedQuery.edit");
|
|
1003
|
-
(0,
|
|
1017
|
+
(0, import_react6.useEffect)(() => {
|
|
1004
1018
|
setDraft(value);
|
|
1005
1019
|
setIsEditing(false);
|
|
1006
1020
|
}, [value]);
|
|
@@ -1031,9 +1045,9 @@ var TransformedQueryChip = ({ value, onChange, onRemove }) => {
|
|
|
1031
1045
|
return;
|
|
1032
1046
|
}
|
|
1033
1047
|
};
|
|
1034
|
-
return /* @__PURE__ */ (0,
|
|
1035
|
-
/* @__PURE__ */ (0,
|
|
1036
|
-
isEditing ? /* @__PURE__ */ (0,
|
|
1048
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { ...chipStyles4, ...style }, children: [
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SearchIcon, { style: { width: "16px", height: "16px", color: "#03852e" } }),
|
|
1050
|
+
isEditing ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1037
1051
|
"input",
|
|
1038
1052
|
{
|
|
1039
1053
|
ref: inputRef,
|
|
@@ -1048,8 +1062,8 @@ var TransformedQueryChip = ({ value, onChange, onRemove }) => {
|
|
|
1048
1062
|
style: inputStyles2,
|
|
1049
1063
|
autoFocus: true
|
|
1050
1064
|
}
|
|
1051
|
-
) : /* @__PURE__ */ (0,
|
|
1052
|
-
!isEditing && /* @__PURE__ */ (0,
|
|
1065
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: { fontSize: "16px" }, children: value }),
|
|
1066
|
+
!isEditing && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1053
1067
|
"button",
|
|
1054
1068
|
{
|
|
1055
1069
|
type: "button",
|
|
@@ -1062,20 +1076,20 @@ var TransformedQueryChip = ({ value, onChange, onRemove }) => {
|
|
|
1062
1076
|
onClick: () => setIsEditing(true),
|
|
1063
1077
|
onMouseEnter: () => setEditHover(true),
|
|
1064
1078
|
onMouseLeave: () => setEditHover(false),
|
|
1065
|
-
children: /* @__PURE__ */ (0,
|
|
1079
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(EditIcon, {})
|
|
1066
1080
|
}
|
|
1067
1081
|
),
|
|
1068
|
-
/* @__PURE__ */ (0,
|
|
1082
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CloseButton, { onClick: onRemove })
|
|
1069
1083
|
] });
|
|
1070
1084
|
};
|
|
1071
1085
|
|
|
1072
1086
|
// src/hooks/useFilterScroll.ts
|
|
1073
|
-
var
|
|
1087
|
+
var import_react7 = require("react");
|
|
1074
1088
|
var useFilterScroll = (dependency) => {
|
|
1075
|
-
const scrollerRef = (0,
|
|
1076
|
-
const [atStart, setAtStart] = (0,
|
|
1077
|
-
const [atEnd, setAtEnd] = (0,
|
|
1078
|
-
const updateScrollButtons = (0,
|
|
1089
|
+
const scrollerRef = (0, import_react7.useRef)(null);
|
|
1090
|
+
const [atStart, setAtStart] = (0, import_react7.useState)(true);
|
|
1091
|
+
const [atEnd, setAtEnd] = (0, import_react7.useState)(true);
|
|
1092
|
+
const updateScrollButtons = (0, import_react7.useCallback)(() => {
|
|
1079
1093
|
const el = scrollerRef.current;
|
|
1080
1094
|
if (!el) {
|
|
1081
1095
|
setAtStart(true);
|
|
@@ -1086,7 +1100,7 @@ var useFilterScroll = (dependency) => {
|
|
|
1086
1100
|
setAtStart(scrollLeft <= 0);
|
|
1087
1101
|
setAtEnd(scrollLeft + clientWidth >= scrollWidth - 1);
|
|
1088
1102
|
}, []);
|
|
1089
|
-
(0,
|
|
1103
|
+
(0, import_react7.useEffect)(() => {
|
|
1090
1104
|
const el = scrollerRef.current;
|
|
1091
1105
|
updateScrollButtons();
|
|
1092
1106
|
if (!el) {
|
|
@@ -1100,7 +1114,7 @@ var useFilterScroll = (dependency) => {
|
|
|
1100
1114
|
window.removeEventListener("resize", updateScrollButtons);
|
|
1101
1115
|
};
|
|
1102
1116
|
}, [dependency, updateScrollButtons]);
|
|
1103
|
-
const scrollByDir = (0,
|
|
1117
|
+
const scrollByDir = (0, import_react7.useCallback)((dir) => {
|
|
1104
1118
|
const el = scrollerRef.current;
|
|
1105
1119
|
if (!el) {
|
|
1106
1120
|
return;
|
|
@@ -1120,7 +1134,7 @@ var useFilterScroll = (dependency) => {
|
|
|
1120
1134
|
};
|
|
1121
1135
|
|
|
1122
1136
|
// src/components/smart-filter/FilterChips.tsx
|
|
1123
|
-
var
|
|
1137
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1124
1138
|
var containerStyles = {
|
|
1125
1139
|
position: "relative",
|
|
1126
1140
|
width: "100%"
|
|
@@ -1166,20 +1180,22 @@ var FilterChips = ({
|
|
|
1166
1180
|
formatCurrency: _formatCurrency,
|
|
1167
1181
|
onFilterChange,
|
|
1168
1182
|
onResetFilters: _onResetFilters,
|
|
1169
|
-
onClearAll
|
|
1183
|
+
onClearAll,
|
|
1184
|
+
beforeContent,
|
|
1185
|
+
styles
|
|
1170
1186
|
}) => {
|
|
1171
1187
|
const { scrollerRef, atStart, atEnd, scrollByDir } = useFilterScroll(
|
|
1172
1188
|
filters.length
|
|
1173
1189
|
);
|
|
1174
|
-
const [navHover, setNavHover] =
|
|
1175
|
-
const [clearHover, setClearHover] =
|
|
1176
|
-
const removeFilter =
|
|
1190
|
+
const [navHover, setNavHover] = import_react8.default.useState(null);
|
|
1191
|
+
const [clearHover, setClearHover] = import_react8.default.useState(false);
|
|
1192
|
+
const removeFilter = import_react8.default.useCallback(
|
|
1177
1193
|
(filterId) => {
|
|
1178
1194
|
void onFilterChange(filters.filter((f) => f.id !== filterId));
|
|
1179
1195
|
},
|
|
1180
1196
|
[filters, onFilterChange]
|
|
1181
1197
|
);
|
|
1182
|
-
const patchFilter =
|
|
1198
|
+
const patchFilter = import_react8.default.useCallback(
|
|
1183
1199
|
(filterId, patch) => {
|
|
1184
1200
|
const nextFilters = filters.map(
|
|
1185
1201
|
(f) => f.id === filterId ? { ...f, ...patch } : f
|
|
@@ -1188,30 +1204,33 @@ var FilterChips = ({
|
|
|
1188
1204
|
},
|
|
1189
1205
|
[filters, onFilterChange]
|
|
1190
1206
|
);
|
|
1191
|
-
return /* @__PURE__ */ (0,
|
|
1192
|
-
/* @__PURE__ */ (0,
|
|
1207
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { style: containerStyles, children: [
|
|
1208
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1193
1209
|
"div",
|
|
1194
1210
|
{
|
|
1195
1211
|
ref: scrollerRef,
|
|
1196
1212
|
style: {
|
|
1197
1213
|
...scrollContainerBase,
|
|
1198
1214
|
padding: "8px",
|
|
1199
|
-
WebkitOverflowScrolling: "touch"
|
|
1215
|
+
WebkitOverflowScrolling: "touch",
|
|
1216
|
+
...styles == null ? void 0 : styles.scrollContainer
|
|
1200
1217
|
},
|
|
1201
1218
|
children: [
|
|
1202
|
-
/* @__PURE__ */ (0,
|
|
1219
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("style", { children: `
|
|
1203
1220
|
div::-webkit-scrollbar {
|
|
1204
1221
|
display: none;
|
|
1205
1222
|
}
|
|
1206
1223
|
` }),
|
|
1224
|
+
beforeContent,
|
|
1207
1225
|
filters.map((filter) => {
|
|
1208
1226
|
var _a, _b;
|
|
1209
|
-
const renderStandardChip = () => /* @__PURE__ */ (0,
|
|
1227
|
+
const renderStandardChip = () => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1210
1228
|
Chip,
|
|
1211
1229
|
{
|
|
1212
1230
|
label: filter.label,
|
|
1213
1231
|
icon: filter.icon,
|
|
1214
|
-
remove: () => removeFilter(filter.id)
|
|
1232
|
+
remove: () => removeFilter(filter.id),
|
|
1233
|
+
style: styles == null ? void 0 : styles.chip
|
|
1215
1234
|
},
|
|
1216
1235
|
filter.id
|
|
1217
1236
|
);
|
|
@@ -1220,7 +1239,7 @@ var FilterChips = ({
|
|
|
1220
1239
|
if (!Number.isFinite(currentRating)) {
|
|
1221
1240
|
return renderStandardChip();
|
|
1222
1241
|
}
|
|
1223
|
-
return /* @__PURE__ */ (0,
|
|
1242
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1224
1243
|
MinRatingFilterChip,
|
|
1225
1244
|
{
|
|
1226
1245
|
star: filter.type === "starRating",
|
|
@@ -1231,13 +1250,14 @@ var FilterChips = ({
|
|
|
1231
1250
|
value: String(nextRating)
|
|
1232
1251
|
});
|
|
1233
1252
|
},
|
|
1234
|
-
onRemove: () => removeFilter(filter.id)
|
|
1253
|
+
onRemove: () => removeFilter(filter.id),
|
|
1254
|
+
style: styles == null ? void 0 : styles.minRatingChip
|
|
1235
1255
|
},
|
|
1236
1256
|
filter.id
|
|
1237
1257
|
);
|
|
1238
1258
|
}
|
|
1239
1259
|
if (filter.type === "priceRange" && filter.priceRange) {
|
|
1240
|
-
return /* @__PURE__ */ (0,
|
|
1260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1241
1261
|
PriceRangeFilterChip,
|
|
1242
1262
|
{
|
|
1243
1263
|
priceRange: filter.priceRange,
|
|
@@ -1245,40 +1265,43 @@ var FilterChips = ({
|
|
|
1245
1265
|
onChange: (nextRange) => {
|
|
1246
1266
|
patchFilter(filter.id, { priceRange: nextRange });
|
|
1247
1267
|
},
|
|
1248
|
-
onRemove: () => removeFilter(filter.id)
|
|
1268
|
+
onRemove: () => removeFilter(filter.id),
|
|
1269
|
+
style: styles == null ? void 0 : styles.priceRangeChip
|
|
1249
1270
|
},
|
|
1250
1271
|
filter.id
|
|
1251
1272
|
);
|
|
1252
1273
|
}
|
|
1253
1274
|
if (filter.type === "transformed_query") {
|
|
1254
|
-
return /* @__PURE__ */ (0,
|
|
1275
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1255
1276
|
TransformedQueryChip,
|
|
1256
1277
|
{
|
|
1257
1278
|
value: filter.value,
|
|
1258
1279
|
onChange: (nextValue) => {
|
|
1259
1280
|
patchFilter(filter.id, { value: nextValue });
|
|
1260
1281
|
},
|
|
1261
|
-
onRemove: () => removeFilter(filter.id)
|
|
1282
|
+
onRemove: () => removeFilter(filter.id),
|
|
1283
|
+
style: styles == null ? void 0 : styles.transformedQueryChip
|
|
1262
1284
|
},
|
|
1263
1285
|
filter.id
|
|
1264
1286
|
);
|
|
1265
1287
|
}
|
|
1266
1288
|
if (filter.type === "selected_restaurant_price_levels") {
|
|
1267
|
-
return /* @__PURE__ */ (0,
|
|
1289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1268
1290
|
RestaurantPriceLevelChip,
|
|
1269
1291
|
{
|
|
1270
1292
|
values: (_b = filter.priceLevels) != null ? _b : [],
|
|
1271
1293
|
onChange: (nextLevels) => {
|
|
1272
1294
|
patchFilter(filter.id, { priceLevels: nextLevels });
|
|
1273
1295
|
},
|
|
1274
|
-
onRemove: () => removeFilter(filter.id)
|
|
1296
|
+
onRemove: () => removeFilter(filter.id),
|
|
1297
|
+
style: styles == null ? void 0 : styles.restaurantPriceLevelChip
|
|
1275
1298
|
},
|
|
1276
1299
|
filter.id
|
|
1277
1300
|
);
|
|
1278
1301
|
}
|
|
1279
1302
|
return renderStandardChip();
|
|
1280
1303
|
}),
|
|
1281
|
-
/* @__PURE__ */ (0,
|
|
1304
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1282
1305
|
"button",
|
|
1283
1306
|
{
|
|
1284
1307
|
style: {
|
|
@@ -1290,7 +1313,8 @@ var FilterChips = ({
|
|
|
1290
1313
|
userSelect: "none",
|
|
1291
1314
|
backgroundColor: clearHover ? "#e5e5e5" : "transparent",
|
|
1292
1315
|
color: "black",
|
|
1293
|
-
border: "none"
|
|
1316
|
+
border: "none",
|
|
1317
|
+
...styles == null ? void 0 : styles.clearAllButton
|
|
1294
1318
|
},
|
|
1295
1319
|
onClick: onClearAll,
|
|
1296
1320
|
onMouseEnter: () => setClearHover(true),
|
|
@@ -1301,7 +1325,7 @@ var FilterChips = ({
|
|
|
1301
1325
|
]
|
|
1302
1326
|
}
|
|
1303
1327
|
),
|
|
1304
|
-
!atStart && /* @__PURE__ */ (0,
|
|
1328
|
+
!atStart && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1305
1329
|
"div",
|
|
1306
1330
|
{
|
|
1307
1331
|
"aria-hidden": "true",
|
|
@@ -1312,7 +1336,7 @@ var FilterChips = ({
|
|
|
1312
1336
|
}
|
|
1313
1337
|
}
|
|
1314
1338
|
),
|
|
1315
|
-
!atEnd && /* @__PURE__ */ (0,
|
|
1339
|
+
!atEnd && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1316
1340
|
"div",
|
|
1317
1341
|
{
|
|
1318
1342
|
"aria-hidden": "true",
|
|
@@ -1323,7 +1347,7 @@ var FilterChips = ({
|
|
|
1323
1347
|
}
|
|
1324
1348
|
}
|
|
1325
1349
|
),
|
|
1326
|
-
!atStart && /* @__PURE__ */ (0,
|
|
1350
|
+
!atStart && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1327
1351
|
"button",
|
|
1328
1352
|
{
|
|
1329
1353
|
type: "button",
|
|
@@ -1332,15 +1356,16 @@ var FilterChips = ({
|
|
|
1332
1356
|
...navButtonStyles,
|
|
1333
1357
|
left: "4px",
|
|
1334
1358
|
transform: "translateY(-50%) rotate(180deg)",
|
|
1335
|
-
backgroundColor: navHover === "prev" ? "#e5e5e5" : "white"
|
|
1359
|
+
backgroundColor: navHover === "prev" ? "#e5e5e5" : "white",
|
|
1360
|
+
...styles == null ? void 0 : styles.navButton
|
|
1336
1361
|
},
|
|
1337
1362
|
onClick: () => scrollByDir("prev"),
|
|
1338
1363
|
onMouseEnter: () => setNavHover("prev"),
|
|
1339
1364
|
onMouseLeave: () => setNavHover(null),
|
|
1340
|
-
children: /* @__PURE__ */ (0,
|
|
1365
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NextIcon, { style: { width: "20px", height: "20px" } })
|
|
1341
1366
|
}
|
|
1342
1367
|
),
|
|
1343
|
-
!atEnd && /* @__PURE__ */ (0,
|
|
1368
|
+
!atEnd && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1344
1369
|
"button",
|
|
1345
1370
|
{
|
|
1346
1371
|
type: "button",
|
|
@@ -1348,19 +1373,20 @@ var FilterChips = ({
|
|
|
1348
1373
|
style: {
|
|
1349
1374
|
...navButtonStyles,
|
|
1350
1375
|
right: "4px",
|
|
1351
|
-
backgroundColor: navHover === "next" ? "#e5e5e5" : "white"
|
|
1376
|
+
backgroundColor: navHover === "next" ? "#e5e5e5" : "white",
|
|
1377
|
+
...styles == null ? void 0 : styles.navButton
|
|
1352
1378
|
},
|
|
1353
1379
|
onClick: () => scrollByDir("next"),
|
|
1354
1380
|
onMouseEnter: () => setNavHover("next"),
|
|
1355
1381
|
onMouseLeave: () => setNavHover(null),
|
|
1356
|
-
children: /* @__PURE__ */ (0,
|
|
1382
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NextIcon, { style: { width: "20px", height: "20px" } })
|
|
1357
1383
|
}
|
|
1358
1384
|
)
|
|
1359
1385
|
] });
|
|
1360
1386
|
};
|
|
1361
1387
|
|
|
1362
1388
|
// src/components/SmartFilter.tsx
|
|
1363
|
-
var
|
|
1389
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1364
1390
|
var containerStyles2 = {
|
|
1365
1391
|
position: "relative",
|
|
1366
1392
|
display: "flex",
|
|
@@ -1374,6 +1400,8 @@ var SmartFilter = ({
|
|
|
1374
1400
|
onFilterChange,
|
|
1375
1401
|
customTranslations,
|
|
1376
1402
|
currency = "USD",
|
|
1403
|
+
beforeContent,
|
|
1404
|
+
styles,
|
|
1377
1405
|
containerStyle,
|
|
1378
1406
|
style
|
|
1379
1407
|
}) => {
|
|
@@ -1382,7 +1410,7 @@ var SmartFilter = ({
|
|
|
1382
1410
|
const previousFiltersLabel = t("smartFilter.nav.previous");
|
|
1383
1411
|
const nextFiltersLabel = t("smartFilter.nav.next");
|
|
1384
1412
|
const clearAllLabel = t("smartFilter.clearAll");
|
|
1385
|
-
const handleFilterChange = (0,
|
|
1413
|
+
const handleFilterChange = (0, import_react9.useCallback)(
|
|
1386
1414
|
async (nextFilters, clearAll) => {
|
|
1387
1415
|
if (isSearching) {
|
|
1388
1416
|
return;
|
|
@@ -1395,25 +1423,38 @@ var SmartFilter = ({
|
|
|
1395
1423
|
},
|
|
1396
1424
|
[isSearching, onFilterChange]
|
|
1397
1425
|
);
|
|
1398
|
-
const resetFilters = (0,
|
|
1426
|
+
const resetFilters = (0, import_react9.useCallback)(() => {
|
|
1399
1427
|
void handleFilterChange([]);
|
|
1400
1428
|
}, [handleFilterChange]);
|
|
1401
|
-
const clearAllFilters = (0,
|
|
1429
|
+
const clearAllFilters = (0, import_react9.useCallback)(() => {
|
|
1402
1430
|
void handleFilterChange([], true);
|
|
1403
1431
|
}, [handleFilterChange]);
|
|
1404
|
-
return /* @__PURE__ */ (0,
|
|
1405
|
-
|
|
1432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TranslationProvider, { value: customTranslations, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1433
|
+
"div",
|
|
1406
1434
|
{
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1435
|
+
style: {
|
|
1436
|
+
...containerStyles2,
|
|
1437
|
+
...styles == null ? void 0 : styles.container,
|
|
1438
|
+
...containerStyle,
|
|
1439
|
+
...style
|
|
1440
|
+
},
|
|
1441
|
+
children: filters.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1442
|
+
FilterChips,
|
|
1443
|
+
{
|
|
1444
|
+
filters,
|
|
1445
|
+
currency,
|
|
1446
|
+
minRatingSuffix,
|
|
1447
|
+
clearAllLabel,
|
|
1448
|
+
previousFiltersLabel,
|
|
1449
|
+
nextFiltersLabel,
|
|
1450
|
+
formatCurrency,
|
|
1451
|
+
onFilterChange: handleFilterChange,
|
|
1452
|
+
onResetFilters: resetFilters,
|
|
1453
|
+
onClearAll: clearAllFilters,
|
|
1454
|
+
beforeContent,
|
|
1455
|
+
styles
|
|
1456
|
+
}
|
|
1457
|
+
)
|
|
1417
1458
|
}
|
|
1418
1459
|
) });
|
|
1419
1460
|
};
|
|
@@ -1432,12 +1473,12 @@ function attachMapOnce(instanceRef, attachedRef, map, config) {
|
|
|
1432
1473
|
attachedRef.current = true;
|
|
1433
1474
|
}
|
|
1434
1475
|
function useMapFirst(options) {
|
|
1435
|
-
const optionsRef =
|
|
1436
|
-
|
|
1476
|
+
const optionsRef = import_react10.default.useRef(options);
|
|
1477
|
+
import_react10.default.useEffect(() => {
|
|
1437
1478
|
optionsRef.current = options;
|
|
1438
1479
|
});
|
|
1439
|
-
const callbacksRef =
|
|
1440
|
-
const instanceRef =
|
|
1480
|
+
const callbacksRef = import_react10.default.useRef({});
|
|
1481
|
+
const instanceRef = import_react10.default.useRef(null);
|
|
1441
1482
|
if (instanceRef.current === null) {
|
|
1442
1483
|
instanceRef.current = new import_core.MapFirstCore({
|
|
1443
1484
|
adapter: null,
|
|
@@ -1445,10 +1486,10 @@ function useMapFirst(options) {
|
|
|
1445
1486
|
callbacks: callbacksRef.current
|
|
1446
1487
|
});
|
|
1447
1488
|
}
|
|
1448
|
-
const [state, setState] =
|
|
1489
|
+
const [state, setState] = import_react10.default.useState(
|
|
1449
1490
|
() => instanceRef.current.getState()
|
|
1450
1491
|
);
|
|
1451
|
-
|
|
1492
|
+
import_react10.default.useEffect(() => {
|
|
1452
1493
|
if (!instanceRef.current) {
|
|
1453
1494
|
callbacksRef.current = {};
|
|
1454
1495
|
instanceRef.current = new import_core.MapFirstCore({
|
|
@@ -1527,17 +1568,17 @@ function useMapFirst(options) {
|
|
|
1527
1568
|
instanceRef.current = null;
|
|
1528
1569
|
};
|
|
1529
1570
|
}, []);
|
|
1530
|
-
const setPrimaryType =
|
|
1571
|
+
const setPrimaryType = import_react10.default.useCallback((type) => {
|
|
1531
1572
|
if (instanceRef.current) {
|
|
1532
1573
|
instanceRef.current.setPrimaryType(type);
|
|
1533
1574
|
}
|
|
1534
1575
|
}, []);
|
|
1535
|
-
const setSelectedMarker =
|
|
1576
|
+
const setSelectedMarker = import_react10.default.useCallback((id) => {
|
|
1536
1577
|
if (instanceRef.current) {
|
|
1537
1578
|
instanceRef.current.setSelectedMarker(id);
|
|
1538
1579
|
}
|
|
1539
1580
|
}, []);
|
|
1540
|
-
const setUseApi =
|
|
1581
|
+
const setUseApi = import_react10.default.useCallback(
|
|
1541
1582
|
(useApi, autoLoad = true) => {
|
|
1542
1583
|
if (instanceRef.current) {
|
|
1543
1584
|
instanceRef.current.setUseApi(useApi, autoLoad);
|
|
@@ -1545,7 +1586,7 @@ function useMapFirst(options) {
|
|
|
1545
1586
|
},
|
|
1546
1587
|
[]
|
|
1547
1588
|
);
|
|
1548
|
-
const propertiesSearch =
|
|
1589
|
+
const propertiesSearch = import_react10.default.useCallback(
|
|
1549
1590
|
async (options2) => {
|
|
1550
1591
|
if (!instanceRef.current) {
|
|
1551
1592
|
throw new Error("MapFirst instance not available");
|
|
@@ -1554,7 +1595,7 @@ function useMapFirst(options) {
|
|
|
1554
1595
|
},
|
|
1555
1596
|
[]
|
|
1556
1597
|
);
|
|
1557
|
-
const smartFilterSearch =
|
|
1598
|
+
const smartFilterSearch = import_react10.default.useCallback(
|
|
1558
1599
|
async (options2) => {
|
|
1559
1600
|
if (!instanceRef.current) {
|
|
1560
1601
|
throw new Error("MapFirst instance not available");
|
|
@@ -1563,14 +1604,14 @@ function useMapFirst(options) {
|
|
|
1563
1604
|
},
|
|
1564
1605
|
[]
|
|
1565
1606
|
);
|
|
1566
|
-
const boundsSearch =
|
|
1607
|
+
const boundsSearch = import_react10.default.useCallback(async () => {
|
|
1567
1608
|
if (!instanceRef.current) {
|
|
1568
1609
|
return null;
|
|
1569
1610
|
}
|
|
1570
1611
|
return await instanceRef.current.performBoundsSearch();
|
|
1571
1612
|
}, []);
|
|
1572
|
-
const mapLibreAttachedRef =
|
|
1573
|
-
const attachMapLibre =
|
|
1613
|
+
const mapLibreAttachedRef = import_react10.default.useRef(false);
|
|
1614
|
+
const attachMapLibre = import_react10.default.useCallback(
|
|
1574
1615
|
(map, maplibregl, options2) => {
|
|
1575
1616
|
attachMapOnce(instanceRef, mapLibreAttachedRef, map, {
|
|
1576
1617
|
platform: "maplibre",
|
|
@@ -1581,8 +1622,8 @@ function useMapFirst(options) {
|
|
|
1581
1622
|
},
|
|
1582
1623
|
[]
|
|
1583
1624
|
);
|
|
1584
|
-
const googleMapsAttachedRef =
|
|
1585
|
-
const attachGoogle =
|
|
1625
|
+
const googleMapsAttachedRef = import_react10.default.useRef(false);
|
|
1626
|
+
const attachGoogle = import_react10.default.useCallback(
|
|
1586
1627
|
(map, google, options2) => {
|
|
1587
1628
|
attachMapOnce(instanceRef, googleMapsAttachedRef, map, {
|
|
1588
1629
|
platform: "google",
|
|
@@ -1593,8 +1634,8 @@ function useMapFirst(options) {
|
|
|
1593
1634
|
},
|
|
1594
1635
|
[]
|
|
1595
1636
|
);
|
|
1596
|
-
const mapboxAttachedRef =
|
|
1597
|
-
const attachMapbox =
|
|
1637
|
+
const mapboxAttachedRef = import_react10.default.useRef(false);
|
|
1638
|
+
const attachMapbox = import_react10.default.useCallback(
|
|
1598
1639
|
(map, mapboxgl, options2) => {
|
|
1599
1640
|
attachMapOnce(instanceRef, mapboxAttachedRef, map, {
|
|
1600
1641
|
platform: "mapbox",
|
|
@@ -1605,8 +1646,8 @@ function useMapFirst(options) {
|
|
|
1605
1646
|
},
|
|
1606
1647
|
[]
|
|
1607
1648
|
);
|
|
1608
|
-
const leafletAttachedRef =
|
|
1609
|
-
const attachLeaflet =
|
|
1649
|
+
const leafletAttachedRef = import_react10.default.useRef(false);
|
|
1650
|
+
const attachLeaflet = import_react10.default.useCallback(
|
|
1610
1651
|
(map, leaflet, options2) => {
|
|
1611
1652
|
if (!instanceRef.current || !map || leafletAttachedRef.current) return;
|
|
1612
1653
|
const adapter = new import_core.LeafletAdapter(map);
|