@vvedantb/native-ui 0.37.2 → 0.38.0

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 (42) hide show
  1. package/README.md +8 -7
  2. package/dist/app-root/AuthGroupGate.jsx +65 -0
  3. package/dist/app-root/SsoCallbackScreen.jsx +97 -0
  4. package/dist/app-root/fonts.js +88 -0
  5. package/dist/app-root/index.js +3 -0
  6. package/dist/auth/AuthScreen.jsx +252 -74
  7. package/dist/auth/SecondFactorScreen.jsx +18 -12
  8. package/dist/auth/SignInScreen.jsx +40 -17
  9. package/dist/crash/LastCrashDialog.jsx +56 -0
  10. package/dist/crash/lastCrash.js +213 -0
  11. package/dist/entries/app-root.js +6 -0
  12. package/dist/entries/crash.js +5 -0
  13. package/dist/entries/theme.js +3 -0
  14. package/dist/index.js +3 -0
  15. package/dist/neutralTheme.js +163 -0
  16. package/dist/primitives/icon.jsx +0 -4
  17. package/dist/primitives/select.jsx +0 -2
  18. package/dist/settings/ThemeModePicker.jsx +2 -5
  19. package/dist/themeModeStore.js +67 -0
  20. package/dist/themeModes.js +9 -0
  21. package/package.json +47 -19
  22. package/src/app-root/AuthGroupGate.tsx +46 -0
  23. package/src/app-root/SsoCallbackScreen.tsx +62 -0
  24. package/src/app-root/fonts.ts +55 -0
  25. package/src/app-root/index.ts +6 -0
  26. package/src/auth/AuthScreen.tsx +102 -1
  27. package/src/auth/SecondFactorScreen.tsx +20 -2
  28. package/src/auth/SignInScreen.tsx +119 -53
  29. package/src/crash/LastCrashDialog.tsx +42 -0
  30. package/src/crash/lastCrash.ts +239 -0
  31. package/src/entries/app-root.ts +6 -0
  32. package/src/entries/crash.ts +16 -0
  33. package/src/entries/theme.ts +6 -0
  34. package/src/highlight.ts +1 -1
  35. package/src/index.ts +5 -0
  36. package/src/neutralTheme.ts +130 -0
  37. package/src/primitives/icon.tsx +0 -2
  38. package/src/primitives/select.tsx +0 -2
  39. package/src/settings/ThemeModePicker.tsx +2 -5
  40. package/src/themeModeStore.ts +94 -0
  41. package/src/themeModes.ts +10 -0
  42. package/types/prism-react-renderer.d.ts +22 -0
@@ -0,0 +1,213 @@
1
+ import { useSyncExternalStore } from "react";
2
+
3
+ // The last error that closed the app. A release build closes with no message
4
+ // and no log a phone user can read, so the global error handler saves the
5
+ // error here and the next launch shows it (`LastCrashDialog`), ready to copy.
6
+ // Moved from eva (`apps/mobile/src/logging`). Not moved: eva's native exit
7
+ // record (its own Expo module) and the report to its backend.
8
+
9
+ /** Where the crash is kept between launches, for example `expo-secure-store`. */
10
+
11
+ /** What a fatal error leaves behind for the next launch. */
12
+
13
+ const KEY = "v.lastCrash";
14
+ /** SecureStore values over 2 KB warn on iOS, so a report is cut below that. */
15
+ const MAX_CHARS = 1_800;
16
+ /** How long a fatal error waits for the save before the app closes anyway. */
17
+ const FATAL_SAVE_MS = 1_000;
18
+
19
+ // `expo-secure-store` and `expo-constants` are optional peers. Metro bundles a
20
+ // `require` placed directly in a `try` block as optional, so a missing peer
21
+ // does not break the bundle.
22
+ let secureStore;
23
+ function defaultStorage() {
24
+ if (secureStore === undefined) {
25
+ try {
26
+ const store = require("expo-secure-store");
27
+ secureStore = {
28
+ getItem: key => store.getItemAsync(key),
29
+ setItem: (key, value) => store.setItemAsync(key, value),
30
+ removeItem: key => store.deleteItemAsync(key)
31
+ };
32
+ } catch {
33
+ secureStore = null;
34
+ }
35
+ }
36
+ return secureStore;
37
+ }
38
+ function defaultVersion() {
39
+ try {
40
+ const constants = require("expo-constants");
41
+ return constants.default?.expoConfig?.version ?? "?";
42
+ } catch {
43
+ return "?";
44
+ }
45
+ }
46
+ let settings = null;
47
+ const current = () => settings ??= {
48
+ storage: defaultStorage(),
49
+ version: defaultVersion()
50
+ };
51
+ let last = null;
52
+ const listeners = new Set();
53
+ function publish(next) {
54
+ last = next;
55
+ for (const listener of listeners) listener();
56
+ }
57
+ const text = value => typeof value === "string" && value ? value : undefined;
58
+ const field = (caught, name) => typeof caught === "object" && caught !== null ? text(caught[name]) : undefined;
59
+
60
+ /** The name, message and a short stack of a thrown value. Never the value itself. */
61
+ export function fatalReport(caught) {
62
+ return {
63
+ name: field(caught, "name") ?? "Error",
64
+ message: (field(caught, "message") ?? String(caught)).slice(0, 500),
65
+ stack: (field(caught, "stack") ?? "").split("\n").slice(0, 15).join("\n")
66
+ };
67
+ }
68
+ function isLastCrash(value) {
69
+ if (typeof value !== "object" || value === null) return false;
70
+ const crash = value;
71
+ return typeof crash.at === "number" && ["version", "name", "message", "stack"].every(key => typeof crash[key] === "string");
72
+ }
73
+
74
+ /** Saves the report for the next launch. Never throws. */
75
+ export async function saveLastCrash(report) {
76
+ try {
77
+ const {
78
+ storage,
79
+ version
80
+ } = current();
81
+ if (!storage) return;
82
+ const crash = {
83
+ at: Date.now(),
84
+ version,
85
+ ...report
86
+ };
87
+ let json = JSON.stringify(crash);
88
+ if (json.length > MAX_CHARS) {
89
+ json = JSON.stringify({
90
+ ...crash,
91
+ stack: crash.stack.slice(0, Math.max(0, MAX_CHARS - (json.length - crash.stack.length)))
92
+ });
93
+ }
94
+ await storage.setItem(KEY, json);
95
+ } catch {
96
+ // A crash logger must never throw.
97
+ }
98
+ }
99
+
100
+ /** Reads the saved crash, so `LastCrashDialog` shows it. Never throws. */
101
+ export async function loadLastCrash() {
102
+ try {
103
+ const saved = await current().storage?.getItem(KEY);
104
+ const parsed = saved ? JSON.parse(saved) : null;
105
+ if (isLastCrash(parsed)) publish(parsed);
106
+ } catch {
107
+ // Nothing to show.
108
+ }
109
+ }
110
+
111
+ /** Shows `crash` in `LastCrashDialog` without saving it. For the gallery. */
112
+ export function showLastCrash(crash) {
113
+ publish(crash);
114
+ }
115
+
116
+ /** Forgets the shown crash. */
117
+ export function dismissLastCrash() {
118
+ publish(null);
119
+ void current().storage?.removeItem(KEY).catch(() => {});
120
+ }
121
+
122
+ /** The crash saved by the last session, or `null`. */
123
+ export function useLastCrash() {
124
+ return useSyncExternalStore(_temp, _temp2, _temp3);
125
+ }
126
+
127
+ /** The text Copy puts on the clipboard. */
128
+ function _temp3() {
129
+ return last;
130
+ }
131
+ function _temp2() {
132
+ return last;
133
+ }
134
+ function _temp(listener) {
135
+ listeners.add(listener);
136
+ return () => listeners.delete(listener);
137
+ }
138
+ export function crashDetails(crash, appName) {
139
+ return [`${appName} ${crash.version}, ${new Date(crash.at).toISOString()}`, `${crash.name}: ${crash.message}`, crash.stack].join("\n");
140
+ }
141
+ function errorUtilsOf(env) {
142
+ const value = env.ErrorUtils;
143
+ return typeof value?.getGlobalHandler === "function" && typeof value.setGlobalHandler === "function" ? value : null;
144
+ }
145
+ function trackerOf(env) {
146
+ const tracker = env.HermesInternal?.enablePromiseRejectionTracker;
147
+ return typeof tracker === "function" ? tracker : null;
148
+ }
149
+
150
+ /** Logs name, message and a short stack, so release builds show it in logcat. Never throws. */
151
+ function logUncaught(kind, caught, isFatal) {
152
+ try {
153
+ const report = fatalReport(caught);
154
+ console.error("[uncaught]", {
155
+ kind,
156
+ isFatal,
157
+ errorName: report.name,
158
+ errorMessage: report.message.slice(0, 200),
159
+ stack: report.stack.split("\n").slice(0, 6).join("\n")
160
+ });
161
+ } catch {
162
+ // A logger must never throw.
163
+ }
164
+ }
165
+ let installed = false;
166
+ /**
167
+ * Call once at the top of the root layout, outside any component. It:
168
+ * - logs unhandled promise rejections and uncaught errors to `console.error`,
169
+ * which release builds otherwise swallow;
170
+ * - saves a fatal error before the app closes (waiting at most one second);
171
+ * - loads the crash the last session saved, for `LastCrashDialog`.
172
+ * Installs once; later calls return `false`. Never throws.
173
+ */
174
+ export function installCrashCapture(options = {}) {
175
+ if (installed) return false;
176
+ try {
177
+ installed = true;
178
+ settings = {
179
+ storage: options.storage === undefined ? defaultStorage() : options.storage,
180
+ version: options.version ?? defaultVersion()
181
+ };
182
+ const env = options.env ?? globalThis;
183
+ trackerOf(env)?.({
184
+ allRejections: true,
185
+ onUnhandled: (_id, error) => logUncaught("unhandled-rejection", error)
186
+ });
187
+ const errorUtils = errorUtilsOf(env);
188
+ if (errorUtils) {
189
+ const previous = errorUtils.getGlobalHandler();
190
+ errorUtils.setGlobalHandler((error, isFatal) => {
191
+ logUncaught("uncaught-error", error, isFatal);
192
+ if (!isFatal) {
193
+ previous(error, isFatal);
194
+ return;
195
+ }
196
+ // Save first, then let the app close as before.
197
+ const timeout = new Promise(resolve => setTimeout(resolve, FATAL_SAVE_MS));
198
+ void Promise.race([saveLastCrash(fatalReport(error)), timeout]).finally(() => previous(error, isFatal));
199
+ });
200
+ }
201
+ void loadLastCrash();
202
+ return true;
203
+ } catch {
204
+ return false;
205
+ }
206
+ }
207
+
208
+ /** For tests only. */
209
+ export function resetCrashCaptureForTests() {
210
+ installed = false;
211
+ settings = null;
212
+ publish(null);
213
+ }
@@ -0,0 +1,6 @@
1
+ // `@vvedantb/native-ui/app-root`: the Instrument Sans font helper, the splash hide
2
+ // helper, `AuthGroupGate` and `SsoCallbackScreen` for Expo app shells. Apps keep their
3
+ // own provider trees. Not on the root entry: it imports `@clerk/expo`, `expo-router`,
4
+ // `expo-font`, `expo-splash-screen` and `@expo-google-fonts/instrument-sans`, and Metro
5
+ // does not tree-shake.
6
+ export * from "../app-root";
@@ -0,0 +1,5 @@
1
+ // `@vvedantb/native-ui/crash`: shows the error that closed the app last time.
2
+ // Call `installCrashCapture()` once at the top of the root layout and mount
3
+ // `<LastCrashDialog appName="…" />` inside it.
4
+ export { LastCrashDialog } from "../crash/LastCrashDialog";
5
+ export { crashDetails, dismissLastCrash, fatalReport, installCrashCapture, loadLastCrash, saveLastCrash, showLastCrash, useLastCrash } from "../crash/lastCrash";
@@ -3,6 +3,9 @@ export { cn } from "../cn";
3
3
  export { tokens, NativeUiProvider, useNativeUi, useLargerText, useAccentColor, DEFAULT_ACCENT } from "../theme";
4
4
  export { palette, withAlpha } from "../palette";
5
5
  export { configureTheme } from "../configureTheme";
6
+ export { NEUTRAL_PALETTE, NEUTRAL_CHANNELS, paintDarkFamily } from "../neutralTheme";
7
+ export { THEME_MODES, parseThemeMode } from "../themeModes";
8
+ export { createThemeModeStore } from "../themeModeStore";
6
9
  export { fontClass, fontFamily } from "../typography";
7
10
  export { PINK_50, PINK_100, PINK_600, PINK_700, NEUTRAL_100, NEUTRAL_500, NEUTRAL_900, Colors } from "../colors";
8
11
  export { useScheme } from "../useScheme";
package/dist/index.js CHANGED
@@ -2,6 +2,9 @@ export { cn } from "./cn";
2
2
  export { tokens, NativeUiProvider, useNativeUi, useLargerText, useAccentColor, DEFAULT_ACCENT } from "./theme";
3
3
  export { palette, withAlpha } from "./palette";
4
4
  export { configureTheme } from "./configureTheme";
5
+ export { NEUTRAL_PALETTE, NEUTRAL_CHANNELS, paintDarkFamily } from "./neutralTheme";
6
+ export { parseThemeMode } from "./themeModes";
7
+ export { createThemeModeStore } from "./themeModeStore";
5
8
  export { fontClass, fontFamily } from "./typography";
6
9
  export { FLOATING_INSET, FLOATING_TAB_BAR_HEIGHT, FLOATING_TAB_BAR_HEIGHT_LARGE, FLOATING_RADIUS, FLOATING_ROW_RADIUS, FLOATING_PILL_RADIUS, floatingShadow, floatingHairline, floatingFill, floatingSolidFill, tabBarReserve } from "./floating";
7
10
  export { impactHaptic, notificationHaptic, selectionHaptic } from "./haptics";
@@ -0,0 +1,163 @@
1
+ import { configureTheme } from "./configureTheme";
2
+ import { palette, withAlpha } from "./palette";
3
+ import { tokens } from "./tokens";
4
+
5
+ /** The web Neutral theme (`.dark.neutral` in `@vvedantb/ui` tokens.css), as hex. */
6
+ export const NEUTRAL_PALETTE = {
7
+ background: "#222325",
8
+ surface: "#303134",
9
+ surfaceSecondary: "#3a3b3e",
10
+ surfaceTertiary: "#444548",
11
+ border: "#4e4f52",
12
+ muted: "#9fa0a2",
13
+ foreground: "#fafafa"
14
+ };
15
+
16
+ /** The same colours as space-separated RGB channels, for NativeWind variables that take channels. */
17
+ export const NEUTRAL_CHANNELS = {
18
+ background: "34 35 37",
19
+ surface: "48 49 52",
20
+ surfaceSecondary: "58 59 62",
21
+ surfaceTertiary: "68 69 72",
22
+ border: "78 79 82",
23
+ muted: "159 160 162",
24
+ foreground: "250 250 250"
25
+ };
26
+
27
+ /** The kit dark-slot values that Neutral changes. */
28
+
29
+ /** The package dark values, copied at import so a Neutral pick can be undone. */
30
+ const DARK = {
31
+ color: {
32
+ background: tokens.color.background.dark,
33
+ foreground: tokens.color.foreground.dark,
34
+ muted: tokens.color.muted.dark,
35
+ border: tokens.color.border.dark,
36
+ separator: tokens.color.separator.dark,
37
+ surface: tokens.color.surface.dark,
38
+ surfaceSecondary: tokens.color.surfaceSecondary.dark,
39
+ surfaceCard: tokens.color.surfaceCard.dark,
40
+ fill: tokens.color.fill.dark
41
+ },
42
+ palette: {
43
+ default: palette.default.dark,
44
+ overlay: palette.overlay.dark,
45
+ segment: palette.segment.dark,
46
+ surfaceTertiary: palette.surfaceTertiary.dark,
47
+ fieldPlaceholder: palette.fieldPlaceholder.dark,
48
+ tabBarPill: palette.tabBarPill.dark
49
+ }
50
+ };
51
+ const NEUTRAL = {
52
+ color: {
53
+ background: NEUTRAL_PALETTE.background,
54
+ foreground: NEUTRAL_PALETTE.foreground,
55
+ muted: NEUTRAL_PALETTE.muted,
56
+ border: NEUTRAL_PALETTE.border,
57
+ separator: NEUTRAL_PALETTE.surfaceSecondary,
58
+ surface: NEUTRAL_PALETTE.surface,
59
+ surfaceSecondary: NEUTRAL_PALETTE.surfaceSecondary,
60
+ surfaceCard: NEUTRAL_PALETTE.surface,
61
+ // The package glass is its dark surface at 88%; Neutral's surface the same.
62
+ fill: withAlpha(NEUTRAL_PALETTE.surface, 0.88)
63
+ },
64
+ palette: {
65
+ default: NEUTRAL_PALETTE.surfaceTertiary,
66
+ overlay: NEUTRAL_PALETTE.surface,
67
+ segment: NEUTRAL_PALETTE.surfaceTertiary,
68
+ surfaceTertiary: NEUTRAL_PALETTE.surfaceTertiary,
69
+ fieldPlaceholder: NEUTRAL_PALETTE.muted,
70
+ tabBarPill: NEUTRAL_PALETTE.surfaceTertiary
71
+ }
72
+ };
73
+
74
+ /** Dark-slot colours that replace the ones `paintDarkFamily` would paint. */
75
+
76
+ /**
77
+ * Puts the Dark or Neutral colours in the kit's dark slot (`configureTheme`).
78
+ * Light is not changed. Kit parts under `NativeUiProvider` redraw at once.
79
+ * Status and accent colours stay Dark's. `overrides` replaces any painted
80
+ * dark-slot colour, for an app that keeps its own value.
81
+ */
82
+ export function paintDarkFamily(family, overrides) {
83
+ const base = family === "neutral" ? NEUTRAL : DARK;
84
+ const next = {
85
+ color: {
86
+ ...base.color,
87
+ ...overrides?.color
88
+ },
89
+ palette: {
90
+ ...base.palette,
91
+ ...overrides?.palette
92
+ }
93
+ };
94
+ const {
95
+ color
96
+ } = tokens;
97
+ configureTheme({
98
+ color: {
99
+ background: {
100
+ light: color.background.light,
101
+ dark: next.color.background
102
+ },
103
+ foreground: {
104
+ light: color.foreground.light,
105
+ dark: next.color.foreground
106
+ },
107
+ muted: {
108
+ light: color.muted.light,
109
+ dark: next.color.muted
110
+ },
111
+ border: {
112
+ light: color.border.light,
113
+ dark: next.color.border
114
+ },
115
+ separator: {
116
+ light: color.separator.light,
117
+ dark: next.color.separator
118
+ },
119
+ surface: {
120
+ light: color.surface.light,
121
+ dark: next.color.surface
122
+ },
123
+ surfaceSecondary: {
124
+ light: color.surfaceSecondary.light,
125
+ dark: next.color.surfaceSecondary
126
+ },
127
+ surfaceCard: {
128
+ light: color.surfaceCard.light,
129
+ dark: next.color.surfaceCard
130
+ },
131
+ fill: {
132
+ light: color.fill.light,
133
+ dark: next.color.fill
134
+ }
135
+ },
136
+ palette: {
137
+ default: {
138
+ light: palette.default.light,
139
+ dark: next.palette.default
140
+ },
141
+ overlay: {
142
+ light: palette.overlay.light,
143
+ dark: next.palette.overlay
144
+ },
145
+ segment: {
146
+ light: palette.segment.light,
147
+ dark: next.palette.segment
148
+ },
149
+ surfaceTertiary: {
150
+ light: palette.surfaceTertiary.light,
151
+ dark: next.palette.surfaceTertiary
152
+ },
153
+ fieldPlaceholder: {
154
+ light: palette.fieldPlaceholder.light,
155
+ dark: next.palette.fieldPlaceholder
156
+ },
157
+ tabBarPill: {
158
+ light: palette.tabBarPill.light,
159
+ dark: next.palette.tabBarPill
160
+ }
161
+ }
162
+ });
163
+ }
@@ -1,9 +1,5 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import * as React from "react";
3
-
4
- // Tabler, not Lucide: a Lucide icon always sets `testID` on its `Svg`, which
5
- // on web is a DOM `<svg>`, so React logs it as an unknown DOM prop.
6
-
7
3
  function Icon(t0) {
8
4
  const $ = _c(6);
9
5
  let Component;
@@ -1,7 +1,5 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import * as SelectPrimitive from "@rn-primitives/select";
3
- // Tabler, not Lucide: a Lucide icon always sets `testID` on its `Svg`, which
4
- // on web is a DOM `<svg>`, so React logs it as an unknown DOM prop.
5
3
  import { IconCheck, IconChevronDown, IconChevronUp } from "@tabler/icons-react-native";
6
4
  import * as React from "react";
7
5
  import { Platform, ScrollView, StyleSheet, Text, View } from "react-native";
@@ -8,11 +8,8 @@ import { palette, withAlpha } from "../palette";
8
8
  import { useLargerText } from "../theme";
9
9
  import { tokens } from "../tokens";
10
10
  import { useScheme } from "../useScheme";
11
-
12
- /** A theme the picker can show, as the web `ThemeModePicker`. Neutral is the dark scheme with a grey palette. */
13
-
14
- /** Default order: light to dark, then system. */
15
- export const THEME_MODES = ["light", "neutral", "dark", "system"];
11
+ import { THEME_MODES } from "../themeModes";
12
+ export { THEME_MODES };
16
13
  const LABELS = {
17
14
  light: "Light",
18
15
  neutral: "Neutral",
@@ -0,0 +1,67 @@
1
+ import { colorScheme } from "nativewind";
2
+ import { useSyncExternalStore } from "react";
3
+ import { paintDarkFamily } from "./neutralTheme";
4
+ import { parseThemeMode } from "./themeModes";
5
+
6
+ /** Where the mode is kept: SecureStore, AsyncStorage or the app's own store. Sync or async. */
7
+
8
+ function toError(error) {
9
+ return error instanceof Error ? error : new Error(String(error));
10
+ }
11
+
12
+ /**
13
+ * The appearance mode of this phone: light, neutral, dark or system, starting
14
+ * at "system". Neutral is the NativeWind dark scheme with the Neutral palette
15
+ * in the kit's dark slot (`paintDarkFamily`).
16
+ */
17
+ export function createThemeModeStore({
18
+ key,
19
+ storage,
20
+ onError
21
+ }) {
22
+ let current = "system";
23
+ /** True once the user picked a mode: a slow restore must not undo it. */
24
+ let chosen = false;
25
+ const listeners = new Set();
26
+ const report = error => onError?.(toError(error));
27
+
28
+ /** Paints `mode`. The dark slot goes first, so the scheme change redraws with it. */
29
+ function apply(mode) {
30
+ current = mode;
31
+ paintDarkFamily(mode === "neutral" ? "neutral" : "dark");
32
+ colorScheme.set(mode === "neutral" ? "dark" : mode);
33
+ for (const listener of listeners) listener();
34
+ }
35
+ function subscribe(listener) {
36
+ listeners.add(listener);
37
+ return () => {
38
+ listeners.delete(listener);
39
+ };
40
+ }
41
+ const getMode = () => current;
42
+ async function restore() {
43
+ let saved = null;
44
+ try {
45
+ saved = await storage.getItem(key);
46
+ } catch (error) {
47
+ report(error instanceof Error ? error : String(error));
48
+ }
49
+ if (chosen) return;
50
+ apply(parseThemeMode(saved) ?? "system");
51
+ }
52
+ function set(mode) {
53
+ chosen = true;
54
+ if (mode !== current) apply(mode);
55
+ Promise.resolve().then(() => storage.setItem(key, mode)).catch(report);
56
+ }
57
+
58
+ /** Server render and hydration: the mode is always "system" until `restore` runs on the client. */
59
+ const getServerSnapshot = () => "system";
60
+ return {
61
+ getMode,
62
+ subscribe,
63
+ restore,
64
+ set,
65
+ useMode: () => useSyncExternalStore(subscribe, getMode, getServerSnapshot)
66
+ };
67
+ }
@@ -0,0 +1,9 @@
1
+ /** A theme the picker can show, as the web `ThemeModePicker`. Neutral is the dark scheme with a grey palette. */
2
+
3
+ /** Default order: light to dark, then system. */
4
+ export const THEME_MODES = ["light", "neutral", "dark", "system"];
5
+
6
+ /** The mode that `value` names, or `undefined` for anything else (a missing or stale stored value). */
7
+ export function parseThemeMode(value) {
8
+ return THEME_MODES.find(mode => mode === value);
9
+ }