@kbach/react-native 1.0.0-beta.3 → 1.0.0-beta.30

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/dist/index.mjs DELETED
@@ -1,80 +0,0 @@
1
- import {
2
- defaultTheme,
3
- getGlobalDarkMode,
4
- getGlobalThemeMode,
5
- getTheme,
6
- resolveStyle,
7
- seedDefaultMode,
8
- setGlobalThemeMode,
9
- setTheme,
10
- subscribeGlobalDarkMode,
11
- toggleGlobalDarkMode
12
- } from "./chunk-7KUNKZBM.mjs";
13
-
14
- // src/useGlobalDarkMode.ts
15
- import { useSyncExternalStore } from "react";
16
- function useGlobalDarkMode() {
17
- return useSyncExternalStore(subscribeGlobalDarkMode, getGlobalDarkMode);
18
- }
19
-
20
- // src/ThemeProvider.tsx
21
- import { useEffect, useMemo, useRef, useSyncExternalStore as useSyncExternalStore2 } from "react";
22
-
23
- // src/ThemeContext.tsx
24
- import { createContext, useContext } from "react";
25
- var ThemeContext = createContext(null);
26
- function useTheme() {
27
- const ctx = useContext(ThemeContext);
28
- if (!ctx) {
29
- throw new Error(
30
- 'useTheme() must be called within a <ThemeProvider>. For dark-mode state without a provider, use useGlobalDarkMode() (read) or toggleGlobalDarkMode()/setGlobalThemeMode() (write) from "@kbach/react-native" instead.'
31
- );
32
- }
33
- return ctx;
34
- }
35
-
36
- // src/ThemeProvider.tsx
37
- import { jsx } from "react/jsx-runtime";
38
- var mountedProviderCount = 0;
39
- var warnedMultipleProviders = false;
40
- function ThemeProvider({ children, defaultMode = "system" }) {
41
- useEffect(() => {
42
- mountedProviderCount++;
43
- if (mountedProviderCount > 1 && !warnedMultipleProviders) {
44
- warnedMultipleProviders = true;
45
- console.warn(
46
- "[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store (the same one useGlobalDarkMode()/toggleGlobalDarkMode() read and write), not scoped per-provider, so they will fight over the same state instead of each getting their own."
47
- );
48
- }
49
- return () => {
50
- mountedProviderCount--;
51
- };
52
- }, []);
53
- const seeded = useRef(false);
54
- useEffect(() => {
55
- if (seeded.current) return;
56
- seeded.current = true;
57
- seedDefaultMode(defaultMode);
58
- }, []);
59
- const isDark = useSyncExternalStore2(subscribeGlobalDarkMode, getGlobalDarkMode);
60
- const mode = useSyncExternalStore2(subscribeGlobalDarkMode, getGlobalThemeMode);
61
- const value = useMemo(
62
- () => ({ mode, isDark, setMode: setGlobalThemeMode, toggle: toggleGlobalDarkMode }),
63
- [mode, isDark]
64
- );
65
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value, children });
66
- }
67
- export {
68
- ThemeProvider,
69
- defaultTheme,
70
- getGlobalDarkMode,
71
- getGlobalThemeMode,
72
- getTheme,
73
- resolveStyle,
74
- setGlobalThemeMode,
75
- setTheme,
76
- subscribeGlobalDarkMode,
77
- toggleGlobalDarkMode,
78
- useGlobalDarkMode,
79
- useTheme
80
- };
@@ -1,19 +0,0 @@
1
- import { ReactElement } from 'react';
2
- export { Fragment } from 'react';
3
-
4
- /**
5
- * @kbach/react-native/jsx-dev-runtime
6
- *
7
- * Development variant — Metro calls jsxDEV instead of jsx/jsxs in dev
8
- * builds. Same pattern as @kbach/react/jsx-dev-runtime (Phase 3): reuses
9
- * jsx/jsxs for the actual interception, then patches _source/_self onto
10
- * the result so React DevTools shows the original file/line.
11
- */
12
-
13
- declare function jsxDEV(type: unknown, props: Record<string, unknown> | null, key?: string, isStaticChildren?: boolean, source?: {
14
- fileName: string;
15
- lineNumber: number;
16
- columnNumber: number;
17
- }, self?: unknown): ReactElement;
18
-
19
- export { jsxDEV };
@@ -1,20 +0,0 @@
1
- import {
2
- Fragment,
3
- jsx,
4
- jsxs
5
- } from "./chunk-UP5ZN7CN.mjs";
6
- import "./chunk-7KUNKZBM.mjs";
7
-
8
- // src/jsx-dev-runtime.tsx
9
- function jsxDEV(type, props, key, isStaticChildren, source, self) {
10
- const element = (isStaticChildren ? jsxs : jsx)(type, props, key);
11
- if (source && element && typeof element === "object" && Object.isExtensible(element)) {
12
- element._source = source;
13
- element._self = self;
14
- }
15
- return element;
16
- }
17
- export {
18
- Fragment,
19
- jsxDEV
20
- };
@@ -1,30 +0,0 @@
1
- import { ReactElement } from 'react';
2
- export { Fragment, JSX } from 'react';
3
-
4
- /**
5
- * @kbach/react-native/jsx-runtime
6
- *
7
- * Drop-in replacement for react/jsx-runtime — same interception shape as
8
- * @kbach/react/jsx-runtime (Phase 3), but the resolved value becomes the
9
- * `style` prop instead of `className`: View/Text have no `className` prop
10
- * at all. Covers layout, color, spacing, border, typography, dark:,
11
- * active: (Pressable only), and sm:/md:/lg:/xl:/2xl: (gated against the
12
- * current window width, live) — see nativeBridge.ts / resolve_style.rs for
13
- * exactly what's resolved; every other modifier (hover:, group- and peer-
14
- * variants, has-[...], container queries, ...) parses but isn't applied —
15
- * there's no selector/pseudo-state/ancestor system on native to apply them
16
- * with.
17
- *
18
- * `active:` needs different handling from every other modifier: whether an
19
- * element is "pressed" isn't a value that can be read once and reused like
20
- * `dark:`'s color scheme — only RN's `Pressable` ever knows it, and only
21
- * via a style FUNCTION it calls on every press/release
22
- * (`style={({pressed}) => ...}`). So for `type === Pressable` specifically,
23
- * `style` is built as a function instead of a static value; every other
24
- * element type is completely unaffected by this — same code path as before.
25
- */
26
-
27
- declare function jsx(type: unknown, props: Record<string, unknown> | null, key?: string): ReactElement;
28
- declare function jsxs(type: unknown, props: Record<string, unknown> | null, key?: string): ReactElement;
29
-
30
- export { jsx, jsxs };