react-native-terra-ui 0.1.1 → 0.2.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 +90 -0
- package/lib/module/components/avatar/Avatar.js +118 -35
- package/lib/module/components/avatar/Avatar.js.map +1 -1
- package/lib/module/components/box/Box.js +15 -2
- package/lib/module/components/box/Box.js.map +1 -1
- package/lib/module/components/box/utils.js +4 -1
- package/lib/module/components/box/utils.js.map +1 -1
- package/lib/module/components/button/Button.js +7 -14
- package/lib/module/components/button/Button.js.map +1 -1
- package/lib/module/components/chip/Chip.js +372 -0
- package/lib/module/components/chip/Chip.js.map +1 -0
- package/lib/module/components/chip/index.js +4 -0
- package/lib/module/components/chip/index.js.map +1 -0
- package/lib/module/components/chip/types.js +2 -0
- package/lib/module/components/chip/types.js.map +1 -0
- package/lib/module/components/chip/utils.js +36 -0
- package/lib/module/components/chip/utils.js.map +1 -0
- package/lib/module/components/empty-state/EmptyState.js +200 -0
- package/lib/module/components/empty-state/EmptyState.js.map +1 -0
- package/lib/module/components/empty-state/index.js +4 -0
- package/lib/module/components/empty-state/index.js.map +1 -0
- package/lib/module/components/empty-state/types.js +2 -0
- package/lib/module/components/empty-state/types.js.map +1 -0
- package/lib/module/components/header/header-buttons.js +31 -36
- package/lib/module/components/header/header-buttons.js.map +1 -1
- package/lib/module/components/header/index.js +1 -1
- package/lib/module/components/header/index.js.map +1 -1
- package/lib/module/components/header/parts/HeaderGradientOverlay.js +38 -0
- package/lib/module/components/header/parts/HeaderGradientOverlay.js.map +1 -0
- package/lib/module/components/header/variants/LargeTitleHeader/index.js +69 -99
- package/lib/module/components/header/variants/LargeTitleHeader/index.js.map +1 -1
- package/lib/module/components/header/variants/TitleHeader/index.js +32 -63
- package/lib/module/components/header/variants/TitleHeader/index.js.map +1 -1
- package/lib/module/components/icon/Icon.js +20 -8
- package/lib/module/components/icon/Icon.js.map +1 -1
- package/lib/module/components/image/Image.js +54 -0
- package/lib/module/components/image/Image.js.map +1 -0
- package/lib/module/components/image/index.js +4 -0
- package/lib/module/components/image/index.js.map +1 -0
- package/lib/module/components/image/types.js +4 -0
- package/lib/module/components/image/types.js.map +1 -0
- package/lib/module/components/index.js +4 -0
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/portal/Portal.js +42 -0
- package/lib/module/components/portal/Portal.js.map +1 -0
- package/lib/module/components/portal/PortalContext.js +1 -16
- package/lib/module/components/portal/PortalContext.js.map +1 -1
- package/lib/module/components/portal/PortalHost.js +16 -14
- package/lib/module/components/portal/PortalHost.js.map +1 -1
- package/lib/module/components/portal/PortalProvider.js +51 -19
- package/lib/module/components/portal/PortalProvider.js.map +1 -1
- package/lib/module/components/portal/index.js +1 -1
- package/lib/module/components/portal/index.js.map +1 -1
- package/lib/module/components/screen/Screen.js +25 -28
- package/lib/module/components/screen/Screen.js.map +1 -1
- package/lib/module/components/screen/ScreenContext.js +7 -5
- package/lib/module/components/screen/ScreenContext.js.map +1 -1
- package/lib/module/components/screen/ScreenFlashList.js +144 -0
- package/lib/module/components/screen/ScreenFlashList.js.map +1 -0
- package/lib/module/components/screen/ScreenFlatList.js +88 -27
- package/lib/module/components/screen/ScreenFlatList.js.map +1 -1
- package/lib/module/components/screen/ScreenScrollView.js +101 -34
- package/lib/module/components/screen/ScreenScrollView.js.map +1 -1
- package/lib/module/components/screen/index.js +1 -0
- package/lib/module/components/screen/index.js.map +1 -1
- package/lib/module/components/screen/parts/BottomSafeArea.js +62 -0
- package/lib/module/components/screen/parts/BottomSafeArea.js.map +1 -0
- package/lib/module/components/screen/parts/ScreenPlaceholder.js +50 -0
- package/lib/module/components/screen/parts/ScreenPlaceholder.js.map +1 -0
- package/lib/module/components/screen/types.js +4 -0
- package/lib/module/components/screen/types.js.map +1 -0
- package/lib/module/components/screen/utils.js +12 -9
- package/lib/module/components/screen/utils.js.map +1 -1
- package/lib/module/components/surface/Surface.js +16 -9
- package/lib/module/components/surface/Surface.js.map +1 -1
- package/lib/module/components/text/Text.js +23 -5
- package/lib/module/components/text/Text.js.map +1 -1
- package/lib/module/components/toast/Toast.js +8 -8
- package/lib/module/components/toast/Toast.js.map +1 -1
- package/lib/module/components/toolbar/Toolbar.js +268 -0
- package/lib/module/components/toolbar/Toolbar.js.map +1 -0
- package/lib/module/components/toolbar/index.js +4 -0
- package/lib/module/components/toolbar/index.js.map +1 -0
- package/lib/module/context/ThemeProvider.js +5 -2
- package/lib/module/context/ThemeProvider.js.map +1 -1
- package/lib/module/{components/icon/utils.js → theme/defaults/icons.js} +1 -1
- package/lib/module/theme/defaults/icons.js.map +1 -0
- package/lib/module/theme/defaults/image.js +30 -0
- package/lib/module/theme/defaults/image.js.map +1 -0
- package/lib/module/theme/index.js +1 -1
- package/lib/module/theme/{configure.js → registry.js} +21 -28
- package/lib/module/theme/registry.js.map +1 -0
- package/lib/module/theme/runtime.js +1 -1
- package/lib/module/theme/theme.js +91 -10
- package/lib/module/theme/theme.js.map +1 -1
- package/lib/module/theme/tokens/dark.js +59 -68
- package/lib/module/theme/tokens/dark.js.map +1 -1
- package/lib/module/theme/tokens/light.js +49 -67
- package/lib/module/theme/tokens/light.js.map +1 -1
- package/lib/module/theme/tokens/primitives.js +241 -20
- package/lib/module/theme/tokens/primitives.js.map +1 -1
- package/lib/module/utils/accent-utils.js +4 -4
- package/lib/module/utils/accent-utils.js.map +1 -1
- package/lib/typescript/src/components/avatar/Avatar.d.ts.map +1 -1
- package/lib/typescript/src/components/avatar/types.d.ts +4 -4
- package/lib/typescript/src/components/avatar/types.d.ts.map +1 -1
- package/lib/typescript/src/components/box/Box.d.ts.map +1 -1
- package/lib/typescript/src/components/box/utils.d.ts +6 -1
- package/lib/typescript/src/components/box/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/button/Button.d.ts +1 -1
- package/lib/typescript/src/components/button/Button.d.ts.map +1 -1
- package/lib/typescript/src/components/chip/Chip.d.ts +24 -0
- package/lib/typescript/src/components/chip/Chip.d.ts.map +1 -0
- package/lib/typescript/src/components/chip/index.d.ts +4 -0
- package/lib/typescript/src/components/chip/index.d.ts.map +1 -0
- package/lib/typescript/src/components/chip/types.d.ts +8 -0
- package/lib/typescript/src/components/chip/types.d.ts.map +1 -0
- package/lib/typescript/src/components/chip/utils.d.ts +8 -0
- package/lib/typescript/src/components/chip/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/empty-state/EmptyState.d.ts +45 -0
- package/lib/typescript/src/components/empty-state/EmptyState.d.ts.map +1 -0
- package/lib/typescript/src/components/empty-state/index.d.ts +4 -0
- package/lib/typescript/src/components/empty-state/index.d.ts.map +1 -0
- package/lib/typescript/src/components/empty-state/types.d.ts +6 -0
- package/lib/typescript/src/components/empty-state/types.d.ts.map +1 -0
- package/lib/typescript/src/components/header/header-buttons.d.ts +27 -0
- package/lib/typescript/src/components/header/header-buttons.d.ts.map +1 -1
- package/lib/typescript/src/components/header/index.d.ts +1 -1
- package/lib/typescript/src/components/header/index.d.ts.map +1 -1
- package/lib/typescript/src/components/header/parts/HeaderGradientOverlay.d.ts +7 -0
- package/lib/typescript/src/components/header/parts/HeaderGradientOverlay.d.ts.map +1 -0
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts +1 -1
- package/lib/typescript/src/components/header/variants/LargeTitleHeader/index.d.ts.map +1 -1
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts +18 -7
- package/lib/typescript/src/components/header/variants/TitleHeader/index.d.ts.map +1 -1
- package/lib/typescript/src/components/icon/Icon.d.ts.map +1 -1
- package/lib/typescript/src/components/image/Image.d.ts +16 -0
- package/lib/typescript/src/components/image/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/image/index.d.ts +3 -0
- package/lib/typescript/src/components/image/index.d.ts.map +1 -0
- package/lib/typescript/src/components/image/types.d.ts +7 -0
- package/lib/typescript/src/components/image/types.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +4 -0
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/portal/Portal.d.ts +26 -0
- package/lib/typescript/src/components/portal/Portal.d.ts.map +1 -0
- package/lib/typescript/src/components/portal/PortalContext.d.ts +11 -14
- package/lib/typescript/src/components/portal/PortalContext.d.ts.map +1 -1
- package/lib/typescript/src/components/portal/PortalHost.d.ts +9 -4
- package/lib/typescript/src/components/portal/PortalHost.d.ts.map +1 -1
- package/lib/typescript/src/components/portal/PortalProvider.d.ts +3 -3
- package/lib/typescript/src/components/portal/PortalProvider.d.ts.map +1 -1
- package/lib/typescript/src/components/portal/index.d.ts +4 -2
- package/lib/typescript/src/components/portal/index.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/Screen.d.ts +18 -13
- package/lib/typescript/src/components/screen/Screen.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenContext.d.ts +12 -9
- package/lib/typescript/src/components/screen/ScreenContext.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenFlashList.d.ts +43 -0
- package/lib/typescript/src/components/screen/ScreenFlashList.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts +17 -7
- package/lib/typescript/src/components/screen/ScreenFlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts +51 -16
- package/lib/typescript/src/components/screen/ScreenScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/index.d.ts +3 -0
- package/lib/typescript/src/components/screen/index.d.ts.map +1 -1
- package/lib/typescript/src/components/screen/parts/BottomSafeArea.d.ts +30 -0
- package/lib/typescript/src/components/screen/parts/BottomSafeArea.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/parts/ScreenPlaceholder.d.ts +22 -0
- package/lib/typescript/src/components/screen/parts/ScreenPlaceholder.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/types.d.ts +42 -0
- package/lib/typescript/src/components/screen/types.d.ts.map +1 -0
- package/lib/typescript/src/components/screen/utils.d.ts +9 -9
- package/lib/typescript/src/components/screen/utils.d.ts.map +1 -1
- package/lib/typescript/src/components/surface/Surface.d.ts +7 -0
- package/lib/typescript/src/components/surface/Surface.d.ts.map +1 -1
- package/lib/typescript/src/components/text/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/toolbar/Toolbar.d.ts +115 -0
- package/lib/typescript/src/components/toolbar/Toolbar.d.ts.map +1 -0
- package/lib/typescript/src/components/toolbar/index.d.ts +3 -0
- package/lib/typescript/src/components/toolbar/index.d.ts.map +1 -0
- package/lib/typescript/src/context/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/src/{components/icon/utils.d.ts → theme/defaults/icons.d.ts} +2 -2
- package/lib/typescript/src/theme/defaults/icons.d.ts.map +1 -0
- package/lib/typescript/src/theme/defaults/image.d.ts +4 -0
- package/lib/typescript/src/theme/defaults/image.d.ts.map +1 -0
- package/lib/typescript/src/theme/index.d.ts +1 -1
- package/lib/typescript/src/theme/index.d.ts.map +1 -1
- package/lib/typescript/src/theme/{configure.d.ts → registry.d.ts} +1 -1
- package/lib/typescript/src/theme/registry.d.ts.map +1 -0
- package/lib/typescript/src/theme/theme.d.ts +21 -1
- package/lib/typescript/src/theme/theme.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/dark.d.ts +41 -64
- package/lib/typescript/src/theme/tokens/dark.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/light.d.ts +44 -65
- package/lib/typescript/src/theme/tokens/light.d.ts.map +1 -1
- package/lib/typescript/src/theme/tokens/primitives.d.ts +228 -17
- package/lib/typescript/src/theme/tokens/primitives.d.ts.map +1 -1
- package/lib/typescript/src/theme/types.d.ts +65 -35
- package/lib/typescript/src/theme/types.d.ts.map +1 -1
- package/package.json +23 -9
- package/skills/terra-ui/SKILL.md +193 -0
- package/skills/terra-ui/references/recipes.md +198 -0
- package/skills/terra-ui/references/troubleshooting.md +112 -0
- package/src/components/avatar/Avatar.tsx +128 -38
- package/src/components/avatar/types.ts +5 -5
- package/src/components/box/Box.tsx +13 -1
- package/src/components/box/utils.ts +10 -0
- package/src/components/button/Button.tsx +7 -15
- package/src/components/chip/Chip.tsx +444 -0
- package/src/components/chip/index.ts +3 -0
- package/src/components/chip/types.ts +15 -0
- package/src/components/chip/utils.ts +34 -0
- package/src/components/empty-state/EmptyState.tsx +209 -0
- package/src/components/empty-state/index.ts +3 -0
- package/src/components/empty-state/types.ts +5 -0
- package/src/components/header/header-buttons.tsx +33 -45
- package/src/components/header/index.ts +2 -0
- package/src/components/header/parts/HeaderGradientOverlay.tsx +29 -0
- package/src/components/header/variants/LargeTitleHeader/index.tsx +68 -102
- package/src/components/header/variants/TitleHeader/index.tsx +47 -56
- package/src/components/icon/Icon.tsx +20 -15
- package/src/components/image/Image.tsx +48 -0
- package/src/components/image/index.ts +2 -0
- package/src/components/image/types.ts +7 -0
- package/src/components/index.ts +4 -0
- package/src/components/portal/Portal.tsx +55 -0
- package/src/components/portal/PortalContext.tsx +14 -22
- package/src/components/portal/PortalHost.tsx +17 -10
- package/src/components/portal/PortalProvider.tsx +58 -21
- package/src/components/portal/index.ts +4 -2
- package/src/components/screen/Screen.tsx +45 -59
- package/src/components/screen/ScreenContext.tsx +19 -12
- package/src/components/screen/ScreenFlashList.tsx +196 -0
- package/src/components/screen/ScreenFlatList.tsx +100 -39
- package/src/components/screen/ScreenScrollView.tsx +114 -53
- package/src/components/screen/index.ts +3 -0
- package/src/components/screen/parts/BottomSafeArea.tsx +60 -0
- package/src/components/screen/parts/ScreenPlaceholder.tsx +55 -0
- package/src/components/screen/types.ts +43 -0
- package/src/components/screen/utils.ts +29 -15
- package/src/components/surface/Surface.tsx +17 -20
- package/src/components/text/Text.tsx +23 -5
- package/src/components/toast/Toast.tsx +8 -8
- package/src/components/toolbar/Toolbar.tsx +353 -0
- package/src/components/toolbar/index.ts +6 -0
- package/src/context/ThemeProvider.tsx +5 -4
- package/src/{components/icon/utils.tsx → theme/defaults/icons.tsx} +1 -1
- package/src/theme/defaults/image.tsx +34 -0
- package/src/theme/index.ts +1 -1
- package/src/theme/{configure.ts → registry.ts} +19 -34
- package/src/theme/runtime.ts +1 -1
- package/src/theme/theme.ts +127 -13
- package/src/theme/tokens/dark.ts +60 -69
- package/src/theme/tokens/light.ts +50 -68
- package/src/theme/tokens/primitives.ts +248 -20
- package/src/theme/types.ts +67 -35
- package/src/utils/accent-utils.ts +4 -4
- package/lib/module/components/icon/utils.js.map +0 -1
- package/lib/module/theme/configure.js.map +0 -1
- package/lib/typescript/src/components/icon/utils.d.ts.map +0 -1
- package/lib/typescript/src/theme/configure.d.ts.map +0 -1
|
@@ -1,82 +1,149 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { Children } from 'react';
|
|
3
4
|
import { View } from 'react-native';
|
|
4
5
|
import Animated, { useAnimatedScrollHandler, useComposedEventHandler } from 'react-native-reanimated';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
7
|
+
import { scheduleOnRN } from 'react-native-worklets';
|
|
7
8
|
import { PortalHost } from "../portal/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
9
|
+
import { BottomSafeArea } from "./parts/BottomSafeArea.js";
|
|
10
|
+
import { renderScreenPlaceholder } from "./parts/ScreenPlaceholder.js";
|
|
11
|
+
import { SCREEN_HEADER_PORTAL_HOST, useScreen } from "./ScreenContext.js";
|
|
12
|
+
import { hasXMargin, hasYMargin } from "./utils.js";
|
|
10
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
14
|
/**
|
|
12
15
|
* Scrollable content container for a `Screen`. Binds the screen's shared scroll
|
|
13
16
|
* ref, mirrors offset into `scrollY`, hosts the portal target at the top (where
|
|
14
17
|
* header content is injected), and applies token-driven content padding.
|
|
15
18
|
*
|
|
19
|
+
* For simple side effects (analytics, infinite-scroll triggers), pass a plain
|
|
20
|
+
* `onScroll` callback. For scroll-driven animation, pass your own
|
|
21
|
+
* `useAnimatedScrollHandler` via `scrollHandler` instead — it runs on the UI
|
|
22
|
+
* thread alongside the screen's own handler, with no JS-thread round trip.
|
|
23
|
+
*
|
|
16
24
|
* @example
|
|
17
25
|
* ```tsx
|
|
18
26
|
* <Screen.ScrollView>
|
|
19
27
|
* <Text>Scrollable content</Text>
|
|
20
28
|
* </Screen.ScrollView>
|
|
21
29
|
* ```
|
|
30
|
+
*
|
|
31
|
+
* @example Loading placeholder instead of a per-screen spinner branch
|
|
32
|
+
* ```tsx
|
|
33
|
+
* const { data, loading } = useQuery();
|
|
34
|
+
*
|
|
35
|
+
* <Screen.ScrollView loading={loading}>
|
|
36
|
+
* <Text>{data?.title}</Text>
|
|
37
|
+
* </Screen.ScrollView>
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @example Empty placeholder when there is nothing to render
|
|
41
|
+
* ```tsx
|
|
42
|
+
* <Screen.ScrollView EmptyComponent={<EmptyState icon="status.info" title="Nothing yet" fill />}>
|
|
43
|
+
* {items.map((item) => <Row key={item.id} item={item} />)}
|
|
44
|
+
* </Screen.ScrollView>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example Simple JS-side scroll callback
|
|
48
|
+
* ```tsx
|
|
49
|
+
* <Screen.ScrollView onScroll={(e) => console.log(e.nativeEvent.contentOffset.y)}>
|
|
50
|
+
* <Text>Scrollable content</Text>
|
|
51
|
+
* </Screen.ScrollView>
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @example Custom scroll-driven animation
|
|
55
|
+
* ```tsx
|
|
56
|
+
* const headerOpacity = useSharedValue(1);
|
|
57
|
+
* const scrollHandler = useAnimatedScrollHandler({
|
|
58
|
+
* onScroll: (event) => {
|
|
59
|
+
* headerOpacity.value = interpolate(event.contentOffset.y, [0, 100], [1, 0]);
|
|
60
|
+
* // Need a JS-side side effect too? Call scheduleOnRN(fn, ...args) here.
|
|
61
|
+
* },
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* <Screen.ScrollView scrollHandler={scrollHandler}>
|
|
65
|
+
* <Text>Scrollable content</Text>
|
|
66
|
+
* </Screen.ScrollView>
|
|
67
|
+
* ```
|
|
22
68
|
*/
|
|
23
69
|
export function ScreenScrollView({
|
|
24
70
|
children,
|
|
25
71
|
style,
|
|
26
72
|
contentContainerStyle,
|
|
27
|
-
hasMargins,
|
|
28
|
-
bottomInset,
|
|
29
73
|
scrollHandler: externalScrollHandler,
|
|
30
74
|
onScroll: onScrollProp,
|
|
31
75
|
horizontal = false,
|
|
76
|
+
loading = false,
|
|
77
|
+
LoadingComponent,
|
|
78
|
+
EmptyComponent,
|
|
79
|
+
margins,
|
|
32
80
|
...rest
|
|
33
81
|
}) {
|
|
34
|
-
const {
|
|
35
|
-
theme
|
|
36
|
-
} = useUnistyles();
|
|
37
|
-
const {
|
|
38
|
-
top
|
|
39
|
-
} = useSafeAreaInsets();
|
|
40
82
|
const {
|
|
41
83
|
scrollRef,
|
|
42
84
|
scrollHandler: screenScrollHandler,
|
|
43
|
-
headerSnapOffsets,
|
|
44
85
|
margins: screenMargins,
|
|
45
|
-
hasHeader
|
|
86
|
+
hasHeader,
|
|
87
|
+
background
|
|
46
88
|
} = useScreen();
|
|
47
|
-
const
|
|
89
|
+
const resolvedMargins = margins ?? screenMargins;
|
|
90
|
+
// `toArray` drops the nullish/boolean children a conditional render leaves
|
|
91
|
+
// behind, so `{items.map(...)}` over an empty array counts as empty.
|
|
92
|
+
const placeholder = renderScreenPlaceholder({
|
|
93
|
+
loading,
|
|
94
|
+
LoadingComponent,
|
|
95
|
+
EmptyComponent,
|
|
96
|
+
isEmpty: Children.toArray(children).length === 0
|
|
97
|
+
});
|
|
98
|
+
const jsScrollHandler = useAnimatedScrollHandler({
|
|
48
99
|
onScroll: event => {
|
|
49
|
-
onScrollProp
|
|
50
|
-
|
|
51
|
-
|
|
100
|
+
if (onScrollProp) {
|
|
101
|
+
scheduleOnRN(onScrollProp, {
|
|
102
|
+
nativeEvent: event
|
|
103
|
+
});
|
|
104
|
+
}
|
|
52
105
|
}
|
|
53
|
-
}
|
|
106
|
+
});
|
|
54
107
|
const handlers = [screenScrollHandler, ...(externalScrollHandler ? [externalScrollHandler] : []), ...(onScrollProp ? [jsScrollHandler] : [])];
|
|
55
108
|
const composedHandler = useComposedEventHandler(handlers);
|
|
56
|
-
const margin = theme.layout.screen.margin;
|
|
57
|
-
const marginsEnabled = hasMargins ?? screenMargins;
|
|
58
|
-
const compactHeaderHeight = hasHeader ? top + theme.layout.header.height : 0;
|
|
59
|
-
const {
|
|
60
|
-
contentPadding
|
|
61
|
-
} = resolveScreenContentInsets(margin, marginsEnabled, bottomInset, compactHeaderHeight);
|
|
62
109
|
return /*#__PURE__*/_jsxs(Animated.ScrollView, {
|
|
63
110
|
ref: scrollRef,
|
|
64
|
-
style:
|
|
111
|
+
style: [{
|
|
112
|
+
backgroundColor: background
|
|
113
|
+
}, style],
|
|
65
114
|
horizontal: horizontal,
|
|
115
|
+
contentInsetAdjustmentBehavior: hasHeader ? 'never' : undefined,
|
|
66
116
|
showsVerticalScrollIndicator: false,
|
|
67
117
|
scrollEventThrottle: 16,
|
|
68
|
-
contentContainerStyle:
|
|
69
|
-
snapToOffsets
|
|
118
|
+
contentContainerStyle: styles.scrollContent(hasHeader, resolvedMargins)
|
|
119
|
+
// snapToOffsets={headerSnapOffsets}
|
|
120
|
+
,
|
|
70
121
|
...rest,
|
|
71
122
|
onScroll: composedHandler,
|
|
72
123
|
children: [/*#__PURE__*/_jsx(View, {
|
|
73
|
-
children: /*#__PURE__*/_jsx(PortalHost, {
|
|
124
|
+
children: /*#__PURE__*/_jsx(PortalHost, {
|
|
125
|
+
name: SCREEN_HEADER_PORTAL_HOST
|
|
126
|
+
})
|
|
74
127
|
}), /*#__PURE__*/_jsx(View, {
|
|
75
|
-
style: [contentContainerStyle,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
children: children
|
|
79
|
-
})]
|
|
128
|
+
style: [styles.content(horizontal, resolvedMargins), contentContainerStyle],
|
|
129
|
+
children: placeholder ?? children
|
|
130
|
+
}), horizontal ? null : /*#__PURE__*/_jsx(BottomSafeArea, {})]
|
|
80
131
|
});
|
|
81
132
|
}
|
|
133
|
+
const styles = StyleSheet.create((theme, rt) => ({
|
|
134
|
+
scrollContent: (hasHeader, margins) => ({
|
|
135
|
+
flexGrow: 1,
|
|
136
|
+
// The header inset and the safe area are structural — they apply whether
|
|
137
|
+
// or not margins are on; the y margin stacks on top of them.
|
|
138
|
+
paddingTop: (hasHeader ? theme.layout.header.height + rt.insets.top : 0) + (hasYMargin(margins) ? theme.layout.screen.margin.y : 0),
|
|
139
|
+
// The safe area is `BottomSafeArea`'s job; counting it here as well would
|
|
140
|
+
// leave a gap the height of the gesture bar.
|
|
141
|
+
paddingBottom: hasYMargin(margins) ? theme.layout.screen.margin.y : 0
|
|
142
|
+
}),
|
|
143
|
+
content: (horizontal, margins) => ({
|
|
144
|
+
flexGrow: 1,
|
|
145
|
+
paddingHorizontal: hasXMargin(margins) ? theme.layout.screen.margin.x : 0,
|
|
146
|
+
flexDirection: horizontal ? 'row' : 'column'
|
|
147
|
+
})
|
|
148
|
+
}));
|
|
82
149
|
//# sourceMappingURL=ScreenScrollView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["View","Animated","useAnimatedScrollHandler","useComposedEventHandler","
|
|
1
|
+
{"version":3,"names":["Children","View","Animated","useAnimatedScrollHandler","useComposedEventHandler","StyleSheet","scheduleOnRN","PortalHost","BottomSafeArea","renderScreenPlaceholder","SCREEN_HEADER_PORTAL_HOST","useScreen","hasXMargin","hasYMargin","jsx","_jsx","jsxs","_jsxs","ScreenScrollView","children","style","contentContainerStyle","scrollHandler","externalScrollHandler","onScroll","onScrollProp","horizontal","loading","LoadingComponent","EmptyComponent","margins","rest","scrollRef","screenScrollHandler","screenMargins","hasHeader","background","resolvedMargins","placeholder","isEmpty","toArray","length","jsScrollHandler","event","nativeEvent","handlers","composedHandler","ScrollView","ref","backgroundColor","contentInsetAdjustmentBehavior","undefined","showsVerticalScrollIndicator","scrollEventThrottle","styles","scrollContent","name","content","create","theme","rt","flexGrow","paddingTop","layout","header","height","insets","top","screen","margin","y","paddingBottom","paddingHorizontal","x","flexDirection"],"sourceRoot":"../../../../src","sources":["components/screen/ScreenScrollView.tsx"],"mappings":";;AAAA,SAASA,QAAQ,QAAwB,OAAO;AAChD,SAIEC,IAAI,QACC,cAAc;AAErB,OAAOC,QAAQ,IAEbC,wBAAwB,EACxBC,uBAAuB,QAClB,yBAAyB;AAChC,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,YAAY,QAAQ,uBAAuB;AACpD,SAASC,UAAU;AACnB,SAASC,cAAc;AACvB,SAASC,uBAAuB;AAChC,SAASC,yBAAyB,EAAEC,SAAS;AAE7C,SAASC,UAAU,EAAEC,UAAU;AAAkB,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAejD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAC;EAC/BC,QAAQ;EACRC,KAAK;EACLC,qBAAqB;EACrBC,aAAa,EAAEC,qBAAqB;EACpCC,QAAQ,EAAEC,YAAY;EACtBC,UAAU,GAAG,KAAK;EAClBC,OAAO,GAAG,KAAK;EACfC,gBAAgB;EAChBC,cAAc;EACdC,OAAO;EACP,GAAGC;AACkB,CAAC,EAAE;EACxB,MAAM;IACJC,SAAS;IACTV,aAAa,EAAEW,mBAAmB;IAClCH,OAAO,EAAEI,aAAa;IACtBC,SAAS;IACTC;EACF,CAAC,GAAGzB,SAAS,CAAC,CAAC;EAEf,MAAM0B,eAA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js";
|
|
5
|
+
export { ScreenFlashList } from "./ScreenFlashList.js";
|
|
5
6
|
export { ScreenFlatList } from "./ScreenFlatList.js";
|
|
6
7
|
export { ScreenScrollView } from "./ScreenScrollView.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Screen","useScreen","ScreenFlatList","ScreenScrollView"],"sourceRoot":"../../../../src","sources":["components/screen/index.ts"],"mappings":";;AACA,SAASA,MAAM;AAEf,SAASC,SAAS;AAElB,SAASC,cAAc;AAEvB,SAASC,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Screen","useScreen","ScreenFlashList","ScreenFlatList","ScreenScrollView"],"sourceRoot":"../../../../src","sources":["components/screen/index.ts"],"mappings":";;AACA,SAASA,MAAM;AAEf,SAASC,SAAS;AAElB,SAASC,eAAe;AAExB,SAASC,cAAc;AAEvB,SAASC,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* `SafeAreaView` is not re-exported from the `react-native-screens` root, so it
|
|
6
|
+
* has to be reached by path — and it has to be the TypeScript source entry, the
|
|
7
|
+
* one the package points React Native at. The built `lib/module` copy of the
|
|
8
|
+
* native component never went through React Native's codegen, so loading it
|
|
9
|
+
* fails at bundle time with "Could not find component config for native
|
|
10
|
+
* component".
|
|
11
|
+
*
|
|
12
|
+
* `require` rather than `import` so the dependency's own `.tsx` is not pulled
|
|
13
|
+
* into this package's build, where it trips compiler options it was never
|
|
14
|
+
* written against.
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
17
|
+
const {
|
|
18
|
+
SafeAreaView
|
|
19
|
+
} = require('react-native-screens/src/components/safe-area');
|
|
20
|
+
const BOTTOM_EDGE = {
|
|
21
|
+
bottom: true
|
|
22
|
+
};
|
|
23
|
+
const SPACER = {
|
|
24
|
+
flex: 0
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Bottom clearance that measures itself.
|
|
29
|
+
*
|
|
30
|
+
* The insets Unistyles reports are the window's, which cover the system bars and
|
|
31
|
+
* nothing else — 24dp for the gesture bar on a Pixel — while a native tab bar
|
|
32
|
+
* sits on top of them for another 80dp and overlaps the content beneath it.
|
|
33
|
+
* `react-native-screens` tracks that second one separately, as an *interface*
|
|
34
|
+
* inset, and reports it to its own `SafeAreaView`; asking a view is the only way
|
|
35
|
+
* to learn it. Neither `runtime.insets.bottom` nor `useSafeAreaInsets()` knows
|
|
36
|
+
* about it — both read 24 on a tab screen — and a constant would be wrong the
|
|
37
|
+
* moment the bar is absent, which is every pushed screen.
|
|
38
|
+
*
|
|
39
|
+
* `insetType="all"` covers system and interface both, so this view owns the
|
|
40
|
+
* whole bottom edge — which is why the scroll containers pad only their margin;
|
|
41
|
+
* adding the window inset there too would double-count the gesture bar.
|
|
42
|
+
* `"interface"` alone would be wrong: it measures the same on a tab screen (the
|
|
43
|
+
* bar's inset already spans the gesture bar beneath it) but reports nothing on a
|
|
44
|
+
* pushed screen, which would then lose its gesture-bar clearance.
|
|
45
|
+
*
|
|
46
|
+
* `insetType` is Android-only; on iOS the bottom safe area of a view inside a
|
|
47
|
+
* tab controller already includes the bar. Measured on a tab screen: 132dp on a
|
|
48
|
+
* Pixel, 95pt on an iPhone 17 — against the 24dp / 34pt the window insets
|
|
49
|
+
* report, which is the gap this closes.
|
|
50
|
+
*
|
|
51
|
+
* `flex: 0` cancels the `flex: 1` that `SafeAreaView` sets on itself, which
|
|
52
|
+
* would otherwise stretch it into the leftover space of a list shorter than the
|
|
53
|
+
* viewport. With no children, its height is exactly the padding it applies.
|
|
54
|
+
*/
|
|
55
|
+
export function BottomSafeArea() {
|
|
56
|
+
return /*#__PURE__*/_jsx(SafeAreaView, {
|
|
57
|
+
edges: BOTTOM_EDGE,
|
|
58
|
+
insetType: "all",
|
|
59
|
+
style: SPACER
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=BottomSafeArea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SafeAreaView","require","BOTTOM_EDGE","bottom","SPACER","flex","BottomSafeArea","_jsx","edges","insetType","style"],"sourceRoot":"../../../../../src","sources":["components/screen/parts/BottomSafeArea.tsx"],"mappings":";;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;EAAEA;AAAa,CAAC,GACpBC,OAAO,CAAC,+CAA+C,CAEtD;AAEH,MAAMC,WAAW,GAAG;EAAEC,MAAM,EAAE;AAAK,CAAU;AAC7C,MAAMC,MAAM,GAAG;EAAEC,IAAI,EAAE;AAAE,CAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAA,EAAG;EAC/B,oBAAOC,IAAA,CAACP,YAAY;IAACQ,KAAK,EAAEN,WAAY;IAACO,SAAS,EAAC,KAAK;IAACC,KAAK,EAAEN;EAAO,CAAE,CAAC;AAC5E","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { Spinner } from "../../spinner/index.js";
|
|
6
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
+
/**
|
|
8
|
+
* Centres a loading/empty placeholder in whatever space the content leaves.
|
|
9
|
+
* Grows so the placeholder sits in the middle of the content area rather than
|
|
10
|
+
* hugging the top, which needs the content container to grow as well.
|
|
11
|
+
*/
|
|
12
|
+
export function ScreenPlaceholder({
|
|
13
|
+
children
|
|
14
|
+
}) {
|
|
15
|
+
return /*#__PURE__*/_jsx(View, {
|
|
16
|
+
style: styles.placeholder,
|
|
17
|
+
children: children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The placeholder a scroll container should show instead of its content, or
|
|
22
|
+
* `null` to render the content. Loading wins over empty: while data is in
|
|
23
|
+
* flight there is nothing to be empty about yet.
|
|
24
|
+
*/
|
|
25
|
+
export function renderScreenPlaceholder({
|
|
26
|
+
loading,
|
|
27
|
+
LoadingComponent,
|
|
28
|
+
EmptyComponent,
|
|
29
|
+
isEmpty
|
|
30
|
+
}) {
|
|
31
|
+
if (loading) {
|
|
32
|
+
return /*#__PURE__*/_jsx(ScreenPlaceholder, {
|
|
33
|
+
children: LoadingComponent ?? /*#__PURE__*/_jsx(Spinner, {})
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (isEmpty && EmptyComponent) {
|
|
37
|
+
return /*#__PURE__*/_jsx(ScreenPlaceholder, {
|
|
38
|
+
children: EmptyComponent
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const styles = StyleSheet.create(() => ({
|
|
44
|
+
placeholder: {
|
|
45
|
+
flexGrow: 1,
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
justifyContent: 'center'
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
50
|
+
//# sourceMappingURL=ScreenPlaceholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","StyleSheet","Spinner","jsx","_jsx","ScreenPlaceholder","children","style","styles","placeholder","renderScreenPlaceholder","loading","LoadingComponent","EmptyComponent","isEmpty","create","flexGrow","alignItems","justifyContent"],"sourceRoot":"../../../../../src","sources":["components/screen/parts/ScreenPlaceholder.tsx"],"mappings":";;AACA,SAASA,IAAI,QAAQ,cAAc;AAEnC,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,SAASC,OAAO;AAAwB,SAAAC,GAAA,IAAAC,IAAA;AAGxC;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAAC;EAAEC;AAAkC,CAAC,EAAE;EACvE,oBAAOF,IAAA,CAACJ,IAAI;IAACO,KAAK,EAAEC,MAAM,CAACC,WAAY;IAAAH,QAAA,EAAEA;EAAQ,CAAO,CAAC;AAC3D;AAWA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,uBAAuBA,CAAC;EACtCC,OAAO;EACPC,gBAAgB;EAChBC,cAAc;EACdC;AACgB,CAAC,EAAuB;EACxC,IAAIH,OAAO,EAAE;IACX,oBACEP,IAAA,CAACC,iBAAiB;MAAAC,QAAA,EAAEM,gBAAgB,iBAAIR,IAAA,CAACF,OAAO,IAAE;IAAC,CAAoB,CAAC;EAE5E;EACA,IAAIY,OAAO,IAAID,cAAc,EAAE;IAC7B,oBAAOT,IAAA,CAACC,iBAAiB;MAAAC,QAAA,EAAEO;IAAc,CAAoB,CAAC;EAChE;EACA,OAAO,IAAI;AACb;AAEA,MAAML,MAAM,GAAGP,UAAU,CAACc,MAAM,CAAC,OAAO;EACtCN,WAAW,EAAE;IACXO,QAAQ,EAAE,CAAC;IACXC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB;AACF,CAAC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../src","sources":["components/screen/types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
paddingBottom: bottomInset ?? (margins ? margin.y : 0)
|
|
10
|
-
}
|
|
11
|
-
};
|
|
3
|
+
import { createElement, isValidElement } from 'react';
|
|
4
|
+
/** Renders a `ListHeaderComponent`-shaped prop (element, component, or nullish) into an element. */
|
|
5
|
+
export function renderListHeader(ListHeaderComponent) {
|
|
6
|
+
if (!ListHeaderComponent) return null;
|
|
7
|
+
if (/*#__PURE__*/isValidElement(ListHeaderComponent)) return ListHeaderComponent;
|
|
8
|
+
return /*#__PURE__*/createElement(ListHeaderComponent);
|
|
12
9
|
}
|
|
10
|
+
|
|
11
|
+
/** Whether `margins` pads the horizontal axis. */
|
|
12
|
+
export const hasXMargin = margins => margins === 'all' || margins === 'x';
|
|
13
|
+
|
|
14
|
+
/** Whether `margins` pads the vertical axis (the bottom of the content area). */
|
|
15
|
+
export const hasYMargin = margins => margins === 'all' || margins === 'y';
|
|
13
16
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createElement","isValidElement","renderListHeader","ListHeaderComponent","hasXMargin","margins","hasYMargin"],"sourceRoot":"../../../../src","sources":["components/screen/utils.ts"],"mappings":";;AAAA,SAEEA,aAAa,EACbC,cAAc,QAET,OAAO;AAUd;AACA,OAAO,SAASC,gBAAgBA,CAC9BC,mBAAwC,EACnB;EACrB,IAAI,CAACA,mBAAmB,EAAE,OAAO,IAAI;EACrC,iBAAIF,cAAc,CAACE,mBAAmB,CAAC,EAAE,OAAOA,mBAAmB;EACnE,oBAAOH,aAAa,CAACG,mBAAmB,CAAC;AAC3C;;AAEA;AACA,OAAO,MAAMC,UAAU,GAAIC,OAAsB,IAC/CA,OAAO,KAAK,KAAK,IAAIA,OAAO,KAAK,GAAG;;AAEtC;AACA,OAAO,MAAMC,UAAU,GAAID,OAAsB,IAC/CA,OAAO,KAAK,KAAK,IAAIA,OAAO,KAAK,GAAG","ignoreList":[]}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import { getDefaultRadius, getSurfaceElevation } from "../../theme/configure.js";
|
|
4
|
+
import { getDefaultRadius, getSurfaceElevation } from "../../theme/registry.js";
|
|
6
5
|
import { Box } from "../box/index.js";
|
|
7
6
|
|
|
8
7
|
/** Background level of a {@link Surface}. */
|
|
@@ -27,7 +26,14 @@ const VARIANT_BORDER = {
|
|
|
27
26
|
},
|
|
28
27
|
transparent: {}
|
|
29
28
|
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Picks the elevation *token key* — never a resolved shadow, so this stays
|
|
32
|
+
* theme-independent. `transparent` collapses to `'none'` because a shadow needs
|
|
33
|
+
* an opaque fill behind it to render.
|
|
34
|
+
*/
|
|
30
35
|
const resolveElevation = (variant, elevation) => {
|
|
36
|
+
if (variant === 'transparent') return 'none';
|
|
31
37
|
if (elevation !== undefined) return elevation;
|
|
32
38
|
if (variant === 'raised') return 'sm';
|
|
33
39
|
return getSurfaceElevation();
|
|
@@ -39,6 +45,13 @@ const resolveElevation = (variant, elevation) => {
|
|
|
39
45
|
* default (overridable via `radius`), and an optional drop shadow via
|
|
40
46
|
* `elevation`. All other Box style-props are accepted.
|
|
41
47
|
*
|
|
48
|
+
* Every visual decision is expressed as a **theme token key** handed to `Box`,
|
|
49
|
+
* which resolves it against the active theme. Surface therefore never reads the
|
|
50
|
+
* theme itself — no `useUnistyles()` in the render path, and no stylesheet
|
|
51
|
+
* crossing a component boundary (a Unistyles style handed to `Box` would land
|
|
52
|
+
* on a plain `View` the Babel plugin has not processed, and so would freeze at
|
|
53
|
+
* whichever theme was active when it was created).
|
|
54
|
+
*
|
|
42
55
|
* @example
|
|
43
56
|
* ```tsx
|
|
44
57
|
* <Surface variant="raised" elevation="md" p="4" radius="lg">
|
|
@@ -52,22 +65,16 @@ export const Surface = /*#__PURE__*/forwardRef(function Surface({
|
|
|
52
65
|
radius,
|
|
53
66
|
borderWidth,
|
|
54
67
|
borderColor,
|
|
55
|
-
style,
|
|
56
68
|
...rest
|
|
57
69
|
}, ref) {
|
|
58
|
-
const {
|
|
59
|
-
theme
|
|
60
|
-
} = useUnistyles();
|
|
61
|
-
const resolvedElevation = resolveElevation(variant, elevation);
|
|
62
70
|
const variantBorder = VARIANT_BORDER[variant];
|
|
63
|
-
const shadowStyle = variant !== 'transparent' && resolvedElevation !== 'none' ? theme.elevation[resolvedElevation] : undefined;
|
|
64
71
|
return /*#__PURE__*/_jsx(Box, {
|
|
65
72
|
ref: ref,
|
|
66
73
|
bg: VARIANT_BG[variant],
|
|
67
74
|
radius: radius ?? getDefaultRadius('surface'),
|
|
68
75
|
borderWidth: borderWidth ?? variantBorder.borderWidth,
|
|
69
76
|
borderColor: borderColor ?? variantBorder.borderColor,
|
|
70
|
-
|
|
77
|
+
elevation: resolveElevation(variant, elevation),
|
|
71
78
|
...rest
|
|
72
79
|
});
|
|
73
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","
|
|
1
|
+
{"version":3,"names":["forwardRef","getDefaultRadius","getSurfaceElevation","Box","jsx","_jsx","VARIANT_BG","base","raised","sunken","transparent","VARIANT_BORDER","borderWidth","borderColor","resolveElevation","variant","elevation","undefined","Surface","radius","rest","ref","variantBorder","bg"],"sourceRoot":"../../../../src","sources":["components/surface/Surface.tsx"],"mappings":";;AAAA,SAA4BA,UAAU,QAAQ,OAAO;AAGrD,SAASC,gBAAgB,EAAEC,mBAAmB;AAG9C,SAAgCC,GAAG;;AAEnC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAgBA,MAAMC,UAA8C,GAAG;EACrDC,IAAI,EAAE,iBAAiB;EACvBC,MAAM,EAAE,gBAAgB;EACxBC,MAAM,EAAE,gBAAgB;EACxBC,WAAW,EAAE;AACf,CAAC;;AAED;AACA,MAAMC,cAGL,GAAG;EACFJ,IAAI,EAAE,CAAC,CAAC;EACRC,MAAM,EAAE;IAAEI,WAAW,EAAE,UAAU;IAAEC,WAAW,EAAE;EAAgB,CAAC;EACjEJ,MAAM,EAAE;IAAEG,WAAW,EAAE,UAAU;IAAEC,WAAW,EAAE;EAAiB,CAAC;EAClEH,WAAW,EAAE,CAAC;AAChB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMI,gBAAgB,GAAGA,CACvBC,OAAuB,EACvBC,SAAwB,KACP;EACjB,IAAID,OAAO,KAAK,aAAa,EAAE,OAAO,MAAM;EAC5C,IAAIC,SAAS,KAAKC,SAAS,EAAE,OAAOD,SAAS;EAC7C,IAAID,OAAO,KAAK,QAAQ,EAAE,OAAO,IAAI;EACrC,OAAOb,mBAAmB,CAAC,CAAC;AAC9B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMgB,OAAO,gBAAGlB,UAAU,CAC/B,SAASkB,OAAOA,CACd;EAAEH,OAAO,GAAG,MAAM;EAAEC,SAAS;EAAEG,MAAM;EAAEP,WAAW;EAAEC,WAAW;EAAE,GAAGO;AAAK,CAAC,EAC1EC,GAAG,EACH;EACA,MAAMC,aAAa,GAAGX,cAAc,CAACI,OAAO,CAAC;EAE7C,oBACEV,IAAA,CAACF,GAAG;IACFkB,GAAG,EAAEA,GAAI;IACTE,EAAE,EAAEjB,UAAU,CAACS,OAAO,CAAE;IACxBI,MAAM,EAAEA,MAAM,IAAIlB,gBAAgB,CAAC,SAAS,CAAE;IAC9CW,WAAW,EAAEA,WAAW,IAAIU,aAAa,CAACV,WAAY;IACtDC,WAAW,EAAEA,WAAW,IAAIS,aAAa,CAACT,WAAY;IACtDG,SAAS,EAAEF,gBAAgB,CAACC,OAAO,EAAEC,SAAS,CAAE;IAAA,GAC5CI;EAAI,CACT,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { forwardRef } from 'react';
|
|
4
4
|
import { Text as RNText } from 'react-native';
|
|
5
|
-
import { useUnistyles } from 'react-native-unistyles';
|
|
5
|
+
import { StyleSheet, useUnistyles } from 'react-native-unistyles';
|
|
6
6
|
import { resolveThemeColor } from "../../utils/resolve-theme-color.js";
|
|
7
7
|
import { FONT_WEIGHT_VALUE, SYSTEM_FONT } from "../../utils/typography.js";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -43,7 +43,9 @@ export const Text = /*#__PURE__*/forwardRef(function Text({
|
|
|
43
43
|
const v = theme.typography.variants[resolvedVariant];
|
|
44
44
|
const effectiveWeight = weight ?? v.fontWeight;
|
|
45
45
|
const fontFamily = theme.typography.fonts[effectiveWeight];
|
|
46
|
-
const
|
|
46
|
+
const italicFamily = italic ? theme.typography.fontsItalic?.[effectiveWeight] : undefined;
|
|
47
|
+
const resolvedFamily = italicFamily ?? fontFamily;
|
|
48
|
+
const isSystemFont = resolvedFamily === SYSTEM_FONT;
|
|
47
49
|
const base = {
|
|
48
50
|
fontSize: v.fontSize,
|
|
49
51
|
lineHeight: v.lineHeight,
|
|
@@ -51,17 +53,33 @@ export const Text = /*#__PURE__*/forwardRef(function Text({
|
|
|
51
53
|
color: resolveThemeColor(color, theme) ?? theme.color['text.default'] ?? ''
|
|
52
54
|
};
|
|
53
55
|
// System font: apply numeric weight. Custom font: family encodes the weight.
|
|
54
|
-
if (isSystemFont) base.fontWeight = FONT_WEIGHT_VALUE[effectiveWeight];else base.fontFamily =
|
|
56
|
+
if (isSystemFont) base.fontWeight = FONT_WEIGHT_VALUE[effectiveWeight];else base.fontFamily = resolvedFamily;
|
|
55
57
|
if (align) base.textAlign = align;
|
|
56
|
-
|
|
58
|
+
// A dedicated italic family already renders slanted; `fontStyle` is only
|
|
59
|
+
// needed (and only works) for the system font or as a best-effort
|
|
60
|
+
// fallback when no italic family is configured for this weight.
|
|
61
|
+
if (italic && !italicFamily) base.fontStyle = 'italic';
|
|
57
62
|
if (underline && strikeThrough) base.textDecorationLine = 'underline line-through';else if (underline) base.textDecorationLine = 'underline';else if (strikeThrough) base.textDecorationLine = 'line-through';
|
|
58
63
|
return /*#__PURE__*/_jsx(RNText, {
|
|
59
64
|
ref: ref,
|
|
60
|
-
style: [base, style],
|
|
65
|
+
style: [styles.root, base, style],
|
|
61
66
|
maxFontSizeMultiplier: maxFontSizeMultiplier ?? v.maxFontSizeMultiplier,
|
|
62
67
|
numberOfLines: isTruncated ? 1 : numberOfLines,
|
|
63
68
|
ellipsizeMode: isTruncated ? 'tail' : ellipsizeMode,
|
|
64
69
|
...rest
|
|
65
70
|
});
|
|
66
71
|
});
|
|
72
|
+
|
|
73
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
74
|
+
//
|
|
75
|
+
// Text has no static style of its own — this stylesheet exists so the
|
|
76
|
+
// Unistyles Babel plugin swaps the `RNText` imported above for its Unistyles-aware
|
|
77
|
+
// counterpart, which registers the ShadowNode with the native side. That is what
|
|
78
|
+
// keeps a Unistyles style passed in through `style` updating on theme change;
|
|
79
|
+
// without it the style freezes at whichever theme was active when it was
|
|
80
|
+
// created, and only callers that happen to subscribe to the theme themselves
|
|
81
|
+
// would appear to work.
|
|
82
|
+
const styles = StyleSheet.create(() => ({
|
|
83
|
+
root: {}
|
|
84
|
+
}));
|
|
67
85
|
//# sourceMappingURL=Text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","Text","RNText","useUnistyles","resolveThemeColor","FONT_WEIGHT_VALUE","SYSTEM_FONT","jsx","_jsx","HEADING_VARIANT_ALIAS","h1","h2","h3","h4","h5","h6","resolveTextVariant","variant","color","weight","align","italic","underline","strikeThrough","isTruncated","style","numberOfLines","ellipsizeMode","maxFontSizeMultiplier","rest","ref","theme","resolvedVariant","v","typography","variants","effectiveWeight","fontWeight","fontFamily","fonts","isSystemFont","base","fontSize","lineHeight","letterSpacing","textAlign","fontStyle","textDecorationLine"],"sourceRoot":"../../../../src","sources":["components/text/Text.tsx"],"mappings":";;AAAA,SAA4BA,UAAU,QAAQ,OAAO;AACrD,SACEC,IAAI,IAAIC,MAAM,QAGT,cAAc;AAErB,SAASC,YAAY,QAAQ,wBAAwB;
|
|
1
|
+
{"version":3,"names":["forwardRef","Text","RNText","StyleSheet","useUnistyles","resolveThemeColor","FONT_WEIGHT_VALUE","SYSTEM_FONT","jsx","_jsx","HEADING_VARIANT_ALIAS","h1","h2","h3","h4","h5","h6","resolveTextVariant","variant","color","weight","align","italic","underline","strikeThrough","isTruncated","style","numberOfLines","ellipsizeMode","maxFontSizeMultiplier","rest","ref","theme","resolvedVariant","v","typography","variants","effectiveWeight","fontWeight","fontFamily","fonts","italicFamily","fontsItalic","undefined","resolvedFamily","isSystemFont","base","fontSize","lineHeight","letterSpacing","textAlign","fontStyle","textDecorationLine","styles","root","create"],"sourceRoot":"../../../../src","sources":["components/text/Text.tsx"],"mappings":";;AAAA,SAA4BA,UAAU,QAAQ,OAAO;AACrD,SACEC,IAAI,IAAIC,MAAM,QAGT,cAAc;AAErB,SAASC,UAAU,EAAEC,YAAY,QAAQ,wBAAwB;AASjE,SAASC,iBAAiB;AAC1B,SAASC,iBAAiB,EAAEC,WAAW;AAA4B,SAAAC,GAAA,IAAAC,IAAA;AAInE,MAAMC,qBAAkE,GAAG;EACzEC,EAAE,EAAE,aAAa;EACjBC,EAAE,EAAE,aAAa;EACjBC,EAAE,EAAE,UAAU;EACdC,EAAE,EAAE,UAAU;EACdC,EAAE,EAAE,UAAU;EACdC,EAAE,EAAE;AACN,CAAC;AAED,SAASC,kBAAkBA,CAACC,OAAoB,EAAmB;EACjE,OAAOA,OAAO,IAAIR,qBAAqB,GACnCA,qBAAqB,CAACQ,OAAO,CAAuB,GACnDA,OAA2B;AAClC;AAiBA;AACA;AACA;AACA;AACA,OAAO,MAAMjB,IAAI,gBAAGD,UAAU,CAC5B,SAASC,IAAIA,CACX;EACEiB,OAAO,GAAG,SAAS;EACnBC,KAAK;EACLC,MAAM;EACNC,KAAK;EACLC,MAAM;EACNC,SAAS;EACTC,aAAa;EACbC,WAAW;EACXC,KAAK;EACLC,aAAa;EACbC,aAAa;EACbC,qBAAqB;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,CAACM,kBAAkB,GAAG,WAAW,CAAC,KACrD,IAAI5B,aAAa,EAAEsB,IAAI,CAACM,kBAAkB,GAAG,cAAc;EAEhE,oBACE3C,IAAA,CAACP,MAAM;IACL6B,GAAG,EAAEA,GAAI;IACTL,KAAK,EAAE,CAAC2B,MAAM,CAACC,IAAI,EAAER,IAAI,EAAEpB,KAAK,CAAE;IAClCG,qBAAqB,EAAEA,qBAAqB,IAAIK,CAAC,CAACL,qBAAsB;IACxEF,aAAa,EAAEF,WAAW,GAAG,CAAC,GAAGE,aAAc;IAC/CC,aAAa,EAAEH,WAAW,GAAG,MAAM,GAAGG,aAAc;IAAA,GAChDE;EAAI,CACT,CAAC;AAEN,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMuB,MAAM,GAAGlD,UAAU,CAACoD,MAAM,CAAC,OAAO;EAAED,IAAI,EAAE,CAAC;AAAE,CAAC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -30,7 +30,7 @@ function getToastColors(variant, theme) {
|
|
|
30
30
|
case 'accent':
|
|
31
31
|
return {
|
|
32
32
|
...base,
|
|
33
|
-
title: get('action.fg.subtle'),
|
|
33
|
+
title: get('action.fg.primary.subtle'),
|
|
34
34
|
icon: get('text.accent'),
|
|
35
35
|
actionBg: get('action.bg.primary'),
|
|
36
36
|
actionFg: get('action.fg.primary')
|
|
@@ -41,18 +41,18 @@ function getToastColors(variant, theme) {
|
|
|
41
41
|
case 'danger':
|
|
42
42
|
return {
|
|
43
43
|
...base,
|
|
44
|
-
title: get(`status
|
|
45
|
-
icon: get(`status
|
|
46
|
-
actionBg: get(`status
|
|
47
|
-
actionFg: get(`status
|
|
44
|
+
title: get(`status.${variant}.bg`),
|
|
45
|
+
icon: get(`status.${variant}.bg`),
|
|
46
|
+
actionBg: get(`status.${variant}.bg`),
|
|
47
|
+
actionFg: get(`status.${variant}.fg`)
|
|
48
48
|
};
|
|
49
49
|
case 'default':
|
|
50
50
|
return {
|
|
51
51
|
...base,
|
|
52
52
|
title: get('text.default'),
|
|
53
53
|
icon: get('text.subtle'),
|
|
54
|
-
actionBg: get('action.bg.
|
|
55
|
-
actionFg: get('action.fg.
|
|
54
|
+
actionBg: get('action.bg.secondary'),
|
|
55
|
+
actionFg: get('action.fg.secondary')
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -155,7 +155,7 @@ const ToastDescription = /*#__PURE__*/forwardRef(function ToastDescription({
|
|
|
155
155
|
function renderActionChildren(children, color) {
|
|
156
156
|
if (typeof children === 'string' || typeof children === 'number') {
|
|
157
157
|
return /*#__PURE__*/_jsx(Text, {
|
|
158
|
-
variant: "label-
|
|
158
|
+
variant: "label-md",
|
|
159
159
|
weight: "semibold",
|
|
160
160
|
style: {
|
|
161
161
|
color
|