@vvedantb/native-ui 0.37.0 → 0.37.2
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/dist/AmbientBackground.jsx +16 -28
- package/dist/Avatar.jsx +2 -2
- package/dist/BottomSheetContainer.jsx +1 -1
- package/dist/BulkActionBar.jsx +1 -1
- package/dist/Card.jsx +4 -4
- package/dist/Chip.jsx +2 -2
- package/dist/DateTimeField.jsx +1 -1
- package/dist/Dialog.jsx +3 -3
- package/dist/DropdownMenu.jsx +310 -154
- package/dist/EmptyState.jsx +4 -4
- package/dist/FloatingTabBar.jsx +2 -2
- package/dist/LabeledSwitchRow.jsx +2 -2
- package/dist/ListRow.jsx +2 -2
- package/dist/PinnedBotTile.jsx +2 -2
- package/dist/StatGrid.jsx +1 -1
- package/dist/Stepper.jsx +2 -2
- package/dist/Toast.jsx +1 -1
- package/dist/ai/activity-question.jsx +2 -2
- package/dist/ai/card-button.jsx +2 -2
- package/dist/ai/choice-question.jsx +8 -8
- package/dist/ai/message-action-sheet.jsx +2 -2
- package/dist/ai/message-quote.jsx +2 -2
- package/dist/ai/message.jsx +2 -2
- package/dist/ai/reply-quote-chip.jsx +2 -2
- package/dist/ai/subagent-cards.jsx +6 -6
- package/dist/ai/tool-approval-card.jsx +1 -1
- package/dist/auth/AuthScreen.jsx +2 -2
- package/dist/examples/ParityGallery.jsx +2 -2
- package/dist/generative-ui/components.jsx +2 -2
- package/dist/marketing/UpgradeToProCard.jsx +2 -2
- package/dist/media/ImageGallery.jsx +2 -2
- package/dist/motion.js +3 -2
- package/dist/primitives/card.jsx +2 -2
- package/dist/primitives/text.jsx +13 -13
- package/dist/primitives/toast-drag-gesture.jsx +3 -2
- package/dist/settings/MoreFromProjectV.jsx +2 -2
- package/dist/settings/SettingsSection.jsx +1 -1
- package/dist/settings/ThemeModePicker.jsx +6 -6
- package/package.json +1 -1
- package/src/AmbientBackground.tsx +8 -26
- package/src/Avatar.tsx +2 -2
- package/src/BottomSheetContainer.tsx +1 -1
- package/src/BulkActionBar.tsx +2 -2
- package/src/Card.tsx +5 -5
- package/src/Chip.tsx +2 -2
- package/src/DateTimeField.tsx +2 -2
- package/src/Dialog.tsx +3 -3
- package/src/DropdownMenu.tsx +122 -25
- package/src/EmptyState.tsx +4 -4
- package/src/FloatingTabBar.tsx +2 -2
- package/src/LabeledSwitchRow.tsx +2 -2
- package/src/ListRow.tsx +2 -2
- package/src/PinnedBotTile.tsx +2 -2
- package/src/StatGrid.tsx +2 -2
- package/src/Stepper.tsx +2 -2
- package/src/Toast.tsx +2 -2
- package/src/ai/activity-question.tsx +1 -1
- package/src/ai/card-button.tsx +1 -1
- package/src/ai/choice-question.tsx +10 -10
- package/src/ai/message-action-sheet.tsx +2 -2
- package/src/ai/message-quote.tsx +2 -2
- package/src/ai/message.tsx +2 -2
- package/src/ai/reply-quote-chip.tsx +2 -2
- package/src/ai/subagent-cards.tsx +5 -5
- package/src/ai/tool-approval-card.tsx +4 -4
- package/src/auth/AuthScreen.tsx +2 -2
- package/src/examples/ParityGallery.tsx +2 -2
- package/src/generative-ui/components.tsx +3 -3
- package/src/marketing/UpgradeToProCard.tsx +2 -2
- package/src/media/ImageGallery.tsx +1 -1
- package/src/motion.ts +3 -2
- package/src/primitives/card.tsx +3 -3
- package/src/primitives/text.tsx +13 -13
- package/src/primitives/toast-drag-gesture.tsx +2 -2
- package/src/settings/MoreFromProjectV.tsx +2 -2
- package/src/settings/SettingsSection.tsx +3 -3
- package/src/settings/ThemeModePicker.tsx +9 -14
|
@@ -1,43 +1,25 @@
|
|
|
1
1
|
import { StyleSheet, View, type ViewProps } from "react-native";
|
|
2
2
|
import { cn } from "./cn";
|
|
3
|
-
import { loadLinearGradient } from "./gradient";
|
|
4
3
|
import { tokens } from "./tokens";
|
|
5
4
|
import { useScheme } from "./useScheme";
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
const DARK = ["#1c1c1e", "#2a1820", "#1a1a1c"] as const;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A soft gradient behind the screen. Without the optional
|
|
12
|
-
* `expo-linear-gradient` peer it draws the solid `tokens.color.background`.
|
|
13
|
-
*/
|
|
6
|
+
/** A flat `tokens.color.background` layer behind the screen. */
|
|
14
7
|
export function AmbientBackground({
|
|
15
8
|
children,
|
|
16
9
|
className,
|
|
17
10
|
...props
|
|
18
11
|
}: ViewProps & { className?: string }) {
|
|
19
12
|
const scheme = useScheme();
|
|
20
|
-
const LinearGradient = loadLinearGradient()?.LinearGradient;
|
|
21
13
|
|
|
22
14
|
return (
|
|
23
15
|
<View className={cn("flex-1", className)} {...props}>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/>
|
|
32
|
-
) : (
|
|
33
|
-
<View
|
|
34
|
-
pointerEvents="none"
|
|
35
|
-
style={{
|
|
36
|
-
...StyleSheet.absoluteFill,
|
|
37
|
-
backgroundColor: tokens.color.background[scheme],
|
|
38
|
-
}}
|
|
39
|
-
/>
|
|
40
|
-
)}
|
|
16
|
+
<View
|
|
17
|
+
pointerEvents="none"
|
|
18
|
+
style={{
|
|
19
|
+
...StyleSheet.absoluteFill,
|
|
20
|
+
backgroundColor: tokens.color.background[scheme],
|
|
21
|
+
}}
|
|
22
|
+
/>
|
|
41
23
|
{children}
|
|
42
24
|
</View>
|
|
43
25
|
);
|
package/src/Avatar.tsx
CHANGED
|
@@ -125,10 +125,10 @@ export function AvatarFallback({
|
|
|
125
125
|
{typeof children === "string" ? (
|
|
126
126
|
<Text
|
|
127
127
|
numberOfLines={1}
|
|
128
|
-
className={cn("font-instrument-sans-
|
|
128
|
+
className={cn("font-instrument-sans-medium", textClassName)}
|
|
129
129
|
style={[
|
|
130
130
|
{ fontSize: Math.round(size * 0.4), color: palette.defaultForeground[scheme] },
|
|
131
|
-
typeStyle("
|
|
131
|
+
typeStyle("medium"),
|
|
132
132
|
]}
|
|
133
133
|
>
|
|
134
134
|
{children}
|
package/src/BulkActionBar.tsx
CHANGED
|
@@ -217,8 +217,8 @@ export function BulkActionBar({
|
|
|
217
217
|
}}
|
|
218
218
|
>
|
|
219
219
|
<Text
|
|
220
|
-
className="font-instrument-sans-
|
|
221
|
-
style={[metrics.caption, typeStyle("
|
|
220
|
+
className="font-instrument-sans-medium"
|
|
221
|
+
style={[metrics.caption, typeStyle("medium"), { fontVariant: ["tabular-nums"], color: tokens.color.foreground[scheme] }]}
|
|
222
222
|
>
|
|
223
223
|
{selectedCount}
|
|
224
224
|
</Text>
|
package/src/Card.tsx
CHANGED
|
@@ -65,11 +65,11 @@ export function Card({
|
|
|
65
65
|
)}
|
|
66
66
|
{title ? (
|
|
67
67
|
<PrimitiveCardTitle
|
|
68
|
-
className={cn("font-instrument-sans-
|
|
68
|
+
className={cn("font-instrument-sans-medium leading-tight", titleSize)}
|
|
69
69
|
style={[
|
|
70
70
|
textStyle("foreground", scheme),
|
|
71
71
|
sizeStyle(titleSize, "tight"),
|
|
72
|
-
typeStyle("
|
|
72
|
+
typeStyle("medium"),
|
|
73
73
|
]}
|
|
74
74
|
>
|
|
75
75
|
{title}
|
|
@@ -112,7 +112,7 @@ export function CardHeader({ className, ...props }: PartProps) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
* Web `font-
|
|
115
|
+
* Web `font-medium leading-none` at the inherited 16. The line height is
|
|
116
116
|
* `leading-tight` (20), not 16: below the face's ascent and descent, iOS and
|
|
117
117
|
* Android can clip the glyphs.
|
|
118
118
|
*/
|
|
@@ -123,11 +123,11 @@ export function CardTitle({ className, style, ...props }: TextPartProps) {
|
|
|
123
123
|
return (
|
|
124
124
|
<Text
|
|
125
125
|
accessibilityRole="header"
|
|
126
|
-
className={cn("font-instrument-sans-
|
|
126
|
+
className={cn("font-instrument-sans-medium leading-tight", size, className)}
|
|
127
127
|
style={[
|
|
128
128
|
textStyle("foreground", scheme),
|
|
129
129
|
sizeStyle(size, "tight"),
|
|
130
|
-
typeStyle("
|
|
130
|
+
typeStyle("medium"),
|
|
131
131
|
style,
|
|
132
132
|
]}
|
|
133
133
|
{...props}
|
package/src/Chip.tsx
CHANGED
|
@@ -42,12 +42,12 @@ export function Chip({
|
|
|
42
42
|
} ${selected ? "bg-pink-100 dark:bg-pink-900/40" : "bg-secondary"}`}
|
|
43
43
|
>
|
|
44
44
|
<Text
|
|
45
|
-
className={`font-instrument-sans-
|
|
45
|
+
className={`font-instrument-sans-medium ${
|
|
46
46
|
largerText ? "text-xl" : "text-lg"
|
|
47
47
|
} ${
|
|
48
48
|
selected ? "text-pink-700 dark:text-pink-300" : ""
|
|
49
49
|
}`}
|
|
50
|
-
style={[selected ? null : textStyle("muted", scheme), typeStyle("
|
|
50
|
+
style={[selected ? null : textStyle("muted", scheme), typeStyle("medium")]}
|
|
51
51
|
>
|
|
52
52
|
{label}
|
|
53
53
|
</Text>
|
package/src/DateTimeField.tsx
CHANGED
|
@@ -100,8 +100,8 @@ export function DateTimeField({
|
|
|
100
100
|
style={{ backgroundColor: palette.default[scheme] }}
|
|
101
101
|
>
|
|
102
102
|
<Text
|
|
103
|
-
className={`${largerText ? "text-xl" : "text-lg"} font-instrument-sans-
|
|
104
|
-
style={[textColor, typeStyle("
|
|
103
|
+
className={`${largerText ? "text-xl" : "text-lg"} font-instrument-sans-medium`}
|
|
104
|
+
style={[textColor, typeStyle("medium")]}
|
|
105
105
|
>
|
|
106
106
|
{button.label}
|
|
107
107
|
</Text>
|
package/src/Dialog.tsx
CHANGED
|
@@ -193,7 +193,7 @@ export function DialogHeader({ className, ...props }: PartProps) {
|
|
|
193
193
|
// Text colours are styles (`textStyle`), so they follow the colour scheme in
|
|
194
194
|
// apps whose `text-foreground` does not. Recolour with `style`, not `className`.
|
|
195
195
|
|
|
196
|
-
/** Web `text-lg font-
|
|
196
|
+
/** Web `text-lg font-medium`. */
|
|
197
197
|
export function DialogTitle({ className, style, ...props }: TextPartProps) {
|
|
198
198
|
const largerText = useLargerText();
|
|
199
199
|
const scheme = useScheme();
|
|
@@ -201,11 +201,11 @@ export function DialogTitle({ className, style, ...props }: TextPartProps) {
|
|
|
201
201
|
<Text
|
|
202
202
|
accessibilityRole="header"
|
|
203
203
|
className={cn(
|
|
204
|
-
"font-instrument-sans-
|
|
204
|
+
"font-instrument-sans-medium",
|
|
205
205
|
largerText ? "text-2xl" : "text-lg",
|
|
206
206
|
className,
|
|
207
207
|
)}
|
|
208
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
208
|
+
style={[textStyle("foreground", scheme), typeStyle("medium"), style]}
|
|
209
209
|
{...props}
|
|
210
210
|
/>
|
|
211
211
|
);
|
package/src/DropdownMenu.tsx
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
View,
|
|
19
19
|
useWindowDimensions,
|
|
20
20
|
type GestureResponderEvent,
|
|
21
|
+
type LayoutChangeEvent,
|
|
21
22
|
type PressableProps,
|
|
22
23
|
type ViewProps,
|
|
23
24
|
} from "react-native";
|
|
@@ -123,58 +124,140 @@ export function isMeasuredRect(rect: DropdownMenuRect): boolean {
|
|
|
123
124
|
|
|
124
125
|
type Measurable = Pick<ComponentRef<typeof View>, "measureInWindow" | "measure">;
|
|
125
126
|
|
|
127
|
+
/** The wrapper shrink-wraps the trigger in a flex row (such as the PromptInput `leading` slot). */
|
|
128
|
+
const TRIGGER_HOST = { alignSelf: "flex-start" } as const;
|
|
129
|
+
|
|
130
|
+
/** Frames to wait for layout to settle, when a view reads empty. */
|
|
131
|
+
const MEASURE_RETRIES = 2;
|
|
132
|
+
|
|
133
|
+
type LayoutSize = { width: number; height: number };
|
|
134
|
+
|
|
135
|
+
/** Last-resort trigger size when a press has a touch point but no `onLayout` size and no style size: a 44 point touch target. */
|
|
136
|
+
const FALLBACK_SIZE: LayoutSize = { width: 44, height: 44 };
|
|
137
|
+
|
|
138
|
+
/** Numeric `width` and `height` of a plain style object, such as `{ width: 44, height: 44 }`; `undefined` for a function, array or missing size. */
|
|
139
|
+
export function sizeFromStyle(style: PressableProps["style"]): LayoutSize | undefined {
|
|
140
|
+
if (!style || typeof style !== "object" || Array.isArray(style)) return undefined;
|
|
141
|
+
if (!("width" in style) || !("height" in style)) return undefined;
|
|
142
|
+
const { width, height } = style;
|
|
143
|
+
if (typeof width !== "number" || typeof height !== "number") return undefined;
|
|
144
|
+
return width > 0 && height > 0 ? { width, height } : undefined;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The trigger's box from a press: the press point in window coordinates
|
|
149
|
+
* (`pageX`, `pageY`) less its point in the view (`locationX`, `locationY`) is
|
|
150
|
+
* the view's origin, and `size` is its laid-out size. `null` without a size or a usable touch point.
|
|
151
|
+
*/
|
|
152
|
+
export function triggerRectFromPress(
|
|
153
|
+
event: { nativeEvent?: Partial<Record<"pageX" | "pageY" | "locationX" | "locationY", number>> } | null | undefined,
|
|
154
|
+
size: LayoutSize | undefined,
|
|
155
|
+
): DropdownMenuRect | null {
|
|
156
|
+
const point = event?.nativeEvent;
|
|
157
|
+
if (!size || !point) return null;
|
|
158
|
+
const { pageX, pageY, locationX, locationY } = point;
|
|
159
|
+
if (
|
|
160
|
+
typeof pageX !== "number" || !Number.isFinite(pageX) ||
|
|
161
|
+
typeof pageY !== "number" || !Number.isFinite(pageY) ||
|
|
162
|
+
typeof locationX !== "number" || !Number.isFinite(locationX) ||
|
|
163
|
+
typeof locationY !== "number" || !Number.isFinite(locationY)
|
|
164
|
+
) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
const rect = { x: pageX - locationX, y: pageY - locationY, width: size.width, height: size.height };
|
|
168
|
+
return isMeasuredRect(rect) ? rect : null;
|
|
169
|
+
}
|
|
170
|
+
|
|
126
171
|
/**
|
|
127
172
|
* The view's box in window coordinates, or `null` when it cannot be measured.
|
|
128
173
|
* `measureInWindow` first; when it returns an empty box, `measure` (its
|
|
129
|
-
* `pageX` and `pageY` are window coordinates too) as a second reading.
|
|
174
|
+
* `pageX` and `pageY` are window coordinates too) as a second reading. When
|
|
175
|
+
* both are empty, it tries again on the next frame, up to `retries` times: a
|
|
176
|
+
* view under a keyboard-lifted or avoiding parent may not be laid out yet.
|
|
130
177
|
*/
|
|
131
|
-
export function measureAnchor(view: Measurable, done: (rect: DropdownMenuRect | null) => void) {
|
|
178
|
+
export function measureAnchor(view: Measurable, done: (rect: DropdownMenuRect | null) => void, retries = MEASURE_RETRIES) {
|
|
132
179
|
view.measureInWindow((x, y, width, height) => {
|
|
133
180
|
const rect = { x, y, width, height };
|
|
134
181
|
if (isMeasuredRect(rect)) return done(rect);
|
|
135
182
|
view.measure((_x, _y, w, h, pageX, pageY) => {
|
|
136
183
|
const second = { x: pageX, y: pageY, width: w, height: h };
|
|
137
|
-
|
|
184
|
+
if (isMeasuredRect(second)) return done(second);
|
|
185
|
+
if (retries <= 0) return done(null);
|
|
186
|
+
requestAnimationFrame(() => measureAnchor(view, done, retries - 1));
|
|
138
187
|
});
|
|
139
188
|
});
|
|
140
189
|
}
|
|
141
190
|
|
|
142
191
|
/**
|
|
143
|
-
* Opens the menu, or closes it when open. On press it measures
|
|
144
|
-
* (`measureInWindow`) and the menu opens under it.
|
|
145
|
-
*
|
|
192
|
+
* Opens the menu, or closes it when open. On press it measures its wrapper
|
|
193
|
+
* (`measureInWindow`) and the menu opens under it. The wrapper is a
|
|
194
|
+
* `collapsable={false}` view, so Android keeps a native view to measure. On
|
|
195
|
+
* press, the box comes at once from the press point and a size (`onLayout`,
|
|
196
|
+
* then a numeric `style` width and height, then 44), and the menu opens; a live
|
|
197
|
+
* measure then refines it. When the press has no touch point and every measure
|
|
198
|
+
* reads empty, the last good box is used. Reports `expanded`. A caller `ref` is
|
|
199
|
+
* kept: it gets the wrapper, as the menu's own handle does.
|
|
146
200
|
*/
|
|
147
201
|
export function DropdownMenuTrigger({
|
|
148
202
|
asChild,
|
|
149
203
|
onPress,
|
|
150
204
|
accessibilityState,
|
|
151
205
|
ref: callerRef,
|
|
206
|
+
style,
|
|
152
207
|
...props
|
|
153
208
|
}: DropdownMenuTriggerProps) {
|
|
154
209
|
const { open, setOpen, setTrigger } = useMenu("DropdownMenuTrigger");
|
|
155
210
|
const ref = useRef<ComponentRef<typeof View> | null>(null);
|
|
211
|
+
// This trigger's last `onLayout` size and last good measured box, kept for when a live reading is empty.
|
|
212
|
+
const layoutSizeRef = useRef<LayoutSize | undefined>(undefined);
|
|
213
|
+
const lastRectRef = useRef<DropdownMenuRect | undefined>(undefined);
|
|
214
|
+
const styleSize = sizeFromStyle(style);
|
|
156
215
|
const Component = asChild ? Slot.Pressable : Pressable;
|
|
157
216
|
return (
|
|
158
|
-
<
|
|
217
|
+
<View
|
|
159
218
|
ref={(view: ComponentRef<typeof View> | null) => {
|
|
160
219
|
ref.current = view;
|
|
161
220
|
if (typeof callerRef === "function") callerRef(view);
|
|
162
221
|
else if (callerRef) callerRef.current = view;
|
|
163
222
|
}}
|
|
164
|
-
|
|
165
|
-
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
onPress?.(event);
|
|
169
|
-
if (open) return setOpen(false);
|
|
223
|
+
collapsable={false}
|
|
224
|
+
accessible={false}
|
|
225
|
+
style={styleSize ? { ...TRIGGER_HOST, ...styleSize } : TRIGGER_HOST}
|
|
226
|
+
onLayout={(event: LayoutChangeEvent) => {
|
|
170
227
|
const view = ref.current;
|
|
171
|
-
if (!view) return
|
|
228
|
+
if (!view) return;
|
|
229
|
+
const { width, height } = event.nativeEvent.layout;
|
|
230
|
+
if (width > 0 && height > 0) layoutSizeRef.current = { width, height };
|
|
172
231
|
measureAnchor(view, (rect) => {
|
|
173
|
-
if (rect)
|
|
174
|
-
setOpen(true);
|
|
232
|
+
if (rect) lastRectRef.current = rect;
|
|
175
233
|
});
|
|
176
234
|
}}
|
|
177
|
-
|
|
235
|
+
>
|
|
236
|
+
<Component
|
|
237
|
+
accessibilityRole="button"
|
|
238
|
+
{...props}
|
|
239
|
+
style={style}
|
|
240
|
+
accessibilityState={{ ...accessibilityState, expanded: open }}
|
|
241
|
+
onPress={(event: GestureResponderEvent) => {
|
|
242
|
+
onPress?.(event);
|
|
243
|
+
if (open) return setOpen(false);
|
|
244
|
+
const view = ref.current;
|
|
245
|
+
const size = layoutSizeRef.current ?? styleSize ?? FALLBACK_SIZE;
|
|
246
|
+
const pressRect = triggerRectFromPress(event, size);
|
|
247
|
+
// Anchor and open at once from the press, then refine from a live measure.
|
|
248
|
+
if (pressRect) setTrigger(pressRect);
|
|
249
|
+
setOpen(true);
|
|
250
|
+
if (!view) return;
|
|
251
|
+
measureAnchor(view, (rect) => {
|
|
252
|
+
if (rect) {
|
|
253
|
+
lastRectRef.current = rect;
|
|
254
|
+
return setTrigger(rect);
|
|
255
|
+
}
|
|
256
|
+
if (!pressRect && lastRectRef.current) setTrigger(lastRectRef.current);
|
|
257
|
+
});
|
|
258
|
+
}}
|
|
259
|
+
/>
|
|
260
|
+
</View>
|
|
178
261
|
);
|
|
179
262
|
}
|
|
180
263
|
|
|
@@ -192,8 +275,10 @@ export type DropdownMenuPosition = {
|
|
|
192
275
|
* Where the menu goes: under the trigger, `sideOffset` away, its start edge on
|
|
193
276
|
* the trigger's start (`"start"`) or its end edge on the trigger's end
|
|
194
277
|
* (`"end"`), kept 8 inside the safe area. It flips above the trigger when its
|
|
195
|
-
* content does not fit below and there is more room above
|
|
196
|
-
*
|
|
278
|
+
* content does not fit below and there is more room above; it then sets `top`
|
|
279
|
+
* only, never `bottom`. Before the content
|
|
280
|
+
* is measured (0), it flips only when less than one item row fits below. Without
|
|
281
|
+
* a trigger box it sits at the top of the safe area.
|
|
197
282
|
*/
|
|
198
283
|
export function dropdownMenuPosition({
|
|
199
284
|
trigger,
|
|
@@ -224,8 +309,14 @@ export function dropdownMenuPosition({
|
|
|
224
309
|
const above = trigger.y - sideOffset;
|
|
225
310
|
const roomBelow = maxBottom - below;
|
|
226
311
|
const roomAbove = above - minTop;
|
|
227
|
-
|
|
228
|
-
|
|
312
|
+
// Not measured yet (0): flip only when almost no room is below, so a bottom
|
|
313
|
+
// trigger never gets a first layout with a tiny `maxHeight`.
|
|
314
|
+
const tooTight = contentHeight > 0 ? contentHeight > roomBelow : roomBelow < DROPDOWN_MENU.itemHeight;
|
|
315
|
+
if (tooTight && roomAbove > roomBelow) {
|
|
316
|
+
// `top` only: `bottom` is ignored inside `WindowLayerHost` on Android. The menu's
|
|
317
|
+
// bottom edge lands on `above`; before measure, a two-row estimate stands in.
|
|
318
|
+
const height = contentHeight > 0 ? contentHeight : Math.min(roomAbove, DROPDOWN_MENU.itemHeight * 2 + DROPDOWN_MENU.padding * 2);
|
|
319
|
+
return { ...horizontal, top: Math.max(minTop, above - height), maxHeight: roomAbove };
|
|
229
320
|
}
|
|
230
321
|
return { ...horizontal, top: below, maxHeight: roomBelow };
|
|
231
322
|
}
|
|
@@ -338,7 +429,13 @@ export function DropdownMenuContent({
|
|
|
338
429
|
pointerEvents={open ? "auto" : "none"}
|
|
339
430
|
style={{
|
|
340
431
|
position: "absolute",
|
|
341
|
-
|
|
432
|
+
// Every edge is set, `null` when unused, so React Native clears the one
|
|
433
|
+
// a flip leaves behind instead of keeping a stale `top`.
|
|
434
|
+
top: position.top ?? null,
|
|
435
|
+
bottom: position.bottom ?? null,
|
|
436
|
+
left: position.left ?? null,
|
|
437
|
+
right: position.right ?? null,
|
|
438
|
+
maxHeight: position.maxHeight,
|
|
342
439
|
minWidth: DROPDOWN_MENU.minWidth,
|
|
343
440
|
maxWidth: window.width - insets.left - insets.right - 2 * DROPDOWN_MENU.edge,
|
|
344
441
|
opacity: contentHeight === null ? 0 : 1,
|
|
@@ -530,17 +627,17 @@ export function DropdownMenuRadioItem({ checked, ...props }: DropdownMenuRadioIt
|
|
|
530
627
|
|
|
531
628
|
export type DropdownMenuLabelProps = { children: ReactNode; className?: string };
|
|
532
629
|
|
|
533
|
-
/** A group heading: the web `text-xs font-
|
|
630
|
+
/** A group heading: the web `text-xs font-medium uppercase tracking-widest text-muted-foreground`, `px-2.5 py-1.5`. */
|
|
534
631
|
export function DropdownMenuLabel({ children, className }: DropdownMenuLabelProps) {
|
|
535
632
|
const scheme = useScheme();
|
|
536
633
|
const text = sizeStyle(useLargerText() ? "text-base" : "text-xs");
|
|
537
634
|
return (
|
|
538
635
|
<Text
|
|
539
636
|
accessibilityRole="header"
|
|
540
|
-
className={cn("font-instrument-sans-
|
|
637
|
+
className={cn("font-instrument-sans-medium uppercase", className)}
|
|
541
638
|
style={[
|
|
542
639
|
text,
|
|
543
|
-
typeStyle("
|
|
640
|
+
typeStyle("medium"),
|
|
544
641
|
{
|
|
545
642
|
letterSpacing: text.fontSize / 10,
|
|
546
643
|
color: tokens.color.muted[scheme],
|
package/src/EmptyState.tsx
CHANGED
|
@@ -33,10 +33,10 @@ function EmptyStateView({
|
|
|
33
33
|
<Icon size={largerText ? 44 : 40} color={tokens.color.muted[scheme]} />
|
|
34
34
|
<Text
|
|
35
35
|
className={cn(
|
|
36
|
-
"mt-4 text-center font-instrument-sans-
|
|
36
|
+
"mt-4 text-center font-instrument-sans-medium",
|
|
37
37
|
largerText ? "text-xl" : "text-lg",
|
|
38
38
|
)}
|
|
39
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
39
|
+
style={[textStyle("foreground", scheme), typeStyle("medium")]}
|
|
40
40
|
>
|
|
41
41
|
{title}
|
|
42
42
|
</Text>
|
|
@@ -123,11 +123,11 @@ function Title({ className, style, ...props }: TextProps & { className?: string
|
|
|
123
123
|
return (
|
|
124
124
|
<Text
|
|
125
125
|
className={cn(
|
|
126
|
-
"text-center font-instrument-sans-
|
|
126
|
+
"text-center font-instrument-sans-medium",
|
|
127
127
|
largerText ? "text-xl" : "text-lg",
|
|
128
128
|
className,
|
|
129
129
|
)}
|
|
130
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
130
|
+
style={[textStyle("foreground", scheme), typeStyle("medium"), style]}
|
|
131
131
|
{...props}
|
|
132
132
|
/>
|
|
133
133
|
);
|
package/src/FloatingTabBar.tsx
CHANGED
|
@@ -195,8 +195,8 @@ function TabBarItem({
|
|
|
195
195
|
// The bar has a fixed height (`tabBarReserve`), so labels
|
|
196
196
|
// scale with Dynamic Type only up to what fits in it.
|
|
197
197
|
maxFontSizeMultiplier={1.5}
|
|
198
|
-
className={`font-instrument-sans-
|
|
199
|
-
style={[{ color }, typeStyle("
|
|
198
|
+
className={`font-instrument-sans-medium ${largerText ? "text-base" : "text-sm"}`}
|
|
199
|
+
style={[{ color }, typeStyle("medium")]}
|
|
200
200
|
>
|
|
201
201
|
{label}
|
|
202
202
|
</Text>
|
package/src/LabeledSwitchRow.tsx
CHANGED
|
@@ -56,11 +56,11 @@ export function LabeledSwitchRow({
|
|
|
56
56
|
<View className="min-w-0 flex-1">
|
|
57
57
|
<Text
|
|
58
58
|
className={cn(
|
|
59
|
-
"font-instrument-sans-
|
|
59
|
+
"font-instrument-sans-medium",
|
|
60
60
|
largerText ? "text-xl" : "text-lg",
|
|
61
61
|
disabled && "opacity-70",
|
|
62
62
|
)}
|
|
63
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
63
|
+
style={[textStyle("foreground", scheme), typeStyle("medium")]}
|
|
64
64
|
>
|
|
65
65
|
{label}
|
|
66
66
|
</Text>
|
package/src/ListRow.tsx
CHANGED
|
@@ -63,11 +63,11 @@ export function ListRow({
|
|
|
63
63
|
<Text
|
|
64
64
|
numberOfLines={2}
|
|
65
65
|
className={cn(
|
|
66
|
-
"font-instrument-sans-
|
|
66
|
+
"font-instrument-sans-medium",
|
|
67
67
|
largerText ? "text-xl" : "text-lg",
|
|
68
68
|
titleEnd != null && "min-w-0 flex-1",
|
|
69
69
|
)}
|
|
70
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
70
|
+
style={[textStyle("foreground", scheme), typeStyle("medium")]}
|
|
71
71
|
>
|
|
72
72
|
{title}
|
|
73
73
|
</Text>
|
package/src/PinnedBotTile.tsx
CHANGED
|
@@ -49,8 +49,8 @@ export function PinnedBotTile({ title, leading, unread = false, generating = fal
|
|
|
49
49
|
{leading}
|
|
50
50
|
<Text
|
|
51
51
|
numberOfLines={2}
|
|
52
|
-
className={cn("text-center font-instrument-sans-
|
|
53
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
52
|
+
className={cn("text-center font-instrument-sans-medium", largerText ? "text-lg" : "text-base")}
|
|
53
|
+
style={[textStyle("foreground", scheme), typeStyle("medium")]}
|
|
54
54
|
>
|
|
55
55
|
{title}
|
|
56
56
|
</Text>
|
package/src/StatGrid.tsx
CHANGED
|
@@ -58,11 +58,11 @@ export function StatGrid({ items, columns = 2, testID }: StatGridProps) {
|
|
|
58
58
|
{item.label}
|
|
59
59
|
</Text>
|
|
60
60
|
<Text
|
|
61
|
-
className={cn("font-instrument-sans-
|
|
61
|
+
className={cn("font-instrument-sans-medium", valueSize)}
|
|
62
62
|
style={[
|
|
63
63
|
textStyle("foreground", scheme),
|
|
64
64
|
sizeStyle(valueSize, "tight"),
|
|
65
|
-
typeStyle("
|
|
65
|
+
typeStyle("medium"),
|
|
66
66
|
{ fontVariant: ["tabular-nums"] },
|
|
67
67
|
]}
|
|
68
68
|
>
|
package/src/Stepper.tsx
CHANGED
|
@@ -49,8 +49,8 @@ export function Stepper({
|
|
|
49
49
|
/>
|
|
50
50
|
<Text
|
|
51
51
|
accessibilityLabel={valueLabel}
|
|
52
|
-
className={cn("min-w-8 text-center font-instrument-sans-
|
|
53
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
52
|
+
className={cn("min-w-8 text-center font-instrument-sans-medium", largerText ? "text-3xl" : "text-2xl")}
|
|
53
|
+
style={[textStyle("foreground", scheme), typeStyle("medium")]}
|
|
54
54
|
>
|
|
55
55
|
{value}
|
|
56
56
|
</Text>
|
package/src/Toast.tsx
CHANGED
|
@@ -183,8 +183,8 @@ function ToastCard({ item }: { item: ToastItem }) {
|
|
|
183
183
|
className="rounded-full bg-secondary px-3 py-1.5 active:opacity-70"
|
|
184
184
|
>
|
|
185
185
|
<Text
|
|
186
|
-
className="font-instrument-sans-
|
|
187
|
-
style={[textStyle("foreground", scheme), typeStyle("
|
|
186
|
+
className="font-instrument-sans-medium text-sm"
|
|
187
|
+
style={[textStyle("foreground", scheme), typeStyle("medium")]}
|
|
188
188
|
>
|
|
189
189
|
{item.action.label}
|
|
190
190
|
</Text>
|
|
@@ -156,7 +156,7 @@ function RecordRow({
|
|
|
156
156
|
) : mark === "other" ? (
|
|
157
157
|
<IconPencil size={glyph} strokeWidth={3} color={markColor} />
|
|
158
158
|
) : (
|
|
159
|
-
<Text className="font-instrument-sans-
|
|
159
|
+
<Text className="font-instrument-sans-medium" style={[{ fontSize: largerText ? 13 : 10, color: markColor }, typeStyle("medium")]}>
|
|
160
160
|
{mark}
|
|
161
161
|
</Text>
|
|
162
162
|
)}
|
package/src/ai/card-button.tsx
CHANGED
|
@@ -47,7 +47,7 @@ export function CardButton({ label, variant, onPress, disabled, accessibilityLab
|
|
|
47
47
|
press.style,
|
|
48
48
|
]}
|
|
49
49
|
>
|
|
50
|
-
<Text className={cn(size, "font-instrument-sans-
|
|
50
|
+
<Text className={cn(size, "font-instrument-sans-medium")} style={[sizeStyle(size), typeStyle("medium"), { color: colors.color }]}>
|
|
51
51
|
{label}
|
|
52
52
|
</Text>
|
|
53
53
|
</AnimatedPressable>
|
|
@@ -89,8 +89,8 @@ export function ChoiceQuestion({
|
|
|
89
89
|
text
|
|
90
90
|
) : (
|
|
91
91
|
<Text
|
|
92
|
-
className={`${buttonText} font-instrument-sans-
|
|
93
|
-
style={[sizeStyle(buttonText), typeStyle("
|
|
92
|
+
className={`${buttonText} font-instrument-sans-medium`}
|
|
93
|
+
style={[sizeStyle(buttonText), typeStyle("medium"), { color: buttonColors(variant, scheme)?.color }]}
|
|
94
94
|
>
|
|
95
95
|
{text}
|
|
96
96
|
</Text>
|
|
@@ -127,9 +127,9 @@ export function ChoiceQuestion({
|
|
|
127
127
|
<View style={{ gap: 16 }}>
|
|
128
128
|
<View className="flex-row items-center justify-between" style={{ gap: 8 }}>
|
|
129
129
|
<Text
|
|
130
|
-
className="flex-1 font-instrument-sans-
|
|
130
|
+
className="flex-1 font-instrument-sans-medium"
|
|
131
131
|
// Web `text-[15px] leading-snug` (15 / 20.625); larger text steps up to 18.
|
|
132
|
-
style={[{ fontSize: largerText ? 18 : 15, lineHeight: largerText ? 24 : 15 * 1.375 }, textStyle("foreground", scheme), typeStyle("
|
|
132
|
+
style={[{ fontSize: largerText ? 18 : 15, lineHeight: largerText ? 24 : 15 * 1.375 }, textStyle("foreground", scheme), typeStyle("medium")]}
|
|
133
133
|
>
|
|
134
134
|
{question.question}
|
|
135
135
|
</Text>
|
|
@@ -229,7 +229,7 @@ export function ChoiceQuestion({
|
|
|
229
229
|
|
|
230
230
|
/**
|
|
231
231
|
* The question's topic, the web `Badge variant="secondary"` with Eva's
|
|
232
|
-
* `text-3xs font-
|
|
232
|
+
* `text-3xs font-medium` (10 / 14, 600) in a `px-2.5 py-0.5` pill. Drawn here
|
|
233
233
|
* because `Badge` sets its own size and weight.
|
|
234
234
|
*/
|
|
235
235
|
export function TopicBadge({ children }: { children: string }) {
|
|
@@ -243,10 +243,10 @@ export function TopicBadge({ children }: { children: string }) {
|
|
|
243
243
|
>
|
|
244
244
|
<Text
|
|
245
245
|
numberOfLines={1}
|
|
246
|
-
className="font-instrument-sans-
|
|
246
|
+
className="font-instrument-sans-medium"
|
|
247
247
|
style={[
|
|
248
248
|
{ fontSize, lineHeight: largerText ? 20 : 14, color: palette.defaultForeground[scheme] },
|
|
249
|
-
typeStyle("
|
|
249
|
+
typeStyle("medium"),
|
|
250
250
|
]}
|
|
251
251
|
>
|
|
252
252
|
{children}
|
|
@@ -373,13 +373,13 @@ function ChoiceRow({
|
|
|
373
373
|
) : mark === "other" ? (
|
|
374
374
|
<IconPencil size={glyph} color={muted} />
|
|
375
375
|
) : (
|
|
376
|
-
// Web `text-2xs font-
|
|
376
|
+
// Web `text-2xs font-medium tracking-wide`, at semibold: native-ui draws no bold face.
|
|
377
377
|
<Text
|
|
378
|
-
className="font-instrument-sans-
|
|
378
|
+
className="font-instrument-sans-medium"
|
|
379
379
|
style={[
|
|
380
380
|
{ fontSize: markText, lineHeight: largerText ? 20 : 16, color: muted },
|
|
381
381
|
trackingStyle(markText, "wide"),
|
|
382
|
-
typeStyle("
|
|
382
|
+
typeStyle("medium"),
|
|
383
383
|
]}
|
|
384
384
|
>
|
|
385
385
|
{mark}
|
|
@@ -149,8 +149,8 @@ export function MessageActionSheet({
|
|
|
149
149
|
}}
|
|
150
150
|
>
|
|
151
151
|
<Text
|
|
152
|
-
className={cn(body, "font-instrument-sans-
|
|
153
|
-
style={[sizeStyle(body), typeStyle("
|
|
152
|
+
className={cn(body, "font-instrument-sans-medium")}
|
|
153
|
+
style={[sizeStyle(body), typeStyle("medium"), textStyle("foreground", scheme)]}
|
|
154
154
|
>
|
|
155
155
|
{cancelLabel}
|
|
156
156
|
</Text>
|
package/src/ai/message-quote.tsx
CHANGED
|
@@ -49,8 +49,8 @@ export function MessageQuote({
|
|
|
49
49
|
<>
|
|
50
50
|
<Text
|
|
51
51
|
numberOfLines={1}
|
|
52
|
-
className={cn(caption, "font-instrument-sans-
|
|
53
|
-
style={[sizeStyle(caption), typeStyle("
|
|
52
|
+
className={cn(caption, "font-instrument-sans-medium")}
|
|
53
|
+
style={[sizeStyle(caption), typeStyle("medium"), { color: withAlpha(color, 0.75) }]}
|
|
54
54
|
>
|
|
55
55
|
{author}
|
|
56
56
|
</Text>
|
package/src/ai/message.tsx
CHANGED
|
@@ -287,8 +287,8 @@ export function MessageBotLabel({ name, avatar, className, testID = "message-bot
|
|
|
287
287
|
{avatar}
|
|
288
288
|
<Text
|
|
289
289
|
numberOfLines={1}
|
|
290
|
-
className={cn(size, "font-instrument-sans-
|
|
291
|
-
style={[sizeStyle(size), typeStyle("
|
|
290
|
+
className={cn(size, "font-instrument-sans-medium")}
|
|
291
|
+
style={[sizeStyle(size), typeStyle("medium"), { color: tokens.color.muted[scheme] }]}
|
|
292
292
|
>
|
|
293
293
|
{name}
|
|
294
294
|
</Text>
|