@multiplatform.one/core 6.0.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.
- package/CHANGELOG.md +25 -0
- package/LICENSE +201 -0
- package/package.json +126 -0
- package/src/app/CreateApp.tsx +325 -0
- package/src/app/CreateRootLayout.native.tsx +74 -0
- package/src/app/CreateRootLayout.tsx +66 -0
- package/src/app/CreateRootLayout.web.tsx +181 -0
- package/src/app/TanstackDevtools.tsx +138 -0
- package/src/app/TanstackProvider.tsx +41 -0
- package/src/app/index.ts +27 -0
- package/src/app/loadWalletProvider.d.ts +7 -0
- package/src/app/loadWalletProvider.native.ts +14 -0
- package/src/app/loadWalletProvider.web.ts +10 -0
- package/src/app/rootLayoutShared.ts +60 -0
- package/src/app/tanstackProvider.native.tsx +13 -0
- package/src/healthz.ts +4 -0
- package/src/index.ts +2 -0
- package/src/layouts/CreateDefaultLayout.tsx +127 -0
- package/src/layouts/index.ts +6 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
|
+
import { YStack } from "tamagui";
|
|
3
|
+
import { config } from "@multiplatform.one/platform";
|
|
4
|
+
import { createWithLayout, type WithLayout } from "@multiplatform.one/platform";
|
|
5
|
+
|
|
6
|
+
export type SafeAreaEdge = "top" | "bottom" | "left" | "right";
|
|
7
|
+
|
|
8
|
+
export interface CreateDefaultLayoutOptions {
|
|
9
|
+
/**
|
|
10
|
+
* SafeArea wrapper component.
|
|
11
|
+
* Pass SafeAreaWrapper from @multiplatform.one/components.
|
|
12
|
+
*/
|
|
13
|
+
SafeAreaWrapper?: ComponentType<any>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Edges to apply safe area insets to.
|
|
17
|
+
* @default ["top", "left", "right"]
|
|
18
|
+
*/
|
|
19
|
+
safeAreaEdges?: SafeAreaEdge[];
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Background color token for the safe area wrapper.
|
|
23
|
+
* @default "$background"
|
|
24
|
+
*/
|
|
25
|
+
safeAreaBackground?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* KeyboardAvoiding wrapper component.
|
|
29
|
+
* Pass KeyboardAvoidingWrapper from @multiplatform.one/components.
|
|
30
|
+
*/
|
|
31
|
+
KeyboardAvoidingWrapper?: ComponentType<any>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Background color token for the content area.
|
|
35
|
+
* @default "$background"
|
|
36
|
+
*/
|
|
37
|
+
background?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Toast component to render inside the layout.
|
|
41
|
+
*/
|
|
42
|
+
Toast?: ComponentType;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Debug overlay configuration.
|
|
46
|
+
* - `true`: enable a minimal debug overlay (visible when DEBUG=1)
|
|
47
|
+
* - `ComponentType`: render this component as the debug view when DEBUG=1
|
|
48
|
+
*/
|
|
49
|
+
debug?: boolean | ComponentType;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Additional layout HOCs to compose with the default layout.
|
|
53
|
+
*/
|
|
54
|
+
extraLayouts?: WithLayout[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface DefaultLayoutProps {
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Factory that creates a DefaultLayout component and withDefaultLayout HOC
|
|
63
|
+
* from configuration. Handles SafeArea, KeyboardAvoiding, fullscreen YStack,
|
|
64
|
+
* Toast, and optional debug overlay composition.
|
|
65
|
+
*/
|
|
66
|
+
export function createDefaultLayout(options: CreateDefaultLayoutOptions = {}) {
|
|
67
|
+
const {
|
|
68
|
+
SafeAreaWrapper,
|
|
69
|
+
safeAreaEdges = ["top", "left", "right"],
|
|
70
|
+
safeAreaBackground = "$background",
|
|
71
|
+
KeyboardAvoidingWrapper,
|
|
72
|
+
background = "$background",
|
|
73
|
+
Toast,
|
|
74
|
+
debug = false,
|
|
75
|
+
extraLayouts = [],
|
|
76
|
+
} = options;
|
|
77
|
+
|
|
78
|
+
function DefaultLayout({ children }: DefaultLayoutProps) {
|
|
79
|
+
let content = (
|
|
80
|
+
<YStack
|
|
81
|
+
position="absolute"
|
|
82
|
+
top={0}
|
|
83
|
+
right={0}
|
|
84
|
+
bottom={0}
|
|
85
|
+
left={0}
|
|
86
|
+
backgroundColor={background}
|
|
87
|
+
>
|
|
88
|
+
{children}
|
|
89
|
+
{Toast && <Toast />}
|
|
90
|
+
</YStack>
|
|
91
|
+
);
|
|
92
|
+
if (KeyboardAvoidingWrapper) {
|
|
93
|
+
content = <KeyboardAvoidingWrapper flex={1}>{content}</KeyboardAvoidingWrapper>;
|
|
94
|
+
}
|
|
95
|
+
if (SafeAreaWrapper) {
|
|
96
|
+
content = (
|
|
97
|
+
<SafeAreaWrapper edges={safeAreaEdges} bg={safeAreaBackground}>
|
|
98
|
+
{content}
|
|
99
|
+
</SafeAreaWrapper>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return content;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const allExtraLayouts = [...extraLayouts];
|
|
106
|
+
if (debug) {
|
|
107
|
+
const DebugView = typeof debug === "function" ? debug : undefined;
|
|
108
|
+
const withDebug = createWithLayout(({ children }: { children: ReactNode }) => {
|
|
109
|
+
if (config.get("DEBUG") !== "1") return <>{children}</>;
|
|
110
|
+
return (
|
|
111
|
+
<YStack position="absolute" top={0} right={0} bottom={0} left={0}>
|
|
112
|
+
{children}
|
|
113
|
+
{DebugView && (
|
|
114
|
+
<YStack position="absolute" pointerEvents="box-none">
|
|
115
|
+
<DebugView />
|
|
116
|
+
</YStack>
|
|
117
|
+
)}
|
|
118
|
+
</YStack>
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
allExtraLayouts.push(withDebug);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const withDefaultLayout = createWithLayout(DefaultLayout, allExtraLayouts);
|
|
125
|
+
|
|
126
|
+
return { DefaultLayout, withDefaultLayout };
|
|
127
|
+
}
|
package/tsconfig.json
ADDED