reactnatively-primitives 0.1.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/LICENSE +20 -0
- package/dist/index.d.mts +237 -0
- package/dist/index.d.ts +237 -0
- package/dist/index.js +467 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +453 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Hakizimana Fred
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewProps, StyleProp, ViewStyle, PressableProps, TextProps, TextStyle } from 'react-native';
|
|
3
|
+
import { GlassElevation, GlassTintVariant, GlassHighlight, RadiiKey, ThemeColorKey, fontWeight, lineHeight } from 'reactnatively-theme';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Full glass configuration for when fine-grained control is needed.
|
|
8
|
+
* Pass this as the `glass` prop to Surface.
|
|
9
|
+
*/
|
|
10
|
+
interface GlassSurfaceConfig {
|
|
11
|
+
elevation?: GlassElevation;
|
|
12
|
+
variant?: GlassTintVariant;
|
|
13
|
+
highlight?: GlassHighlight | boolean;
|
|
14
|
+
border?: boolean;
|
|
15
|
+
borderWidth?: number;
|
|
16
|
+
blurOverride?: number;
|
|
17
|
+
tintOverride?: string;
|
|
18
|
+
glow?: {
|
|
19
|
+
color: string;
|
|
20
|
+
radius?: number;
|
|
21
|
+
opacity?: number;
|
|
22
|
+
} | false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Surface is the unified rendering unit.
|
|
26
|
+
*
|
|
27
|
+
* - glass={true} → GlassView with optional shorthand elevation/variant
|
|
28
|
+
* - glass={GlassSurfaceConfig} → GlassView with full config
|
|
29
|
+
* - glass={false} | undefined → plain View with optional bg color
|
|
30
|
+
* - animated={true} → wraps the output in Reanimated Animated.View
|
|
31
|
+
*/
|
|
32
|
+
interface SurfaceProps extends Omit<ViewProps, 'style'> {
|
|
33
|
+
/** Enable glass rendering. Pass true for defaults or a GlassSurfaceConfig for full control. */
|
|
34
|
+
glass?: boolean | GlassSurfaceConfig;
|
|
35
|
+
/** Shorthand glass elevation — only meaningful when glass=true */
|
|
36
|
+
elevation?: GlassElevation;
|
|
37
|
+
/** Shorthand glass variant — only meaningful when glass=true */
|
|
38
|
+
variant?: GlassTintVariant;
|
|
39
|
+
/** Solid background color (used when glass is false or undefined) */
|
|
40
|
+
bg?: string;
|
|
41
|
+
/** Border radius — accepts a RadiiKey token name or a raw pixel number */
|
|
42
|
+
borderRadius?: number | RadiiKey;
|
|
43
|
+
/** Show a border ring */
|
|
44
|
+
border?: boolean;
|
|
45
|
+
/** Border color override */
|
|
46
|
+
borderColor?: string;
|
|
47
|
+
/** Border width override */
|
|
48
|
+
borderWidth?: number;
|
|
49
|
+
/** Wrap in Reanimated Animated.View for animated transforms */
|
|
50
|
+
animated?: boolean;
|
|
51
|
+
style?: StyleProp<ViewStyle>;
|
|
52
|
+
/** Style applied to the inner content wrapper (passed through to GlassView contentStyle or plain View) */
|
|
53
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Surface — the unified rendering primitive.
|
|
59
|
+
*
|
|
60
|
+
* Handles three rendering paths:
|
|
61
|
+
* 1. glass=true/config → GlassView (liquid glass layer stack)
|
|
62
|
+
* 2. solid bg → plain View with backgroundColor
|
|
63
|
+
* 3. animated=true → wraps whichever output in Animated.View
|
|
64
|
+
*
|
|
65
|
+
* All hooks are called unconditionally (Rules of Hooks). The glass/solid
|
|
66
|
+
* branch decision happens in the return, not at hook call sites.
|
|
67
|
+
*/
|
|
68
|
+
declare const Surface: React.NamedExoticComponent<SurfaceProps>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* GlassPressable — animated pressable primitive built on Surface.
|
|
72
|
+
*
|
|
73
|
+
* Combines:
|
|
74
|
+
* - Surface (glass or solid background rendering)
|
|
75
|
+
* - Press scale + opacity animation via Reanimated
|
|
76
|
+
* - Optional haptic feedback via expo-haptics
|
|
77
|
+
*
|
|
78
|
+
* Used as the interactive base for all interactive glass components
|
|
79
|
+
* (buttons, cards, pills, chips, etc.)
|
|
80
|
+
*/
|
|
81
|
+
interface GlassPressableProps extends Omit<PressableProps, 'style' | 'children'>, Omit<SurfaceProps, 'animated'> {
|
|
82
|
+
/** Scale factor applied on press. Default: 0.97 */
|
|
83
|
+
pressedScale?: number;
|
|
84
|
+
/** Opacity applied on press. Default: 0.90 */
|
|
85
|
+
pressedOpacity?: number;
|
|
86
|
+
/** Fire a haptic impact on press (requires expo-haptics). Default: false */
|
|
87
|
+
haptic?: boolean;
|
|
88
|
+
/** Show a loading state (disables interactions and passes through to children). Default: false */
|
|
89
|
+
loading?: boolean;
|
|
90
|
+
/** Disable all interactions. Default: false */
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* GlassPressable — the interactive foundation of the Reactnatively component system.
|
|
96
|
+
*
|
|
97
|
+
* Layer order (outer → inner):
|
|
98
|
+
* Pressable (touch target)
|
|
99
|
+
* └─ Animated.View (scale + opacity spring animation)
|
|
100
|
+
* └─ Surface (glass or solid background)
|
|
101
|
+
* └─ children
|
|
102
|
+
*/
|
|
103
|
+
declare const GlassPressable: React.NamedExoticComponent<GlassPressableProps>;
|
|
104
|
+
|
|
105
|
+
interface PortalProps {
|
|
106
|
+
children: ReactNode;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Portal — mounts its children into the PortalProvider's host layer.
|
|
110
|
+
*
|
|
111
|
+
* Renders nothing at its own position in the tree; the children appear
|
|
112
|
+
* above all other content at zIndex 9999 via the PortalProvider.
|
|
113
|
+
*
|
|
114
|
+
* Usage:
|
|
115
|
+
* ```tsx
|
|
116
|
+
* <Portal>
|
|
117
|
+
* <ModalContent />
|
|
118
|
+
* </Portal>
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* Lifecycle:
|
|
122
|
+
* - mount → registers children in the portal registry
|
|
123
|
+
* - update → keeps the portal in sync when children change
|
|
124
|
+
* - unmount → removes children from the registry
|
|
125
|
+
*/
|
|
126
|
+
declare function Portal({ children }: PortalProps): null;
|
|
127
|
+
declare namespace Portal {
|
|
128
|
+
var displayName: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* PortalHost — an additional named host for portals that need to be
|
|
133
|
+
* scoped below the root-level PortalProvider host.
|
|
134
|
+
*
|
|
135
|
+
* The root host is rendered automatically inside PortalProvider.
|
|
136
|
+
* Use PortalHost if you want a secondary portal target inside a specific
|
|
137
|
+
* screen or layout region (e.g. inside a bottom sheet for nested portals).
|
|
138
|
+
*
|
|
139
|
+
* Must be placed inside a PortalProvider.
|
|
140
|
+
*/
|
|
141
|
+
declare const PortalHost: React.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
142
|
+
|
|
143
|
+
interface PortalProviderProps {
|
|
144
|
+
children: ReactNode;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* PortalProvider — must wrap the root of your app (alongside ThemeProvider).
|
|
148
|
+
*
|
|
149
|
+
* Maintains the registry of active portal entries and renders them in a
|
|
150
|
+
* full-screen host view layered above all other content (zIndex 9999).
|
|
151
|
+
*
|
|
152
|
+
* Architecture:
|
|
153
|
+
* - entries state holds { key, element }[] — a plain array so React
|
|
154
|
+
* reconciles portal renders without needing forceUpdate hacks.
|
|
155
|
+
* - mount/update/unmount are stable references via useCallback.
|
|
156
|
+
*/
|
|
157
|
+
declare const PortalProvider: React.NamedExoticComponent<PortalProviderProps>;
|
|
158
|
+
|
|
159
|
+
interface PortalEntry {
|
|
160
|
+
key: string;
|
|
161
|
+
element: ReactNode;
|
|
162
|
+
}
|
|
163
|
+
interface PortalContextValue {
|
|
164
|
+
mount: (key: string, element: ReactNode) => void;
|
|
165
|
+
unmount: (key: string) => void;
|
|
166
|
+
update: (key: string, element: ReactNode) => void;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* usePortal — access the portal mount/unmount/update API.
|
|
171
|
+
*
|
|
172
|
+
* @throws if called outside a PortalProvider.
|
|
173
|
+
*/
|
|
174
|
+
declare function usePortal(): PortalContextValue;
|
|
175
|
+
|
|
176
|
+
interface SlotProps {
|
|
177
|
+
children?: React.ReactNode;
|
|
178
|
+
style?: StyleProp<ViewStyle>;
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Slot — Radix-style render delegation primitive.
|
|
183
|
+
*
|
|
184
|
+
* Merges its own props with the single child element's props, then renders
|
|
185
|
+
* that child (not a wrapper element). Event handlers from both Slot and the
|
|
186
|
+
* child are composed so both fire. Styles are merged with the child's styles
|
|
187
|
+
* taking precedence.
|
|
188
|
+
*
|
|
189
|
+
* Usage — implementing `asChild` on a component:
|
|
190
|
+
* ```tsx
|
|
191
|
+
* function Button({ asChild, ...props }) {
|
|
192
|
+
* const Comp = asChild ? Slot : Pressable;
|
|
193
|
+
* return <Comp {...props} />;
|
|
194
|
+
* }
|
|
195
|
+
*
|
|
196
|
+
* // Render a Link as a button:
|
|
197
|
+
* <Button asChild>
|
|
198
|
+
* <Link href="/home" />
|
|
199
|
+
* </Button>
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare const Slot: React.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & React.RefAttributes<unknown>>;
|
|
203
|
+
|
|
204
|
+
/** Semantic text roles — map to predefined size + weight + line-height combos */
|
|
205
|
+
type GlassTextVariant = 'display' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading' | 'body' | 'bodyLarge' | 'label' | 'caption' | 'overline' | 'code';
|
|
206
|
+
type GlassTextWeight = keyof typeof fontWeight;
|
|
207
|
+
interface GlassTextProps extends Omit<TextProps, 'style'> {
|
|
208
|
+
/** Semantic variant. Defaults to 'body'. */
|
|
209
|
+
variant?: GlassTextVariant;
|
|
210
|
+
/** Theme color key or any valid CSS/RN color string */
|
|
211
|
+
color?: ThemeColorKey | string;
|
|
212
|
+
/** Override font weight token */
|
|
213
|
+
weight?: GlassTextWeight;
|
|
214
|
+
/** Override font size in pixels */
|
|
215
|
+
size?: number;
|
|
216
|
+
/** Override line height multiplier */
|
|
217
|
+
leading?: keyof typeof lineHeight;
|
|
218
|
+
/** Uppercase transform (auto-applied for 'overline' variant) */
|
|
219
|
+
uppercase?: boolean;
|
|
220
|
+
style?: TextStyle | TextStyle[];
|
|
221
|
+
children?: ReactNode;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* GlassText — theme-aware text primitive.
|
|
225
|
+
*
|
|
226
|
+
* Automatically applies typography scale tokens and theme colors.
|
|
227
|
+
* All variants are memoized; only re-resolves when props change.
|
|
228
|
+
*
|
|
229
|
+
* ```tsx
|
|
230
|
+
* <GlassText variant="heading" color="primary">Hello</GlassText>
|
|
231
|
+
* <GlassText variant="caption" color="textMuted">Fine print</GlassText>
|
|
232
|
+
* <GlassText size={20} weight="bold">Custom size</GlassText>
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare const GlassText: React.NamedExoticComponent<GlassTextProps>;
|
|
236
|
+
|
|
237
|
+
export { GlassPressable, type GlassPressableProps, type GlassSurfaceConfig, GlassText, type GlassTextProps, type GlassTextVariant, type GlassTextWeight, Portal, type PortalContextValue, type PortalEntry, PortalHost, PortalProvider, Slot, Surface, type SurfaceProps, usePortal };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ViewProps, StyleProp, ViewStyle, PressableProps, TextProps, TextStyle } from 'react-native';
|
|
3
|
+
import { GlassElevation, GlassTintVariant, GlassHighlight, RadiiKey, ThemeColorKey, fontWeight, lineHeight } from 'reactnatively-theme';
|
|
4
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Full glass configuration for when fine-grained control is needed.
|
|
8
|
+
* Pass this as the `glass` prop to Surface.
|
|
9
|
+
*/
|
|
10
|
+
interface GlassSurfaceConfig {
|
|
11
|
+
elevation?: GlassElevation;
|
|
12
|
+
variant?: GlassTintVariant;
|
|
13
|
+
highlight?: GlassHighlight | boolean;
|
|
14
|
+
border?: boolean;
|
|
15
|
+
borderWidth?: number;
|
|
16
|
+
blurOverride?: number;
|
|
17
|
+
tintOverride?: string;
|
|
18
|
+
glow?: {
|
|
19
|
+
color: string;
|
|
20
|
+
radius?: number;
|
|
21
|
+
opacity?: number;
|
|
22
|
+
} | false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Surface is the unified rendering unit.
|
|
26
|
+
*
|
|
27
|
+
* - glass={true} → GlassView with optional shorthand elevation/variant
|
|
28
|
+
* - glass={GlassSurfaceConfig} → GlassView with full config
|
|
29
|
+
* - glass={false} | undefined → plain View with optional bg color
|
|
30
|
+
* - animated={true} → wraps the output in Reanimated Animated.View
|
|
31
|
+
*/
|
|
32
|
+
interface SurfaceProps extends Omit<ViewProps, 'style'> {
|
|
33
|
+
/** Enable glass rendering. Pass true for defaults or a GlassSurfaceConfig for full control. */
|
|
34
|
+
glass?: boolean | GlassSurfaceConfig;
|
|
35
|
+
/** Shorthand glass elevation — only meaningful when glass=true */
|
|
36
|
+
elevation?: GlassElevation;
|
|
37
|
+
/** Shorthand glass variant — only meaningful when glass=true */
|
|
38
|
+
variant?: GlassTintVariant;
|
|
39
|
+
/** Solid background color (used when glass is false or undefined) */
|
|
40
|
+
bg?: string;
|
|
41
|
+
/** Border radius — accepts a RadiiKey token name or a raw pixel number */
|
|
42
|
+
borderRadius?: number | RadiiKey;
|
|
43
|
+
/** Show a border ring */
|
|
44
|
+
border?: boolean;
|
|
45
|
+
/** Border color override */
|
|
46
|
+
borderColor?: string;
|
|
47
|
+
/** Border width override */
|
|
48
|
+
borderWidth?: number;
|
|
49
|
+
/** Wrap in Reanimated Animated.View for animated transforms */
|
|
50
|
+
animated?: boolean;
|
|
51
|
+
style?: StyleProp<ViewStyle>;
|
|
52
|
+
/** Style applied to the inner content wrapper (passed through to GlassView contentStyle or plain View) */
|
|
53
|
+
contentStyle?: StyleProp<ViewStyle>;
|
|
54
|
+
children?: ReactNode;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Surface — the unified rendering primitive.
|
|
59
|
+
*
|
|
60
|
+
* Handles three rendering paths:
|
|
61
|
+
* 1. glass=true/config → GlassView (liquid glass layer stack)
|
|
62
|
+
* 2. solid bg → plain View with backgroundColor
|
|
63
|
+
* 3. animated=true → wraps whichever output in Animated.View
|
|
64
|
+
*
|
|
65
|
+
* All hooks are called unconditionally (Rules of Hooks). The glass/solid
|
|
66
|
+
* branch decision happens in the return, not at hook call sites.
|
|
67
|
+
*/
|
|
68
|
+
declare const Surface: React.NamedExoticComponent<SurfaceProps>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* GlassPressable — animated pressable primitive built on Surface.
|
|
72
|
+
*
|
|
73
|
+
* Combines:
|
|
74
|
+
* - Surface (glass or solid background rendering)
|
|
75
|
+
* - Press scale + opacity animation via Reanimated
|
|
76
|
+
* - Optional haptic feedback via expo-haptics
|
|
77
|
+
*
|
|
78
|
+
* Used as the interactive base for all interactive glass components
|
|
79
|
+
* (buttons, cards, pills, chips, etc.)
|
|
80
|
+
*/
|
|
81
|
+
interface GlassPressableProps extends Omit<PressableProps, 'style' | 'children'>, Omit<SurfaceProps, 'animated'> {
|
|
82
|
+
/** Scale factor applied on press. Default: 0.97 */
|
|
83
|
+
pressedScale?: number;
|
|
84
|
+
/** Opacity applied on press. Default: 0.90 */
|
|
85
|
+
pressedOpacity?: number;
|
|
86
|
+
/** Fire a haptic impact on press (requires expo-haptics). Default: false */
|
|
87
|
+
haptic?: boolean;
|
|
88
|
+
/** Show a loading state (disables interactions and passes through to children). Default: false */
|
|
89
|
+
loading?: boolean;
|
|
90
|
+
/** Disable all interactions. Default: false */
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* GlassPressable — the interactive foundation of the Reactnatively component system.
|
|
96
|
+
*
|
|
97
|
+
* Layer order (outer → inner):
|
|
98
|
+
* Pressable (touch target)
|
|
99
|
+
* └─ Animated.View (scale + opacity spring animation)
|
|
100
|
+
* └─ Surface (glass or solid background)
|
|
101
|
+
* └─ children
|
|
102
|
+
*/
|
|
103
|
+
declare const GlassPressable: React.NamedExoticComponent<GlassPressableProps>;
|
|
104
|
+
|
|
105
|
+
interface PortalProps {
|
|
106
|
+
children: ReactNode;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Portal — mounts its children into the PortalProvider's host layer.
|
|
110
|
+
*
|
|
111
|
+
* Renders nothing at its own position in the tree; the children appear
|
|
112
|
+
* above all other content at zIndex 9999 via the PortalProvider.
|
|
113
|
+
*
|
|
114
|
+
* Usage:
|
|
115
|
+
* ```tsx
|
|
116
|
+
* <Portal>
|
|
117
|
+
* <ModalContent />
|
|
118
|
+
* </Portal>
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* Lifecycle:
|
|
122
|
+
* - mount → registers children in the portal registry
|
|
123
|
+
* - update → keeps the portal in sync when children change
|
|
124
|
+
* - unmount → removes children from the registry
|
|
125
|
+
*/
|
|
126
|
+
declare function Portal({ children }: PortalProps): null;
|
|
127
|
+
declare namespace Portal {
|
|
128
|
+
var displayName: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* PortalHost — an additional named host for portals that need to be
|
|
133
|
+
* scoped below the root-level PortalProvider host.
|
|
134
|
+
*
|
|
135
|
+
* The root host is rendered automatically inside PortalProvider.
|
|
136
|
+
* Use PortalHost if you want a secondary portal target inside a specific
|
|
137
|
+
* screen or layout region (e.g. inside a bottom sheet for nested portals).
|
|
138
|
+
*
|
|
139
|
+
* Must be placed inside a PortalProvider.
|
|
140
|
+
*/
|
|
141
|
+
declare const PortalHost: React.MemoExoticComponent<() => react_jsx_runtime.JSX.Element>;
|
|
142
|
+
|
|
143
|
+
interface PortalProviderProps {
|
|
144
|
+
children: ReactNode;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* PortalProvider — must wrap the root of your app (alongside ThemeProvider).
|
|
148
|
+
*
|
|
149
|
+
* Maintains the registry of active portal entries and renders them in a
|
|
150
|
+
* full-screen host view layered above all other content (zIndex 9999).
|
|
151
|
+
*
|
|
152
|
+
* Architecture:
|
|
153
|
+
* - entries state holds { key, element }[] — a plain array so React
|
|
154
|
+
* reconciles portal renders without needing forceUpdate hacks.
|
|
155
|
+
* - mount/update/unmount are stable references via useCallback.
|
|
156
|
+
*/
|
|
157
|
+
declare const PortalProvider: React.NamedExoticComponent<PortalProviderProps>;
|
|
158
|
+
|
|
159
|
+
interface PortalEntry {
|
|
160
|
+
key: string;
|
|
161
|
+
element: ReactNode;
|
|
162
|
+
}
|
|
163
|
+
interface PortalContextValue {
|
|
164
|
+
mount: (key: string, element: ReactNode) => void;
|
|
165
|
+
unmount: (key: string) => void;
|
|
166
|
+
update: (key: string, element: ReactNode) => void;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* usePortal — access the portal mount/unmount/update API.
|
|
171
|
+
*
|
|
172
|
+
* @throws if called outside a PortalProvider.
|
|
173
|
+
*/
|
|
174
|
+
declare function usePortal(): PortalContextValue;
|
|
175
|
+
|
|
176
|
+
interface SlotProps {
|
|
177
|
+
children?: React.ReactNode;
|
|
178
|
+
style?: StyleProp<ViewStyle>;
|
|
179
|
+
[key: string]: unknown;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Slot — Radix-style render delegation primitive.
|
|
183
|
+
*
|
|
184
|
+
* Merges its own props with the single child element's props, then renders
|
|
185
|
+
* that child (not a wrapper element). Event handlers from both Slot and the
|
|
186
|
+
* child are composed so both fire. Styles are merged with the child's styles
|
|
187
|
+
* taking precedence.
|
|
188
|
+
*
|
|
189
|
+
* Usage — implementing `asChild` on a component:
|
|
190
|
+
* ```tsx
|
|
191
|
+
* function Button({ asChild, ...props }) {
|
|
192
|
+
* const Comp = asChild ? Slot : Pressable;
|
|
193
|
+
* return <Comp {...props} />;
|
|
194
|
+
* }
|
|
195
|
+
*
|
|
196
|
+
* // Render a Link as a button:
|
|
197
|
+
* <Button asChild>
|
|
198
|
+
* <Link href="/home" />
|
|
199
|
+
* </Button>
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare const Slot: React.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & React.RefAttributes<unknown>>;
|
|
203
|
+
|
|
204
|
+
/** Semantic text roles — map to predefined size + weight + line-height combos */
|
|
205
|
+
type GlassTextVariant = 'display' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'heading' | 'body' | 'bodyLarge' | 'label' | 'caption' | 'overline' | 'code';
|
|
206
|
+
type GlassTextWeight = keyof typeof fontWeight;
|
|
207
|
+
interface GlassTextProps extends Omit<TextProps, 'style'> {
|
|
208
|
+
/** Semantic variant. Defaults to 'body'. */
|
|
209
|
+
variant?: GlassTextVariant;
|
|
210
|
+
/** Theme color key or any valid CSS/RN color string */
|
|
211
|
+
color?: ThemeColorKey | string;
|
|
212
|
+
/** Override font weight token */
|
|
213
|
+
weight?: GlassTextWeight;
|
|
214
|
+
/** Override font size in pixels */
|
|
215
|
+
size?: number;
|
|
216
|
+
/** Override line height multiplier */
|
|
217
|
+
leading?: keyof typeof lineHeight;
|
|
218
|
+
/** Uppercase transform (auto-applied for 'overline' variant) */
|
|
219
|
+
uppercase?: boolean;
|
|
220
|
+
style?: TextStyle | TextStyle[];
|
|
221
|
+
children?: ReactNode;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* GlassText — theme-aware text primitive.
|
|
225
|
+
*
|
|
226
|
+
* Automatically applies typography scale tokens and theme colors.
|
|
227
|
+
* All variants are memoized; only re-resolves when props change.
|
|
228
|
+
*
|
|
229
|
+
* ```tsx
|
|
230
|
+
* <GlassText variant="heading" color="primary">Hello</GlassText>
|
|
231
|
+
* <GlassText variant="caption" color="textMuted">Fine print</GlassText>
|
|
232
|
+
* <GlassText size={20} weight="bold">Custom size</GlassText>
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
declare const GlassText: React.NamedExoticComponent<GlassTextProps>;
|
|
236
|
+
|
|
237
|
+
export { GlassPressable, type GlassPressableProps, type GlassSurfaceConfig, GlassText, type GlassTextProps, type GlassTextVariant, type GlassTextWeight, Portal, type PortalContextValue, type PortalEntry, PortalHost, PortalProvider, Slot, Surface, type SurfaceProps, usePortal };
|