@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.
Files changed (101) hide show
  1. package/README.md +47 -47
  2. package/dist/index.d.mts +181 -51
  3. package/dist/index.d.ts +181 -51
  4. package/dist/index.js +3614 -3015
  5. package/dist/index.mjs +3021 -2418
  6. package/package.json +12 -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 +415 -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 +546 -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/push/PushTokenRegistrar.tsx +47 -0
  49. package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
  50. package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
  51. package/src/components/search/Search.tsx +320 -320
  52. package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
  53. package/src/components/title/Title.tsx +100 -100
  54. package/src/components/vision/Vision.tsx +447 -447
  55. package/src/components/vision/VisionActionCard.tsx +117 -117
  56. package/src/components/vision/VisionCapture.tsx +30 -30
  57. package/src/components/vision/VisionTapOverlay.tsx +122 -122
  58. package/src/contexts/AnnouncementsContext.tsx +171 -171
  59. package/src/contexts/AppDataContext.tsx +458 -0
  60. package/src/contexts/ChallengesContext.tsx +182 -182
  61. package/src/contexts/HeaderConfigContext.tsx +29 -0
  62. package/src/contexts/LocalContext.tsx +227 -227
  63. package/src/contexts/ThemeContext.tsx +37 -37
  64. package/src/contexts/WastoContext.tsx +132 -127
  65. package/src/helpers/blogPost.ts +72 -72
  66. package/src/helpers/generateQuizQuestions.ts +247 -247
  67. package/src/helpers/getContrastColor.ts +18 -18
  68. package/src/helpers/haptics.ts +20 -20
  69. package/src/helpers/hoursSchedule.ts +230 -230
  70. package/src/helpers/htmlContentToMarkdown.ts +114 -114
  71. package/src/helpers/layout.ts +54 -54
  72. package/src/helpers/loadLinearGradient.ts +22 -22
  73. package/src/helpers/mapLocations.ts +170 -0
  74. package/src/helpers/maquetteTheme.ts +76 -76
  75. package/src/helpers/markdownUnderlinePlugin.ts +32 -32
  76. package/src/helpers/nextCollection.ts +122 -0
  77. package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
  78. package/src/helpers/publicMediaUrl.ts +8 -8
  79. package/src/helpers/resolveApiAssetUrl.ts +21 -21
  80. package/src/helpers/systemRoutes.ts +7 -7
  81. package/src/helpers/themeStyles.ts +114 -114
  82. package/src/helpers/ttlCache.ts +41 -0
  83. package/src/helpers/useSafeAreaPadding.ts +14 -14
  84. package/src/hooks/useBadges.ts +100 -100
  85. package/src/hooks/useBlogPosts.ts +109 -105
  86. package/src/hooks/useChallenges.ts +110 -110
  87. package/src/hooks/useCities.ts +56 -56
  88. package/src/hooks/useCityAnnouncements.ts +118 -118
  89. package/src/hooks/useCollectionCalendar.ts +421 -421
  90. package/src/hooks/useColumns.ts +19 -19
  91. package/src/hooks/useConsignes.ts +62 -62
  92. package/src/hooks/useLocations.ts +120 -248
  93. package/src/hooks/useNextCollection.ts +163 -238
  94. package/src/hooks/useRecyclingInfo.ts +90 -90
  95. package/src/hooks/useWastoClient.ts +16 -16
  96. package/src/index.ts +161 -142
  97. package/src/navigation/NavigationContext.tsx +56 -56
  98. package/src/push/registerExpoPushToken.ts +133 -0
  99. package/src/sentry/initSentry.ts +120 -120
  100. package/src/types/Theme.ts +72 -72
  101. package/src/types/css-modules.d.ts +1 -1
@@ -1,120 +1,120 @@
1
- import type { ComponentType } from "react";
2
-
3
- export type WastoSentryConfig = {
4
- dsn?: string;
5
- enabled?: boolean | string;
6
- environment?: string;
7
- debug?: boolean | string;
8
- release?: string;
9
- appId?: string;
10
- };
11
-
12
- export type WastoErrorContext = Record<string, unknown> & {
13
- source?: string;
14
- };
15
-
16
- type SentryModule = typeof import("@sentry/react-native");
17
-
18
- let sentryModule: SentryModule | null | undefined;
19
- let initialized = false;
20
- let active = false;
21
-
22
- function parseFlag(value: boolean | string | undefined, defaultWhenDsn: boolean): boolean {
23
- if (typeof value === "boolean") return value;
24
- const raw = String(value ?? "")
25
- .trim()
26
- .toLowerCase();
27
- if (raw === "true" || raw === "1" || raw === "yes") return true;
28
- if (raw === "false" || raw === "0" || raw === "no") return false;
29
- return defaultWhenDsn;
30
- }
31
-
32
- function loadSentry(): SentryModule | null {
33
- if (sentryModule !== undefined) return sentryModule;
34
- try {
35
- // Optional peer: apps without the package still load cms-components.
36
- // eslint-disable-next-line @typescript-eslint/no-require-imports
37
- sentryModule = require("@sentry/react-native") as SentryModule;
38
- } catch {
39
- sentryModule = null;
40
- }
41
- return sentryModule;
42
- }
43
-
44
- /**
45
- * Initialize Sentry for GitLab Error Tracking (DSN from env).
46
- * No-op when DSN is empty, disabled, or `@sentry/react-native` is missing.
47
- */
48
- export function initWastoSentry(config: WastoSentryConfig = {}): boolean {
49
- const dsn = (config.dsn ?? "").trim();
50
- const enabled = Boolean(dsn) && parseFlag(config.enabled, true);
51
- if (!enabled || !dsn) {
52
- active = false;
53
- return false;
54
- }
55
-
56
- const Sentry = loadSentry();
57
- if (!Sentry) {
58
- active = false;
59
- if (__DEV__) {
60
- console.warn(
61
- "[wasto] @sentry/react-native is not installed; error tracking disabled",
62
- );
63
- }
64
- return false;
65
- }
66
-
67
- if (!initialized) {
68
- Sentry.init({
69
- dsn,
70
- enabled: true,
71
- debug: parseFlag(config.debug, false),
72
- environment: (config.environment || "production").trim() || "production",
73
- release: (config.release || "").trim() || undefined,
74
- // GitLab Error Tracking: keep payload minimal (exceptions / messages).
75
- tracesSampleRate: 0,
76
- enableAutoSessionTracking: false,
77
- sendDefaultPii: false,
78
- });
79
- initialized = true;
80
- }
81
-
82
- if (config.appId) {
83
- Sentry.setTag("appId", config.appId);
84
- }
85
-
86
- active = true;
87
- return true;
88
- }
89
-
90
- export function isWastoSentryActive(): boolean {
91
- return active;
92
- }
93
-
94
- export function reportError(error: unknown, context?: WastoErrorContext): void {
95
- if (!active) return;
96
- const Sentry = loadSentry();
97
- if (!Sentry) return;
98
-
99
- Sentry.withScope((scope) => {
100
- if (context) {
101
- for (const [key, value] of Object.entries(context)) {
102
- if (value === undefined) continue;
103
- if (key === "source" && typeof value === "string") {
104
- scope.setTag("source", value);
105
- } else {
106
- scope.setExtra(key, value);
107
- }
108
- }
109
- }
110
- Sentry.captureException(error instanceof Error ? error : new Error(String(error)));
111
- });
112
- }
113
-
114
- export function wrapWithSentry<P extends Record<string, unknown>>(
115
- Component: ComponentType<P>,
116
- ): ComponentType<P> {
117
- const Sentry = loadSentry();
118
- if (!Sentry?.wrap) return Component;
119
- return Sentry.wrap(Component) as ComponentType<P>;
120
- }
1
+ import type { ComponentType } from "react";
2
+
3
+ export type WastoSentryConfig = {
4
+ dsn?: string;
5
+ enabled?: boolean | string;
6
+ environment?: string;
7
+ debug?: boolean | string;
8
+ release?: string;
9
+ appId?: string;
10
+ };
11
+
12
+ export type WastoErrorContext = Record<string, unknown> & {
13
+ source?: string;
14
+ };
15
+
16
+ type SentryModule = typeof import("@sentry/react-native");
17
+
18
+ let sentryModule: SentryModule | null | undefined;
19
+ let initialized = false;
20
+ let active = false;
21
+
22
+ function parseFlag(value: boolean | string | undefined, defaultWhenDsn: boolean): boolean {
23
+ if (typeof value === "boolean") return value;
24
+ const raw = String(value ?? "")
25
+ .trim()
26
+ .toLowerCase();
27
+ if (raw === "true" || raw === "1" || raw === "yes") return true;
28
+ if (raw === "false" || raw === "0" || raw === "no") return false;
29
+ return defaultWhenDsn;
30
+ }
31
+
32
+ function loadSentry(): SentryModule | null {
33
+ if (sentryModule !== undefined) return sentryModule;
34
+ try {
35
+ // Optional peer: apps without the package still load cms-components.
36
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
37
+ sentryModule = require("@sentry/react-native") as SentryModule;
38
+ } catch {
39
+ sentryModule = null;
40
+ }
41
+ return sentryModule;
42
+ }
43
+
44
+ /**
45
+ * Initialize Sentry for GitLab Error Tracking (DSN from env).
46
+ * No-op when DSN is empty, disabled, or `@sentry/react-native` is missing.
47
+ */
48
+ export function initWastoSentry(config: WastoSentryConfig = {}): boolean {
49
+ const dsn = (config.dsn ?? "").trim();
50
+ const enabled = Boolean(dsn) && parseFlag(config.enabled, true);
51
+ if (!enabled || !dsn) {
52
+ active = false;
53
+ return false;
54
+ }
55
+
56
+ const Sentry = loadSentry();
57
+ if (!Sentry) {
58
+ active = false;
59
+ if (__DEV__) {
60
+ console.warn(
61
+ "[wasto] @sentry/react-native is not installed; error tracking disabled",
62
+ );
63
+ }
64
+ return false;
65
+ }
66
+
67
+ if (!initialized) {
68
+ Sentry.init({
69
+ dsn,
70
+ enabled: true,
71
+ debug: parseFlag(config.debug, false),
72
+ environment: (config.environment || "production").trim() || "production",
73
+ release: (config.release || "").trim() || undefined,
74
+ // GitLab Error Tracking: keep payload minimal (exceptions / messages).
75
+ tracesSampleRate: 0,
76
+ enableAutoSessionTracking: false,
77
+ sendDefaultPii: false,
78
+ });
79
+ initialized = true;
80
+ }
81
+
82
+ if (config.appId) {
83
+ Sentry.setTag("appId", config.appId);
84
+ }
85
+
86
+ active = true;
87
+ return true;
88
+ }
89
+
90
+ export function isWastoSentryActive(): boolean {
91
+ return active;
92
+ }
93
+
94
+ export function reportError(error: unknown, context?: WastoErrorContext): void {
95
+ if (!active) return;
96
+ const Sentry = loadSentry();
97
+ if (!Sentry) return;
98
+
99
+ Sentry.withScope((scope) => {
100
+ if (context) {
101
+ for (const [key, value] of Object.entries(context)) {
102
+ if (value === undefined) continue;
103
+ if (key === "source" && typeof value === "string") {
104
+ scope.setTag("source", value);
105
+ } else {
106
+ scope.setExtra(key, value);
107
+ }
108
+ }
109
+ }
110
+ Sentry.captureException(error instanceof Error ? error : new Error(String(error)));
111
+ });
112
+ }
113
+
114
+ export function wrapWithSentry<P extends Record<string, unknown>>(
115
+ Component: ComponentType<P>,
116
+ ): ComponentType<P> {
117
+ const Sentry = loadSentry();
118
+ if (!Sentry?.wrap) return Component;
119
+ return Sentry.wrap(Component) as ComponentType<P>;
120
+ }
@@ -1,72 +1,72 @@
1
- export type ThemeShadowStyle = {
2
- shadowColor: string;
3
- shadowOffset: { width: number; height: number };
4
- shadowOpacity: number;
5
- shadowRadius: number;
6
- elevation: number;
7
- };
8
-
9
- /**
10
- * CMS app theme — edited in console (`config.theme`), injected via WastoProvider.
11
- * Maquette defaults live in `createMaquetteTheme` / `MAQUETTE_*`; components must
12
- * read colors/radii from here (no hardcoded brand hex / borderRadius).
13
- */
14
- export type Theme = {
15
- colors: {
16
- primary: string;
17
- onPrimary: string;
18
- surface: string;
19
- onSurface: string;
20
- background: string;
21
- onBackground: string;
22
- /** Also used for completed challenges (maquette yellow when customized). */
23
- success: string;
24
- onSuccess: string;
25
- error: string;
26
- onError: string;
27
- border: string;
28
- /** Soft tint of primary (~15–20% alpha). Optional — resolved at runtime if omitted. */
29
- primarySoft?: string;
30
- /** Slightly elevated surface (cards on cards). Optional. */
31
- surfaceElevated?: string;
32
- /** Secondary / muted text color. Optional — derived from onSurface if omitted. */
33
- muted?: string;
34
- gradient: {
35
- from: string;
36
- to: string;
37
- };
38
- };
39
- /** Primary corner radius (cards, inputs). */
40
- radius: number;
41
- /** Named radii. Optional — derived from `radius` if omitted. */
42
- radii?: {
43
- sm: number;
44
- md: number;
45
- lg: number;
46
- pill: number;
47
- };
48
- /** Elevation shadows. Optional — sensible defaults if omitted. */
49
- shadow?: {
50
- card: ThemeShadowStyle;
51
- soft: ThemeShadowStyle;
52
- };
53
- };
54
-
55
- /** Fully resolved theme (all optional fields filled). */
56
- export type ResolvedTheme = Theme & {
57
- colors: Theme["colors"] & {
58
- primarySoft: string;
59
- surfaceElevated: string;
60
- muted: string;
61
- };
62
- radii: {
63
- sm: number;
64
- md: number;
65
- lg: number;
66
- pill: number;
67
- };
68
- shadow: {
69
- card: ThemeShadowStyle;
70
- soft: ThemeShadowStyle;
71
- };
72
- };
1
+ export type ThemeShadowStyle = {
2
+ shadowColor: string;
3
+ shadowOffset: { width: number; height: number };
4
+ shadowOpacity: number;
5
+ shadowRadius: number;
6
+ elevation: number;
7
+ };
8
+
9
+ /**
10
+ * CMS app theme — edited in console (`config.theme`), injected via WastoProvider.
11
+ * Maquette defaults live in `createMaquetteTheme` / `MAQUETTE_*`; components must
12
+ * read colors/radii from here (no hardcoded brand hex / borderRadius).
13
+ */
14
+ export type Theme = {
15
+ colors: {
16
+ primary: string;
17
+ onPrimary: string;
18
+ surface: string;
19
+ onSurface: string;
20
+ background: string;
21
+ onBackground: string;
22
+ /** Also used for completed challenges (maquette yellow when customized). */
23
+ success: string;
24
+ onSuccess: string;
25
+ error: string;
26
+ onError: string;
27
+ border: string;
28
+ /** Soft tint of primary (~15–20% alpha). Optional — resolved at runtime if omitted. */
29
+ primarySoft?: string;
30
+ /** Slightly elevated surface (cards on cards). Optional. */
31
+ surfaceElevated?: string;
32
+ /** Secondary / muted text color. Optional — derived from onSurface if omitted. */
33
+ muted?: string;
34
+ gradient: {
35
+ from: string;
36
+ to: string;
37
+ };
38
+ };
39
+ /** Primary corner radius (cards, inputs). */
40
+ radius: number;
41
+ /** Named radii. Optional — derived from `radius` if omitted. */
42
+ radii?: {
43
+ sm: number;
44
+ md: number;
45
+ lg: number;
46
+ pill: number;
47
+ };
48
+ /** Elevation shadows. Optional — sensible defaults if omitted. */
49
+ shadow?: {
50
+ card: ThemeShadowStyle;
51
+ soft: ThemeShadowStyle;
52
+ };
53
+ };
54
+
55
+ /** Fully resolved theme (all optional fields filled). */
56
+ export type ResolvedTheme = Theme & {
57
+ colors: Theme["colors"] & {
58
+ primarySoft: string;
59
+ surfaceElevated: string;
60
+ muted: string;
61
+ };
62
+ radii: {
63
+ sm: number;
64
+ md: number;
65
+ lg: number;
66
+ pill: number;
67
+ };
68
+ shadow: {
69
+ card: ThemeShadowStyle;
70
+ soft: ThemeShadowStyle;
71
+ };
72
+ };
@@ -1 +1 @@
1
- declare module "maplibre-gl/dist/maplibre-gl.css";
1
+ declare module "maplibre-gl/dist/maplibre-gl.css";