@wasto/cms-components 1.5.10 → 1.5.11

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.
Files changed (98) hide show
  1. package/README.md +47 -47
  2. package/dist/index.d.mts +103 -2
  3. package/dist/index.d.ts +103 -2
  4. package/dist/index.js +2861 -2442
  5. package/dist/index.mjs +3651 -3227
  6. package/package.json +2 -2
  7. package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
  8. package/src/components/article/Article.tsx +21 -21
  9. package/src/components/article/ArticleCard.tsx +81 -81
  10. package/src/components/article/ArticleExcerpts.tsx +80 -80
  11. package/src/components/article/ArticleList.tsx +114 -114
  12. package/src/components/article/ArticleMarkdown.tsx +170 -170
  13. package/src/components/article/ArticleReaderModal.tsx +93 -93
  14. package/src/components/article/ArticleSingle.tsx +57 -57
  15. package/src/components/bottom-tab/BottomTab.tsx +392 -392
  16. package/src/components/button/Button.tsx +154 -154
  17. package/src/components/challenge/Badges.tsx +84 -84
  18. package/src/components/challenge/BadgesModal.tsx +166 -166
  19. package/src/components/challenge/Challenge.tsx +380 -380
  20. package/src/components/challenge/ChallengeModal.tsx +231 -231
  21. package/src/components/challenge/ChallengeVignette.tsx +249 -249
  22. package/src/components/challenge/ChallengesModal.tsx +243 -243
  23. package/src/components/challenge/QuizModal.tsx +381 -381
  24. package/src/components/challenge/ResultModal.tsx +144 -144
  25. package/src/components/chat/Chat.tsx +928 -928
  26. package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
  27. package/src/components/columns/Columns.tsx +33 -33
  28. package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
  29. package/src/components/content-inset/ContentInset.tsx +33 -33
  30. package/src/components/header/Header.tsx +391 -391
  31. package/src/components/image/Image.tsx +15 -15
  32. package/src/components/image/ImageFrame.tsx +102 -102
  33. package/src/components/image/ImageMedia.tsx +31 -31
  34. package/src/components/image/ImageUrl.tsx +30 -30
  35. package/src/components/locations-map/LocationSheet.tsx +417 -417
  36. package/src/components/locations-map/LocationsMap.native.tsx +260 -260
  37. package/src/components/locations-map/LocationsMap.tsx +13 -13
  38. package/src/components/locations-map/LocationsMap.web.tsx +10 -10
  39. package/src/components/locations-map/LocationsMapShell.tsx +527 -527
  40. package/src/components/locations-map/LocationsMapView.tsx +108 -108
  41. package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
  42. package/src/components/nav-button/NavButton.tsx +59 -59
  43. package/src/components/next-collection/NextCollection.tsx +636 -621
  44. package/src/components/notifications/NotificationsScreen.tsx +247 -247
  45. package/src/components/page/Page.tsx +102 -64
  46. package/src/components/parapraph/Paragraph.tsx +67 -67
  47. package/src/components/profile/ProfileScreen.tsx +236 -236
  48. package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
  49. package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
  50. package/src/components/search/Search.tsx +320 -320
  51. package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
  52. package/src/components/title/Title.tsx +100 -100
  53. package/src/components/vision/Vision.tsx +447 -447
  54. package/src/components/vision/VisionActionCard.tsx +117 -117
  55. package/src/components/vision/VisionCapture.tsx +30 -30
  56. package/src/components/vision/VisionTapOverlay.tsx +122 -122
  57. package/src/contexts/AnnouncementsContext.tsx +171 -171
  58. package/src/contexts/AppDataContext.tsx +458 -0
  59. package/src/contexts/ChallengesContext.tsx +182 -182
  60. package/src/contexts/LocalContext.tsx +227 -227
  61. package/src/contexts/ThemeContext.tsx +37 -37
  62. package/src/contexts/WastoContext.tsx +130 -127
  63. package/src/helpers/blogPost.ts +72 -72
  64. package/src/helpers/generateQuizQuestions.ts +247 -247
  65. package/src/helpers/getContrastColor.ts +18 -18
  66. package/src/helpers/haptics.ts +20 -20
  67. package/src/helpers/hoursSchedule.ts +230 -230
  68. package/src/helpers/htmlContentToMarkdown.ts +114 -114
  69. package/src/helpers/layout.ts +54 -54
  70. package/src/helpers/loadLinearGradient.ts +22 -22
  71. package/src/helpers/mapLocations.ts +170 -0
  72. package/src/helpers/maquetteTheme.ts +76 -76
  73. package/src/helpers/markdownUnderlinePlugin.ts +32 -32
  74. package/src/helpers/nextCollection.ts +122 -0
  75. package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
  76. package/src/helpers/publicMediaUrl.ts +8 -8
  77. package/src/helpers/resolveApiAssetUrl.ts +21 -21
  78. package/src/helpers/systemRoutes.ts +7 -7
  79. package/src/helpers/themeStyles.ts +114 -114
  80. package/src/helpers/ttlCache.ts +41 -0
  81. package/src/helpers/useSafeAreaPadding.ts +14 -14
  82. package/src/hooks/useBadges.ts +100 -100
  83. package/src/hooks/useBlogPosts.ts +109 -105
  84. package/src/hooks/useChallenges.ts +110 -110
  85. package/src/hooks/useCities.ts +56 -56
  86. package/src/hooks/useCityAnnouncements.ts +118 -118
  87. package/src/hooks/useCollectionCalendar.ts +421 -421
  88. package/src/hooks/useColumns.ts +19 -19
  89. package/src/hooks/useConsignes.ts +62 -62
  90. package/src/hooks/useLocations.ts +120 -248
  91. package/src/hooks/useNextCollection.ts +163 -238
  92. package/src/hooks/useRecyclingInfo.ts +90 -90
  93. package/src/hooks/useWastoClient.ts +16 -16
  94. package/src/index.ts +149 -142
  95. package/src/navigation/NavigationContext.tsx +56 -56
  96. package/src/sentry/initSentry.ts +120 -120
  97. package/src/types/Theme.ts +72 -72
  98. package/src/types/css-modules.d.ts +1 -1
@@ -1,231 +1,231 @@
1
- import { Dimensions, Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
2
- import { ChallengeSeriesWithProgress, ChallengeWithProgress } from "../../hooks/useChallenges";
3
- import { Title } from "../title/Title";
4
- import { NavButton } from "../nav-button/NavButton";
5
- import { Play, Trophy, XIcon } from "lucide-react-native";
6
- import { Theme } from "../../types/Theme";
7
- import { useTheme } from "../../contexts/ThemeContext";
8
- import { useSafeAreaPadding } from "../../helpers/useSafeAreaPadding";
9
- import { useState, type ReactNode } from "react";
10
- import { QuizModal } from "./QuizModal";
11
- import { resolveTheme } from "../../helpers/themeStyles";
12
- import { SPACE } from "../../helpers/layout";
13
-
14
- export type ChallengeModalProps = {
15
- challenge: ChallengeWithProgress;
16
- onClose: () => void;
17
- };
18
-
19
- function isSerieComplete(serie: ChallengeSeriesWithProgress) {
20
- return !!serie.progression;
21
- }
22
-
23
- function serieProgressRatio(serie: ChallengeSeriesWithProgress) {
24
- return Math.min(1, Math.max(0, (serie.progression?.score ?? 0) / 100));
25
- }
26
-
27
- function serieProgressLabel(serie: ChallengeSeriesWithProgress) {
28
- return `${Math.round(serie.progression?.score ?? 0)}%`;
29
- }
30
-
31
- export function ChallengeModal({
32
- challenge,
33
- onClose,
34
- }: ChallengeModalProps): ReactNode {
35
- const { theme } = useTheme();
36
- const t = resolveTheme(theme);
37
- const themedStyles = createThemedStyles(theme);
38
- const topInset = useSafeAreaPadding(["top"]);
39
- const bottomInset = useSafeAreaPadding(["bottom"]);
40
- const [selectedSerieId, setSelectedSerieId] = useState<string | null>(null);
41
- const series = challenge.series ?? [];
42
- const selectedSerie =
43
- selectedSerieId != null
44
- ? (series.find((s) => s.id === selectedSerieId) ?? null)
45
- : null;
46
-
47
- const handleSerieSelected = (serie: ChallengeSeriesWithProgress) => () => {
48
- setSelectedSerieId(serie.id);
49
- };
50
-
51
- return (
52
- <>
53
- {!selectedSerie ? (
54
- <View style={[styles.modal, themedStyles.modal]}>
55
- <View style={topInset}>
56
- <View style={styles.header}>
57
- <Title text={challenge.name} level="2" numberOfLines={1} />
58
- <NavButton icon={XIcon} onPress={onClose} />
59
- </View>
60
- </View>
61
- <View style={[styles.listWrap, bottomInset]}>
62
- <ScrollView bounces={false} contentContainerStyle={styles.body}>
63
- {series.length === 0 ? (
64
- <Text style={styles.empty}>Aucune série pour ce challenge.</Text>
65
- ) : (
66
- series.map((serie) => {
67
- const done = isSerieComplete(serie);
68
- const ratio = serieProgressRatio(serie);
69
- return (
70
- <Pressable
71
- key={serie.id}
72
- style={themedStyles.serie}
73
- onPress={handleSerieSelected(serie)}
74
- >
75
- <View style={styles.serieRow}>
76
- <View style={styles.serieMain}>
77
- <Title text={serie.name} level="3" />
78
- {serie.description ? (
79
- <Text numberOfLines={1}>
80
- {serie.description}
81
- </Text>
82
- ) : null}
83
- <View
84
- style={[
85
- styles.track,
86
- {
87
- backgroundColor: theme.colors.border,
88
- borderRadius: t.radii.pill,
89
- },
90
- ]}
91
- >
92
- <View
93
- style={[
94
- styles.fill,
95
- {
96
- width: `${Math.round(ratio * 100)}%`,
97
- backgroundColor: done
98
- ? theme.colors.success
99
- : theme.colors.primary,
100
- borderRadius: t.radii.pill,
101
- },
102
- ]}
103
- >
104
- <Text
105
- style={[
106
- styles.fillLabel,
107
- {
108
- color: done
109
- ? theme.colors.onSuccess
110
- : theme.colors.onPrimary,
111
- },
112
- ]}
113
- >
114
- {serieProgressLabel(serie)}
115
- </Text>
116
- </View>
117
- </View>
118
- </View>
119
- <View
120
- style={[
121
- styles.actionBtn,
122
- {
123
- backgroundColor: done
124
- ? theme.colors.success
125
- : theme.colors.primary,
126
- borderRadius: t.radii.pill,
127
- },
128
- ]}
129
- >
130
- {done ? (
131
- <Trophy
132
- size={18}
133
- color={theme.colors.onSuccess}
134
- />
135
- ) : (
136
- <Play
137
- size={18}
138
- color={theme.colors.onPrimary}
139
- fill={theme.colors.onPrimary}
140
- />
141
- )}
142
- </View>
143
- </View>
144
- </Pressable>
145
- );
146
- })
147
- )}
148
- </ScrollView>
149
- </View>
150
- </View>
151
- ) : (
152
- <QuizModal
153
- serie={selectedSerie}
154
- challengeId={challenge.id}
155
- onClose={() => setSelectedSerieId(null)}
156
- />
157
- )}
158
- </>
159
- );
160
- }
161
-
162
- const createThemedStyles = (theme: Theme) =>
163
- StyleSheet.create({
164
- modal: {
165
- backgroundColor: theme.colors.background,
166
- },
167
- serie: {
168
- backgroundColor: theme.colors.surface,
169
- borderRadius: theme.radii?.lg ?? theme.radius,
170
- ...(theme.shadow?.soft ?? {}),
171
- paddingHorizontal: SPACE.cardPad,
172
- },
173
- });
174
-
175
- const styles = StyleSheet.create({
176
- modal: {
177
- height: Dimensions.get("screen").height,
178
- },
179
- header: {
180
- paddingHorizontal: 16,
181
- paddingVertical: 16,
182
- width: "100%",
183
- flexDirection: "row",
184
- justifyContent: "space-between",
185
- alignItems: "center",
186
- gap: 12,
187
- },
188
- listWrap: {
189
- flex: 1,
190
- },
191
- body: {
192
- padding: 16,
193
- gap: 12,
194
- flexGrow: 1,
195
- },
196
- empty: {
197
- opacity: 0.7,
198
- },
199
- serieRow: {
200
- flexDirection: "row",
201
- alignItems: "center",
202
- gap: 16,
203
- paddingVertical: 14,
204
- },
205
- serieMain: {
206
- flex: 1,
207
- gap: 12,
208
- },
209
- track: {
210
- height: 16,
211
- overflow: "hidden",
212
- justifyContent: "center",
213
- },
214
- fill: {
215
- height: "100%",
216
- minWidth: 40,
217
- justifyContent: "center",
218
- paddingHorizontal: 8,
219
- },
220
- fillLabel: {
221
- fontSize: 11,
222
- fontWeight: "700",
223
- textAlign: "center",
224
- },
225
- actionBtn: {
226
- width: SPACE.iconHit,
227
- height: SPACE.iconHit,
228
- alignItems: "center",
229
- justifyContent: "center",
230
- },
231
- });
1
+ import { Dimensions, Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
2
+ import { ChallengeSeriesWithProgress, ChallengeWithProgress } from "../../hooks/useChallenges";
3
+ import { Title } from "../title/Title";
4
+ import { NavButton } from "../nav-button/NavButton";
5
+ import { Play, Trophy, XIcon } from "lucide-react-native";
6
+ import { Theme } from "../../types/Theme";
7
+ import { useTheme } from "../../contexts/ThemeContext";
8
+ import { useSafeAreaPadding } from "../../helpers/useSafeAreaPadding";
9
+ import { useState, type ReactNode } from "react";
10
+ import { QuizModal } from "./QuizModal";
11
+ import { resolveTheme } from "../../helpers/themeStyles";
12
+ import { SPACE } from "../../helpers/layout";
13
+
14
+ export type ChallengeModalProps = {
15
+ challenge: ChallengeWithProgress;
16
+ onClose: () => void;
17
+ };
18
+
19
+ function isSerieComplete(serie: ChallengeSeriesWithProgress) {
20
+ return !!serie.progression;
21
+ }
22
+
23
+ function serieProgressRatio(serie: ChallengeSeriesWithProgress) {
24
+ return Math.min(1, Math.max(0, (serie.progression?.score ?? 0) / 100));
25
+ }
26
+
27
+ function serieProgressLabel(serie: ChallengeSeriesWithProgress) {
28
+ return `${Math.round(serie.progression?.score ?? 0)}%`;
29
+ }
30
+
31
+ export function ChallengeModal({
32
+ challenge,
33
+ onClose,
34
+ }: ChallengeModalProps): ReactNode {
35
+ const { theme } = useTheme();
36
+ const t = resolveTheme(theme);
37
+ const themedStyles = createThemedStyles(theme);
38
+ const topInset = useSafeAreaPadding(["top"]);
39
+ const bottomInset = useSafeAreaPadding(["bottom"]);
40
+ const [selectedSerieId, setSelectedSerieId] = useState<string | null>(null);
41
+ const series = challenge.series ?? [];
42
+ const selectedSerie =
43
+ selectedSerieId != null
44
+ ? (series.find((s) => s.id === selectedSerieId) ?? null)
45
+ : null;
46
+
47
+ const handleSerieSelected = (serie: ChallengeSeriesWithProgress) => () => {
48
+ setSelectedSerieId(serie.id);
49
+ };
50
+
51
+ return (
52
+ <>
53
+ {!selectedSerie ? (
54
+ <View style={[styles.modal, themedStyles.modal]}>
55
+ <View style={topInset}>
56
+ <View style={styles.header}>
57
+ <Title text={challenge.name} level="2" numberOfLines={1} />
58
+ <NavButton icon={XIcon} onPress={onClose} />
59
+ </View>
60
+ </View>
61
+ <View style={[styles.listWrap, bottomInset]}>
62
+ <ScrollView bounces={false} contentContainerStyle={styles.body}>
63
+ {series.length === 0 ? (
64
+ <Text style={styles.empty}>Aucune série pour ce challenge.</Text>
65
+ ) : (
66
+ series.map((serie) => {
67
+ const done = isSerieComplete(serie);
68
+ const ratio = serieProgressRatio(serie);
69
+ return (
70
+ <Pressable
71
+ key={serie.id}
72
+ style={themedStyles.serie}
73
+ onPress={handleSerieSelected(serie)}
74
+ >
75
+ <View style={styles.serieRow}>
76
+ <View style={styles.serieMain}>
77
+ <Title text={serie.name} level="3" />
78
+ {serie.description ? (
79
+ <Text numberOfLines={1}>
80
+ {serie.description}
81
+ </Text>
82
+ ) : null}
83
+ <View
84
+ style={[
85
+ styles.track,
86
+ {
87
+ backgroundColor: theme.colors.border,
88
+ borderRadius: t.radii.pill,
89
+ },
90
+ ]}
91
+ >
92
+ <View
93
+ style={[
94
+ styles.fill,
95
+ {
96
+ width: `${Math.round(ratio * 100)}%`,
97
+ backgroundColor: done
98
+ ? theme.colors.success
99
+ : theme.colors.primary,
100
+ borderRadius: t.radii.pill,
101
+ },
102
+ ]}
103
+ >
104
+ <Text
105
+ style={[
106
+ styles.fillLabel,
107
+ {
108
+ color: done
109
+ ? theme.colors.onSuccess
110
+ : theme.colors.onPrimary,
111
+ },
112
+ ]}
113
+ >
114
+ {serieProgressLabel(serie)}
115
+ </Text>
116
+ </View>
117
+ </View>
118
+ </View>
119
+ <View
120
+ style={[
121
+ styles.actionBtn,
122
+ {
123
+ backgroundColor: done
124
+ ? theme.colors.success
125
+ : theme.colors.primary,
126
+ borderRadius: t.radii.pill,
127
+ },
128
+ ]}
129
+ >
130
+ {done ? (
131
+ <Trophy
132
+ size={18}
133
+ color={theme.colors.onSuccess}
134
+ />
135
+ ) : (
136
+ <Play
137
+ size={18}
138
+ color={theme.colors.onPrimary}
139
+ fill={theme.colors.onPrimary}
140
+ />
141
+ )}
142
+ </View>
143
+ </View>
144
+ </Pressable>
145
+ );
146
+ })
147
+ )}
148
+ </ScrollView>
149
+ </View>
150
+ </View>
151
+ ) : (
152
+ <QuizModal
153
+ serie={selectedSerie}
154
+ challengeId={challenge.id}
155
+ onClose={() => setSelectedSerieId(null)}
156
+ />
157
+ )}
158
+ </>
159
+ );
160
+ }
161
+
162
+ const createThemedStyles = (theme: Theme) =>
163
+ StyleSheet.create({
164
+ modal: {
165
+ backgroundColor: theme.colors.background,
166
+ },
167
+ serie: {
168
+ backgroundColor: theme.colors.surface,
169
+ borderRadius: theme.radii?.lg ?? theme.radius,
170
+ ...(theme.shadow?.soft ?? {}),
171
+ paddingHorizontal: SPACE.cardPad,
172
+ },
173
+ });
174
+
175
+ const styles = StyleSheet.create({
176
+ modal: {
177
+ height: Dimensions.get("screen").height,
178
+ },
179
+ header: {
180
+ paddingHorizontal: 16,
181
+ paddingVertical: 16,
182
+ width: "100%",
183
+ flexDirection: "row",
184
+ justifyContent: "space-between",
185
+ alignItems: "center",
186
+ gap: 12,
187
+ },
188
+ listWrap: {
189
+ flex: 1,
190
+ },
191
+ body: {
192
+ padding: 16,
193
+ gap: 12,
194
+ flexGrow: 1,
195
+ },
196
+ empty: {
197
+ opacity: 0.7,
198
+ },
199
+ serieRow: {
200
+ flexDirection: "row",
201
+ alignItems: "center",
202
+ gap: 16,
203
+ paddingVertical: 14,
204
+ },
205
+ serieMain: {
206
+ flex: 1,
207
+ gap: 12,
208
+ },
209
+ track: {
210
+ height: 16,
211
+ overflow: "hidden",
212
+ justifyContent: "center",
213
+ },
214
+ fill: {
215
+ height: "100%",
216
+ minWidth: 40,
217
+ justifyContent: "center",
218
+ paddingHorizontal: 8,
219
+ },
220
+ fillLabel: {
221
+ fontSize: 11,
222
+ fontWeight: "700",
223
+ textAlign: "center",
224
+ },
225
+ actionBtn: {
226
+ width: SPACE.iconHit,
227
+ height: SPACE.iconHit,
228
+ alignItems: "center",
229
+ justifyContent: "center",
230
+ },
231
+ });