@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
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { configureTheme } from "./configureTheme";
|
|
2
|
+
import { palette, withAlpha } from "./palette";
|
|
3
|
+
import { tokens } from "./tokens";
|
|
4
|
+
|
|
5
|
+
/** The web Neutral theme (`.dark.neutral` in `@vvedantb/ui` tokens.css), as hex. */
|
|
6
|
+
export const NEUTRAL_PALETTE = {
|
|
7
|
+
background: "#222325",
|
|
8
|
+
surface: "#303134",
|
|
9
|
+
surfaceSecondary: "#3a3b3e",
|
|
10
|
+
surfaceTertiary: "#444548",
|
|
11
|
+
border: "#4e4f52",
|
|
12
|
+
muted: "#9fa0a2",
|
|
13
|
+
foreground: "#fafafa",
|
|
14
|
+
} as const;
|
|
15
|
+
|
|
16
|
+
/** The same colours as space-separated RGB channels, for NativeWind variables that take channels. */
|
|
17
|
+
export const NEUTRAL_CHANNELS = {
|
|
18
|
+
background: "34 35 37",
|
|
19
|
+
surface: "48 49 52",
|
|
20
|
+
surfaceSecondary: "58 59 62",
|
|
21
|
+
surfaceTertiary: "68 69 72",
|
|
22
|
+
border: "78 79 82",
|
|
23
|
+
muted: "159 160 162",
|
|
24
|
+
foreground: "250 250 250",
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
type DarkFamily = {
|
|
28
|
+
color: Record<
|
|
29
|
+
| "background"
|
|
30
|
+
| "foreground"
|
|
31
|
+
| "muted"
|
|
32
|
+
| "border"
|
|
33
|
+
| "separator"
|
|
34
|
+
| "surface"
|
|
35
|
+
| "surfaceSecondary"
|
|
36
|
+
| "surfaceCard"
|
|
37
|
+
| "fill",
|
|
38
|
+
string
|
|
39
|
+
>;
|
|
40
|
+
palette: Record<"default" | "overlay" | "segment" | "surfaceTertiary" | "fieldPlaceholder" | "tabBarPill", string>;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const DARK: DarkFamily = {
|
|
44
|
+
color: {
|
|
45
|
+
background: tokens.color.background.dark,
|
|
46
|
+
foreground: tokens.color.foreground.dark,
|
|
47
|
+
muted: tokens.color.muted.dark,
|
|
48
|
+
border: tokens.color.border.dark,
|
|
49
|
+
separator: tokens.color.separator.dark,
|
|
50
|
+
surface: tokens.color.surface.dark,
|
|
51
|
+
surfaceSecondary: tokens.color.surfaceSecondary.dark,
|
|
52
|
+
surfaceCard: tokens.color.surfaceCard.dark,
|
|
53
|
+
fill: tokens.color.fill.dark,
|
|
54
|
+
},
|
|
55
|
+
palette: {
|
|
56
|
+
default: palette.default.dark,
|
|
57
|
+
overlay: palette.overlay.dark,
|
|
58
|
+
segment: palette.segment.dark,
|
|
59
|
+
surfaceTertiary: palette.surfaceTertiary.dark,
|
|
60
|
+
fieldPlaceholder: palette.fieldPlaceholder.dark,
|
|
61
|
+
tabBarPill: palette.tabBarPill.dark,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const NEUTRAL: DarkFamily = {
|
|
66
|
+
color: {
|
|
67
|
+
background: NEUTRAL_PALETTE.background,
|
|
68
|
+
foreground: NEUTRAL_PALETTE.foreground,
|
|
69
|
+
muted: NEUTRAL_PALETTE.muted,
|
|
70
|
+
border: NEUTRAL_PALETTE.border,
|
|
71
|
+
separator: NEUTRAL_PALETTE.surfaceSecondary,
|
|
72
|
+
surface: NEUTRAL_PALETTE.surface,
|
|
73
|
+
surfaceSecondary: NEUTRAL_PALETTE.surfaceSecondary,
|
|
74
|
+
surfaceCard: NEUTRAL_PALETTE.surface,
|
|
75
|
+
fill: withAlpha(NEUTRAL_PALETTE.surface, 0.88),
|
|
76
|
+
},
|
|
77
|
+
palette: {
|
|
78
|
+
default: NEUTRAL_PALETTE.surfaceTertiary,
|
|
79
|
+
overlay: NEUTRAL_PALETTE.surface,
|
|
80
|
+
segment: NEUTRAL_PALETTE.surfaceTertiary,
|
|
81
|
+
surfaceTertiary: NEUTRAL_PALETTE.surfaceTertiary,
|
|
82
|
+
fieldPlaceholder: NEUTRAL_PALETTE.muted,
|
|
83
|
+
tabBarPill: NEUTRAL_PALETTE.surfaceTertiary,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/** Dark-slot colours that replace the ones `paintDarkFamily` would paint. */
|
|
88
|
+
export type PaintDarkFamilyOverrides = {
|
|
89
|
+
color?: Partial<DarkFamily["color"]>;
|
|
90
|
+
palette?: Partial<DarkFamily["palette"]>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Puts the Dark or Neutral colours in the kit's dark slot (`configureTheme`).
|
|
95
|
+
* Light is not changed. Kit parts under `NativeUiProvider` redraw at once.
|
|
96
|
+
* Status and accent colours stay Dark's. `overrides` replaces any painted
|
|
97
|
+
* dark-slot colour, for an app that keeps its own value.
|
|
98
|
+
*/
|
|
99
|
+
export function paintDarkFamily(family: "dark" | "neutral", overrides?: PaintDarkFamilyOverrides): void {
|
|
100
|
+
const base = family === "neutral" ? NEUTRAL : DARK;
|
|
101
|
+
const next: DarkFamily = {
|
|
102
|
+
color: { ...base.color, ...overrides?.color },
|
|
103
|
+
palette: { ...base.palette, ...overrides?.palette },
|
|
104
|
+
};
|
|
105
|
+
const { color } = tokens;
|
|
106
|
+
configureTheme({
|
|
107
|
+
color: {
|
|
108
|
+
background: { light: color.background.light, dark: next.color.background },
|
|
109
|
+
foreground: { light: color.foreground.light, dark: next.color.foreground },
|
|
110
|
+
muted: { light: color.muted.light, dark: next.color.muted },
|
|
111
|
+
border: { light: color.border.light, dark: next.color.border },
|
|
112
|
+
separator: { light: color.separator.light, dark: next.color.separator },
|
|
113
|
+
surface: { light: color.surface.light, dark: next.color.surface },
|
|
114
|
+
surfaceSecondary: { light: color.surfaceSecondary.light, dark: next.color.surfaceSecondary },
|
|
115
|
+
surfaceCard: { light: color.surfaceCard.light, dark: next.color.surfaceCard },
|
|
116
|
+
fill: { light: color.fill.light, dark: next.color.fill },
|
|
117
|
+
},
|
|
118
|
+
palette: {
|
|
119
|
+
default: { light: palette.default.light, dark: next.palette.default },
|
|
120
|
+
overlay: { light: palette.overlay.light, dark: next.palette.overlay },
|
|
121
|
+
segment: { light: palette.segment.light, dark: next.palette.segment },
|
|
122
|
+
surfaceTertiary: { light: palette.surfaceTertiary.light, dark: next.palette.surfaceTertiary },
|
|
123
|
+
fieldPlaceholder: { light: palette.fieldPlaceholder.light, dark: next.palette.fieldPlaceholder },
|
|
124
|
+
tabBarPill: { light: palette.tabBarPill.light, dark: next.palette.tabBarPill },
|
|
125
|
+
},
|
|
126
|
+
});
|
|
127
|
+
}
|
package/src/pagerSwipe.ts
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The rules of a swiped `Pager`, as plain numbers, so they stay testable
|
|
3
|
-
* apart from the gesture. The pager's position is in pages: 0 is the first
|
|
4
|
-
* page, 1.5 is halfway between the second and the third. Distances are in
|
|
5
|
-
* points and velocities in points per second (the Gesture Handler units),
|
|
6
|
-
* positive to the right. Each rule is a worklet, so the drag runs it on the
|
|
7
|
-
* UI thread.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
1
|
/**
|
|
11
2
|
* Sideways travel (pt) before a drag takes the pager: twice a row swipe's
|
|
12
3
|
* (`SWIPE_ACTIVE_OFFSET_X`), so a swipeable row under the finger takes its
|
|
@@ -17,13 +8,10 @@ export const PAGER_ACTIVE_OFFSET_X = 24;
|
|
|
17
8
|
/** Vertical travel (pt) that leaves the touch to the page's own scroll. */
|
|
18
9
|
export const PAGER_FAIL_OFFSET_Y = 14;
|
|
19
10
|
|
|
20
|
-
/** A sideways flick at this speed (pt/s) turns the page, however short the drag. */
|
|
21
11
|
const FLICK_VELOCITY = 500;
|
|
22
12
|
|
|
23
|
-
/** How far ahead (s) the release velocity carries the pages when deciding where they settle. */
|
|
24
13
|
const PROJECTION_S = 0.2;
|
|
25
14
|
|
|
26
|
-
/** How far the pages move past the first or last page: less and less the further the finger goes. */
|
|
27
15
|
function rubberband(overshoot: number, dimension: number): number {
|
|
28
16
|
"worklet";
|
|
29
17
|
const constant = 0.55;
|
|
@@ -55,7 +43,6 @@ export function pagerPosition(start: number, dx: number, width: number, count: n
|
|
|
55
43
|
export function pagerSettle(position: number, vx: number, width: number, from: number, count: number): number {
|
|
56
44
|
"worklet";
|
|
57
45
|
const moved = position - from;
|
|
58
|
-
// A drag left (negative `vx`) moves toward the next page (a larger position).
|
|
59
46
|
const toward = -Math.sign(vx);
|
|
60
47
|
let target: number;
|
|
61
48
|
if (Math.abs(vx) >= FLICK_VELOCITY && moved !== 0 && toward === Math.sign(moved)) {
|
package/src/palette.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* drifts, so change `tokens.css` first and then this file.
|
|
10
10
|
*/
|
|
11
11
|
export const palette = {
|
|
12
|
-
/** `--accent` (web `primary`): near-black in light, near-white in dark. */
|
|
13
12
|
primary: { light: "#181818", dark: "#fcfcfc" },
|
|
14
13
|
primaryForeground: { light: "#fcfcfc", dark: "#181818" },
|
|
15
14
|
danger: { light: "#ff373c", dark: "#db3b3e" },
|
|
@@ -18,26 +17,17 @@ export const palette = {
|
|
|
18
17
|
successForeground: { light: "#161917", dark: "#161917" },
|
|
19
18
|
warning: { light: "#f5a523", dark: "#f7b750" },
|
|
20
19
|
warningForeground: { light: "#1a1815", dark: "#1a1815" },
|
|
21
|
-
/** `--default` (web `secondary`): neutral control fill. */
|
|
22
20
|
default: { light: "#ebebeb", dark: "#272727" },
|
|
23
21
|
defaultForeground: { light: "#181818", dark: "#fcfcfc" },
|
|
24
22
|
overlay: { light: "#ffffff", dark: "#181818" },
|
|
25
23
|
overlayForeground: { light: "#181818", dark: "#fcfcfc" },
|
|
26
24
|
segment: { light: "#ffffff", dark: "#474747" },
|
|
27
25
|
segmentForeground: { light: "#181818", dark: "#fcfcfc" },
|
|
28
|
-
/**
|
|
29
|
-
* The `FloatingTabBar` active pill: `--default` in light (it shows on the
|
|
30
|
-
* near-white glass bar) and `--segment` in dark. Its own key, so an app that
|
|
31
|
-
* themes `segment` for the segmented `Tabs` thumb keeps a pill that shows on
|
|
32
|
-
* the dark glass bar.
|
|
33
|
-
*/
|
|
34
26
|
tabBarPill: { light: "#ebebeb", dark: "#474747" },
|
|
35
27
|
surfaceTertiary: { light: "#eaeaea", dark: "#282627" },
|
|
36
28
|
fieldPlaceholder: { light: "#727272", dark: "#a0a0a0" },
|
|
37
29
|
backdrop: { light: "rgba(0, 0, 0, 0.5)", dark: "rgba(0, 0, 0, 0.6)" },
|
|
38
|
-
/** Web `DialogDescription` text: `--overlay-foreground` mixed 72% into `--overlay` (oklch), for 4.5:1 on the overlay. */
|
|
39
30
|
overlayMuted: { light: "#505050", dark: "#b5b5b5" },
|
|
40
|
-
/** Fill of the web destructive `Button` (`oklch(47.2% 0.195 25.7)`), the same in both schemes. */
|
|
41
31
|
destructive: "#af0015",
|
|
42
32
|
} as const;
|
|
43
33
|
|
package/src/pressScale.ts
CHANGED
|
@@ -14,19 +14,12 @@ export const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
|
14
14
|
cssInterop(AnimatedPressable, { className: "style" });
|
|
15
15
|
|
|
16
16
|
export type PressScaleOptions = {
|
|
17
|
-
/** Scale while pressed. Default 0.97. */
|
|
18
17
|
scale?: number;
|
|
19
|
-
/** Opacity while pressed, a light dim. Default 0.7, the dim these controls had before the scale. */
|
|
20
18
|
dim?: number;
|
|
21
|
-
/** Dim used instead under Reduce Motion. Default `dim`. */
|
|
22
19
|
reducedDim?: number;
|
|
23
|
-
/** Opacity at rest, such as 0.5 when disabled. The press dims from here. Default 1. */
|
|
24
20
|
restOpacity?: number;
|
|
25
|
-
/** Press-in duration in ms. Default 120. */
|
|
26
21
|
pressInMs?: number;
|
|
27
|
-
/** Release duration in ms. Default 160. */
|
|
28
22
|
pressOutMs?: number;
|
|
29
|
-
/** A disabled control lets go at once, so it cannot stay pressed. */
|
|
30
23
|
disabled?: boolean;
|
|
31
24
|
};
|
|
32
25
|
|
|
@@ -40,8 +40,6 @@ const buttonVariants = cva(
|
|
|
40
40
|
lg: "h-11 px-6",
|
|
41
41
|
icon: "h-10 w-10",
|
|
42
42
|
},
|
|
43
|
-
// The web `shape`: `pill` (default) is fully round, `rounded` the radius
|
|
44
|
-
// before 0.6.0. `Button` also sets the radius as a style, which wins.
|
|
45
43
|
shape: {
|
|
46
44
|
pill: "rounded-full",
|
|
47
45
|
rounded: "rounded-lg",
|
|
@@ -55,8 +53,6 @@ const buttonVariants = cva(
|
|
|
55
53
|
},
|
|
56
54
|
);
|
|
57
55
|
|
|
58
|
-
// No weight: a class context cannot carry the `typeStyle` that a face class
|
|
59
|
-
// needs, so `Button` sets the medium face and its weight on its label.
|
|
60
56
|
const buttonTextVariants = cva("text-sm text-foreground", {
|
|
61
57
|
variants: {
|
|
62
58
|
variant: {
|
package/src/primitives/card.tsx
CHANGED
|
@@ -42,7 +42,6 @@ const CardTitle = React.forwardRef<
|
|
|
42
42
|
React.ElementRef<typeof Text>,
|
|
43
43
|
React.ComponentPropsWithoutRef<typeof Text> & { className?: string }
|
|
44
44
|
>(({ className, style, ...props }, ref) => {
|
|
45
|
-
// The web `font-medium`: the semibold face, with its weight as a style.
|
|
46
45
|
return (
|
|
47
46
|
<Text
|
|
48
47
|
ref={ref}
|
package/src/primitives/icon.tsx
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { IconProps as TablerIconProps } from "@tabler/icons-react-native";
|
|
3
3
|
|
|
4
|
-
// Tabler, not Lucide: a Lucide icon always sets `testID` on its `Svg`, which
|
|
5
|
-
// on web is a DOM `<svg>`, so React logs it as an unknown DOM prop.
|
|
6
4
|
type IconProps = TablerIconProps & {
|
|
7
5
|
as: React.ComponentType<TablerIconProps>;
|
|
8
6
|
className?: string;
|
package/src/primitives/input.tsx
CHANGED
|
@@ -14,10 +14,6 @@ const Input = React.forwardRef<React.ElementRef<typeof TextInput>, InputProps>(
|
|
|
14
14
|
return (
|
|
15
15
|
<TextInput
|
|
16
16
|
ref={ref}
|
|
17
|
-
// A prop, not a `placeholder:` class: on native NativeWind turns that
|
|
18
|
-
// class into `placeholderTextColor`, which beats the prop. The old
|
|
19
|
-
// `placeholder:text-muted-foreground/50` was the light grey at half
|
|
20
|
-
// opacity in apps that nest `dark` under `muted-foreground`.
|
|
21
17
|
placeholderTextColor={placeholderTextColor ?? palette.fieldPlaceholder[scheme]}
|
|
22
18
|
className={cn(
|
|
23
19
|
"flex w-full flex-row items-center rounded-lg border-0 bg-secondary px-3 py-2 text-base text-foreground",
|
|
@@ -10,17 +10,6 @@ import {
|
|
|
10
10
|
import { runOnJS } from "react-native-reanimated";
|
|
11
11
|
import { COMPOSER_INPUT_ID, KeyboardPartsContext, type KeyboardParts } from "./keyboard-parts";
|
|
12
12
|
|
|
13
|
-
// The keyboard parts on `react-native-keyboard-controller`: the keyboard's
|
|
14
|
-
// real position, frame by frame, on the UI thread. No timing of our own, so
|
|
15
|
-
// the composer can neither lag nor lead the keyboard; with Reduce Motion the
|
|
16
|
-
// system shortens the keyboard's own motion and the parts follow it.
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* A drag moves the keyboard on iOS (`keyboardDismissMode="interactive"`) and
|
|
20
|
-
* on Android 11+ (API 30, `WindowInsetsAnimation`). Android 10 and below has
|
|
21
|
-
* no interactive keyboard: `KeyboardGestureArea` then only renders its
|
|
22
|
-
* children, and the transcript keeps `on-drag`.
|
|
23
|
-
*/
|
|
24
13
|
const INTERACTIVE = Platform.OS === "ios" || (Platform.OS === "android" && Number(Platform.Version) >= 30);
|
|
25
14
|
|
|
26
15
|
function AvoidingView(props: ComponentProps<KeyboardParts["AvoidingView"]>) {
|
|
@@ -31,15 +20,6 @@ function StickyView({ bottomOffset, ...props }: ComponentProps<KeyboardParts["St
|
|
|
31
20
|
return <KeyboardStickyView {...props} offset={{ opened: bottomOffset }} />;
|
|
32
21
|
}
|
|
33
22
|
|
|
34
|
-
/**
|
|
35
|
-
* `always`: the content rises with the keyboard wherever the reader is, so
|
|
36
|
-
* what sat on the composer stays there (the newest message, at the end).
|
|
37
|
-
* Inverted, the keyboard's space is the content's top inset, the visual
|
|
38
|
-
* bottom: iOS scrolls below offset 0 into it, so the end moves there; Android
|
|
39
|
-
* moves the content down by it instead, so offset 0 stays the end. While the
|
|
40
|
-
* keyboard moves, the list scrolls with it, through offsets that are not the
|
|
41
|
-
* end on either platform.
|
|
42
|
-
*/
|
|
43
23
|
function ChatScrollView({
|
|
44
24
|
bottomOffset,
|
|
45
25
|
inverted = false,
|
|
@@ -65,7 +45,6 @@ function ChatScrollView({
|
|
|
65
45
|
<KeyboardChatScrollView
|
|
66
46
|
{...props}
|
|
67
47
|
inverted={inverted}
|
|
68
|
-
// An overlay window (a hold menu) takes the focus on Android: its keyboard events must not scroll the list.
|
|
69
48
|
freeze={freeze}
|
|
70
49
|
offset={bottomOffset}
|
|
71
50
|
keyboardLiftBehavior="always"
|
|
@@ -76,10 +55,6 @@ function ChatScrollView({
|
|
|
76
55
|
);
|
|
77
56
|
}
|
|
78
57
|
|
|
79
|
-
/**
|
|
80
|
-
* `ios`: the keyboard follows once the finger reaches the composer, then 1:1,
|
|
81
|
-
* and a release carries the finger's velocity, on both platforms.
|
|
82
|
-
*/
|
|
83
58
|
function GestureArea({ offset, style, children }: ComponentProps<KeyboardParts["GestureArea"]>) {
|
|
84
59
|
return (
|
|
85
60
|
<KeyboardGestureArea interpolator="ios" offset={offset} textInputNativeID={COMPOSER_INPUT_ID} style={style}>
|
|
@@ -16,24 +16,8 @@ import {
|
|
|
16
16
|
* the peer and an app without it bundles as before.
|
|
17
17
|
*/
|
|
18
18
|
export type KeyboardParts = {
|
|
19
|
-
/** A `KeyboardAvoidingView` that pads frame by frame with the keyboard. */
|
|
20
19
|
AvoidingView: ComponentType<KeyboardAvoidingViewProps>;
|
|
21
|
-
/**
|
|
22
|
-
* Moves with the keyboard (`translateY`), less `bottomOffset` while it is
|
|
23
|
-
* open: the bottom inset the content pads, which the keyboard covers.
|
|
24
|
-
*/
|
|
25
20
|
StickyView: ComponentType<ViewProps & { bottomOffset: number }>;
|
|
26
|
-
/**
|
|
27
|
-
* The chat transcript's scroll view (a `FlatList` `renderScrollComponent`).
|
|
28
|
-
* Its content gains the keyboard height less `bottomOffset` at the end (at
|
|
29
|
-
* its start when `inverted`, the visual bottom either way), and moves up
|
|
30
|
-
* with the keyboard, so the newest message stays in view. `onInsetChange`
|
|
31
|
-
* gets that extra space as the scroll offset sees it, which `onScroll` does
|
|
32
|
-
* not report: past the content's end, or when `inverted` before offset 0.
|
|
33
|
-
* `onKeyboardMove` is true from the start to the end of each keyboard
|
|
34
|
-
* move, while the keyboard, not the reader, scrolls the list. With
|
|
35
|
-
* `freeze`, keyboard events change nothing (an overlay window is open).
|
|
36
|
-
*/
|
|
37
21
|
ChatScrollView: ComponentType<
|
|
38
22
|
ScrollViewProps & {
|
|
39
23
|
bottomOffset: number;
|
|
@@ -43,15 +27,7 @@ export type KeyboardParts = {
|
|
|
43
27
|
onKeyboardMove: (moving: boolean) => void;
|
|
44
28
|
}
|
|
45
29
|
>;
|
|
46
|
-
/**
|
|
47
|
-
* Around the transcript: a drag that reaches `offset` above the keyboard
|
|
48
|
-
* (the composer's top) moves the keyboard with the finger.
|
|
49
|
-
*/
|
|
50
30
|
GestureArea: ComponentType<{ offset: number; style?: StyleProp<ViewStyle>; children: ReactNode }>;
|
|
51
|
-
/**
|
|
52
|
-
* Whether a drag on the transcript moves the keyboard (iOS, Android 11+).
|
|
53
|
-
* False on Android 10 and below: there a drag lowers it at once.
|
|
54
|
-
*/
|
|
55
31
|
interactive: boolean;
|
|
56
32
|
};
|
|
57
33
|
|
|
@@ -83,12 +59,9 @@ export function useKeyboardParts(): KeyboardParts | null {
|
|
|
83
59
|
export const COMPOSER_INPUT_ID = "native-ui-composer";
|
|
84
60
|
|
|
85
61
|
export type KeyboardAvoidingViewProps = {
|
|
86
|
-
/** Default `padding`, on iOS and Android: Android `height` does nothing edge-to-edge. */
|
|
87
62
|
behavior?: "padding" | "height" | "position";
|
|
88
|
-
/** Height of anything above the view's top, such as a navigation header. Default 0. */
|
|
89
63
|
keyboardVerticalOffset?: number;
|
|
90
64
|
enabled?: boolean;
|
|
91
|
-
/** A style, not a class: the keyboard-controller view takes no NativeWind `className`. */
|
|
92
65
|
style?: StyleProp<ViewStyle>;
|
|
93
66
|
testID?: string;
|
|
94
67
|
children?: ReactNode;
|
|
@@ -8,11 +8,6 @@ type NativeOnlyAnimatedViewProps = ViewProps & {
|
|
|
8
8
|
layout?: AnimatedProps<ViewProps>["layout"];
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* `Animated.View` with layout animations on iOS and Android, a plain `View`
|
|
13
|
-
* on web. With Reduce Motion on, it drops the animations: sheets, toasts and
|
|
14
|
-
* the `Select` popover appear and leave in place.
|
|
15
|
-
*/
|
|
16
11
|
function NativeOnlyAnimatedView({
|
|
17
12
|
children,
|
|
18
13
|
entering,
|
|
@@ -53,11 +53,8 @@ export function useOverlay(part: string): OverlayContextValue {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export type OverlayRootProps = {
|
|
56
|
-
/** Open state when the parent controls it. */
|
|
57
56
|
open?: boolean;
|
|
58
|
-
/** Initial open state when `open` is not set. Default `false`. */
|
|
59
57
|
defaultOpen?: boolean;
|
|
60
|
-
/** Called with the next open state (trigger, close, backdrop, Android back). */
|
|
61
58
|
onOpenChange?: (open: boolean) => void;
|
|
62
59
|
children?: ReactNode;
|
|
63
60
|
};
|
|
@@ -82,7 +79,6 @@ export function OverlayRoot({
|
|
|
82
79
|
}
|
|
83
80
|
|
|
84
81
|
export type OverlayPressableProps = ComponentPropsWithoutRef<typeof Pressable> & {
|
|
85
|
-
/** Merge the press handler into the single child (for example a `Button`) instead of wrapping it. */
|
|
86
82
|
asChild?: boolean;
|
|
87
83
|
};
|
|
88
84
|
|
|
@@ -144,7 +140,6 @@ export function OverlayModal({
|
|
|
144
140
|
part: string;
|
|
145
141
|
placement: "center" | "bottom";
|
|
146
142
|
dismissible: boolean;
|
|
147
|
-
/** Once the overlay is on screen: where to focus a field (see `DialogContent`'s `onShow`). */
|
|
148
143
|
onShow?: () => void;
|
|
149
144
|
children: ReactNode;
|
|
150
145
|
}) {
|
|
@@ -153,7 +148,6 @@ export function OverlayModal({
|
|
|
153
148
|
const reduceMotion = useReduceMotion();
|
|
154
149
|
const slides = placement === "bottom" && !reduceMotion;
|
|
155
150
|
const scales = placement === "center" && !reduceMotion;
|
|
156
|
-
// Up while open, and after a close until a sliding sheet or a scaling dialog is out of sight.
|
|
157
151
|
const [shown, setShown] = useState(open);
|
|
158
152
|
if (open && !shown) setShown(true);
|
|
159
153
|
if (!open && shown && !slides && !scales) setShown(false);
|
|
@@ -162,8 +156,6 @@ export function OverlayModal({
|
|
|
162
156
|
|
|
163
157
|
if (!shown) return null;
|
|
164
158
|
return (
|
|
165
|
-
// The layer runs its own motion, so no fade; a layer loses the context
|
|
166
|
-
// between it and the host, so the open state is provided again.
|
|
167
159
|
<WindowLayer onRequestClose={close} onShow={onShow} fade={false}>
|
|
168
160
|
<OverlayContext.Provider value={overlay}>
|
|
169
161
|
<ModalRoot>
|
|
@@ -185,7 +177,6 @@ export function OverlayModal({
|
|
|
185
177
|
);
|
|
186
178
|
}
|
|
187
179
|
|
|
188
|
-
/** The layer's content: mounted with each opening, so a sheet starts below the screen (or at rest). */
|
|
189
180
|
function OverlayModalBody({
|
|
190
181
|
part,
|
|
191
182
|
placement,
|
|
@@ -211,9 +202,6 @@ function OverlayModalBody({
|
|
|
211
202
|
const insets = useSafeAreaInsets();
|
|
212
203
|
const drag = useSheetDragState(close, slides);
|
|
213
204
|
const sheetBackdropStyle = useSheetBackdropStyle(drag);
|
|
214
|
-
// A centred dialog: one 0 to 1 `progress` drives the backdrop fade and the
|
|
215
|
-
// panel's scale and opacity. It mounts at 0 with each opening, and at 1
|
|
216
|
-
// under Reduce Motion, so there the dialog simply appears.
|
|
217
205
|
const progress = useSharedValue(scales ? 0 : 1);
|
|
218
206
|
const centreBackdropStyle = useAnimatedStyle(() => ({ opacity: progress.get() }));
|
|
219
207
|
const centrePanelStyle = useAnimatedStyle(() => ({
|
|
@@ -221,18 +209,11 @@ function OverlayModalBody({
|
|
|
221
209
|
transform: [{ scale: PANEL_SCALE_FROM + (1 - PANEL_SCALE_FROM) * progress.get() }],
|
|
222
210
|
}));
|
|
223
211
|
const backdropStyle = placement === "center" ? centreBackdropStyle : sheetBackdropStyle;
|
|
224
|
-
// The open state lives in React, the sheet's position on the UI thread:
|
|
225
|
-
// each change of `open` starts the slide that matches it. The slide in on
|
|
226
|
-
// opening starts from the sheet's first layout (`SheetDragView`).
|
|
227
212
|
useEffect(() => {
|
|
228
213
|
if (!slides) return;
|
|
229
214
|
if (open) slideSheetIn(drag);
|
|
230
215
|
else slideSheetOut(drag, onHidden);
|
|
231
|
-
// Only a change of `open` starts a slide; `drag` and `onHidden` keep their meaning.
|
|
232
216
|
}, [open, slides]);
|
|
233
|
-
// The same for a centred dialog, from wherever `progress` is. Opened again
|
|
234
|
-
// while it leaves, it turns back at once, and the exit callback reports
|
|
235
|
-
// `finished` false, so the layer stays up.
|
|
236
217
|
useEffect(() => {
|
|
237
218
|
if (!scales) return;
|
|
238
219
|
if (open) {
|
|
@@ -245,16 +226,10 @@ function OverlayModalBody({
|
|
|
245
226
|
}),
|
|
246
227
|
);
|
|
247
228
|
}
|
|
248
|
-
// As the slide: only a change of `open` starts it.
|
|
249
229
|
}, [open, scales]);
|
|
250
230
|
return (
|
|
251
231
|
<SheetDragProvider value={drag}>
|
|
252
|
-
{/* Android too: a modal window with `statusBarTranslucent` may not
|
|
253
|
-
resize for the keyboard, which then covers the fields. The padding
|
|
254
|
-
is the measured overlap, so it drops to 0 where the window does
|
|
255
|
-
resize. Frame by frame with `KeyboardControllerProvider`. */}
|
|
256
232
|
<KeyboardAvoidingView style={styles.fill}>
|
|
257
|
-
{/* Over the app, not in the dock it opened from: the dock's lift is not for it. */}
|
|
258
233
|
<KeyboardLiftContext.Provider value={false}>
|
|
259
234
|
<Animated.View
|
|
260
235
|
pointerEvents="box-none"
|
|
@@ -15,33 +15,21 @@ import { InsidePagerContext, type PagerProps } from "../Pager";
|
|
|
15
15
|
import { PAGER_ACTIVE_OFFSET_X, PAGER_FAIL_OFFSET_Y, pagerPosition, pagerSettle, pagesBetween } from "../pagerSwipe";
|
|
16
16
|
import { useWebClickGuard } from "./web-click-guard";
|
|
17
17
|
|
|
18
|
-
// The pager on Gesture Handler: the track phase and the release run as
|
|
19
|
-
// worklets on the UI thread, so the pages never lag the finger. The rules are
|
|
20
|
-
// plain worklets in `pagerSwipe`.
|
|
21
|
-
|
|
22
|
-
/** The release: springs on at the finger's speed, no bounce (an overshoot would flash the next page's edge). */
|
|
23
18
|
const PAGER_SPRING = { duration: 250, dampingRatio: 1, reduceMotion: ReduceMotion.System } as const;
|
|
24
19
|
|
|
25
|
-
/** A page set from outside (a tab press) slides there; at once with Reduce Motion. */
|
|
26
20
|
const PAGER_SLIDE = { duration: 220, reduceMotion: ReduceMotion.System } as const;
|
|
27
21
|
|
|
28
22
|
export function GesturePager({ index, count, onIndexChange, progress, renderPage }: PagerProps) {
|
|
29
23
|
const width = useSharedValue(0);
|
|
30
|
-
// Where the pages were when the finger caught them, and the finger's travel then.
|
|
31
24
|
const start = useSharedValue(0);
|
|
32
25
|
const startX = useSharedValue(0);
|
|
33
26
|
const [mounted, setMounted] = useState<ReadonlySet<number>>(() => new Set([index]));
|
|
34
27
|
const [shown, setShown] = useState(index);
|
|
35
|
-
// A page reached from outside is drawn from then on, with every page the
|
|
36
|
-
// slide there passes, so it never crosses a blank page.
|
|
37
28
|
if (shown !== index) {
|
|
38
29
|
setShown(index);
|
|
39
30
|
setMounted(new Set([...mounted, ...pagesBetween(shown, index)]));
|
|
40
31
|
}
|
|
41
|
-
// The page a swipe settled on, until the new `index` comes back: that one must not stop the spring.
|
|
42
32
|
const settling = useRef<number | null>(null);
|
|
43
|
-
// A page set from outside slides there. An effect: a shared value is never
|
|
44
|
-
// written in render.
|
|
45
33
|
useEffect(() => {
|
|
46
34
|
const fromSwipe = settling.current === index;
|
|
47
35
|
settling.current = null;
|
|
@@ -52,7 +40,6 @@ export function GesturePager({ index, count, onIndexChange, progress, renderPage
|
|
|
52
40
|
const webClicks = useWebClickGuard();
|
|
53
41
|
const dragStarted = () => {
|
|
54
42
|
webClicks.swallowNext();
|
|
55
|
-
// Both neighbours, so the finger finds a page there.
|
|
56
43
|
setMounted((current) => new Set([...current, index - 1, index + 1].filter((page) => page >= 0 && page < count)));
|
|
57
44
|
};
|
|
58
45
|
const settled = (page: number) => {
|
|
@@ -61,28 +48,22 @@ export function GesturePager({ index, count, onIndexChange, progress, renderPage
|
|
|
61
48
|
onIndexChange(page);
|
|
62
49
|
};
|
|
63
50
|
|
|
64
|
-
// Built on each render (for `index` and `count`): the detector keeps the
|
|
65
|
-
// same handler, and a drag in flight, and only takes the new config.
|
|
66
51
|
const pan = Gesture.Pan()
|
|
67
52
|
.enabled(count > 1)
|
|
68
|
-
// Clearly sideways only: a vertical drag is the page's scroll, and a row swipe starts sooner.
|
|
69
53
|
.activeOffsetX([-PAGER_ACTIVE_OFFSET_X, PAGER_ACTIVE_OFFSET_X])
|
|
70
54
|
.failOffsetY([-PAGER_FAIL_OFFSET_Y, PAGER_FAIL_OFFSET_Y])
|
|
71
55
|
.onStart((event) => {
|
|
72
56
|
cancelAnimation(progress);
|
|
73
57
|
start.set(progress.get());
|
|
74
|
-
// Count from here, so the pages do not jump by the slop the drag needed to start.
|
|
75
58
|
startX.set(event.translationX);
|
|
76
59
|
runOnJS(dragStarted)();
|
|
77
60
|
})
|
|
78
|
-
// Track phase: one shared value write per frame, on the UI thread.
|
|
79
61
|
.onUpdate((event) => {
|
|
80
62
|
progress.set(pagerPosition(start.get(), event.translationX - startX.get(), width.get(), count));
|
|
81
63
|
})
|
|
82
64
|
.onEnd((event) => {
|
|
83
65
|
const pageWidth = width.get();
|
|
84
66
|
const target = pagerSettle(progress.get(), event.velocityX, pageWidth, Math.round(start.get()), count);
|
|
85
|
-
// The finger's speed in pages per second, the unit of `progress`.
|
|
86
67
|
const velocity = pageWidth > 0 ? -event.velocityX / pageWidth : 0;
|
|
87
68
|
progress.set(withSpring(target, { ...PAGER_SPRING, velocity }));
|
|
88
69
|
if (target !== index) runOnJS(settled)(target);
|
|
@@ -100,7 +81,6 @@ export function GesturePager({ index, count, onIndexChange, progress, renderPage
|
|
|
100
81
|
{Array.from({ length: count }, (_, page) => (
|
|
101
82
|
<View
|
|
102
83
|
key={page}
|
|
103
|
-
// Off-screen pages are hidden from screen readers; the tabs above switch pages for them.
|
|
104
84
|
accessibilityElementsHidden={page !== index}
|
|
105
85
|
importantForAccessibility={page === index ? "auto" : "no-hide-descendants"}
|
|
106
86
|
style={{ width: `${100 / count}%` }}
|
|
@@ -2,10 +2,6 @@ import { TextInputWrapper, type PasteEventPayload } from "expo-paste-input";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import { PastePartsContext, type PasteParts } from "./paste-parts";
|
|
4
4
|
|
|
5
|
-
// The image paste on `expo-paste-input`: on Android an `OnReceiveContentListener`
|
|
6
|
-
// on the wrapped field (Paste, and the keyboard's image insert), on iOS the
|
|
7
|
-
// field's `paste(_:)` and keyboard stickers. Text paste stays the field's own.
|
|
8
|
-
|
|
9
5
|
const Target: PasteParts["Target"] = ({ onPasteImages, style, children }) => (
|
|
10
6
|
<TextInputWrapper
|
|
11
7
|
style={style}
|
|
@@ -12,7 +12,6 @@ import type { StyleProp, ViewStyle } from "react-native";
|
|
|
12
12
|
*/
|
|
13
13
|
export type PasteParts = {
|
|
14
14
|
Target: ComponentType<{
|
|
15
|
-
/** The pasted images, as `file://` URIs in the app's cache. */
|
|
16
15
|
onPasteImages: (uris: string[]) => void;
|
|
17
16
|
style?: StyleProp<ViewStyle>;
|
|
18
17
|
children: ReactNode;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as SelectPrimitive from "@rn-primitives/select";
|
|
2
|
-
// Tabler, not Lucide: a Lucide icon always sets `testID` on its `Svg`, which
|
|
3
|
-
// on web is a DOM `<svg>`, so React logs it as an unknown DOM prop.
|
|
4
2
|
import { IconCheck, IconChevronDown, IconChevronUp } from "@tabler/icons-react-native";
|
|
5
3
|
import * as React from "react";
|
|
6
4
|
import { Platform, ScrollView, StyleSheet, Text, View } from "react-native";
|
|
@@ -33,8 +31,6 @@ const SelectValue = React.forwardRef<
|
|
|
33
31
|
>(({ className, style, ...props }, ref) => {
|
|
34
32
|
const classes = cn("line-clamp-1 text-sm text-foreground", className);
|
|
35
33
|
if (Platform.OS === "web") {
|
|
36
|
-
// Radix `Select.Value` drops `className` and `style`, so the placeholder
|
|
37
|
-
// took the page colour. Its span inherits them from this Text instead.
|
|
38
34
|
return (
|
|
39
35
|
<Text className={classes} style={style}>
|
|
40
36
|
<SelectPrimitive.Value ref={ref} {...props} />
|
|
@@ -81,7 +77,6 @@ type SelectContentProps = React.ComponentPropsWithoutRef<
|
|
|
81
77
|
portalHost?: string;
|
|
82
78
|
};
|
|
83
79
|
|
|
84
|
-
/** The popover fades in and out on the strong ease-out. */
|
|
85
80
|
const SELECT_ENTER = FadeIn.duration(150).easing(EASE_OUT);
|
|
86
81
|
const SELECT_EXIT = FadeOut.duration(100).easing(EASE_OUT);
|
|
87
82
|
|
|
@@ -97,9 +92,6 @@ const SelectContent = React.forwardRef<
|
|
|
97
92
|
entering={SELECT_ENTER}
|
|
98
93
|
exiting={SELECT_EXIT}
|
|
99
94
|
className="z-50"
|
|
100
|
-
// Content is absolutely positioned, so a bare wrapper has zero height
|
|
101
|
-
// and UI tests drop its children as invisible. Fill the overlay and
|
|
102
|
-
// let touches fall through to it.
|
|
103
95
|
style={overlayFill}
|
|
104
96
|
pointerEvents={Platform.select({ native: "box-none" })}
|
|
105
97
|
>
|
|
@@ -134,9 +126,6 @@ const SelectContent = React.forwardRef<
|
|
|
134
126
|
</SelectPrimitive.Overlay>
|
|
135
127
|
);
|
|
136
128
|
|
|
137
|
-
// Android: no Portal. A Modal inside a portal mounts empty, so `SelectHost`
|
|
138
|
-
// renders the Modal directly and gates it on `open`. iOS and web keep the
|
|
139
|
-
// Portal; `SelectHost` adds the full-window layer on iOS.
|
|
140
129
|
if (Platform.OS === "android") {
|
|
141
130
|
return <SelectHost>{content}</SelectHost>;
|
|
142
131
|
}
|
|
@@ -166,11 +155,6 @@ const SelectLabel = React.forwardRef<
|
|
|
166
155
|
);
|
|
167
156
|
});
|
|
168
157
|
|
|
169
|
-
/**
|
|
170
|
-
* On web `SelectPrimitive.Item` passes these props to a Radix DOM node, not a
|
|
171
|
-
* React Native view, so give it `aria-label` and `data-testid` there, not
|
|
172
|
-
* `accessibilityLabel` or `testID` (`selectItemA11yProps`).
|
|
173
|
-
*/
|
|
174
158
|
type SelectItemProps = React.ComponentPropsWithoutRef<
|
|
175
159
|
typeof SelectPrimitive.Item
|
|
176
160
|
> & {
|
|
@@ -188,7 +172,6 @@ const SelectItem = React.forwardRef<
|
|
|
188
172
|
ref={ref}
|
|
189
173
|
disabled={disabled}
|
|
190
174
|
className={cn(
|
|
191
|
-
// 44 high (56 with larger text) so a row is a full touch target.
|
|
192
175
|
"relative min-h-[44px] flex-row items-center gap-2 rounded-sm py-3 pl-2 pr-8 active:opacity-70",
|
|
193
176
|
largerText && "min-h-[56px]",
|
|
194
177
|
disabled && "opacity-50",
|
|
@@ -203,7 +186,6 @@ const SelectItem = React.forwardRef<
|
|
|
203
186
|
</View>
|
|
204
187
|
<SelectPrimitive.ItemText
|
|
205
188
|
className="select-none text-sm font-instrument-sans-medium"
|
|
206
|
-
// One object: on web the item text is a Radix slot, which drops arrays.
|
|
207
189
|
style={{ ...textStyle("foreground", scheme), ...typeStyle("medium") }}
|
|
208
190
|
/>
|
|
209
191
|
</SelectPrimitive.Item>
|