@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,249 +1,249 @@
1
- import { useState, type ReactNode } from "react";
2
- import { ActivityIndicator, Modal, Pressable, StyleSheet, Text, View } from "react-native";
3
- import { Play, Trophy } from "lucide-react-native";
4
- import { useTheme } from "../../contexts/ThemeContext";
5
- import { useChallenges } from "../../hooks/useChallenges";
6
- import type { ChallengeWithProgress } from "../../hooks/useChallenges";
7
- import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
8
- import { SPACE } from "../../helpers/layout";
9
- import { ChallengesModal } from "./ChallengesModal";
10
- import { ChallengeModal } from "./ChallengeModal";
11
-
12
- export type ChallengeVignetteProps = {};
13
-
14
- function isChallengeComplete(c: ChallengeWithProgress) {
15
- return !!c.progression?.badge;
16
- }
17
-
18
- function progressLabel(c: ChallengeWithProgress) {
19
- const series = c.series ?? [];
20
- if (series.length === 0) return isChallengeComplete(c) ? "1/1" : "0/1";
21
- const done = series.filter((s) => s.progression).length;
22
- return `${done}/${series.length}`;
23
- }
24
-
25
- function progressRatio(c: ChallengeWithProgress) {
26
- const series = c.series ?? [];
27
- if (series.length === 0) return isChallengeComplete(c) ? 1 : 0;
28
- return series.filter((s) => s.progression).length / series.length;
29
- }
30
-
31
- export function ChallengeVignette({}: ChallengeVignetteProps): ReactNode {
32
- const { theme } = useTheme();
33
- const t = resolveTheme(theme);
34
- const { challenges, isLoading, error } = useChallenges();
35
- const [displayAll, setDisplayAll] = useState(false);
36
- const [active, setActive] = useState<ChallengeWithProgress | null>(null);
37
-
38
- const preview = challenges.slice(0, 3);
39
-
40
- if (isLoading && !challenges.length) {
41
- return (
42
- <View style={styles.stateBox}>
43
- <ActivityIndicator size="small" color={theme.colors.primary} />
44
- </View>
45
- );
46
- }
47
-
48
- if (error) {
49
- return (
50
- <View style={styles.stateBox}>
51
- <Text style={{ color: theme.colors.error }}>{error}</Text>
52
- </View>
53
- );
54
- }
55
-
56
- return (
57
- <>
58
- <View style={styles.section}>
59
- <View style={styles.sectionHeader}>
60
- <Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
61
- DERNIERS DÉFIS
62
- </Text>
63
- <Pressable onPress={() => setDisplayAll(true)}>
64
- <Text style={{ color: theme.colors.primary, fontWeight: "700" }}>
65
- Tous les défis ›
66
- </Text>
67
- </Pressable>
68
- </View>
69
-
70
- <View style={[styles.card, cardStyle(theme), { borderRadius: t.radii.lg }]}>
71
- {preview.length === 0 ? (
72
- <Text style={[styles.empty, { color: t.colors.muted }]}>
73
- Aucun défi disponible
74
- </Text>
75
- ) : (
76
- preview.map((c, index) => {
77
- const done = isChallengeComplete(c);
78
- const ratio = progressRatio(c);
79
- return (
80
- <Pressable
81
- key={c.id}
82
- onPress={() => setActive(c)}
83
- style={[
84
- styles.row,
85
- index < preview.length - 1 && {
86
- borderBottomWidth: StyleSheet.hairlineWidth,
87
- borderBottomColor: theme.colors.border,
88
- },
89
- ]}
90
- >
91
- <View style={styles.main}>
92
- <Text
93
- style={[
94
- styles.title,
95
- { color: theme.colors.onSurface },
96
- ]}
97
- numberOfLines={2}
98
- >
99
- {c.name}
100
- </Text>
101
- <View
102
- style={[
103
- styles.track,
104
- {
105
- backgroundColor: theme.colors.border,
106
- borderRadius: t.radii.pill,
107
- },
108
- ]}
109
- >
110
- <View
111
- style={[
112
- styles.fill,
113
- {
114
- width: `${Math.round(ratio * 100)}%`,
115
- backgroundColor: done
116
- ? theme.colors.success
117
- : theme.colors.primary,
118
- borderRadius: t.radii.pill,
119
- },
120
- ]}
121
- >
122
- <Text
123
- style={[
124
- styles.fillLabel,
125
- {
126
- color: done
127
- ? theme.colors.onSuccess
128
- : theme.colors.onPrimary,
129
- },
130
- ]}
131
- >
132
- {progressLabel(c)}
133
- </Text>
134
- </View>
135
- </View>
136
- </View>
137
- <View
138
- style={[
139
- styles.action,
140
- {
141
- backgroundColor: done
142
- ? theme.colors.success
143
- : theme.colors.primary,
144
- borderRadius: t.radii.pill,
145
- },
146
- ]}
147
- >
148
- {done ? (
149
- <Trophy size={16} color={theme.colors.onSuccess} />
150
- ) : (
151
- <Play
152
- size={16}
153
- color={theme.colors.onPrimary}
154
- fill={theme.colors.onPrimary}
155
- />
156
- )}
157
- </View>
158
- </Pressable>
159
- );
160
- })
161
- )}
162
- </View>
163
- </View>
164
-
165
- <ChallengesModal
166
- visible={displayAll}
167
- challenges={challenges}
168
- onClose={() => setDisplayAll(false)}
169
- />
170
- <Modal
171
- visible={!!active}
172
- animationType="slide"
173
- onRequestClose={() => setActive(null)}
174
- >
175
- {active ? (
176
- <ChallengeModal
177
- challenge={active}
178
- onClose={() => setActive(null)}
179
- />
180
- ) : null}
181
- </Modal>
182
- </>
183
- );
184
- }
185
-
186
- const styles = StyleSheet.create({
187
- section: {
188
- gap: 10,
189
- },
190
- sectionHeader: {
191
- flexDirection: "row",
192
- justifyContent: "space-between",
193
- alignItems: "center",
194
- },
195
- sectionLabel: {
196
- fontSize: 12,
197
- fontWeight: "700",
198
- letterSpacing: 0.6,
199
- },
200
- card: {
201
- paddingHorizontal: SPACE.cardPad,
202
- overflow: "hidden",
203
- },
204
- stateBox: {
205
- minHeight: 80,
206
- justifyContent: "center",
207
- alignItems: "center",
208
- },
209
- empty: {
210
- padding: 20,
211
- textAlign: "center",
212
- },
213
- row: {
214
- flexDirection: "row",
215
- alignItems: "center",
216
- gap: 12,
217
- paddingVertical: 14,
218
- },
219
- main: {
220
- flex: 1,
221
- gap: 8,
222
- },
223
- title: {
224
- fontSize: 15,
225
- fontWeight: "700",
226
- },
227
- track: {
228
- height: 16,
229
- overflow: "hidden",
230
- justifyContent: "center",
231
- },
232
- fill: {
233
- height: "100%",
234
- minWidth: 40,
235
- justifyContent: "center",
236
- paddingHorizontal: 8,
237
- },
238
- fillLabel: {
239
- fontSize: 11,
240
- fontWeight: "700",
241
- textAlign: "center",
242
- },
243
- action: {
244
- width: SPACE.iconHit,
245
- height: SPACE.iconHit,
246
- alignItems: "center",
247
- justifyContent: "center",
248
- },
249
- });
1
+ import { useState, type ReactNode } from "react";
2
+ import { ActivityIndicator, Modal, Pressable, StyleSheet, Text, View } from "react-native";
3
+ import { Play, Trophy } from "lucide-react-native";
4
+ import { useTheme } from "../../contexts/ThemeContext";
5
+ import { useChallenges } from "../../hooks/useChallenges";
6
+ import type { ChallengeWithProgress } from "../../hooks/useChallenges";
7
+ import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
8
+ import { SPACE } from "../../helpers/layout";
9
+ import { ChallengesModal } from "./ChallengesModal";
10
+ import { ChallengeModal } from "./ChallengeModal";
11
+
12
+ export type ChallengeVignetteProps = {};
13
+
14
+ function isChallengeComplete(c: ChallengeWithProgress) {
15
+ return !!c.progression?.badge;
16
+ }
17
+
18
+ function progressLabel(c: ChallengeWithProgress) {
19
+ const series = c.series ?? [];
20
+ if (series.length === 0) return isChallengeComplete(c) ? "1/1" : "0/1";
21
+ const done = series.filter((s) => s.progression).length;
22
+ return `${done}/${series.length}`;
23
+ }
24
+
25
+ function progressRatio(c: ChallengeWithProgress) {
26
+ const series = c.series ?? [];
27
+ if (series.length === 0) return isChallengeComplete(c) ? 1 : 0;
28
+ return series.filter((s) => s.progression).length / series.length;
29
+ }
30
+
31
+ export function ChallengeVignette({}: ChallengeVignetteProps): ReactNode {
32
+ const { theme } = useTheme();
33
+ const t = resolveTheme(theme);
34
+ const { challenges, isLoading, error } = useChallenges();
35
+ const [displayAll, setDisplayAll] = useState(false);
36
+ const [active, setActive] = useState<ChallengeWithProgress | null>(null);
37
+
38
+ const preview = challenges.slice(0, 3);
39
+
40
+ if (isLoading && !challenges.length) {
41
+ return (
42
+ <View style={styles.stateBox}>
43
+ <ActivityIndicator size="small" color={theme.colors.primary} />
44
+ </View>
45
+ );
46
+ }
47
+
48
+ if (error) {
49
+ return (
50
+ <View style={styles.stateBox}>
51
+ <Text style={{ color: theme.colors.error }}>{error}</Text>
52
+ </View>
53
+ );
54
+ }
55
+
56
+ return (
57
+ <>
58
+ <View style={styles.section}>
59
+ <View style={styles.sectionHeader}>
60
+ <Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
61
+ DERNIERS DÉFIS
62
+ </Text>
63
+ <Pressable onPress={() => setDisplayAll(true)}>
64
+ <Text style={{ color: theme.colors.primary, fontWeight: "700" }}>
65
+ Tous les défis ›
66
+ </Text>
67
+ </Pressable>
68
+ </View>
69
+
70
+ <View style={[styles.card, cardStyle(theme), { borderRadius: t.radii.lg }]}>
71
+ {preview.length === 0 ? (
72
+ <Text style={[styles.empty, { color: t.colors.muted }]}>
73
+ Aucun défi disponible
74
+ </Text>
75
+ ) : (
76
+ preview.map((c, index) => {
77
+ const done = isChallengeComplete(c);
78
+ const ratio = progressRatio(c);
79
+ return (
80
+ <Pressable
81
+ key={c.id}
82
+ onPress={() => setActive(c)}
83
+ style={[
84
+ styles.row,
85
+ index < preview.length - 1 && {
86
+ borderBottomWidth: StyleSheet.hairlineWidth,
87
+ borderBottomColor: theme.colors.border,
88
+ },
89
+ ]}
90
+ >
91
+ <View style={styles.main}>
92
+ <Text
93
+ style={[
94
+ styles.title,
95
+ { color: theme.colors.onSurface },
96
+ ]}
97
+ numberOfLines={2}
98
+ >
99
+ {c.name}
100
+ </Text>
101
+ <View
102
+ style={[
103
+ styles.track,
104
+ {
105
+ backgroundColor: theme.colors.border,
106
+ borderRadius: t.radii.pill,
107
+ },
108
+ ]}
109
+ >
110
+ <View
111
+ style={[
112
+ styles.fill,
113
+ {
114
+ width: `${Math.round(ratio * 100)}%`,
115
+ backgroundColor: done
116
+ ? theme.colors.success
117
+ : theme.colors.primary,
118
+ borderRadius: t.radii.pill,
119
+ },
120
+ ]}
121
+ >
122
+ <Text
123
+ style={[
124
+ styles.fillLabel,
125
+ {
126
+ color: done
127
+ ? theme.colors.onSuccess
128
+ : theme.colors.onPrimary,
129
+ },
130
+ ]}
131
+ >
132
+ {progressLabel(c)}
133
+ </Text>
134
+ </View>
135
+ </View>
136
+ </View>
137
+ <View
138
+ style={[
139
+ styles.action,
140
+ {
141
+ backgroundColor: done
142
+ ? theme.colors.success
143
+ : theme.colors.primary,
144
+ borderRadius: t.radii.pill,
145
+ },
146
+ ]}
147
+ >
148
+ {done ? (
149
+ <Trophy size={16} color={theme.colors.onSuccess} />
150
+ ) : (
151
+ <Play
152
+ size={16}
153
+ color={theme.colors.onPrimary}
154
+ fill={theme.colors.onPrimary}
155
+ />
156
+ )}
157
+ </View>
158
+ </Pressable>
159
+ );
160
+ })
161
+ )}
162
+ </View>
163
+ </View>
164
+
165
+ <ChallengesModal
166
+ visible={displayAll}
167
+ challenges={challenges}
168
+ onClose={() => setDisplayAll(false)}
169
+ />
170
+ <Modal
171
+ visible={!!active}
172
+ animationType="slide"
173
+ onRequestClose={() => setActive(null)}
174
+ >
175
+ {active ? (
176
+ <ChallengeModal
177
+ challenge={active}
178
+ onClose={() => setActive(null)}
179
+ />
180
+ ) : null}
181
+ </Modal>
182
+ </>
183
+ );
184
+ }
185
+
186
+ const styles = StyleSheet.create({
187
+ section: {
188
+ gap: 10,
189
+ },
190
+ sectionHeader: {
191
+ flexDirection: "row",
192
+ justifyContent: "space-between",
193
+ alignItems: "center",
194
+ },
195
+ sectionLabel: {
196
+ fontSize: 12,
197
+ fontWeight: "700",
198
+ letterSpacing: 0.6,
199
+ },
200
+ card: {
201
+ paddingHorizontal: SPACE.cardPad,
202
+ overflow: "hidden",
203
+ },
204
+ stateBox: {
205
+ minHeight: 80,
206
+ justifyContent: "center",
207
+ alignItems: "center",
208
+ },
209
+ empty: {
210
+ padding: 20,
211
+ textAlign: "center",
212
+ },
213
+ row: {
214
+ flexDirection: "row",
215
+ alignItems: "center",
216
+ gap: 12,
217
+ paddingVertical: 14,
218
+ },
219
+ main: {
220
+ flex: 1,
221
+ gap: 8,
222
+ },
223
+ title: {
224
+ fontSize: 15,
225
+ fontWeight: "700",
226
+ },
227
+ track: {
228
+ height: 16,
229
+ overflow: "hidden",
230
+ justifyContent: "center",
231
+ },
232
+ fill: {
233
+ height: "100%",
234
+ minWidth: 40,
235
+ justifyContent: "center",
236
+ paddingHorizontal: 8,
237
+ },
238
+ fillLabel: {
239
+ fontSize: 11,
240
+ fontWeight: "700",
241
+ textAlign: "center",
242
+ },
243
+ action: {
244
+ width: SPACE.iconHit,
245
+ height: SPACE.iconHit,
246
+ alignItems: "center",
247
+ justifyContent: "center",
248
+ },
249
+ });