@mapfirst.ai/react 0.1.1 → 0.1.3
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 +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.js +168 -145
- package/dist/index.mjs +121 -100
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.tsx
|
|
2
|
-
import
|
|
2
|
+
import React8 from "react";
|
|
3
3
|
import {
|
|
4
4
|
MapFirstCore,
|
|
5
5
|
LeafletAdapter
|
|
@@ -21,9 +21,12 @@ import {
|
|
|
21
21
|
} from "react";
|
|
22
22
|
|
|
23
23
|
// src/components/smart-filter/FilterChips.tsx
|
|
24
|
-
import
|
|
24
|
+
import React7 from "react";
|
|
25
25
|
|
|
26
26
|
// src/components/smart-filter/CloseButton.tsx
|
|
27
|
+
import React2 from "react";
|
|
28
|
+
|
|
29
|
+
// src/context/IconsContext.tsx
|
|
27
30
|
import React from "react";
|
|
28
31
|
|
|
29
32
|
// src/components/Icons.tsx
|
|
@@ -118,8 +121,20 @@ var StarIcon = ({
|
|
|
118
121
|
}
|
|
119
122
|
);
|
|
120
123
|
|
|
121
|
-
// src/
|
|
124
|
+
// src/context/IconsContext.tsx
|
|
122
125
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
126
|
+
var defaultIcons = {
|
|
127
|
+
CloseIcon,
|
|
128
|
+
EditIcon,
|
|
129
|
+
NextIcon,
|
|
130
|
+
SearchIcon
|
|
131
|
+
};
|
|
132
|
+
var IconsContext = React.createContext(defaultIcons);
|
|
133
|
+
var IconsProvider = ({ value, children }) => /* @__PURE__ */ jsx2(IconsContext.Provider, { value: value ? { ...defaultIcons, ...value } : defaultIcons, children });
|
|
134
|
+
var useIcons = () => React.useContext(IconsContext);
|
|
135
|
+
|
|
136
|
+
// src/components/smart-filter/CloseButton.tsx
|
|
137
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
123
138
|
var closeButtonStyles = {
|
|
124
139
|
position: "absolute",
|
|
125
140
|
top: "-8px",
|
|
@@ -139,8 +154,9 @@ var iconStyles = {
|
|
|
139
154
|
height: "17px"
|
|
140
155
|
};
|
|
141
156
|
var CloseButton = ({ onClick, style }) => {
|
|
142
|
-
const [isHovering, setIsHovering] =
|
|
143
|
-
|
|
157
|
+
const [isHovering, setIsHovering] = React2.useState(false);
|
|
158
|
+
const { CloseIcon: CloseIcon2 } = useIcons();
|
|
159
|
+
return /* @__PURE__ */ jsx3(
|
|
144
160
|
"button",
|
|
145
161
|
{
|
|
146
162
|
style: {
|
|
@@ -152,13 +168,13 @@ var CloseButton = ({ onClick, style }) => {
|
|
|
152
168
|
onMouseEnter: () => setIsHovering(true),
|
|
153
169
|
onMouseLeave: () => setIsHovering(false),
|
|
154
170
|
"aria-label": "Remove filter",
|
|
155
|
-
children: /* @__PURE__ */
|
|
171
|
+
children: /* @__PURE__ */ jsx3(CloseIcon2, { style: iconStyles })
|
|
156
172
|
}
|
|
157
173
|
);
|
|
158
174
|
};
|
|
159
175
|
|
|
160
176
|
// src/components/smart-filter/Chip.tsx
|
|
161
|
-
import { jsx as
|
|
177
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
162
178
|
var chipStyles = {
|
|
163
179
|
position: "relative",
|
|
164
180
|
backgroundColor: "white",
|
|
@@ -176,9 +192,9 @@ var chipStyles = {
|
|
|
176
192
|
};
|
|
177
193
|
var Chip = ({ label, icon, remove, style }) => {
|
|
178
194
|
return /* @__PURE__ */ jsxs2("div", { style: { ...chipStyles, ...style }, children: [
|
|
179
|
-
icon && /* @__PURE__ */
|
|
180
|
-
/* @__PURE__ */
|
|
181
|
-
/* @__PURE__ */
|
|
195
|
+
icon && /* @__PURE__ */ jsx4("span", { style: { display: "flex", alignItems: "center" }, children: icon }),
|
|
196
|
+
/* @__PURE__ */ jsx4("span", { style: { whiteSpace: "nowrap" }, children: label }),
|
|
197
|
+
/* @__PURE__ */ jsx4(CloseButton, { onClick: remove })
|
|
182
198
|
] });
|
|
183
199
|
};
|
|
184
200
|
|
|
@@ -191,11 +207,11 @@ import {
|
|
|
191
207
|
import { useCallback, useMemo, useState } from "react";
|
|
192
208
|
|
|
193
209
|
// src/context/TranslationContext.tsx
|
|
194
|
-
import
|
|
195
|
-
import { jsx as
|
|
196
|
-
var TranslationContext =
|
|
197
|
-
var TranslationProvider = ({ value, children }) => /* @__PURE__ */
|
|
198
|
-
var useCustomTranslationsContext = () =>
|
|
210
|
+
import React3 from "react";
|
|
211
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
212
|
+
var TranslationContext = React3.createContext(void 0);
|
|
213
|
+
var TranslationProvider = ({ value, children }) => /* @__PURE__ */ jsx5(TranslationContext.Provider, { value, children });
|
|
214
|
+
var useCustomTranslationsContext = () => React3.useContext(TranslationContext);
|
|
199
215
|
|
|
200
216
|
// src/hooks/useTranslation.ts
|
|
201
217
|
var defaultTranslations = {
|
|
@@ -269,7 +285,7 @@ var useTranslation = (customTranslations, customFormatCurrency) => {
|
|
|
269
285
|
};
|
|
270
286
|
|
|
271
287
|
// src/components/smart-filter/utils.tsx
|
|
272
|
-
import { jsx as
|
|
288
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
273
289
|
var STAR_BASE_STYLES = {
|
|
274
290
|
display: "block",
|
|
275
291
|
width: "12px",
|
|
@@ -301,19 +317,19 @@ var renderStars = (rating) => {
|
|
|
301
317
|
const fullStars = Math.floor(rating);
|
|
302
318
|
const hasHalfStar = rating % 1 !== 0;
|
|
303
319
|
for (let i = 0; i < fullStars; i += 1) {
|
|
304
|
-
stars.push(/* @__PURE__ */
|
|
320
|
+
stars.push(/* @__PURE__ */ jsx6("span", { style: STAR_FULL_STYLES }, `full-${i}`));
|
|
305
321
|
}
|
|
306
322
|
if (hasHalfStar) {
|
|
307
|
-
stars.push(/* @__PURE__ */
|
|
323
|
+
stars.push(/* @__PURE__ */ jsx6("span", { style: STAR_HALF_STYLES }, "half"));
|
|
308
324
|
}
|
|
309
325
|
const remainingStars = Math.max(0, 5 - Math.ceil(rating));
|
|
310
326
|
for (let i = 0; i < remainingStars; i += 1) {
|
|
311
|
-
stars.push(/* @__PURE__ */
|
|
327
|
+
stars.push(/* @__PURE__ */ jsx6("span", { style: STAR_BASE_STYLES }, `empty-${i}`));
|
|
312
328
|
}
|
|
313
329
|
return stars;
|
|
314
330
|
};
|
|
315
331
|
var createMinRatingFilterLabel = (rating, suffix) => /* @__PURE__ */ jsxs3("span", { style: MIN_RATING_LABEL_STYLES, children: [
|
|
316
|
-
/* @__PURE__ */
|
|
332
|
+
/* @__PURE__ */ jsx6("span", { style: MIN_RATING_STARS_WRAPPER_STYLES, children: renderStars(rating) }),
|
|
317
333
|
" ",
|
|
318
334
|
suffix
|
|
319
335
|
] });
|
|
@@ -324,7 +340,7 @@ var createPriceRangeFilterLabel = (min, max, currency, formatCurrencyFn) => `${f
|
|
|
324
340
|
)}`;
|
|
325
341
|
|
|
326
342
|
// src/components/smart-filter/MinRatingFilterChip.tsx
|
|
327
|
-
import { jsx as
|
|
343
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
328
344
|
var chipContainerStyles = {
|
|
329
345
|
position: "relative",
|
|
330
346
|
backgroundColor: "white",
|
|
@@ -401,7 +417,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
401
417
|
style: { display: "flex", alignItems: "center", gap: "4px" },
|
|
402
418
|
onMouseLeave: () => setHoverRating(null),
|
|
403
419
|
children: [
|
|
404
|
-
/* @__PURE__ */
|
|
420
|
+
/* @__PURE__ */ jsx7("div", { style: starContainerStyles, children: Array.from({ length: 5 }).map((_, index) => {
|
|
405
421
|
const fillState = getFillForStar(index);
|
|
406
422
|
const starNumber = index + 1;
|
|
407
423
|
const halfValue = starNumber - 0.5;
|
|
@@ -426,15 +442,15 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
426
442
|
},
|
|
427
443
|
xmlns: "http://www.w3.org/2000/svg",
|
|
428
444
|
children: [
|
|
429
|
-
/* @__PURE__ */
|
|
430
|
-
/* @__PURE__ */
|
|
445
|
+
/* @__PURE__ */ jsx7("defs", { children: /* @__PURE__ */ jsxs4("linearGradient", { id: `star-gradient-${index}`, children: [
|
|
446
|
+
/* @__PURE__ */ jsx7(
|
|
431
447
|
"stop",
|
|
432
448
|
{
|
|
433
449
|
offset: fillState === "half" ? "50%" : "0%",
|
|
434
450
|
stopColor: "#03852e"
|
|
435
451
|
}
|
|
436
452
|
),
|
|
437
|
-
/* @__PURE__ */
|
|
453
|
+
/* @__PURE__ */ jsx7(
|
|
438
454
|
"stop",
|
|
439
455
|
{
|
|
440
456
|
offset: fillState === "half" ? "50%" : "0%",
|
|
@@ -442,7 +458,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
442
458
|
}
|
|
443
459
|
)
|
|
444
460
|
] }) }),
|
|
445
|
-
/* @__PURE__ */
|
|
461
|
+
/* @__PURE__ */ jsx7(
|
|
446
462
|
"path",
|
|
447
463
|
{
|
|
448
464
|
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",
|
|
@@ -454,7 +470,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
454
470
|
]
|
|
455
471
|
}
|
|
456
472
|
),
|
|
457
|
-
/* @__PURE__ */
|
|
473
|
+
/* @__PURE__ */ jsx7(
|
|
458
474
|
"button",
|
|
459
475
|
{
|
|
460
476
|
type: "button",
|
|
@@ -472,7 +488,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
472
488
|
title: formatLabel(halfValue)
|
|
473
489
|
}
|
|
474
490
|
),
|
|
475
|
-
/* @__PURE__ */
|
|
491
|
+
/* @__PURE__ */ jsx7(
|
|
476
492
|
"button",
|
|
477
493
|
{
|
|
478
494
|
type: "button",
|
|
@@ -505,13 +521,13 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
505
521
|
{
|
|
506
522
|
style: { position: "relative", width: "12px", height: "12px" },
|
|
507
523
|
children: [
|
|
508
|
-
/* @__PURE__ */
|
|
524
|
+
/* @__PURE__ */ jsx7(
|
|
509
525
|
"span",
|
|
510
526
|
{
|
|
511
527
|
style: fillState === "half" ? halfCircleStyles : circleStyles
|
|
512
528
|
}
|
|
513
529
|
),
|
|
514
|
-
/* @__PURE__ */
|
|
530
|
+
/* @__PURE__ */ jsx7(
|
|
515
531
|
"button",
|
|
516
532
|
{
|
|
517
533
|
type: "button",
|
|
@@ -531,7 +547,7 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
531
547
|
title: formatLabel(halfValue)
|
|
532
548
|
}
|
|
533
549
|
),
|
|
534
|
-
/* @__PURE__ */
|
|
550
|
+
/* @__PURE__ */ jsx7(
|
|
535
551
|
"button",
|
|
536
552
|
{
|
|
537
553
|
type: "button",
|
|
@@ -556,11 +572,11 @@ var MinRatingFilterChip = ({ rating, onChange, onRemove, star = false, style })
|
|
|
556
572
|
index
|
|
557
573
|
);
|
|
558
574
|
}) }),
|
|
559
|
-
/* @__PURE__ */
|
|
575
|
+
/* @__PURE__ */ jsx7("span", { style: { whiteSpace: "nowrap" }, children: formatLabel(displayRating) })
|
|
560
576
|
]
|
|
561
577
|
}
|
|
562
578
|
),
|
|
563
|
-
/* @__PURE__ */
|
|
579
|
+
/* @__PURE__ */ jsx7(CloseButton, { onClick: onRemove })
|
|
564
580
|
] });
|
|
565
581
|
};
|
|
566
582
|
|
|
@@ -569,7 +585,7 @@ import {
|
|
|
569
585
|
useEffect,
|
|
570
586
|
useState as useState3
|
|
571
587
|
} from "react";
|
|
572
|
-
import { Fragment, jsx as
|
|
588
|
+
import { Fragment, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
573
589
|
var chipStyles2 = {
|
|
574
590
|
position: "relative",
|
|
575
591
|
backgroundColor: "white",
|
|
@@ -678,7 +694,7 @@ var PriceBoundaryChip = ({
|
|
|
678
694
|
}
|
|
679
695
|
};
|
|
680
696
|
return /* @__PURE__ */ jsxs5("div", { style: { ...chipStyles2, ...style }, children: [
|
|
681
|
-
/* @__PURE__ */
|
|
697
|
+
/* @__PURE__ */ jsx8(
|
|
682
698
|
"span",
|
|
683
699
|
{
|
|
684
700
|
style: {
|
|
@@ -690,7 +706,7 @@ var PriceBoundaryChip = ({
|
|
|
690
706
|
children: label
|
|
691
707
|
}
|
|
692
708
|
),
|
|
693
|
-
isEditing ? /* @__PURE__ */
|
|
709
|
+
isEditing ? /* @__PURE__ */ jsx8(
|
|
694
710
|
"input",
|
|
695
711
|
{
|
|
696
712
|
value: draft,
|
|
@@ -707,13 +723,13 @@ var PriceBoundaryChip = ({
|
|
|
707
723
|
style: inputStyles,
|
|
708
724
|
autoFocus: true
|
|
709
725
|
}
|
|
710
|
-
) : hasValue ? /* @__PURE__ */
|
|
726
|
+
) : hasValue ? /* @__PURE__ */ jsx8(
|
|
711
727
|
"span",
|
|
712
728
|
{
|
|
713
729
|
style: { fontSize: "16px", fontWeight: 600, textAlign: "center" },
|
|
714
730
|
children: value
|
|
715
731
|
}
|
|
716
|
-
) : showAddWhenEmpty ? /* @__PURE__ */
|
|
732
|
+
) : showAddWhenEmpty ? /* @__PURE__ */ jsx8(
|
|
717
733
|
"button",
|
|
718
734
|
{
|
|
719
735
|
type: "button",
|
|
@@ -729,8 +745,8 @@ var PriceBoundaryChip = ({
|
|
|
729
745
|
"aria-label": editLabel,
|
|
730
746
|
children: "+"
|
|
731
747
|
}
|
|
732
|
-
) : /* @__PURE__ */
|
|
733
|
-
(!showAddWhenEmpty || showAddWhenEmpty && isEditing) && /* @__PURE__ */
|
|
748
|
+
) : /* @__PURE__ */ jsx8("span", { style: { fontSize: "16px", color: "#737373" }, children: "-" }),
|
|
749
|
+
(!showAddWhenEmpty || showAddWhenEmpty && isEditing) && /* @__PURE__ */ jsx8(
|
|
734
750
|
"span",
|
|
735
751
|
{
|
|
736
752
|
style: {
|
|
@@ -742,7 +758,7 @@ var PriceBoundaryChip = ({
|
|
|
742
758
|
children: currency
|
|
743
759
|
}
|
|
744
760
|
),
|
|
745
|
-
!isEditing && (!showAddWhenEmpty || hasValue) && /* @__PURE__ */
|
|
761
|
+
!isEditing && (!showAddWhenEmpty || hasValue) && /* @__PURE__ */ jsx8(
|
|
746
762
|
"button",
|
|
747
763
|
{
|
|
748
764
|
type: "button",
|
|
@@ -755,10 +771,10 @@ var PriceBoundaryChip = ({
|
|
|
755
771
|
onClick: () => setIsEditing(true),
|
|
756
772
|
onMouseEnter: () => setEditHover(true),
|
|
757
773
|
onMouseLeave: () => setEditHover(false),
|
|
758
|
-
children: /* @__PURE__ */
|
|
774
|
+
children: /* @__PURE__ */ jsx8(EditIcon, {})
|
|
759
775
|
}
|
|
760
776
|
),
|
|
761
|
-
showRemoveButton && /* @__PURE__ */
|
|
777
|
+
showRemoveButton && /* @__PURE__ */ jsx8(CloseButton, { onClick: onRemove })
|
|
762
778
|
] });
|
|
763
779
|
};
|
|
764
780
|
var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style }) => {
|
|
@@ -787,7 +803,7 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style })
|
|
|
787
803
|
}
|
|
788
804
|
};
|
|
789
805
|
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
790
|
-
/* @__PURE__ */
|
|
806
|
+
/* @__PURE__ */ jsx8(
|
|
791
807
|
PriceBoundaryChip,
|
|
792
808
|
{
|
|
793
809
|
label: minLabel,
|
|
@@ -800,7 +816,7 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style })
|
|
|
800
816
|
style
|
|
801
817
|
}
|
|
802
818
|
),
|
|
803
|
-
/* @__PURE__ */
|
|
819
|
+
/* @__PURE__ */ jsx8(
|
|
804
820
|
PriceBoundaryChip,
|
|
805
821
|
{
|
|
806
822
|
label: maxChipLabel,
|
|
@@ -819,7 +835,7 @@ var PriceRangeFilterChip = ({ priceRange, currency, onChange, onRemove, style })
|
|
|
819
835
|
};
|
|
820
836
|
|
|
821
837
|
// src/components/smart-filter/RestaurantPriceLevelChip.tsx
|
|
822
|
-
import { jsx as
|
|
838
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
823
839
|
var chipStyles3 = {
|
|
824
840
|
position: "relative",
|
|
825
841
|
backgroundColor: "white",
|
|
@@ -870,7 +886,7 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
870
886
|
flexWrap: "wrap"
|
|
871
887
|
},
|
|
872
888
|
children: [
|
|
873
|
-
/* @__PURE__ */
|
|
889
|
+
/* @__PURE__ */ jsx9(
|
|
874
890
|
"span",
|
|
875
891
|
{
|
|
876
892
|
style: {
|
|
@@ -900,7 +916,7 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
900
916
|
cursor: "pointer"
|
|
901
917
|
},
|
|
902
918
|
children: [
|
|
903
|
-
/* @__PURE__ */
|
|
919
|
+
/* @__PURE__ */ jsx9(
|
|
904
920
|
"input",
|
|
905
921
|
{
|
|
906
922
|
id: checkboxId,
|
|
@@ -911,18 +927,18 @@ var RestaurantPriceLevelChip = ({ values, onChange, onRemove, style }) => {
|
|
|
911
927
|
style: { accentColor: "#03852e", cursor: "pointer" }
|
|
912
928
|
}
|
|
913
929
|
),
|
|
914
|
-
/* @__PURE__ */
|
|
930
|
+
/* @__PURE__ */ jsx9("span", { children: optionLabel })
|
|
915
931
|
]
|
|
916
932
|
},
|
|
917
933
|
option.value
|
|
918
934
|
);
|
|
919
935
|
}),
|
|
920
|
-
values.length === 0 && /* @__PURE__ */
|
|
936
|
+
values.length === 0 && /* @__PURE__ */ jsx9("span", { style: { fontSize: "12px", color: "#737373" }, children: noneSelectedLabel })
|
|
921
937
|
] })
|
|
922
938
|
]
|
|
923
939
|
}
|
|
924
940
|
),
|
|
925
|
-
/* @__PURE__ */
|
|
941
|
+
/* @__PURE__ */ jsx9(CloseButton, { onClick: onRemove })
|
|
926
942
|
] });
|
|
927
943
|
};
|
|
928
944
|
|
|
@@ -932,7 +948,7 @@ import {
|
|
|
932
948
|
useRef,
|
|
933
949
|
useState as useState4
|
|
934
950
|
} from "react";
|
|
935
|
-
import { jsx as
|
|
951
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
936
952
|
var chipStyles4 = {
|
|
937
953
|
position: "relative",
|
|
938
954
|
backgroundColor: "white",
|
|
@@ -976,6 +992,7 @@ var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
|
976
992
|
const [isEditing, setIsEditing] = useState4(false);
|
|
977
993
|
const [editHover, setEditHover] = useState4(false);
|
|
978
994
|
const { t } = useTranslation();
|
|
995
|
+
const { SearchIcon: SearchIcon2, EditIcon: EditIcon2 } = useIcons();
|
|
979
996
|
const removeLabel = t("smartFilter.transformedQuery.remove");
|
|
980
997
|
const editLabel = t("smartFilter.transformedQuery.edit");
|
|
981
998
|
useEffect2(() => {
|
|
@@ -1010,8 +1027,8 @@ var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
|
1010
1027
|
}
|
|
1011
1028
|
};
|
|
1012
1029
|
return /* @__PURE__ */ jsxs7("div", { style: { ...chipStyles4, ...style }, children: [
|
|
1013
|
-
/* @__PURE__ */
|
|
1014
|
-
isEditing ? /* @__PURE__ */
|
|
1030
|
+
/* @__PURE__ */ jsx10(SearchIcon2, { style: { width: "16px", height: "16px", color: "#03852e" } }),
|
|
1031
|
+
isEditing ? /* @__PURE__ */ jsx10(
|
|
1015
1032
|
"input",
|
|
1016
1033
|
{
|
|
1017
1034
|
ref: inputRef,
|
|
@@ -1026,8 +1043,8 @@ var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
|
1026
1043
|
style: inputStyles2,
|
|
1027
1044
|
autoFocus: true
|
|
1028
1045
|
}
|
|
1029
|
-
) : /* @__PURE__ */
|
|
1030
|
-
!isEditing && /* @__PURE__ */
|
|
1046
|
+
) : /* @__PURE__ */ jsx10("span", { style: { fontSize: "16px" }, children: value }),
|
|
1047
|
+
!isEditing && /* @__PURE__ */ jsx10(
|
|
1031
1048
|
"button",
|
|
1032
1049
|
{
|
|
1033
1050
|
type: "button",
|
|
@@ -1040,10 +1057,10 @@ var TransformedQueryChip = ({ value, onChange, onRemove, style }) => {
|
|
|
1040
1057
|
onClick: () => setIsEditing(true),
|
|
1041
1058
|
onMouseEnter: () => setEditHover(true),
|
|
1042
1059
|
onMouseLeave: () => setEditHover(false),
|
|
1043
|
-
children: /* @__PURE__ */
|
|
1060
|
+
children: /* @__PURE__ */ jsx10(EditIcon2, {})
|
|
1044
1061
|
}
|
|
1045
1062
|
),
|
|
1046
|
-
/* @__PURE__ */
|
|
1063
|
+
/* @__PURE__ */ jsx10(CloseButton, { onClick: onRemove })
|
|
1047
1064
|
] });
|
|
1048
1065
|
};
|
|
1049
1066
|
|
|
@@ -1098,7 +1115,7 @@ var useFilterScroll = (dependency) => {
|
|
|
1098
1115
|
};
|
|
1099
1116
|
|
|
1100
1117
|
// src/components/smart-filter/FilterChips.tsx
|
|
1101
|
-
import { jsx as
|
|
1118
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1102
1119
|
var containerStyles = {
|
|
1103
1120
|
position: "relative",
|
|
1104
1121
|
width: "100%"
|
|
@@ -1151,15 +1168,16 @@ var FilterChips = ({
|
|
|
1151
1168
|
const { scrollerRef, atStart, atEnd, scrollByDir } = useFilterScroll(
|
|
1152
1169
|
filters.length
|
|
1153
1170
|
);
|
|
1154
|
-
const
|
|
1155
|
-
const [
|
|
1156
|
-
const
|
|
1171
|
+
const { NextIcon: NextIcon2 } = useIcons();
|
|
1172
|
+
const [navHover, setNavHover] = React7.useState(null);
|
|
1173
|
+
const [clearHover, setClearHover] = React7.useState(false);
|
|
1174
|
+
const removeFilter = React7.useCallback(
|
|
1157
1175
|
(filterId) => {
|
|
1158
1176
|
void onFilterChange(filters.filter((f) => f.id !== filterId));
|
|
1159
1177
|
},
|
|
1160
1178
|
[filters, onFilterChange]
|
|
1161
1179
|
);
|
|
1162
|
-
const patchFilter =
|
|
1180
|
+
const patchFilter = React7.useCallback(
|
|
1163
1181
|
(filterId, patch) => {
|
|
1164
1182
|
const nextFilters = filters.map(
|
|
1165
1183
|
(f) => f.id === filterId ? { ...f, ...patch } : f
|
|
@@ -1180,7 +1198,7 @@ var FilterChips = ({
|
|
|
1180
1198
|
...styles == null ? void 0 : styles.scrollContainer
|
|
1181
1199
|
},
|
|
1182
1200
|
children: [
|
|
1183
|
-
/* @__PURE__ */
|
|
1201
|
+
/* @__PURE__ */ jsx11("style", { children: `
|
|
1184
1202
|
div::-webkit-scrollbar {
|
|
1185
1203
|
display: none;
|
|
1186
1204
|
}
|
|
@@ -1188,7 +1206,7 @@ var FilterChips = ({
|
|
|
1188
1206
|
beforeContent,
|
|
1189
1207
|
filters.map((filter) => {
|
|
1190
1208
|
var _a, _b;
|
|
1191
|
-
const renderStandardChip = () => /* @__PURE__ */
|
|
1209
|
+
const renderStandardChip = () => /* @__PURE__ */ jsx11(
|
|
1192
1210
|
Chip,
|
|
1193
1211
|
{
|
|
1194
1212
|
label: filter.label,
|
|
@@ -1203,7 +1221,7 @@ var FilterChips = ({
|
|
|
1203
1221
|
if (!Number.isFinite(currentRating)) {
|
|
1204
1222
|
return renderStandardChip();
|
|
1205
1223
|
}
|
|
1206
|
-
return /* @__PURE__ */
|
|
1224
|
+
return /* @__PURE__ */ jsx11(
|
|
1207
1225
|
MinRatingFilterChip,
|
|
1208
1226
|
{
|
|
1209
1227
|
star: filter.type === "starRating",
|
|
@@ -1221,7 +1239,7 @@ var FilterChips = ({
|
|
|
1221
1239
|
);
|
|
1222
1240
|
}
|
|
1223
1241
|
if (filter.type === "priceRange" && filter.priceRange) {
|
|
1224
|
-
return /* @__PURE__ */
|
|
1242
|
+
return /* @__PURE__ */ jsx11(
|
|
1225
1243
|
PriceRangeFilterChip,
|
|
1226
1244
|
{
|
|
1227
1245
|
priceRange: filter.priceRange,
|
|
@@ -1236,7 +1254,7 @@ var FilterChips = ({
|
|
|
1236
1254
|
);
|
|
1237
1255
|
}
|
|
1238
1256
|
if (filter.type === "transformed_query") {
|
|
1239
|
-
return /* @__PURE__ */
|
|
1257
|
+
return /* @__PURE__ */ jsx11(
|
|
1240
1258
|
TransformedQueryChip,
|
|
1241
1259
|
{
|
|
1242
1260
|
value: filter.value,
|
|
@@ -1250,7 +1268,7 @@ var FilterChips = ({
|
|
|
1250
1268
|
);
|
|
1251
1269
|
}
|
|
1252
1270
|
if (filter.type === "selected_restaurant_price_levels") {
|
|
1253
|
-
return /* @__PURE__ */
|
|
1271
|
+
return /* @__PURE__ */ jsx11(
|
|
1254
1272
|
RestaurantPriceLevelChip,
|
|
1255
1273
|
{
|
|
1256
1274
|
values: (_b = filter.priceLevels) != null ? _b : [],
|
|
@@ -1265,7 +1283,7 @@ var FilterChips = ({
|
|
|
1265
1283
|
}
|
|
1266
1284
|
return renderStandardChip();
|
|
1267
1285
|
}),
|
|
1268
|
-
/* @__PURE__ */
|
|
1286
|
+
/* @__PURE__ */ jsx11(
|
|
1269
1287
|
"button",
|
|
1270
1288
|
{
|
|
1271
1289
|
className: "mapfirst-clear-all-button",
|
|
@@ -1290,7 +1308,7 @@ var FilterChips = ({
|
|
|
1290
1308
|
]
|
|
1291
1309
|
}
|
|
1292
1310
|
),
|
|
1293
|
-
!atStart && /* @__PURE__ */
|
|
1311
|
+
!atStart && /* @__PURE__ */ jsx11(
|
|
1294
1312
|
"div",
|
|
1295
1313
|
{
|
|
1296
1314
|
"aria-hidden": "true",
|
|
@@ -1301,7 +1319,7 @@ var FilterChips = ({
|
|
|
1301
1319
|
}
|
|
1302
1320
|
}
|
|
1303
1321
|
),
|
|
1304
|
-
!atEnd && /* @__PURE__ */
|
|
1322
|
+
!atEnd && /* @__PURE__ */ jsx11(
|
|
1305
1323
|
"div",
|
|
1306
1324
|
{
|
|
1307
1325
|
"aria-hidden": "true",
|
|
@@ -1312,7 +1330,7 @@ var FilterChips = ({
|
|
|
1312
1330
|
}
|
|
1313
1331
|
}
|
|
1314
1332
|
),
|
|
1315
|
-
!atStart && /* @__PURE__ */
|
|
1333
|
+
!atStart && /* @__PURE__ */ jsx11(
|
|
1316
1334
|
"button",
|
|
1317
1335
|
{
|
|
1318
1336
|
type: "button",
|
|
@@ -1327,10 +1345,10 @@ var FilterChips = ({
|
|
|
1327
1345
|
onClick: () => scrollByDir("prev"),
|
|
1328
1346
|
onMouseEnter: () => setNavHover("prev"),
|
|
1329
1347
|
onMouseLeave: () => setNavHover(null),
|
|
1330
|
-
children: /* @__PURE__ */
|
|
1348
|
+
children: /* @__PURE__ */ jsx11(NextIcon2, { style: { width: "20px", height: "20px" } })
|
|
1331
1349
|
}
|
|
1332
1350
|
),
|
|
1333
|
-
!atEnd && /* @__PURE__ */
|
|
1351
|
+
!atEnd && /* @__PURE__ */ jsx11(
|
|
1334
1352
|
"button",
|
|
1335
1353
|
{
|
|
1336
1354
|
type: "button",
|
|
@@ -1344,14 +1362,14 @@ var FilterChips = ({
|
|
|
1344
1362
|
onClick: () => scrollByDir("next"),
|
|
1345
1363
|
onMouseEnter: () => setNavHover("next"),
|
|
1346
1364
|
onMouseLeave: () => setNavHover(null),
|
|
1347
|
-
children: /* @__PURE__ */
|
|
1365
|
+
children: /* @__PURE__ */ jsx11(NextIcon2, { style: { width: "20px", height: "20px" } })
|
|
1348
1366
|
}
|
|
1349
1367
|
)
|
|
1350
1368
|
] });
|
|
1351
1369
|
};
|
|
1352
1370
|
|
|
1353
1371
|
// src/components/SmartFilter.tsx
|
|
1354
|
-
import { jsx as
|
|
1372
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1355
1373
|
var containerStyles2 = {
|
|
1356
1374
|
position: "relative",
|
|
1357
1375
|
display: "flex",
|
|
@@ -1367,6 +1385,7 @@ var SmartFilter = ({
|
|
|
1367
1385
|
currency = "USD",
|
|
1368
1386
|
beforeContent,
|
|
1369
1387
|
styles,
|
|
1388
|
+
customIcons,
|
|
1370
1389
|
containerStyle,
|
|
1371
1390
|
style
|
|
1372
1391
|
}) => {
|
|
@@ -1394,7 +1413,7 @@ var SmartFilter = ({
|
|
|
1394
1413
|
const clearAllFilters = useCallback3(() => {
|
|
1395
1414
|
void handleFilterChange([], true);
|
|
1396
1415
|
}, [handleFilterChange]);
|
|
1397
|
-
return /* @__PURE__ */
|
|
1416
|
+
return /* @__PURE__ */ jsx12(IconsProvider, { value: customIcons, children: /* @__PURE__ */ jsx12(TranslationProvider, { value: customTranslations, children: /* @__PURE__ */ jsx12(
|
|
1398
1417
|
"div",
|
|
1399
1418
|
{
|
|
1400
1419
|
style: {
|
|
@@ -1403,7 +1422,7 @@ var SmartFilter = ({
|
|
|
1403
1422
|
...containerStyle,
|
|
1404
1423
|
...style
|
|
1405
1424
|
},
|
|
1406
|
-
children: filters.length > 0 && /* @__PURE__ */
|
|
1425
|
+
children: filters.length > 0 && /* @__PURE__ */ jsx12(
|
|
1407
1426
|
FilterChips,
|
|
1408
1427
|
{
|
|
1409
1428
|
filters,
|
|
@@ -1421,7 +1440,7 @@ var SmartFilter = ({
|
|
|
1421
1440
|
}
|
|
1422
1441
|
)
|
|
1423
1442
|
}
|
|
1424
|
-
) });
|
|
1443
|
+
) }) });
|
|
1425
1444
|
};
|
|
1426
1445
|
|
|
1427
1446
|
// src/index.tsx
|
|
@@ -1438,12 +1457,12 @@ function attachMapOnce(instanceRef, attachedRef, map, config) {
|
|
|
1438
1457
|
attachedRef.current = true;
|
|
1439
1458
|
}
|
|
1440
1459
|
function useMapFirst(options) {
|
|
1441
|
-
const optionsRef =
|
|
1442
|
-
|
|
1460
|
+
const optionsRef = React8.useRef(options);
|
|
1461
|
+
React8.useEffect(() => {
|
|
1443
1462
|
optionsRef.current = options;
|
|
1444
1463
|
});
|
|
1445
|
-
const callbacksRef =
|
|
1446
|
-
const instanceRef =
|
|
1464
|
+
const callbacksRef = React8.useRef({});
|
|
1465
|
+
const instanceRef = React8.useRef(null);
|
|
1447
1466
|
if (instanceRef.current === null) {
|
|
1448
1467
|
instanceRef.current = new MapFirstCore({
|
|
1449
1468
|
adapter: null,
|
|
@@ -1451,10 +1470,10 @@ function useMapFirst(options) {
|
|
|
1451
1470
|
callbacks: callbacksRef.current
|
|
1452
1471
|
});
|
|
1453
1472
|
}
|
|
1454
|
-
const [state, setState] =
|
|
1473
|
+
const [state, setState] = React8.useState(
|
|
1455
1474
|
() => instanceRef.current.getState()
|
|
1456
1475
|
);
|
|
1457
|
-
|
|
1476
|
+
React8.useEffect(() => {
|
|
1458
1477
|
if (!instanceRef.current) {
|
|
1459
1478
|
callbacksRef.current = {};
|
|
1460
1479
|
instanceRef.current = new MapFirstCore({
|
|
@@ -1533,17 +1552,17 @@ function useMapFirst(options) {
|
|
|
1533
1552
|
instanceRef.current = null;
|
|
1534
1553
|
};
|
|
1535
1554
|
}, []);
|
|
1536
|
-
const setPrimaryType =
|
|
1555
|
+
const setPrimaryType = React8.useCallback((type) => {
|
|
1537
1556
|
if (instanceRef.current) {
|
|
1538
1557
|
instanceRef.current.setPrimaryType(type);
|
|
1539
1558
|
}
|
|
1540
1559
|
}, []);
|
|
1541
|
-
const setSelectedMarker =
|
|
1560
|
+
const setSelectedMarker = React8.useCallback((id) => {
|
|
1542
1561
|
if (instanceRef.current) {
|
|
1543
1562
|
instanceRef.current.setSelectedMarker(id);
|
|
1544
1563
|
}
|
|
1545
1564
|
}, []);
|
|
1546
|
-
const setUseApi =
|
|
1565
|
+
const setUseApi = React8.useCallback(
|
|
1547
1566
|
(useApi, autoLoad = true) => {
|
|
1548
1567
|
if (instanceRef.current) {
|
|
1549
1568
|
instanceRef.current.setUseApi(useApi, autoLoad);
|
|
@@ -1551,7 +1570,7 @@ function useMapFirst(options) {
|
|
|
1551
1570
|
},
|
|
1552
1571
|
[]
|
|
1553
1572
|
);
|
|
1554
|
-
const propertiesSearch =
|
|
1573
|
+
const propertiesSearch = React8.useCallback(
|
|
1555
1574
|
async (options2) => {
|
|
1556
1575
|
if (!instanceRef.current) {
|
|
1557
1576
|
throw new Error("MapFirst instance not available");
|
|
@@ -1560,7 +1579,7 @@ function useMapFirst(options) {
|
|
|
1560
1579
|
},
|
|
1561
1580
|
[]
|
|
1562
1581
|
);
|
|
1563
|
-
const smartFilterSearch =
|
|
1582
|
+
const smartFilterSearch = React8.useCallback(
|
|
1564
1583
|
async (options2) => {
|
|
1565
1584
|
if (!instanceRef.current) {
|
|
1566
1585
|
throw new Error("MapFirst instance not available");
|
|
@@ -1569,14 +1588,14 @@ function useMapFirst(options) {
|
|
|
1569
1588
|
},
|
|
1570
1589
|
[]
|
|
1571
1590
|
);
|
|
1572
|
-
const boundsSearch =
|
|
1591
|
+
const boundsSearch = React8.useCallback(async () => {
|
|
1573
1592
|
if (!instanceRef.current) {
|
|
1574
1593
|
return null;
|
|
1575
1594
|
}
|
|
1576
1595
|
return await instanceRef.current.performBoundsSearch();
|
|
1577
1596
|
}, []);
|
|
1578
|
-
const mapLibreAttachedRef =
|
|
1579
|
-
const attachMapLibre =
|
|
1597
|
+
const mapLibreAttachedRef = React8.useRef(false);
|
|
1598
|
+
const attachMapLibre = React8.useCallback(
|
|
1580
1599
|
(map, maplibregl, options2) => {
|
|
1581
1600
|
attachMapOnce(instanceRef, mapLibreAttachedRef, map, {
|
|
1582
1601
|
platform: "maplibre",
|
|
@@ -1587,8 +1606,8 @@ function useMapFirst(options) {
|
|
|
1587
1606
|
},
|
|
1588
1607
|
[]
|
|
1589
1608
|
);
|
|
1590
|
-
const googleMapsAttachedRef =
|
|
1591
|
-
const attachGoogle =
|
|
1609
|
+
const googleMapsAttachedRef = React8.useRef(false);
|
|
1610
|
+
const attachGoogle = React8.useCallback(
|
|
1592
1611
|
(map, google, options2) => {
|
|
1593
1612
|
attachMapOnce(instanceRef, googleMapsAttachedRef, map, {
|
|
1594
1613
|
platform: "google",
|
|
@@ -1599,8 +1618,8 @@ function useMapFirst(options) {
|
|
|
1599
1618
|
},
|
|
1600
1619
|
[]
|
|
1601
1620
|
);
|
|
1602
|
-
const mapboxAttachedRef =
|
|
1603
|
-
const attachMapbox =
|
|
1621
|
+
const mapboxAttachedRef = React8.useRef(false);
|
|
1622
|
+
const attachMapbox = React8.useCallback(
|
|
1604
1623
|
(map, mapboxgl, options2) => {
|
|
1605
1624
|
attachMapOnce(instanceRef, mapboxAttachedRef, map, {
|
|
1606
1625
|
platform: "mapbox",
|
|
@@ -1611,8 +1630,8 @@ function useMapFirst(options) {
|
|
|
1611
1630
|
},
|
|
1612
1631
|
[]
|
|
1613
1632
|
);
|
|
1614
|
-
const leafletAttachedRef =
|
|
1615
|
-
const attachLeaflet =
|
|
1633
|
+
const leafletAttachedRef = React8.useRef(false);
|
|
1634
|
+
const attachLeaflet = React8.useCallback(
|
|
1616
1635
|
(map, leaflet, options2) => {
|
|
1617
1636
|
if (!instanceRef.current || !map || leafletAttachedRef.current) return;
|
|
1618
1637
|
const adapter = new LeafletAdapter(map);
|
|
@@ -1673,6 +1692,7 @@ export {
|
|
|
1673
1692
|
CloseIcon,
|
|
1674
1693
|
EditIcon,
|
|
1675
1694
|
FilterChips,
|
|
1695
|
+
IconsProvider,
|
|
1676
1696
|
LeafletAdapter2 as LeafletAdapter,
|
|
1677
1697
|
MapFirstCore2 as MapFirstCore,
|
|
1678
1698
|
MinRatingFilterChip,
|
|
@@ -1694,6 +1714,7 @@ export {
|
|
|
1694
1714
|
processApiFilters,
|
|
1695
1715
|
renderStars,
|
|
1696
1716
|
useFilterScroll,
|
|
1717
|
+
useIcons,
|
|
1697
1718
|
useMapFirst,
|
|
1698
1719
|
useTranslation
|
|
1699
1720
|
};
|