@wasto/cms-components 1.5.10 → 1.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -47
- package/dist/index.d.mts +181 -51
- package/dist/index.d.ts +181 -51
- package/dist/index.js +3614 -3015
- package/dist/index.mjs +3021 -2418
- package/package.json +12 -2
- package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
- package/src/components/article/Article.tsx +21 -21
- package/src/components/article/ArticleCard.tsx +81 -81
- package/src/components/article/ArticleExcerpts.tsx +80 -80
- package/src/components/article/ArticleList.tsx +114 -114
- package/src/components/article/ArticleMarkdown.tsx +170 -170
- package/src/components/article/ArticleReaderModal.tsx +93 -93
- package/src/components/article/ArticleSingle.tsx +57 -57
- package/src/components/bottom-tab/BottomTab.tsx +392 -392
- package/src/components/button/Button.tsx +154 -154
- package/src/components/challenge/Badges.tsx +84 -84
- package/src/components/challenge/BadgesModal.tsx +166 -166
- package/src/components/challenge/Challenge.tsx +380 -380
- package/src/components/challenge/ChallengeModal.tsx +231 -231
- package/src/components/challenge/ChallengeVignette.tsx +249 -249
- package/src/components/challenge/ChallengesModal.tsx +243 -243
- package/src/components/challenge/QuizModal.tsx +381 -381
- package/src/components/challenge/ResultModal.tsx +144 -144
- package/src/components/chat/Chat.tsx +928 -928
- package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
- package/src/components/columns/Columns.tsx +33 -33
- package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
- package/src/components/content-inset/ContentInset.tsx +33 -33
- package/src/components/header/Header.tsx +415 -391
- package/src/components/image/Image.tsx +15 -15
- package/src/components/image/ImageFrame.tsx +102 -102
- package/src/components/image/ImageMedia.tsx +31 -31
- package/src/components/image/ImageUrl.tsx +30 -30
- package/src/components/locations-map/LocationSheet.tsx +417 -417
- package/src/components/locations-map/LocationsMap.native.tsx +260 -260
- package/src/components/locations-map/LocationsMap.tsx +13 -13
- package/src/components/locations-map/LocationsMap.web.tsx +10 -10
- package/src/components/locations-map/LocationsMapShell.tsx +546 -527
- package/src/components/locations-map/LocationsMapView.tsx +108 -108
- package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
- package/src/components/nav-button/NavButton.tsx +59 -59
- package/src/components/next-collection/NextCollection.tsx +636 -621
- package/src/components/notifications/NotificationsScreen.tsx +247 -247
- package/src/components/page/Page.tsx +102 -64
- package/src/components/parapraph/Paragraph.tsx +67 -67
- package/src/components/profile/ProfileScreen.tsx +236 -236
- package/src/components/push/PushTokenRegistrar.tsx +47 -0
- package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
- package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
- package/src/components/search/Search.tsx +320 -320
- package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
- package/src/components/title/Title.tsx +100 -100
- package/src/components/vision/Vision.tsx +447 -447
- package/src/components/vision/VisionActionCard.tsx +117 -117
- package/src/components/vision/VisionCapture.tsx +30 -30
- package/src/components/vision/VisionTapOverlay.tsx +122 -122
- package/src/contexts/AnnouncementsContext.tsx +171 -171
- package/src/contexts/AppDataContext.tsx +458 -0
- package/src/contexts/ChallengesContext.tsx +182 -182
- package/src/contexts/HeaderConfigContext.tsx +29 -0
- package/src/contexts/LocalContext.tsx +227 -227
- package/src/contexts/ThemeContext.tsx +37 -37
- package/src/contexts/WastoContext.tsx +132 -127
- package/src/helpers/blogPost.ts +72 -72
- package/src/helpers/generateQuizQuestions.ts +247 -247
- package/src/helpers/getContrastColor.ts +18 -18
- package/src/helpers/haptics.ts +20 -20
- package/src/helpers/hoursSchedule.ts +230 -230
- package/src/helpers/htmlContentToMarkdown.ts +114 -114
- package/src/helpers/layout.ts +54 -54
- package/src/helpers/loadLinearGradient.ts +22 -22
- package/src/helpers/mapLocations.ts +170 -0
- package/src/helpers/maquetteTheme.ts +76 -76
- package/src/helpers/markdownUnderlinePlugin.ts +32 -32
- package/src/helpers/nextCollection.ts +122 -0
- package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
- package/src/helpers/publicMediaUrl.ts +8 -8
- package/src/helpers/resolveApiAssetUrl.ts +21 -21
- package/src/helpers/systemRoutes.ts +7 -7
- package/src/helpers/themeStyles.ts +114 -114
- package/src/helpers/ttlCache.ts +41 -0
- package/src/helpers/useSafeAreaPadding.ts +14 -14
- package/src/hooks/useBadges.ts +100 -100
- package/src/hooks/useBlogPosts.ts +109 -105
- package/src/hooks/useChallenges.ts +110 -110
- package/src/hooks/useCities.ts +56 -56
- package/src/hooks/useCityAnnouncements.ts +118 -118
- package/src/hooks/useCollectionCalendar.ts +421 -421
- package/src/hooks/useColumns.ts +19 -19
- package/src/hooks/useConsignes.ts +62 -62
- package/src/hooks/useLocations.ts +120 -248
- package/src/hooks/useNextCollection.ts +163 -238
- package/src/hooks/useRecyclingInfo.ts +90 -90
- package/src/hooks/useWastoClient.ts +16 -16
- package/src/index.ts +161 -142
- package/src/navigation/NavigationContext.tsx +56 -56
- package/src/push/registerExpoPushToken.ts +133 -0
- package/src/sentry/initSentry.ts +120 -120
- package/src/types/Theme.ts +72 -72
- package/src/types/css-modules.d.ts +1 -1
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { Pressable, StyleSheet, View, type LayoutChangeEvent } from "react-native";
|
|
2
|
-
import { MapPin } from "lucide-react-native";
|
|
3
|
-
import { useMemo, useState, type ReactNode } from "react";
|
|
4
|
-
import {
|
|
5
|
-
LOCATION_CATEGORY_META,
|
|
6
|
-
type LocationCategory,
|
|
7
|
-
type MapLocation,
|
|
8
|
-
} from "../../hooks/useLocations";
|
|
9
|
-
import { getContrastColor } from "../../helpers/getContrastColor";
|
|
10
|
-
|
|
11
|
-
export type LocationsMapViewProps = {
|
|
12
|
-
locations: MapLocation[];
|
|
13
|
-
center: { lat: number; lon: number };
|
|
14
|
-
selectedId?: string | null;
|
|
15
|
-
onSelect: (location: MapLocation) => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const PIN = 32;
|
|
19
|
-
|
|
20
|
-
export function LocationsMapView({
|
|
21
|
-
locations,
|
|
22
|
-
center,
|
|
23
|
-
selectedId,
|
|
24
|
-
onSelect,
|
|
25
|
-
}: LocationsMapViewProps): ReactNode {
|
|
26
|
-
const [size, setSize] = useState({ width: 1, height: 1 });
|
|
27
|
-
|
|
28
|
-
const bounds = useMemo(() => {
|
|
29
|
-
const lats = locations.map((l) => l.lat).concat(center.lat);
|
|
30
|
-
const lons = locations.map((l) => l.lon).concat(center.lon);
|
|
31
|
-
const minLat = Math.min(...lats);
|
|
32
|
-
const maxLat = Math.max(...lats);
|
|
33
|
-
const minLon = Math.min(...lons);
|
|
34
|
-
const maxLon = Math.max(...lons);
|
|
35
|
-
const latPad = Math.max((maxLat - minLat) * 0.18, 0.008);
|
|
36
|
-
const lonPad = Math.max((maxLon - minLon) * 0.18, 0.008);
|
|
37
|
-
return {
|
|
38
|
-
minLat: minLat - latPad,
|
|
39
|
-
maxLat: maxLat + latPad,
|
|
40
|
-
minLon: minLon - lonPad,
|
|
41
|
-
maxLon: maxLon + lonPad,
|
|
42
|
-
};
|
|
43
|
-
}, [center.lat, center.lon, locations]);
|
|
44
|
-
|
|
45
|
-
const onLayout = (event: LayoutChangeEvent) => {
|
|
46
|
-
const { width, height } = event.nativeEvent.layout;
|
|
47
|
-
if (width > 0 && height > 0) setSize({ width, height });
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const toXY = (lat: number, lon: number) => {
|
|
51
|
-
const x =
|
|
52
|
-
((lon - bounds.minLon) / Math.max(bounds.maxLon - bounds.minLon, 0.0001)) *
|
|
53
|
-
size.width;
|
|
54
|
-
const y =
|
|
55
|
-
(1 - (lat - bounds.minLat) / Math.max(bounds.maxLat - bounds.minLat, 0.0001)) *
|
|
56
|
-
size.height;
|
|
57
|
-
return { x, y };
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<View style={styles.canvas} onLayout={onLayout}>
|
|
62
|
-
{locations.map((loc: MapLocation) => {
|
|
63
|
-
const { x, y } = toXY(loc.lat, loc.lon);
|
|
64
|
-
const color = LOCATION_CATEGORY_META[loc.category as LocationCategory].color;
|
|
65
|
-
const selected = loc.id === selectedId;
|
|
66
|
-
const iconColor = getContrastColor(color);
|
|
67
|
-
return (
|
|
68
|
-
<Pressable
|
|
69
|
-
key={loc.id}
|
|
70
|
-
onPress={() => onSelect(loc)}
|
|
71
|
-
style={[
|
|
72
|
-
styles.marker,
|
|
73
|
-
{
|
|
74
|
-
left: x - PIN / 2,
|
|
75
|
-
top: y - PIN / 2,
|
|
76
|
-
backgroundColor: color,
|
|
77
|
-
borderColor: selected ? "#111827" : "#ffffff",
|
|
78
|
-
transform: [{ scale: selected ? 1.12 : 1 }],
|
|
79
|
-
zIndex: selected ? 2 : 1,
|
|
80
|
-
},
|
|
81
|
-
]}
|
|
82
|
-
accessibilityLabel={loc.name}
|
|
83
|
-
>
|
|
84
|
-
<MapPin size={16} color={iconColor} />
|
|
85
|
-
</Pressable>
|
|
86
|
-
);
|
|
87
|
-
})}
|
|
88
|
-
</View>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const styles = StyleSheet.create({
|
|
93
|
-
canvas: {
|
|
94
|
-
flex: 1,
|
|
95
|
-
minHeight: 220,
|
|
96
|
-
backgroundColor: "#E8E8E8",
|
|
97
|
-
overflow: "hidden",
|
|
98
|
-
},
|
|
99
|
-
marker: {
|
|
100
|
-
position: "absolute",
|
|
101
|
-
width: PIN,
|
|
102
|
-
height: PIN,
|
|
103
|
-
borderRadius: PIN / 2,
|
|
104
|
-
borderWidth: 3,
|
|
105
|
-
alignItems: "center",
|
|
106
|
-
justifyContent: "center",
|
|
107
|
-
},
|
|
108
|
-
});
|
|
1
|
+
import { Pressable, StyleSheet, View, type LayoutChangeEvent } from "react-native";
|
|
2
|
+
import { MapPin } from "lucide-react-native";
|
|
3
|
+
import { useMemo, useState, type ReactNode } from "react";
|
|
4
|
+
import {
|
|
5
|
+
LOCATION_CATEGORY_META,
|
|
6
|
+
type LocationCategory,
|
|
7
|
+
type MapLocation,
|
|
8
|
+
} from "../../hooks/useLocations";
|
|
9
|
+
import { getContrastColor } from "../../helpers/getContrastColor";
|
|
10
|
+
|
|
11
|
+
export type LocationsMapViewProps = {
|
|
12
|
+
locations: MapLocation[];
|
|
13
|
+
center: { lat: number; lon: number };
|
|
14
|
+
selectedId?: string | null;
|
|
15
|
+
onSelect: (location: MapLocation) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const PIN = 32;
|
|
19
|
+
|
|
20
|
+
export function LocationsMapView({
|
|
21
|
+
locations,
|
|
22
|
+
center,
|
|
23
|
+
selectedId,
|
|
24
|
+
onSelect,
|
|
25
|
+
}: LocationsMapViewProps): ReactNode {
|
|
26
|
+
const [size, setSize] = useState({ width: 1, height: 1 });
|
|
27
|
+
|
|
28
|
+
const bounds = useMemo(() => {
|
|
29
|
+
const lats = locations.map((l) => l.lat).concat(center.lat);
|
|
30
|
+
const lons = locations.map((l) => l.lon).concat(center.lon);
|
|
31
|
+
const minLat = Math.min(...lats);
|
|
32
|
+
const maxLat = Math.max(...lats);
|
|
33
|
+
const minLon = Math.min(...lons);
|
|
34
|
+
const maxLon = Math.max(...lons);
|
|
35
|
+
const latPad = Math.max((maxLat - minLat) * 0.18, 0.008);
|
|
36
|
+
const lonPad = Math.max((maxLon - minLon) * 0.18, 0.008);
|
|
37
|
+
return {
|
|
38
|
+
minLat: minLat - latPad,
|
|
39
|
+
maxLat: maxLat + latPad,
|
|
40
|
+
minLon: minLon - lonPad,
|
|
41
|
+
maxLon: maxLon + lonPad,
|
|
42
|
+
};
|
|
43
|
+
}, [center.lat, center.lon, locations]);
|
|
44
|
+
|
|
45
|
+
const onLayout = (event: LayoutChangeEvent) => {
|
|
46
|
+
const { width, height } = event.nativeEvent.layout;
|
|
47
|
+
if (width > 0 && height > 0) setSize({ width, height });
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const toXY = (lat: number, lon: number) => {
|
|
51
|
+
const x =
|
|
52
|
+
((lon - bounds.minLon) / Math.max(bounds.maxLon - bounds.minLon, 0.0001)) *
|
|
53
|
+
size.width;
|
|
54
|
+
const y =
|
|
55
|
+
(1 - (lat - bounds.minLat) / Math.max(bounds.maxLat - bounds.minLat, 0.0001)) *
|
|
56
|
+
size.height;
|
|
57
|
+
return { x, y };
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View style={styles.canvas} onLayout={onLayout}>
|
|
62
|
+
{locations.map((loc: MapLocation) => {
|
|
63
|
+
const { x, y } = toXY(loc.lat, loc.lon);
|
|
64
|
+
const color = LOCATION_CATEGORY_META[loc.category as LocationCategory].color;
|
|
65
|
+
const selected = loc.id === selectedId;
|
|
66
|
+
const iconColor = getContrastColor(color);
|
|
67
|
+
return (
|
|
68
|
+
<Pressable
|
|
69
|
+
key={loc.id}
|
|
70
|
+
onPress={() => onSelect(loc)}
|
|
71
|
+
style={[
|
|
72
|
+
styles.marker,
|
|
73
|
+
{
|
|
74
|
+
left: x - PIN / 2,
|
|
75
|
+
top: y - PIN / 2,
|
|
76
|
+
backgroundColor: color,
|
|
77
|
+
borderColor: selected ? "#111827" : "#ffffff",
|
|
78
|
+
transform: [{ scale: selected ? 1.12 : 1 }],
|
|
79
|
+
zIndex: selected ? 2 : 1,
|
|
80
|
+
},
|
|
81
|
+
]}
|
|
82
|
+
accessibilityLabel={loc.name}
|
|
83
|
+
>
|
|
84
|
+
<MapPin size={16} color={iconColor} />
|
|
85
|
+
</Pressable>
|
|
86
|
+
);
|
|
87
|
+
})}
|
|
88
|
+
</View>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const styles = StyleSheet.create({
|
|
93
|
+
canvas: {
|
|
94
|
+
flex: 1,
|
|
95
|
+
minHeight: 220,
|
|
96
|
+
backgroundColor: "#E8E8E8",
|
|
97
|
+
overflow: "hidden",
|
|
98
|
+
},
|
|
99
|
+
marker: {
|
|
100
|
+
position: "absolute",
|
|
101
|
+
width: PIN,
|
|
102
|
+
height: PIN,
|
|
103
|
+
borderRadius: PIN / 2,
|
|
104
|
+
borderWidth: 3,
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
},
|
|
108
|
+
});
|