@vvedantb/native-ui 0.37.2 → 0.39.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/README.md +8 -7
- package/dist/Avatar.jsx +22 -19
- package/dist/BottomSheetContainer.jsx +0 -6
- package/dist/BulkActionBar.jsx +0 -24
- package/dist/Button.jsx +92 -116
- package/dist/Card.jsx +56 -50
- package/dist/ColorSwatches.jsx +0 -6
- package/dist/Dialog.jsx +0 -12
- package/dist/DropdownMenu.jsx +0 -10
- package/dist/EmptyState.jsx +0 -3
- package/dist/ExpoWebRoot.jsx +0 -6
- package/dist/Field.jsx +0 -17
- package/dist/FloatingSurface.jsx +95 -80
- package/dist/FloatingTabBar.jsx +0 -23
- package/dist/IconButton.jsx +0 -1
- package/dist/LoadingState.jsx +0 -6
- package/dist/PasswordInput.jsx +0 -15
- package/dist/PillTabs.jsx +39 -36
- package/dist/SearchInput.jsx +0 -13
- package/dist/SectionLabel.jsx +0 -1
- package/dist/SharedTransition.jsx +0 -3
- package/dist/Skeleton.jsx +0 -2
- package/dist/Spinner.jsx +0 -2
- package/dist/StatusDot.jsx +0 -5
- package/dist/Switch.jsx +32 -22
- package/dist/Tabs.jsx +27 -26
- package/dist/Textarea.jsx +0 -1
- package/dist/ThemeToggle.jsx +0 -1
- package/dist/Toast.jsx +80 -91
- package/dist/UpdateChecker.jsx +0 -1
- package/dist/ai/activity-question.jsx +0 -6
- package/dist/ai/activity-step-label.js +0 -6
- package/dist/ai/activity-step-types.js +0 -4
- package/dist/ai/activity-tasks-utils.js +0 -17
- package/dist/ai/activity-timeline.js +0 -8
- package/dist/ai/attachments.jsx +0 -2
- package/dist/ai/chain-of-thought.jsx +0 -3
- package/dist/ai/chat-text.js +0 -1
- package/dist/ai/chat-thread.jsx +0 -1
- package/dist/ai/choice-question.jsx +0 -10
- package/dist/ai/code-block.jsx +0 -31
- package/dist/ai/collapsible.jsx +0 -14
- package/dist/ai/conversation-context.js +0 -3
- package/dist/ai/conversation.jsx +2 -48
- package/dist/ai/file-chip.jsx +0 -2
- package/dist/ai/icon-button.jsx +0 -8
- package/dist/ai/index.js +0 -5
- package/dist/ai/message-context-menu.jsx +0 -7
- package/dist/ai/message.jsx +0 -21
- package/dist/ai/prompt-input-menu.jsx +0 -3
- package/dist/ai/prompt-input.jsx +0 -27
- package/dist/ai/response-text.jsx +0 -6
- package/dist/ai/sources.jsx +0 -1
- package/dist/ai/suggestion.jsx +0 -1
- package/dist/ai/trace.jsx +0 -11
- package/dist/ai/unified-diff.jsx +0 -4
- package/dist/app-root/AuthGroupGate.jsx +65 -0
- package/dist/app-root/SsoCallbackScreen.jsx +97 -0
- package/dist/app-root/fonts.js +88 -0
- package/dist/app-root/index.js +3 -0
- package/dist/auth/AuthScreen.jsx +250 -77
- package/dist/auth/GoogleSignInButton.jsx +0 -3
- package/dist/auth/SecondFactorScreen.jsx +18 -14
- package/dist/auth/SignInScreen.jsx +40 -34
- package/dist/auth/authErrors.js +0 -4
- package/dist/auth/clerkCore3.js +0 -7
- package/dist/auth/index.js +0 -4
- package/dist/auth/totp.js +0 -2
- package/dist/brand/GoogleMark.jsx +0 -1
- package/dist/brand/ProviderIcon.jsx +0 -2
- package/dist/brand/index.js +0 -3
- package/dist/brand/svg.js +0 -6
- package/dist/configureTheme.js +0 -9
- package/dist/controlStyles.js +0 -14
- package/dist/crash/LastCrashDialog.jsx +56 -0
- package/dist/crash/lastCrash.js +192 -0
- package/dist/entries/ai.js +0 -3
- package/dist/entries/ambient.js +0 -2
- package/dist/entries/app-root.js +1 -0
- package/dist/entries/auth.js +0 -4
- package/dist/entries/bottom-sheet.js +0 -2
- package/dist/entries/brand.js +0 -1
- package/dist/entries/button.js +0 -1
- package/dist/entries/crash.js +2 -0
- package/dist/entries/date-time.js +0 -2
- package/dist/entries/expo-router.js +0 -3
- package/dist/entries/expo-web-root.js +0 -2
- package/dist/entries/floating.js +0 -2
- package/dist/entries/generative-ui.js +0 -4
- package/dist/entries/gesture-handler.js +0 -3
- package/dist/entries/keyboard-controller.js +0 -3
- package/dist/entries/layout.js +0 -2
- package/dist/entries/markdown.js +0 -3
- package/dist/entries/marketing.js +0 -1
- package/dist/entries/page-title.js +0 -5
- package/dist/entries/password-input.js +0 -2
- package/dist/entries/paste-input.js +0 -3
- package/dist/entries/primitives.js +0 -6
- package/dist/entries/search-input.js +0 -2
- package/dist/entries/tab-bar.js +0 -2
- package/dist/entries/theme.js +4 -2
- package/dist/entries/toast.js +0 -3
- package/dist/entries/video.js +0 -2
- package/dist/entries/webview.js +0 -2
- package/dist/examples/AiChatGallery.jsx +0 -11
- package/dist/examples/ParityGallery.jsx +0 -12
- package/dist/floating.js +0 -8
- package/dist/generative-ui/GenerativeUiPanel.jsx +0 -2
- package/dist/generative-ui/components.jsx +0 -8
- package/dist/glass.js +55 -0
- package/dist/glassBlur.jsx +0 -12
- package/dist/highlight.js +0 -26
- package/dist/index.js +4 -2
- package/dist/loadingGrid.js +0 -13
- package/dist/markdown/Markdown.jsx +0 -59
- package/dist/markdown/MarkdownTable.jsx +0 -18
- package/dist/markdown/tableText.js +0 -5
- package/dist/marketing/UpgradeToProCard.jsx +0 -5
- package/dist/marketing/pricing.js +0 -3
- package/dist/media/ImageGallery.jsx +0 -16
- package/dist/media/imageZoom.js +0 -4
- package/dist/media/zoom-image-gesture.jsx +0 -8
- package/dist/media/zoomImage.js +0 -3
- package/dist/motion.js +0 -3
- package/dist/neutralTheme.js +158 -0
- package/dist/pagerSwipe.js +0 -16
- package/dist/palette.js +0 -10
- package/dist/primitives/button.jsx +0 -5
- package/dist/primitives/icon.jsx +0 -4
- package/dist/primitives/keyboard-controller.jsx +0 -27
- package/dist/primitives/native-only-animated-view.jsx +0 -5
- package/dist/primitives/overlay.jsx +0 -2
- package/dist/primitives/pager-gesture.jsx +3 -29
- package/dist/primitives/paste-input.jsx +0 -5
- package/dist/primitives/select.jsx +0 -10
- package/dist/primitives/sheet-drag.jsx +0 -3
- package/dist/primitives/sheet-gesture.jsx +0 -8
- package/dist/primitives/swipe-row-gesture.jsx +3 -45
- package/dist/primitives/text.jsx +0 -5
- package/dist/primitives/toast-drag-gesture.jsx +4 -24
- package/dist/primitives/web-click-guard.js +0 -3
- package/dist/primitives/window-layer.jsx +0 -14
- package/dist/push.js +0 -6
- package/dist/relativeTime.js +0 -13
- package/dist/settings/MoreFromProjectV.jsx +0 -5
- package/dist/settings/ThemeModePicker.jsx +2 -9
- package/dist/settings/projectVMobileApps.js +1 -6
- package/dist/sheetDrag.js +0 -10
- package/dist/swipeRow.js +0 -15
- package/dist/tabBarRoutes.js +0 -4
- package/dist/tabIndicator.js +0 -4
- package/dist/tailwind-preset.cjs +0 -54
- package/dist/tailwind-preset.d.cts +0 -8
- package/dist/theme.jsx +29 -21
- package/dist/themeModeStore.js +62 -0
- package/dist/themeModes.js +9 -0
- package/dist/toastChrome.js +0 -6
- package/dist/toastDrag.js +0 -14
- package/dist/toastStore.js +0 -4
- package/dist/updateCheck.js +0 -7
- package/dist/video/InlineVideo.jsx +0 -2
- package/dist/webview/htmlView.js +0 -5
- package/package.json +47 -19
- package/src/ArtifactList.tsx +0 -2
- package/src/Avatar.tsx +3 -3
- package/src/Badge.tsx +0 -1
- package/src/BottomSheetContainer.tsx +0 -11
- package/src/BulkActionBar.tsx +0 -66
- package/src/Button.tsx +4 -40
- package/src/CaptureButton.tsx +0 -1
- package/src/Card.tsx +3 -15
- package/src/Checkbox.tsx +0 -2
- package/src/ColorSwatches.tsx +0 -9
- package/src/ConfirmDialog.tsx +0 -7
- package/src/DateTimeField.tsx +0 -5
- package/src/Dialog.tsx +0 -27
- package/src/DividedList.tsx +0 -1
- package/src/DropdownMenu.tsx +0 -51
- package/src/EmptyState.tsx +0 -5
- package/src/ExpoWebRoot.tsx +0 -10
- package/src/Field.tsx +0 -14
- package/src/FloatingFAB.tsx +0 -3
- package/src/FloatingSurface.tsx +11 -8
- package/src/FloatingTabBar.tsx +0 -25
- package/src/IconButton.tsx +0 -5
- package/src/Input.tsx +0 -1
- package/src/Label.tsx +0 -1
- package/src/LabeledSwitchRow.tsx +0 -2
- package/src/ListRow.tsx +0 -12
- package/src/LoadingState.tsx +0 -12
- package/src/MenuSheet.tsx +0 -2
- package/src/PageIndicator.tsx +0 -2
- package/src/PageTitle.tsx +0 -15
- package/src/Pager.tsx +0 -9
- package/src/PasswordInput.tsx +0 -24
- package/src/PillTabs.tsx +3 -11
- package/src/PinnedBotTile.tsx +0 -6
- package/src/Progress.tsx +0 -3
- package/src/ReactionRow.tsx +0 -8
- package/src/ScreenContainer.tsx +0 -4
- package/src/SearchInput.tsx +0 -25
- package/src/SectionLabel.tsx +0 -2
- package/src/Select.tsx +0 -6
- package/src/Separator.tsx +0 -2
- package/src/SharedTransition.tsx +0 -7
- package/src/Sheet.tsx +0 -3
- package/src/SheetRow.tsx +0 -12
- package/src/Skeleton.tsx +0 -10
- package/src/Spinner.tsx +0 -6
- package/src/StackPageHeader.tsx +0 -16
- package/src/StatGrid.tsx +0 -1
- package/src/StatusDot.tsx +0 -6
- package/src/SurfaceRow.tsx +0 -12
- package/src/SwipeableRow.tsx +0 -4
- package/src/Switch.tsx +3 -4
- package/src/Tabs.tsx +3 -27
- package/src/Textarea.tsx +0 -2
- package/src/ThemeToggle.tsx +0 -1
- package/src/Toast.tsx +3 -19
- package/src/UpdateChecker.tsx +0 -46
- package/src/ai/activity-question.tsx +0 -8
- package/src/ai/activity-step-detail.tsx +0 -5
- package/src/ai/activity-step-label.ts +0 -5
- package/src/ai/activity-step-types.ts +0 -24
- package/src/ai/activity-step.tsx +0 -4
- package/src/ai/activity-tasks-utils.ts +0 -13
- package/src/ai/activity-timeline.ts +0 -6
- package/src/ai/attachments.tsx +0 -13
- package/src/ai/chain-of-thought.tsx +0 -5
- package/src/ai/chat-jump-rail.tsx +0 -2
- package/src/ai/chat-text.ts +0 -1
- package/src/ai/chat-thread.tsx +0 -9
- package/src/ai/choice-question.tsx +0 -36
- package/src/ai/code-block.tsx +0 -52
- package/src/ai/collapsible.tsx +0 -12
- package/src/ai/conversation-context.ts +0 -14
- package/src/ai/conversation.tsx +0 -58
- package/src/ai/file-chip.tsx +0 -1
- package/src/ai/icon-button.tsx +0 -17
- package/src/ai/index.ts +0 -5
- package/src/ai/message-action-sheet.tsx +0 -8
- package/src/ai/message-context-menu.tsx +0 -22
- package/src/ai/message-quote.tsx +0 -4
- package/src/ai/message.tsx +0 -66
- package/src/ai/prompt-input-menu.tsx +0 -19
- package/src/ai/prompt-input.tsx +0 -97
- package/src/ai/reasoning.tsx +0 -6
- package/src/ai/reply-quote-chip.tsx +0 -5
- package/src/ai/response-text.tsx +0 -8
- package/src/ai/shimmer.tsx +0 -2
- package/src/ai/sources.tsx +0 -3
- package/src/ai/subagent-cards.tsx +0 -13
- package/src/ai/suggestion.tsx +0 -4
- package/src/ai/tool-approval-card.tsx +0 -14
- package/src/ai/trace.tsx +0 -23
- package/src/ai/unified-diff.tsx +0 -16
- package/src/ai/use-streaming-disclosure.ts +0 -4
- package/src/app-root/AuthGroupGate.tsx +38 -0
- package/src/app-root/SsoCallbackScreen.tsx +52 -0
- package/src/app-root/fonts.ts +53 -0
- package/src/app-root/index.ts +6 -0
- package/src/auth/AccountScreens.tsx +0 -16
- package/src/auth/AuthProviders.tsx +0 -13
- package/src/auth/AuthScreen.tsx +95 -6
- package/src/auth/GoogleSignInButton.tsx +0 -12
- package/src/auth/SecondFactorScreen.tsx +17 -15
- package/src/auth/SignInScreen.tsx +103 -105
- package/src/auth/authErrors.ts +0 -6
- package/src/auth/clerkCore3.ts +0 -6
- package/src/auth/index.ts +0 -4
- package/src/auth/totp.ts +0 -13
- package/src/brand/AppIcons.tsx +0 -6
- package/src/brand/AppMark.tsx +0 -5
- package/src/brand/AppWordmark.tsx +0 -7
- package/src/brand/GoogleMark.tsx +0 -4
- package/src/brand/ProviderIcon.tsx +0 -6
- package/src/brand/familyApps.ts +0 -2
- package/src/brand/index.ts +0 -3
- package/src/brand/svg.ts +0 -9
- package/src/configureTheme.ts +0 -10
- package/src/controlStyles.ts +0 -12
- package/src/crash/LastCrashDialog.tsx +36 -0
- package/src/crash/lastCrash.ts +218 -0
- package/src/entries/ai.ts +0 -3
- package/src/entries/ambient.ts +0 -2
- package/src/entries/app-root.ts +1 -0
- package/src/entries/auth.ts +0 -4
- package/src/entries/bottom-sheet.ts +0 -2
- package/src/entries/brand.ts +0 -1
- package/src/entries/button.ts +0 -1
- package/src/entries/crash.ts +13 -0
- package/src/entries/date-time.ts +0 -2
- package/src/entries/expo-router.ts +0 -3
- package/src/entries/expo-web-root.ts +0 -2
- package/src/entries/floating.ts +0 -2
- package/src/entries/generative-ui.ts +0 -4
- package/src/entries/gesture-handler.ts +0 -3
- package/src/entries/keyboard-controller.ts +0 -3
- package/src/entries/layout.ts +0 -2
- package/src/entries/markdown.ts +0 -3
- package/src/entries/marketing.ts +0 -1
- package/src/entries/page-title.ts +0 -5
- package/src/entries/password-input.ts +0 -2
- package/src/entries/paste-input.ts +0 -3
- package/src/entries/primitives.ts +0 -6
- package/src/entries/search-input.ts +0 -2
- package/src/entries/tab-bar.ts +0 -2
- package/src/entries/theme.ts +8 -2
- package/src/entries/toast.ts +0 -3
- package/src/entries/video.ts +0 -2
- package/src/entries/webview.ts +0 -2
- package/src/examples/AiChatGallery.tsx +0 -11
- package/src/examples/ParityGallery.tsx +0 -25
- package/src/floating.ts +0 -6
- package/src/generative-ui/GenerativeUiPanel.tsx +0 -15
- package/src/generative-ui/components.tsx +0 -9
- package/src/generative-ui/context.ts +0 -2
- package/src/glass.ts +31 -0
- package/src/glassBlur.tsx +0 -15
- package/src/highlight.ts +1 -21
- package/src/index.ts +7 -2
- package/src/loadingGrid.ts +0 -12
- package/src/markdown/Markdown.tsx +0 -71
- package/src/markdown/MarkdownTable.tsx +0 -23
- package/src/markdown/tableText.ts +0 -3
- package/src/marketing/PricingModal.tsx +0 -13
- package/src/marketing/UpgradeToProCard.tsx +0 -14
- package/src/marketing/pricing.ts +0 -12
- package/src/media/ImageGallery.tsx +0 -18
- package/src/media/MediaCard.tsx +0 -8
- package/src/media/imageZoom.ts +0 -4
- package/src/media/zoom-image-gesture.tsx +0 -9
- package/src/media/zoomImage.ts +0 -5
- package/src/motion.ts +0 -3
- package/src/neutralTheme.ts +127 -0
- package/src/pagerSwipe.ts +0 -13
- package/src/palette.ts +0 -10
- package/src/pressScale.ts +0 -7
- package/src/primitives/button.tsx +0 -4
- package/src/primitives/card.tsx +0 -1
- package/src/primitives/icon.tsx +0 -2
- package/src/primitives/input.tsx +0 -4
- package/src/primitives/keyboard-controller.tsx +0 -25
- package/src/primitives/keyboard-parts.tsx +0 -27
- package/src/primitives/native-only-animated-view.tsx +0 -5
- package/src/primitives/overlay.tsx +0 -25
- package/src/primitives/pager-gesture.tsx +0 -20
- package/src/primitives/paste-input.tsx +0 -4
- package/src/primitives/paste-parts.tsx +0 -1
- package/src/primitives/select.tsx +0 -18
- package/src/primitives/sheet-drag.tsx +0 -19
- package/src/primitives/sheet-gesture.tsx +0 -22
- package/src/primitives/swipe-row-gesture.tsx +0 -33
- package/src/primitives/switch.tsx +0 -4
- package/src/primitives/text.tsx +0 -4
- package/src/primitives/toast-drag-gesture.tsx +0 -13
- package/src/primitives/web-click-guard.ts +0 -2
- package/src/primitives/window-layer.tsx +0 -18
- package/src/push.ts +0 -15
- package/src/relativeTime.ts +0 -21
- package/src/router/RouterStackPageHeader.tsx +0 -1
- package/src/settings/MoreFromProjectV.tsx +0 -8
- package/src/settings/SettingsEmptyState.tsx +0 -2
- package/src/settings/SettingsSection.tsx +0 -3
- package/src/settings/SettingsToggleRow.tsx +0 -4
- package/src/settings/ThemeModePicker.tsx +2 -16
- package/src/settings/projectVMobileApps.ts +0 -8
- package/src/sheetDrag.ts +0 -9
- package/src/swipeRow.ts +0 -23
- package/src/tabBarRoutes.ts +0 -13
- package/src/tabIndicator.ts +0 -5
- package/src/tailwind-preset.cjs +0 -54
- package/src/tailwind-preset.d.cts +0 -8
- package/src/theme.tsx +11 -2
- package/src/themeModeStore.ts +85 -0
- package/src/themeModes.ts +10 -0
- package/src/toastChrome.ts +0 -6
- package/src/toastDrag.ts +0 -13
- package/src/toastStore.ts +0 -7
- package/src/updateCheck.ts +0 -15
- package/src/video/InlineVideo.tsx +0 -5
- package/src/webview/HtmlView.tsx +0 -23
- package/src/webview/HtmlView.web.tsx +0 -1
- package/src/webview/htmlView.ts +0 -5
- package/types/prism-react-renderer.d.ts +22 -0
|
@@ -4,18 +4,12 @@ import Animated, { cancelAnimation, interpolate, ReduceMotion, runOnJS, useAnima
|
|
|
4
4
|
import { impactHaptic } from "../haptics";
|
|
5
5
|
import { TOAST_DRAG_ACTIVE_OFFSET_Y, toastDragDismisses, toastDragOffset } from "../toastDrag";
|
|
6
6
|
import { useWebClickGuard } from "./web-click-guard";
|
|
7
|
-
|
|
8
|
-
// The toast drag on Gesture Handler: the track phase and the release run as
|
|
9
|
-
// worklets on the UI thread. The rules are plain worklets in `toastDrag`.
|
|
10
|
-
|
|
11
|
-
/** Back home after a short drag: critically damped, no bounce. */
|
|
12
7
|
const HOME_SPRING = {
|
|
13
8
|
duration: 250,
|
|
14
9
|
dampingRatio: 1,
|
|
15
10
|
overshootClamping: true,
|
|
16
11
|
reduceMotion: ReduceMotion.System
|
|
17
12
|
};
|
|
18
|
-
/** Away up the screen: no overshoot back into view. */
|
|
19
13
|
const AWAY_SPRING = {
|
|
20
14
|
duration: 250,
|
|
21
15
|
dampingRatio: 1,
|
|
@@ -29,7 +23,6 @@ export function GestureToastDrag({
|
|
|
29
23
|
}) {
|
|
30
24
|
const y = useSharedValue(0);
|
|
31
25
|
const height = useSharedValue(0);
|
|
32
|
-
// Where the toast was when the finger caught it, and the finger's travel then.
|
|
33
26
|
const start = useSharedValue(0);
|
|
34
27
|
const startY = useSharedValue(0);
|
|
35
28
|
const webClicks = useWebClickGuard();
|
|
@@ -37,26 +30,18 @@ export function GestureToastDrag({
|
|
|
37
30
|
impactHaptic("light");
|
|
38
31
|
onDismiss();
|
|
39
32
|
};
|
|
40
|
-
|
|
41
|
-
// Built on each render: the detector keeps the same handler, and a drag in flight.
|
|
42
|
-
const pan = Gesture.Pan().activeOffsetY([-TOAST_DRAG_ACTIVE_OFFSET_Y, TOAST_DRAG_ACTIVE_OFFSET_Y])
|
|
43
|
-
// The timer holds from the touch, a tap included (a tap closes the toast anyway).
|
|
44
|
-
.onBegin(() => {
|
|
33
|
+
const pan = Gesture.Pan().activeOffsetY([-TOAST_DRAG_ACTIVE_OFFSET_Y, TOAST_DRAG_ACTIVE_OFFSET_Y]).onBegin(() => {
|
|
45
34
|
runOnJS(onHoldChange)(true);
|
|
46
35
|
}).onStart(event => {
|
|
47
36
|
cancelAnimation(y);
|
|
48
37
|
start.set(y.get());
|
|
49
|
-
// Count from here, so the toast does not jump by the slop the drag needed to start.
|
|
50
38
|
startY.set(event.translationY);
|
|
51
39
|
runOnJS(webClicks.swallowNext)();
|
|
52
|
-
})
|
|
53
|
-
// Track phase: one shared value write per frame, on the UI thread.
|
|
54
|
-
.onUpdate(event_0 => {
|
|
40
|
+
}).onUpdate(event_0 => {
|
|
55
41
|
y.set(toastDragOffset(start.get() + event_0.translationY - startY.get()));
|
|
56
42
|
}).onEnd(event_1 => {
|
|
57
43
|
const position = y.get();
|
|
58
44
|
if (toastDragDismisses(position, event_1.velocityY, height.get())) {
|
|
59
|
-
// Up past its own height, fading on the way (`toastStyle`), at the finger's speed.
|
|
60
45
|
y.set(withSpring(-height.get() * 1.5, {
|
|
61
46
|
...AWAY_SPRING,
|
|
62
47
|
velocity: event_1.velocityY
|
|
@@ -74,22 +59,17 @@ export function GestureToastDrag({
|
|
|
74
59
|
}).onFinalize(() => {
|
|
75
60
|
runOnJS(onHoldChange)(false);
|
|
76
61
|
});
|
|
77
|
-
|
|
78
|
-
// Linked to the same value: the toast fades as it rises, gone one height up.
|
|
79
62
|
const toastStyle = useAnimatedStyle(() => ({
|
|
80
63
|
opacity: height.get() > 0 ? interpolate(y.get(), [-height.get(), 0], [0, 1], "clamp") : 1,
|
|
81
64
|
transform: [{
|
|
82
65
|
translateY: y.get()
|
|
83
66
|
}]
|
|
84
67
|
}));
|
|
85
|
-
return
|
|
86
|
-
// Its own root: on iOS the toasts draw in a separate window (`FullWindowOverlay`).
|
|
87
|
-
<GestureHandlerRootView>
|
|
68
|
+
return <GestureHandlerRootView>
|
|
88
69
|
<GestureDetector gesture={pan}>
|
|
89
70
|
<Animated.View style={toastStyle} onLayout={event_2 => height.set(event_2.nativeEvent.layout.height)}>
|
|
90
71
|
<View ref={webClicks.ref}>{children}</View>
|
|
91
72
|
</Animated.View>
|
|
92
73
|
</GestureDetector>
|
|
93
|
-
</GestureHandlerRootView
|
|
94
|
-
);
|
|
74
|
+
</GestureHandlerRootView>;
|
|
95
75
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { Platform } from "react-native";
|
|
4
|
-
|
|
5
|
-
/** The part of a DOM element the web click guard uses: on the web a `View` is a DOM element. */
|
|
6
|
-
|
|
7
4
|
function isDomNode(node) {
|
|
8
5
|
return "addEventListener" in node && typeof node.addEventListener === "function";
|
|
9
6
|
}
|
|
@@ -3,14 +3,6 @@ import { useId, useLayoutEffect, useSyncExternalStore } from "react";
|
|
|
3
3
|
import { BackHandler, Modal, StyleSheet, View } from "react-native";
|
|
4
4
|
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
|
|
5
5
|
import { useReduceMotion } from "../useReduceMotion";
|
|
6
|
-
|
|
7
|
-
// Overlays drawn in the app's own window. A React Native `Modal` is a window
|
|
8
|
-
// of its own on Android: it takes the focus as it opens and hands it back as
|
|
9
|
-
// it closes, and each time `react-native-keyboard-controller`'s chat list
|
|
10
|
-
// scrolls to its newest message. A layer in `WindowLayerHost` is a view over
|
|
11
|
-
// the app instead, so the focus never moves. Without a host, `WindowLayer`
|
|
12
|
-
// falls back to a `Modal`, so an app that mounts none keeps working.
|
|
13
|
-
|
|
14
6
|
const EMPTY = [];
|
|
15
7
|
let layers = EMPTY;
|
|
16
8
|
let hosts = 0;
|
|
@@ -29,8 +21,6 @@ const upsert = layer => {
|
|
|
29
21
|
layers = at === -1 ? [...layers, layer] : layers.map((item, index) => index === at ? layer : item);
|
|
30
22
|
emit();
|
|
31
23
|
};
|
|
32
|
-
|
|
33
|
-
// Layers that have called `onShow` once, as a Modal does once per opening.
|
|
34
24
|
const announced = new Set();
|
|
35
25
|
const showOnce = layer => {
|
|
36
26
|
if (announced.has(layer.id)) return;
|
|
@@ -43,16 +33,12 @@ const remove = id => {
|
|
|
43
33
|
layers = layers.filter(item => item.id !== id);
|
|
44
34
|
emit();
|
|
45
35
|
};
|
|
46
|
-
|
|
47
|
-
// Android back closes the newest layer, as a Modal's `onRequestClose`.
|
|
48
36
|
const onBack = () => {
|
|
49
37
|
const top = layers[layers.length - 1];
|
|
50
38
|
if (!top) return false;
|
|
51
39
|
top.onRequestClose();
|
|
52
40
|
return true;
|
|
53
41
|
};
|
|
54
|
-
|
|
55
|
-
/** Mounted: the host is there, and it answers Android back for its layers. */
|
|
56
42
|
const hostRef = view => {
|
|
57
43
|
if (view === null) return undefined;
|
|
58
44
|
hosts += 1;
|
package/dist/push.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef } from "react";
|
|
2
2
|
import { Platform } from "react-native";
|
|
3
|
-
|
|
4
|
-
// `expo-notifications`, `expo-constants` and `expo-device` are optional peers.
|
|
5
|
-
// Metro bundles a `require` placed directly in a `try` block as an optional
|
|
6
|
-
// dependency, so a missing peer does not break the bundle.
|
|
7
|
-
|
|
8
3
|
let notifications;
|
|
9
4
|
let constants;
|
|
10
5
|
let device;
|
|
@@ -77,7 +72,6 @@ export async function getExpoPushToken({
|
|
|
77
72
|
projectId
|
|
78
73
|
})).data;
|
|
79
74
|
} catch {
|
|
80
|
-
// No google-services.json in this build: FCM cannot issue a token.
|
|
81
75
|
return null;
|
|
82
76
|
}
|
|
83
77
|
}
|
package/dist/relativeTime.js
CHANGED
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
// The twin of `@vvedantb/ui`'s `formatCompactRelativeTime`
|
|
2
|
-
// (`ui/app/src/time/compactRelativeTime.ts`), which `RelativeDateTime` shows.
|
|
3
|
-
// The web file pulls no DOM, but the web package does, so this is a copy;
|
|
4
|
-
// tests/relativeTime.test.ts checks both give the same strings.
|
|
5
|
-
|
|
6
1
|
const MS_PER_MINUTE = 60_000;
|
|
7
2
|
const MS_PER_DAY = 86_400_000;
|
|
8
|
-
|
|
9
|
-
/** Rounds toward zero; `-0` becomes `0`. */
|
|
10
3
|
function truncate(n) {
|
|
11
4
|
return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);
|
|
12
5
|
}
|
|
13
|
-
|
|
14
|
-
/** Local UTC offset in minutes, rounded to 15 minutes. */
|
|
15
6
|
function utcOffset(ms) {
|
|
16
7
|
return -Math.round(new Date(ms).getTimezoneOffset() / 15) * 15;
|
|
17
8
|
}
|
|
18
|
-
|
|
19
|
-
/** Adds calendar months in local time and clamps the day to the target month. */
|
|
20
9
|
function addMonths(ms, months) {
|
|
21
10
|
const date = new Date(ms);
|
|
22
11
|
const day = date.getDate();
|
|
@@ -26,8 +15,6 @@ function addMonths(ms, months) {
|
|
|
26
15
|
date.setDate(Math.min(day, daysInMonth));
|
|
27
16
|
return date.getTime();
|
|
28
17
|
}
|
|
29
|
-
|
|
30
|
-
/** Fractional calendar months from `a` to `b`, negated (the moment.js formula). */
|
|
31
18
|
function monthDiff(a, b) {
|
|
32
19
|
if (new Date(a).getDate() < new Date(b).getDate()) return -monthDiff(b, a);
|
|
33
20
|
const from = new Date(a);
|
|
@@ -9,11 +9,6 @@ import { tokens } from "../tokens";
|
|
|
9
9
|
import { useScheme } from "../useScheme";
|
|
10
10
|
import { SettingsSection } from "./SettingsSection";
|
|
11
11
|
import { openProjectVApp, otherProjectVMobileApps } from "./projectVMobileApps";
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* The mark for each phone app. V Store has no mark of its own (it was left out
|
|
15
|
-
* of the brand marks in 0.3.9), so it shows the Project V mark.
|
|
16
|
-
*/
|
|
17
12
|
const MARK = {
|
|
18
13
|
vibot: "vibot",
|
|
19
14
|
verve: "verve",
|
|
@@ -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
|
-
|
|
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",
|
|
@@ -25,10 +22,7 @@ const ICONS = {
|
|
|
25
22
|
dark: IconMoon,
|
|
26
23
|
system: IconDeviceDesktop
|
|
27
24
|
};
|
|
28
|
-
/** Web `bg-zinc-900`. */
|
|
29
25
|
const ZINC_900 = "#18181b";
|
|
30
|
-
// Swatches and icons show the theme itself, so they use the web's fixed colours, not tokens.
|
|
31
|
-
// System has no swatch colour (it is a hard split) and a muted icon.
|
|
32
26
|
const SWATCHES = {
|
|
33
27
|
light: "#ffffff",
|
|
34
28
|
neutral: "#3f3f46",
|
|
@@ -41,7 +35,6 @@ const ICON_COLOURS = {
|
|
|
41
35
|
dark: "#93c5fd",
|
|
42
36
|
system: null
|
|
43
37
|
};
|
|
44
|
-
/** The System swatch: white with a hard diagonal half in zinc-900, no gradient. */
|
|
45
38
|
function SplitSwatch() {
|
|
46
39
|
const $ = _c(1);
|
|
47
40
|
let t0;
|
|
@@ -8,9 +8,6 @@ import { familyApp } from "../brand/familyApps";
|
|
|
8
8
|
* know live Convex ids. So the store step opens V Store's home, not the app's page.
|
|
9
9
|
*/
|
|
10
10
|
export const VSTORE_HOME_URL = "vstore://";
|
|
11
|
-
|
|
12
|
-
// Names and sites come from `FAMILY_APPS` where it has the app. V Store is not
|
|
13
|
-
// a family app there (that file is a byte-identical copy of `@vvedantb/ui`).
|
|
14
11
|
const vibot = familyApp("vibot");
|
|
15
12
|
const verve = familyApp("verve");
|
|
16
13
|
const velth = familyApp("velth");
|
|
@@ -118,9 +115,7 @@ export async function openProjectVApp(id, linking, os) {
|
|
|
118
115
|
if (step.check && !(await linking.canOpenURL(step.url))) continue;
|
|
119
116
|
await linking.openURL(step.url);
|
|
120
117
|
return step.target;
|
|
121
|
-
} catch {
|
|
122
|
-
// Not installed, or no handler: try the next URL.
|
|
123
|
-
}
|
|
118
|
+
} catch {}
|
|
124
119
|
}
|
|
125
120
|
return null;
|
|
126
121
|
}
|
package/dist/sheetDrag.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The rules of a bottom sheet's drag to dismiss, as plain numbers, so they
|
|
3
|
-
* stay testable apart from the gesture. Distances are in points, `vy` in
|
|
4
|
-
* points per millisecond (the React Native `PanResponder` unit). Each is a
|
|
5
|
-
* worklet, so the Gesture Handler drag runs them on the UI thread.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** How far ahead (ms) the release velocity carries the sheet when deciding to close. */
|
|
9
1
|
const PROJECTION_MS = 200;
|
|
10
|
-
|
|
11
|
-
/** A flick down at this speed (pt/ms, so 1000 pt/s) closes the sheet however short the drag. */
|
|
12
2
|
const FLICK_VELOCITY = 1;
|
|
13
3
|
|
|
14
4
|
/** How far an upward pull may lift the sheet: less than the corner radius hidden below the screen. */
|
package/dist/swipeRow.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The rules of a swipeable list row (`SwipeableRow`), as plain numbers, so
|
|
3
|
-
* they stay testable apart from the gesture. The offset is in points:
|
|
4
|
-
* positive when the row moves right (it reveals the leading actions),
|
|
5
|
-
* negative when it moves left (the trailing actions). Velocities are in
|
|
6
|
-
* points per second, the Gesture Handler unit. Each rule is a worklet, so the
|
|
7
|
-
* drag runs it on the UI thread.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
/** One action a swipe reveals behind a row. */
|
|
11
2
|
|
|
12
3
|
/** The revealed widths of each side (0 for a side with no actions) and the row's width. */
|
|
@@ -32,7 +23,6 @@ export function swipeRowActivation(sides, insidePager) {
|
|
|
32
23
|
activeOffsetX: [-SWIPE_ACTIVE_OFFSET_X, SWIPE_ACTIVE_OFFSET_X]
|
|
33
24
|
};
|
|
34
25
|
}
|
|
35
|
-
// Left (negative) reveals the trailing actions; right the leading ones.
|
|
36
26
|
return sides.trailing > 0 ? {
|
|
37
27
|
activeOffsetX: -SWIPE_ACTIVE_OFFSET_X,
|
|
38
28
|
failOffsetX: SWIPE_ACTIVE_OFFSET_X
|
|
@@ -41,11 +31,7 @@ export function swipeRowActivation(sides, insidePager) {
|
|
|
41
31
|
failOffsetX: -SWIPE_ACTIVE_OFFSET_X
|
|
42
32
|
};
|
|
43
33
|
}
|
|
44
|
-
|
|
45
|
-
/** How far ahead (s) the release velocity carries the row when deciding where it settles. */
|
|
46
34
|
const PROJECTION_S = 0.2;
|
|
47
|
-
|
|
48
|
-
/** How far a row moves past its reach: less and less the further the finger goes. */
|
|
49
35
|
function rubberband(overshoot) {
|
|
50
36
|
"worklet";
|
|
51
37
|
|
|
@@ -101,7 +87,6 @@ export function swipeRowSettle(x, vx, sides) {
|
|
|
101
87
|
if (reveal === 0) return {
|
|
102
88
|
kind: "close"
|
|
103
89
|
};
|
|
104
|
-
// The projected travel toward this side: negative after a flick back past rest.
|
|
105
90
|
const reach = Math.sign(x) * (x + vx * PROJECTION_S);
|
|
106
91
|
if (Math.abs(x) > reveal && reach >= swipeFullAt(reveal, sides.width)) return {
|
|
107
92
|
kind: "commit",
|
package/dist/tabBarRoutes.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
// Which routes `FloatingTabBar` draws. No React Native runtime import, so the
|
|
2
|
-
// tests can load this file.
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* The fields `FloatingTabBar` reads from a route's options (React
|
|
6
3
|
* Navigation's `BottomTabNavigationOptions`, and Expo Router's `href`).
|
|
7
4
|
*/
|
|
8
5
|
|
|
9
|
-
/** The `display` a style resolves to: in an array the last one set wins, as in `StyleSheet.flatten`. */
|
|
10
6
|
function displayOf(style) {
|
|
11
7
|
if (Array.isArray(style)) {
|
|
12
8
|
let display;
|
package/dist/tabIndicator.js
CHANGED
|
@@ -2,10 +2,6 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
2
2
|
import { cssInterop } from "nativewind";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import Animated, { interpolate, interpolateColor, useAnimatedStyle } from "react-native-reanimated";
|
|
5
|
-
|
|
6
|
-
// The tab labels are `Animated.Text`s (their colour follows `progress`).
|
|
7
|
-
// NativeWind maps `className` only for components it knows, so it is told
|
|
8
|
-
// about this one, or the labels lose their font and size classes.
|
|
9
5
|
cssInterop(Animated.Text, {
|
|
10
6
|
className: "style"
|
|
11
7
|
});
|
package/dist/tailwind-preset.cjs
CHANGED
|
@@ -1,41 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `@vvedantb/native-ui/tailwind-preset`: the NativeWind / Tailwind preset the
|
|
3
|
-
* Expo apps share. CommonJS, because `tailwind.config.js` `require`s it and
|
|
4
|
-
* Tailwind loads it outside Metro.
|
|
5
|
-
*
|
|
6
|
-
* const { nativeUiPreset, nativeUiContent } = require("@vvedantb/native-ui/tailwind-preset");
|
|
7
|
-
* module.exports = {
|
|
8
|
-
* content: ["./app/**\/*.{js,ts,tsx}", nativeUiContent()],
|
|
9
|
-
* presets: [nativeUiPreset()],
|
|
10
|
-
* };
|
|
11
|
-
*
|
|
12
|
-
* It nests `nativewind/preset`, so callers pass only this one. It sets
|
|
13
|
-
* `darkMode`, the `font-instrument-sans*` font classes (Instrument Sans unless
|
|
14
|
-
* `font` names other families), the colour keys native-ui
|
|
15
|
-
* classes use, `borderWidth.hairline` and, when asked, `borderRadius` from
|
|
16
|
-
* `--radius`.
|
|
17
|
-
* App colours, display fonts, keyframes and font-weight plugins stay in the
|
|
18
|
-
* app config.
|
|
19
|
-
*
|
|
20
|
-
* `color` maps a CSS variable name (without `--`) to a Tailwind colour, as the
|
|
21
|
-
* web `tokensPreset({ color })` of `@vvedantb/ui`. With `injectCssVariables`,
|
|
22
|
-
* the preset also writes those variables (light and dark) from `tokens.ts` and
|
|
23
|
-
* `palette.ts`, as space-separated RGB channels, and the default `color` is
|
|
24
|
-
* `rgbAlpha`.
|
|
25
|
-
*/
|
|
26
1
|
"use strict";
|
|
27
2
|
|
|
28
3
|
const fs = require("node:fs");
|
|
29
4
|
const path = require("node:path");
|
|
30
5
|
|
|
31
|
-
/** `var(--name)`. */
|
|
32
6
|
const cssVar = (name) => `var(--${name})`;
|
|
33
|
-
/** `hsl(var(--name))`, for variables that hold `h s% l%` channels. */
|
|
34
7
|
const hslVar = (name) => `hsl(var(--${name}))`;
|
|
35
|
-
/** `rgb(var(--name) / <alpha-value>)`, for variables that hold `r g b` channels. Keeps opacity modifiers. */
|
|
36
8
|
const rgbAlpha = (name) => `rgb(var(--${name}) / <alpha-value>)`;
|
|
37
9
|
|
|
38
|
-
/** The default families of the four font classes, as `fontFamily` in `typography.ts`. */
|
|
39
10
|
const INSTRUMENT_SANS = {
|
|
40
11
|
regular: "InstrumentSans_400Regular",
|
|
41
12
|
medium: "InstrumentSans_500Medium",
|
|
@@ -43,16 +14,10 @@ const INSTRUMENT_SANS = {
|
|
|
43
14
|
bold: "InstrumentSans_700Bold",
|
|
44
15
|
};
|
|
45
16
|
|
|
46
|
-
/** The glob Tailwind scans for native-ui class names: this package's `src`, at its real path (pnpm symlinks resolve). */
|
|
47
17
|
function nativeUiContent() {
|
|
48
18
|
return path.join(__dirname, "**/*.{js,ts,tsx}").split(path.sep).join("/");
|
|
49
19
|
}
|
|
50
20
|
|
|
51
|
-
/**
|
|
52
|
-
* Reads one `export const name = { … } as const;` object from a sibling
|
|
53
|
-
* `.ts` file. Plain object literals only, so no TypeScript loader is needed:
|
|
54
|
-
* `tokens.ts` and `palette.ts` stay the single source of the colours.
|
|
55
|
-
*/
|
|
56
21
|
function readConst(file, name) {
|
|
57
22
|
const source = fs.readFileSync(path.join(__dirname, file), "utf8");
|
|
58
23
|
const match = source.match(new RegExp(`export const ${name} = (\\{[\\s\\S]*?\\n\\}) as const;`));
|
|
@@ -62,7 +27,6 @@ function readConst(file, name) {
|
|
|
62
27
|
|
|
63
28
|
let cachedSchemeColors = null;
|
|
64
29
|
|
|
65
|
-
/** CSS variable name → `{ light, dark }` hex, from `tokens.ts` and `palette.ts`. */
|
|
66
30
|
function schemeColors() {
|
|
67
31
|
if (cachedSchemeColors) return cachedSchemeColors;
|
|
68
32
|
const tokens = readConst("tokens.ts", "tokens");
|
|
@@ -110,25 +74,21 @@ function schemeColors() {
|
|
|
110
74
|
return cachedSchemeColors;
|
|
111
75
|
}
|
|
112
76
|
|
|
113
|
-
/** `#rrggbb` as `r g b`. */
|
|
114
77
|
function channels(hex) {
|
|
115
78
|
const n = Number.parseInt(hex.slice(1, 7), 16);
|
|
116
79
|
return `${(n >> 16) & 255} ${(n >> 8) & 255} ${n & 255}`;
|
|
117
80
|
}
|
|
118
81
|
|
|
119
|
-
/** `--name: r g b` for every colour in one scheme. */
|
|
120
82
|
function cssVariables(scheme) {
|
|
121
83
|
return Object.fromEntries(
|
|
122
84
|
Object.entries(schemeColors()).map(([name, value]) => [`--${name}`, channels(value[scheme])]),
|
|
123
85
|
);
|
|
124
86
|
}
|
|
125
87
|
|
|
126
|
-
/** `--radius` from `tokens.radius.lg` (16), so `rounded-lg`, `-md` and `-sm` are 16, 14 and 12 as in `tokens.radius`. */
|
|
127
88
|
function radiusVariable() {
|
|
128
89
|
return { "--radius": `${readConst("tokens.ts", "tokens").radius.lg}px` };
|
|
129
90
|
}
|
|
130
91
|
|
|
131
|
-
/** The Tailwind colour keys native-ui classes and the apps share. */
|
|
132
92
|
function themeColors(v) {
|
|
133
93
|
return {
|
|
134
94
|
background: v("background"),
|
|
@@ -160,7 +120,6 @@ function themeColors(v) {
|
|
|
160
120
|
};
|
|
161
121
|
}
|
|
162
122
|
|
|
163
|
-
/** `nativewind/preset`, or none where NativeWind is not installed (this repository's tests). */
|
|
164
123
|
function nestedPresets() {
|
|
165
124
|
try {
|
|
166
125
|
return [require("nativewind/preset")];
|
|
@@ -169,7 +128,6 @@ function nestedPresets() {
|
|
|
169
128
|
}
|
|
170
129
|
}
|
|
171
130
|
|
|
172
|
-
/** `{ hairline: hairlineWidth() }` from `nativewind/theme`, or none without NativeWind. */
|
|
173
131
|
function hairlineBorder() {
|
|
174
132
|
try {
|
|
175
133
|
const { hairlineWidth } = require("nativewind/theme");
|
|
@@ -179,7 +137,6 @@ function hairlineBorder() {
|
|
|
179
137
|
}
|
|
180
138
|
}
|
|
181
139
|
|
|
182
|
-
/** A Tailwind plugin that writes the colour variables: `:root` (light) and the dark set for `darkMode`. */
|
|
183
140
|
function cssVariablesPlugin(darkMode) {
|
|
184
141
|
return function nativeUiCssVariables({ addBase }) {
|
|
185
142
|
const dark = cssVariables("dark");
|
|
@@ -197,17 +154,6 @@ function cssVariablesPlugin(darkMode) {
|
|
|
197
154
|
};
|
|
198
155
|
}
|
|
199
156
|
|
|
200
|
-
/**
|
|
201
|
-
* The preset. Options:
|
|
202
|
-
* - `darkMode`: `"class"` (default; `ThemeToggle` and `setColorScheme` need it) or `"media"`.
|
|
203
|
-
* - `color`: CSS variable name → colour value. Default `cssVar`, or `rgbAlpha` with `injectCssVariables`.
|
|
204
|
-
* - `injectCssVariables`: write the colour variables and `--radius` from `tokens.ts` and `palette.ts`. Default `false`.
|
|
205
|
-
* - `radiusVariable`: `rounded-lg`, `-md` and `-sm` from `var(--radius)`, as vibot and Velth. Default: on with
|
|
206
|
-
* `injectCssVariables`, else off, so an app without `--radius` keeps the Tailwind radii.
|
|
207
|
-
* - `font`: `{ regular, medium, semibold, bold }` family names for `sans` and the four `font-instrument-sans*`
|
|
208
|
-
* classes. Keys not given keep Instrument Sans. Pass the same names to `configureTheme({ font })`, which sets
|
|
209
|
-
* the JS styles; the app loads the font files.
|
|
210
|
-
*/
|
|
211
157
|
function nativeUiPreset(options = {}) {
|
|
212
158
|
const darkMode = options.darkMode === "media" ? "media" : "class";
|
|
213
159
|
const font = { ...INSTRUMENT_SANS };
|
|
@@ -6,18 +6,10 @@ type CssDeclarations = Record<string, string>;
|
|
|
6
6
|
type AddBase = (base: Record<string, CssDeclarations | Record<string, CssDeclarations>>) => void;
|
|
7
7
|
|
|
8
8
|
export interface NativeUiPresetOptions {
|
|
9
|
-
/** Default `"class"`: `ThemeToggle` and NativeWind `setColorScheme` need it. */
|
|
10
9
|
darkMode?: "class" | "media";
|
|
11
|
-
/** Default `cssVar`, or `rgbAlpha` with `injectCssVariables`. */
|
|
12
10
|
color?: ColorFn;
|
|
13
|
-
/** Write the colour variables (as `r g b` channels) and `--radius` from `tokens.ts` and `palette.ts`. Default `false`. */
|
|
14
11
|
injectCssVariables?: boolean;
|
|
15
|
-
/** `rounded-lg`, `-md` and `-sm` from `var(--radius)`. Default: the value of `injectCssVariables`. */
|
|
16
12
|
radiusVariable?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Family names for `sans` and the four `font-instrument-sans*` classes. Keys not given keep Instrument Sans.
|
|
19
|
-
* Pass the same names to `configureTheme({ font })`; the app loads the font files.
|
|
20
|
-
*/
|
|
21
13
|
font?: { regular?: string; medium?: string; semibold?: string; bold?: string };
|
|
22
14
|
}
|
|
23
15
|
|
package/dist/theme.jsx
CHANGED
|
@@ -6,49 +6,54 @@ import { ThemeVersionContext } from "./useScheme";
|
|
|
6
6
|
export const DEFAULT_ACCENT = "#db2777";
|
|
7
7
|
const NativeUiContext = createContext({
|
|
8
8
|
largerText: false,
|
|
9
|
-
accentColor: DEFAULT_ACCENT
|
|
9
|
+
accentColor: DEFAULT_ACCENT,
|
|
10
|
+
surface: "glass"
|
|
10
11
|
});
|
|
11
12
|
export function NativeUiProvider(t0) {
|
|
12
|
-
const $ = _c(
|
|
13
|
+
const $ = _c(10);
|
|
13
14
|
const {
|
|
14
15
|
largerText: t1,
|
|
15
16
|
accentColor: t2,
|
|
17
|
+
surface: t3,
|
|
16
18
|
children
|
|
17
19
|
} = t0;
|
|
18
20
|
const largerText = t1 === undefined ? false : t1;
|
|
19
21
|
const accentColor = t2 === undefined ? DEFAULT_ACCENT : t2;
|
|
22
|
+
const surface = t3 === undefined ? "glass" : t3;
|
|
20
23
|
const themeVersion = useSyncExternalStore(subscribeTheme, getThemeVersion, getThemeVersion);
|
|
21
|
-
let
|
|
22
|
-
if ($[0] !== accentColor || $[1] !== largerText) {
|
|
23
|
-
|
|
24
|
+
let t4;
|
|
25
|
+
if ($[0] !== accentColor || $[1] !== largerText || $[2] !== surface) {
|
|
26
|
+
t4 = {
|
|
24
27
|
largerText,
|
|
25
|
-
accentColor
|
|
28
|
+
accentColor,
|
|
29
|
+
surface
|
|
26
30
|
};
|
|
27
31
|
$[0] = accentColor;
|
|
28
32
|
$[1] = largerText;
|
|
29
|
-
$[2] =
|
|
33
|
+
$[2] = surface;
|
|
34
|
+
$[3] = t4;
|
|
30
35
|
} else {
|
|
31
|
-
|
|
36
|
+
t4 = $[3];
|
|
32
37
|
}
|
|
33
|
-
let
|
|
34
|
-
if ($[
|
|
35
|
-
|
|
36
|
-
$[
|
|
37
|
-
$[
|
|
38
|
-
$[
|
|
38
|
+
let t5;
|
|
39
|
+
if ($[4] !== children || $[5] !== themeVersion) {
|
|
40
|
+
t5 = <ThemeVersionContext.Provider value={themeVersion}>{children}</ThemeVersionContext.Provider>;
|
|
41
|
+
$[4] = children;
|
|
42
|
+
$[5] = themeVersion;
|
|
43
|
+
$[6] = t5;
|
|
39
44
|
} else {
|
|
40
|
-
|
|
45
|
+
t5 = $[6];
|
|
41
46
|
}
|
|
42
|
-
let
|
|
43
|
-
if ($[
|
|
44
|
-
|
|
45
|
-
$[6] = t3;
|
|
47
|
+
let t6;
|
|
48
|
+
if ($[7] !== t4 || $[8] !== t5) {
|
|
49
|
+
t6 = <NativeUiContext.Provider value={t4}>{t5}</NativeUiContext.Provider>;
|
|
46
50
|
$[7] = t4;
|
|
47
51
|
$[8] = t5;
|
|
52
|
+
$[9] = t6;
|
|
48
53
|
} else {
|
|
49
|
-
|
|
54
|
+
t6 = $[9];
|
|
50
55
|
}
|
|
51
|
-
return
|
|
56
|
+
return t6;
|
|
52
57
|
}
|
|
53
58
|
export function useNativeUi() {
|
|
54
59
|
return useContext(NativeUiContext);
|
|
@@ -56,6 +61,9 @@ export function useNativeUi() {
|
|
|
56
61
|
export function useLargerText() {
|
|
57
62
|
return useContext(NativeUiContext).largerText;
|
|
58
63
|
}
|
|
64
|
+
export function useSurface() {
|
|
65
|
+
return useContext(NativeUiContext).surface;
|
|
66
|
+
}
|
|
59
67
|
export function useAccentColor() {
|
|
60
68
|
return useContext(NativeUiContext).accentColor;
|
|
61
69
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
let chosen = false;
|
|
24
|
+
const listeners = new Set();
|
|
25
|
+
const report = error => onError?.(toError(error));
|
|
26
|
+
function apply(mode) {
|
|
27
|
+
current = mode;
|
|
28
|
+
paintDarkFamily(mode === "neutral" ? "neutral" : "dark");
|
|
29
|
+
colorScheme.set(mode === "neutral" ? "dark" : mode);
|
|
30
|
+
for (const listener of listeners) listener();
|
|
31
|
+
}
|
|
32
|
+
function subscribe(listener) {
|
|
33
|
+
listeners.add(listener);
|
|
34
|
+
return () => {
|
|
35
|
+
listeners.delete(listener);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const getMode = () => current;
|
|
39
|
+
async function restore() {
|
|
40
|
+
let saved = null;
|
|
41
|
+
try {
|
|
42
|
+
saved = await storage.getItem(key);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
report(error instanceof Error ? error : String(error));
|
|
45
|
+
}
|
|
46
|
+
if (chosen) return;
|
|
47
|
+
apply(parseThemeMode(saved) ?? "system");
|
|
48
|
+
}
|
|
49
|
+
function set(mode) {
|
|
50
|
+
chosen = true;
|
|
51
|
+
if (mode !== current) apply(mode);
|
|
52
|
+
Promise.resolve().then(() => storage.setItem(key, mode)).catch(report);
|
|
53
|
+
}
|
|
54
|
+
const getServerSnapshot = () => "system";
|
|
55
|
+
return {
|
|
56
|
+
getMode,
|
|
57
|
+
subscribe,
|
|
58
|
+
restore,
|
|
59
|
+
set,
|
|
60
|
+
useMode: () => useSyncExternalStore(subscribe, getMode, getServerSnapshot)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -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
|
+
}
|
package/dist/toastChrome.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The `Toaster` look, from the web `SonnerToaster` at its default density
|
|
3
|
-
* (`createToasterClassNames` in `sonner.tsx`) with `toastIcons="filled24"`
|
|
4
|
-
* (`sonner-icons.tsx`). No React Native import, so the tests can load this
|
|
5
|
-
* file.
|
|
6
|
-
*/
|
|
7
1
|
import { palette, withAlpha } from "./palette";
|
|
8
2
|
import { tokens } from "./tokens";
|
|
9
3
|
/** Web `rounded-lg` (`--radius`, 16), the default `toastRadius`. */
|