@plexui/react-native 0.2.31 → 0.3.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.
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { isValidElement, useId, useLayoutEffect, useMemo, useState } from "react";
3
+ import { InSheetContext } from "./context";
3
4
  import { Animated, Easing, PanResponder, Platform, ScrollView, StyleSheet, View, useWindowDimensions } from "react-native";
4
5
  import { Pressable } from "../../internal/Pressable";
5
6
  import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -244,64 +245,64 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
244
245
  const slide = (progress) => android
245
246
  ? Animated.add(progress.interpolate({ inputRange: [0, 1], outputRange: [(height || screen) + ANDROID_OFFSCREEN, 0] }), Animated.multiply(drag, progress))
246
247
  : Animated.add(progress.interpolate({ inputRange: [0, 1], outputRange: [height || screen, 0] }), drag);
247
- return (_jsx(Overlay, { open: open, onDismiss: close, scrim: android ? ANDROID_DIM.sheet : iosDim(theme), dismissible: dismissible, motion: "sheet", exit: exit, onExited: onExited, testID: testID, children: (progress, _opening, focus) => (_jsxs(View, { pointerEvents: "box-none", style: styles.bottom, children: [_jsxs(Animated.View, { ...a11y, ...(android ? responder.panHandlers : null), onTouchEnd: android ? gesture.end : undefined, onTouchCancel: android ? gesture.end : undefined,
248
- // On the web the sheet itself takes the first focus, not its Close or a field
249
- tabIndex: focus.tabIndex, onBlur: focus.onBlur, onLayout: (event) => setHeight(event.nativeEvent.layout.height), style: [
250
- focus.style,
251
- styles.sheet,
252
- {
253
- maxHeight,
254
- // A fixed sheet grows by the keyboard it stands over, within the screen, so its content keeps its room
255
- height: fixedHeight == null ? undefined : Math.min(fixedHeight + keyboard, maxHeight),
256
- maxWidth,
257
- borderTopLeftRadius: radius,
258
- borderTopRightRadius: radius,
259
- backgroundColor: background,
260
- // Over the keyboard: Android's height is over its navigation bar, iOS's from the screen's edge
261
- paddingBottom: android ? insets.bottom + keyboard : keyboard,
262
- // With reduced motion it fades in place, and follows only the finger
263
- opacity: reduced ? progress : undefined,
264
- transform: [{ translateY: reduced ? drag : slide(progress) }],
265
- },
266
- ], children: [android && title != null ? null : header, _jsx(ScrollView
267
- // A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
268
- , {
248
+ return (_jsx(Overlay, { open: open, onDismiss: close, scrim: android ? ANDROID_DIM.sheet : iosDim(theme), dismissible: dismissible, motion: "sheet", exit: exit, onExited: onExited, testID: testID, children: (progress, _opening, focus) => (_jsx(InSheetContext.Provider, { value: true, children: _jsxs(View, { pointerEvents: "box-none", style: styles.bottom, children: [_jsxs(Animated.View, { ...a11y, ...(android ? responder.panHandlers : null), onTouchEnd: android ? gesture.end : undefined, onTouchCancel: android ? gesture.end : undefined,
249
+ // On the web the sheet itself takes the first focus, not its Close or a field
250
+ tabIndex: focus.tabIndex, onBlur: focus.onBlur, onLayout: (event) => setHeight(event.nativeEvent.layout.height), style: [
251
+ focus.style,
252
+ styles.sheet,
253
+ {
254
+ maxHeight,
255
+ // A fixed sheet grows by the keyboard it stands over, within the screen, so its content keeps its room
256
+ height: fixedHeight == null ? undefined : Math.min(fixedHeight + keyboard, maxHeight),
257
+ maxWidth,
258
+ borderTopLeftRadius: radius,
259
+ borderTopRightRadius: radius,
260
+ backgroundColor: background,
261
+ // Over the keyboard: Android's height is over its navigation bar, iOS's from the screen's edge
262
+ paddingBottom: android ? insets.bottom + keyboard : keyboard,
263
+ // With reduced motion it fades in place, and follows only the finger
264
+ opacity: reduced ? progress : undefined,
265
+ transform: [{ translateY: reduced ? drag : slide(progress) }],
266
+ },
267
+ ], children: [android && title != null ? null : header, _jsx(ScrollView
269
268
  // A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
270
- style: [styles.scroll, fixedHeight != null ? styles.grow : null], ...(android
271
- ? {
272
- ...gesture.content,
273
- onScroll: (event) => {
274
- gesture.content.onScroll(event);
275
- const under = event.nativeEvent.contentOffset.y > 0;
276
- if (under !== scrolled)
277
- setScrolled(under);
278
- },
279
- scrollEventThrottle: 16,
280
- }
281
- : null), contentContainerStyle: [
282
- android
283
- ? [
284
- styles.androidContent,
285
- // A screen whose gutter is Material's compact 16 sets it with --bottom-sheet-android-padding-inline
286
- { paddingHorizontal: androidInline },
287
- // 2 under the bar: 71 under a one-line title
288
- title != null ? { paddingTop: androidBarHeight + 2 } : null,
289
- // Over a footer: 8 above its height, which reaches over the sheet's bottom padding
290
- footer ? { paddingBottom: 8 + Math.max(0, footerHeight - insets.bottom - keyboard) } : null,
291
- ]
292
- : iosContent,
293
- contentStyle,
294
- ], keyboardShouldPersistTaps: "handled", bounces: false, children: content }), android && title != null ? header : null, footer ? (_jsxs(View, { onStartShouldSetResponderCapture: android ? gesture.chrome : undefined, onLayout: android ? (event) => setFooterHeight(event.nativeEvent.layout.height) : undefined, style: [
295
- android
296
- ? [
297
- styles.androidFooter,
298
- { paddingHorizontal: androidInline },
299
- // Over the sheet's color at 80%, faded in over its top 24dp, down over the gesture bar
300
- { paddingBottom: 12 + insets.bottom + keyboard, backgroundImage: `linear-gradient(to bottom, ${withAlpha(background, 0)}, ${withAlpha(background, 0.8)} 24px)` },
301
- ]
302
- : [styles.iosFooter, { paddingHorizontal: margin, paddingBottom: keyboard ? 16 : Math.max(16, insets.bottom) }],
303
- footer.props.style,
304
- ], children: [android ? null : (_jsx(View, { pointerEvents: "none", style: [styles.iosFooterEdge, { backgroundImage: `linear-gradient(${withAlpha(background, 0)}, ${background} 27px)` }] })), footer.props.children] })) : null] }), android && Platform.OS === "android" && dismissible ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel, onPress: close, style: [styles.scrimTarget, { bottom: height }] })) : null] })) }));
269
+ , {
270
+ // A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
271
+ style: [styles.scroll, fixedHeight != null ? styles.grow : null], ...(android
272
+ ? {
273
+ ...gesture.content,
274
+ onScroll: (event) => {
275
+ gesture.content.onScroll(event);
276
+ const under = event.nativeEvent.contentOffset.y > 0;
277
+ if (under !== scrolled)
278
+ setScrolled(under);
279
+ },
280
+ scrollEventThrottle: 16,
281
+ }
282
+ : null), contentContainerStyle: [
283
+ android
284
+ ? [
285
+ styles.androidContent,
286
+ // A screen whose gutter is Material's compact 16 sets it with --bottom-sheet-android-padding-inline
287
+ { paddingHorizontal: androidInline },
288
+ // 2 under the bar: 71 under a one-line title
289
+ title != null ? { paddingTop: androidBarHeight + 2 } : null,
290
+ // Over a footer: 8 above its height, which reaches over the sheet's bottom padding
291
+ footer ? { paddingBottom: 8 + Math.max(0, footerHeight - insets.bottom - keyboard) } : null,
292
+ ]
293
+ : iosContent,
294
+ contentStyle,
295
+ ], keyboardShouldPersistTaps: "handled", bounces: false, children: content }), android && title != null ? header : null, footer ? (_jsxs(View, { onStartShouldSetResponderCapture: android ? gesture.chrome : undefined, onLayout: android ? (event) => setFooterHeight(event.nativeEvent.layout.height) : undefined, style: [
296
+ android
297
+ ? [
298
+ styles.androidFooter,
299
+ { paddingHorizontal: androidInline },
300
+ // Over the sheet's color at 80%, faded in over its top 24dp, down over the gesture bar
301
+ { paddingBottom: 12 + insets.bottom + keyboard, backgroundImage: `linear-gradient(to bottom, ${withAlpha(background, 0)}, ${withAlpha(background, 0.8)} 24px)` },
302
+ ]
303
+ : [styles.iosFooter, { paddingHorizontal: margin, paddingBottom: keyboard ? 16 : Math.max(16, insets.bottom) }],
304
+ footer.props.style,
305
+ ], children: [android ? null : (_jsx(View, { pointerEvents: "none", style: [styles.iosFooterEdge, { backgroundImage: `linear-gradient(${withAlpha(background, 0)}, ${background} 27px)` }] })), footer.props.children] })) : null] }), android && Platform.OS === "android" && dismissible ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel, onPress: close, style: [styles.scrimTarget, { bottom: height }] })) : null] }) })) }));
305
306
  }
306
307
  const isFooter = (child) => isValidElement(child) && child.type === BottomSheetFooter;
307
308
  /** The item of an Android sheet's bar: a 46dp glass circle solved against the sheet's color. */
@@ -0,0 +1,6 @@
1
+ import { createContext } from "react";
2
+ /**
3
+ * True inside a BottomSheet: an iOS sheet's own search field draws its magnifier and its hint in one gray, darker than
4
+ * a bar's hint (IMG_5491), where a bar's magnifier is the text color (IMG_5737).
5
+ */
6
+ export const InSheetContext = createContext(false);
@@ -44,7 +44,13 @@ function DialogView({ open, onOpenChange, title, description, actions = [], chil
44
44
  const ids = { title: useId(), description: useId() };
45
45
  // The web names the alert dialog by its title and describes it by its message; a phone keeps the modal view
46
46
  const a11y = Platform.OS === "web"
47
- ? { role: "alertdialog", "aria-modal": true, "aria-labelledby": ids.title, "aria-describedby": description != null ? ids.description : undefined }
47
+ ? {
48
+ role: "alertdialog",
49
+ "aria-modal": true,
50
+ // A dialog without a title is named by its message
51
+ "aria-labelledby": title != null ? ids.title : description != null ? ids.description : undefined,
52
+ "aria-describedby": title != null && description != null ? ids.description : undefined,
53
+ }
48
54
  : { accessibilityRole: "alert", accessibilityViewIsModal: true };
49
55
  if (theme.isAndroid) {
50
56
  return (_jsx(AndroidFrame, { open: open, onClose: close, dismissible: dismissible ?? true, a11y: a11y, testID: testID, children: _jsx(AndroidDialog, { theme: theme, title: title, description: description, actions: actions, run: run, ids: ids, layout: mobileLayout, children: children }) }));
@@ -165,7 +171,9 @@ function IOSAlert({ theme, title, description, actions, run, ids, layout, childr
165
171
  _jsx(View, { pointerEvents: "none", "aria-hidden": true, style: styles.measure, children: actions.map((action, index) => (_jsx(Text, { weight: action.preferred ? "semibold" : "medium", numberOfLines: 1, style: type, onLayout: (event) => {
166
172
  const next = event.nativeEvent.layout.width;
167
173
  setLabels((current) => (current[index] === next ? current : Object.assign([...current], { [index]: next })));
168
- }, children: action.label }, index))) })) : null, _jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: { gap: 10 }, bounces: false, children: [_jsxs(View, { style: { paddingTop: 5, paddingHorizontal: 15, paddingBottom: 5.5, gap: 5.67 }, children: [_jsx(Text, { nativeID: ids.title, weight: "semibold", style: [type, { textAlign: description == null ? "center" : "auto" }], accessibilityRole: "header", children: title }), description != null ? (_jsx(Text, { nativeID: ids.description, color: theme.color("--dialog-alert-message-color"), style: { fontSize: 15, lineHeight: 20 }, children: description })) : null] }), children != null ? (
174
+ }, children: action.label }, index))) })) : null, _jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: { gap: 10 }, bounces: false, children: [_jsxs(View, { style: { paddingTop: 5, paddingHorizontal: 15, paddingBottom: 5.5, gap: 5.67 }, children: [title != null ? (_jsx(Text, { nativeID: ids.title, weight: "semibold", style: [type, { textAlign: description == null ? "center" : "auto" }], accessibilityRole: "header", children: title })) : null, description != null ? (
175
+ // Without a title the message is the alert's whole text, in the label color (UIAlertController with a nil title)
176
+ _jsx(Text, { nativeID: ids.description, color: title != null ? theme.color("--dialog-alert-message-color") : undefined, style: { fontSize: 15, lineHeight: 20 }, children: description })) : null] }), children != null ? (
169
177
  // A field fills the alert as its actions do: the largest control size is the alert's 48 there
170
178
  // (Dialog.module.css sets --control-size-3xl to --dialog-alert-field-height in the alert's body)
171
179
  _jsx(ThemeProvider, { brand: { tokens: { "--control-size-3xl": `${theme.length("--dialog-alert-field-height", 48)}px` } }, children: _jsx(View, { style: { paddingBottom: 10, marginHorizontal: -1 }, children: children }) })) : null] }), ordered.length ? (_jsx(View, { style: [{ gap, marginTop: children != null ? 0 : 4 }, inline ? styles.row : null], children: ordered.map(({ action, index }) => (_jsx(IOSAction, { theme: theme, action: action, run: run, type: type, grow: inline }, index))) })) : null] }));
@@ -236,7 +244,9 @@ function AndroidDialog({ theme, title, description, actions, run, ids, children,
236
244
  };
237
245
  return (_jsxs(View, { style: [styles.android, { width, backgroundColor: androidDialogBackground(theme), opacity: ready ? 1 : 0 }], children: [list != null ? (
238
246
  // A list: the title stays, 14 over the rows, and the rows scroll under it (AlertDialog with a custom view)
239
- _jsxs(_Fragment, { children: [title != null ? (_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, styles.androidListTitle, theme.font("medium")], children: title })) : null, _jsx(ScrollView, { style: styles.scroll, contentContainerStyle: title != null ? null : styles.androidListTop, bounces: false, children: list })] })) : (_jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.androidText, bounces: false, children: [_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, theme.font("medium")], children: title }), description != null ? (_jsx(Text, { nativeID: ids.description, color: m.onSurface, style: styles.androidMessage, children: description })) : null, children != null ? _jsx(View, { style: styles.androidContent, children: children }) : null] })), bar.length ? (_jsx(View, { onLayout: (event) => setRoom(event.nativeEvent.layout.width - 16), style: stacked ? styles.androidStack : styles.androidActions, children: order.map((index) =>
247
+ _jsxs(_Fragment, { children: [title != null ? (_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, styles.androidListTitle, theme.font("medium")], children: title })) : null, _jsx(ScrollView, { style: styles.scroll, contentContainerStyle: title != null ? null : styles.androidListTop, bounces: false, children: list })] })) : (_jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.androidText, bounces: false, children: [title != null ? (_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, theme.font("medium")], children: title })) : null, description != null ? (
248
+ // Material 3's dialog with no headline: the supporting text alone, in onSurfaceVariant
249
+ _jsx(Text, { nativeID: ids.description, color: title != null ? m.onSurface : m.onSurfaceVariant, style: styles.androidMessage, children: description })) : null, children != null ? _jsx(View, { style: styles.androidContent, children: children }) : null] })), bar.length ? (_jsx(View, { onLayout: (event) => setRoom(event.nativeEvent.layout.width - 16), style: stacked ? styles.androidStack : styles.androidActions, children: order.map((index) =>
240
250
  // The neutral actions at the start, a space, then the negative and the positive
241
251
  !stacked && index === neutral.length && neutral.length ? [_jsx(View, { style: styles.grow }, "space"), button(index)] : button(index)) })) : null] }));
242
252
  }
@@ -15,6 +15,7 @@ import { useTheme } from "../../theme/ThemeProvider";
15
15
  import { BarFieldContext } from "../Button/Button";
16
16
  import { IconDefaultsProvider } from "../Icon/createIcon";
17
17
  import { MaterialCancelFilled, MaterialClose } from "../Icon/material";
18
+ import { InSheetContext } from "../BottomSheet/context";
18
19
  /**
19
20
  * The phone layer's field at each size: Input.module.css's size table under touch.css's phone rules, which give every
20
21
  * size 17pt text and a 14pt gutter (11 beside a start adornment, `html [data-slot="input"]`, scoped rules with no root
@@ -67,7 +68,7 @@ export function useSpringColor(color, stiffness, instant) {
67
68
  return value;
68
69
  }
69
70
  /** The look of a field on this platform: its box, text and colors. Shared by Input, TextField and Select. */
70
- export function fieldLook(theme, { variant, size, pill, startAdornment = false, bar = null, label = false, search = false, }, state) {
71
+ export function fieldLook(theme, { variant, size, pill, startAdornment = false, bar = null, label = false, search = false, inSheet = false, }, state) {
71
72
  if (theme.isAndroid) {
72
73
  const m = theme.material;
73
74
  if (search) {
@@ -167,8 +168,8 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
167
168
  }
168
169
  if (bar) {
169
170
  // A Toolbar's search field (Toolbar.module.css, iOS 26 kit Search Top and Bottom): the bar's item height, the
170
- // glass of its buttons, the bar's magnifier in the hint's gray (iOS 26 draws the glyph and "Search" in one
171
- // color, typed in or not), its text Regular at the bar's label size
171
+ // glass of its buttons, the bar's magnifier in the text color (Contacts, IMG_5737), its text Regular at the bar's
172
+ // label size; in a sheet the magnifier and the hint are one darker gray, typed in or not (IMG_5491)
172
173
  const gutter = theme.length("--toolbar-search-gutter", 10.54);
173
174
  return {
174
175
  box: {
@@ -185,8 +186,12 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
185
186
  lineHeight: theme.length("--toolbar-label-line-height", 22),
186
187
  color: theme.color("--input-text-color", theme.colors.text),
187
188
  },
188
- placeholder: theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
189
- icon: theme.color("--toolbar-search-icon-color", theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary)),
189
+ placeholder: inSheet
190
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
191
+ : theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
192
+ icon: inSheet
193
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
194
+ : theme.color("--toolbar-search-icon-color", theme.colors.text),
190
195
  frame: null,
191
196
  trailingIcon: theme.color("--mobile-label-secondary"),
192
197
  caret: theme.color("--color-background-accent-solid"),
@@ -377,6 +382,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
377
382
  // `readOnly={false}` cannot unlock a disabled field
378
383
  const locked = disabled || readOnly;
379
384
  const barField = useContext(BarFieldContext);
385
+ const inSheet = useContext(InSheetContext);
380
386
  // At an iOS row's end the field is the row's value, as the web's field in a `[data-row]`: it fills the room after the
381
387
  // label, with no frame (the row's error marks it invalid), its text at the end and the placeholder in the tertiary label
382
388
  // (on Android it fills the room too, keeping its own field look)
@@ -410,7 +416,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
410
416
  const search = theme.isAndroid && !barField && variant === "soft" && !!startAdornment && label == null;
411
417
  const barSearch = theme.isAndroid && !!barField;
412
418
  const androidGlass = useAndroidGlass("bar", barField?.canvas);
413
- const fieldLookOf = fieldLook(theme, { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search }, { focused, filled, disabled, invalid });
419
+ const fieldLookOf = fieldLook(theme, { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search, inSheet }, { focused, filled, disabled, invalid });
414
420
  const look = barSearch
415
421
  ? { ...fieldLookOf, box: { ...fieldLookOf.box, ...androidGlass } }
416
422
  : bare
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Platform, StyleSheet, Text, View } from "react-native";
4
+ import { Pressable } from "../../internal/Pressable";
5
+ import { useRipple } from "../../internal/ripple";
6
+ import { withAlpha } from "../../theme/material";
7
+ import { useTheme } from "../../theme/ThemeProvider";
8
+ import AppleLogo from "../../icons/plex/AppleLogo";
9
+ import GoogleLogo from "../../icons/plex/GoogleLogo";
10
+ import { buttonMetrics, useMaterialPress } from "../Button/Button";
11
+ const LABEL = { "sign-in": "Sign in with", "sign-up": "Sign up with", continue: "Continue with" };
12
+ /** Apple HIG, Sign in with Apple: black with white content, or white with black content on dark or over media. */
13
+ function appleLook(white) {
14
+ return white ? { background: "#FFFFFF", text: "#000000" } : { background: "#000000", text: "#FFFFFF" };
15
+ }
16
+ /** Google Sign-In branding guidelines: the light, dark and neutral buttons. */
17
+ function googleLook(dark, neutral) {
18
+ if (neutral)
19
+ return { background: "#F2F2F2", text: "#1F1F1F" };
20
+ return dark ? { background: "#131314", text: "#E3E3E3", border: "#8E918F" } : { background: "#FFFFFF", text: "#1F1F1F", border: "#747775" };
21
+ }
22
+ // The logos' drawn ink inside their 24-unit boxes: the G spans 2.95–21.05, so at 24px it stands 2.95px in from each
23
+ // side; Apple's mark spans 3.36–20.64 of its width
24
+ const GOOGLE_ICON = 24;
25
+ const GOOGLE_INSET = 2.95;
26
+ const APPLE_ICON = 20;
27
+ /**
28
+ * The sign-in button of a provider, drawn to its brand rules rather than to the theme: Apple's black or white button
29
+ * with the real Apple logo, Google's light, dark or neutral one with the four-color G. It takes the height and the
30
+ * shape of the screen's other buttons (a capsule on iOS, a pill on Android). Disabled keeps the brand's colors at 40%.
31
+ */
32
+ export function SignInButton({ provider, action = "continue", scheme, overMedia = false, neutral = false, size = "xl", block = true, disabled = false, style, onPressIn, onPressOut, accessibilityLabel, accessibilityState, ...rest }) {
33
+ const theme = useTheme();
34
+ const dark = (scheme ?? theme.scheme) === "dark";
35
+ const apple = provider === "apple";
36
+ const look = apple ? appleLook(dark || overMedia) : googleLook(dark, neutral);
37
+ const metrics = buttonMetrics(theme, size);
38
+ const label = `${LABEL[action]} ${apple ? "Apple" : "Google"}`;
39
+ const [pressed, setPressed] = useState(false);
40
+ const android = theme.isAndroid;
41
+ const nativeRipple = useMaterialPress(theme);
42
+ const ripple = useRipple(withAlpha(look.text, 0.1), android && !nativeRipple, theme.reducedMotion);
43
+ // Google's spacing: 16 before the G, 12 to the text and 16 after on iOS; 12, 10 and 12 on Android
44
+ const google = android ? { start: 12, gap: 10, end: 12 } : { start: 16, gap: 12, end: 16 };
45
+ const radius = metrics.height / 2;
46
+ // A compact size keeps the platform's 44pt or 48dp target, as Button does
47
+ const reach = Math.max(0, ((android ? 48 : 44) - metrics.height) / 2);
48
+ const padding = apple
49
+ ? // Apple asks for a margin of at least a tenth of the height around the logo and the title
50
+ { paddingHorizontal: Math.max(metrics.height / 10, 16) }
51
+ : { paddingLeft: google.start - GOOGLE_INSET, paddingRight: google.end };
52
+ return (_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel ?? label, accessibilityState: { ...accessibilityState, disabled }, disabled: disabled, hitSlop: reach ? { top: reach, bottom: reach } : undefined, android_ripple: nativeRipple ? { color: withAlpha(look.text, 0.1), foreground: true } : undefined, onPressIn: (event) => {
53
+ setPressed(true);
54
+ ripple.start(event);
55
+ onPressIn?.(event);
56
+ }, onPressOut: (event) => {
57
+ setPressed(false);
58
+ ripple.end();
59
+ onPressOut?.(event);
60
+ }, style: [
61
+ styles.button,
62
+ {
63
+ // At least the size's height: a larger text size grows the button instead of clipping its title
64
+ minHeight: metrics.height,
65
+ paddingVertical: 4,
66
+ minWidth: 140,
67
+ borderRadius: radius,
68
+ backgroundColor: look.background,
69
+ alignSelf: block ? "stretch" : "center",
70
+ opacity: disabled ? 0.4 : 1,
71
+ },
72
+ padding,
73
+ style,
74
+ ], ...rest, children: [ripple.layer, pressed && !android && _jsx(View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { borderRadius: radius, backgroundColor: withAlpha(look.text, 0.12) }] }), look.border && _jsx(View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { borderRadius: radius, borderWidth: 1, borderColor: look.border }] }), _jsxs(View, { style: [styles.content, { gap: apple ? 6 : google.gap - GOOGLE_INSET }], accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: [apple ? _jsx(AppleLogo, { size: APPLE_ICON, color: look.text }) : _jsx(GoogleLogo, { size: GOOGLE_ICON }), _jsx(Text, { numberOfLines: 1, allowFontScaling: true, style: apple
75
+ ? // The system font, as Apple's button sets its title
76
+ { color: look.text, fontSize: metrics.fontSize, lineHeight: metrics.lineHeight, fontWeight: "500" }
77
+ : // Google Sans Medium 14/20 where the app has it, else the system font
78
+ { color: look.text, fontSize: 14, lineHeight: 20, fontWeight: "500", fontFamily: GOOGLE_FONT }, children: label })] })] }));
79
+ }
80
+ /** The font the Google button asks for: an app that bundles Google Sans gets it; elsewhere the system font stands in. */
81
+ const GOOGLE_FONT = Platform.select({ web: "'Google Sans', system-ui, sans-serif", default: undefined });
82
+ const styles = StyleSheet.create({
83
+ button: { flexDirection: "row", alignItems: "center", justifyContent: "center", overflow: "hidden" },
84
+ content: { flexDirection: "row", alignItems: "center", justifyContent: "center", flexShrink: 1 },
85
+ });
@@ -0,0 +1,3 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ import { createIcon } from "../../components/Icon/createIcon";
3
+ export default createIcon("AppleLogo", "0 0 24 24", [["path", { "d": "M20.0911 7.2368C19.3972 7.66168 18.8223 8.25568 18.4204 8.96321C18.0185 9.67075 17.8027 10.4687 17.7932 11.2823C17.7959 12.1981 18.0672 13.0929 18.5735 13.856C19.0798 14.6191 19.7988 15.2169 20.6415 15.5754C20.3093 16.6474 19.8176 17.6632 19.1829 18.5888C18.2748 19.8961 17.3253 21.2032 15.8805 21.2032C14.4358 21.2032 14.0642 20.3638 12.3992 20.3638C10.7755 20.3638 10.1976 21.2308 8.87662 21.2308C7.55564 21.2308 6.63382 20.0198 5.57424 18.5338C4.17461 16.452 3.4054 14.0106 3.35889 11.5024C3.35889 7.37443 6.04214 5.18665 8.68397 5.18665C10.0875 5.18665 11.2572 6.10847 12.1378 6.10847C12.9772 6.10847 14.2844 5.1315 15.8805 5.1315C16.7012 5.11032 17.5145 5.29127 18.2487 5.6584C18.983 6.02553 19.6157 6.56757 20.0911 7.2368ZM15.1238 3.38405C15.8274 2.55637 16.2257 1.51233 16.2521 0.426336C16.2533 0.28317 16.2395 0.140275 16.2108 0C15.0022 0.11806 13.8846 0.694096 13.0872 1.60995C12.3769 2.40465 11.9636 3.42081 11.9176 4.48573C11.9181 4.61524 11.932 4.74435 11.9589 4.87103C12.0542 4.88904 12.1509 4.89827 12.2479 4.89861C12.8049 4.85429 13.347 4.69717 13.8414 4.4368C14.3358 4.17644 14.7721 3.81826 15.1238 3.38405Z", "fill": 0 }]]);
@@ -0,0 +1,3 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ import { createIcon } from "../../components/Icon/createIcon";
3
+ export default createIcon("GoogleLogo", "0 0 24 24", [["path", { "d": "M21.0461 12.2099C21.0461 11.5553 20.9874 10.9259 20.8783 10.3217H12.1846V13.8966H17.1524C16.9342 15.0462 16.2797 16.0197 15.2979 16.6742V18.9987H18.2937C20.0391 17.3875 21.0461 15.0211 21.0461 12.2099Z", "fill": "#4285F4" }], ["path", { "d": "M12.1844 21.2307C14.6767 21.2307 16.7662 20.4084 18.2935 18.9986L15.2977 16.6741C14.4753 17.2279 13.4264 17.5636 12.1844 17.5636C9.78441 17.5636 7.74525 15.944 7.01518 13.7622H3.94385V16.1454C5.46273 19.158 8.57602 21.2307 12.1844 21.2307Z", "fill": "#34A853" }], ["path", { "d": "M7.01516 13.7539C6.83054 13.2 6.72145 12.6126 6.72145 12C6.72145 11.3874 6.83054 10.8 7.01516 10.2462V7.86295H3.94382C3.31445 9.10491 2.95361 10.5063 2.95361 12C2.95361 13.4937 3.31445 14.8951 3.94382 16.1371L6.33544 14.2741L7.01516 13.7539Z", "fill": "#FBBC05" }], ["path", { "d": "M12.1844 6.44475C13.5439 6.44475 14.7522 6.91469 15.7173 7.82098L18.3606 5.17762C16.7578 3.68391 14.6767 2.76923 12.1844 2.76923C8.57602 2.76923 5.46273 4.84196 3.94385 7.86294L7.01518 10.2462C7.74525 8.06434 9.78441 6.44475 12.1844 6.44475Z", "fill": "#EA4335" }]]);
@@ -0,0 +1,3 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ import { createIcon } from "../../components/Icon/createIcon";
3
+ export default createIcon("MicrosoftLogo", "0 0 24 24", [["path", { "d": "M3.25 3.25H11.25V11.25H3.25V3.25Z", "fill": "#F35325" }], ["path", { "d": "M12.75 3.25H20.75V11.25H12.75V3.25Z", "fill": "#81BC06" }], ["path", { "d": "M3.25 12.75H11.25V20.75H3.25V12.75Z", "fill": "#05A6F0" }], ["path", { "d": "M12.75 12.75H20.75V20.75H12.75V12.75Z", "fill": "#FFBA08" }]]);
@@ -20,6 +20,7 @@ export { default as AppPermission } from "./AppPermission";
20
20
  export { default as AppStore } from "./AppStore";
21
21
  export { default as AppStoreSquare } from "./AppStoreSquare";
22
22
  export { default as Apple } from "./Apple";
23
+ export { default as AppleLogo } from "./AppleLogo";
23
24
  export { default as Archive } from "./Archive";
24
25
  export { default as Array } from "./Array";
25
26
  export { default as ArrowBottomLeftSm } from "./ArrowBottomLeftSm";
@@ -268,6 +269,7 @@ export { default as GlobeAlt } from "./GlobeAlt";
268
269
  export { default as GlobeFilled } from "./GlobeFilled";
269
270
  export { default as GlobeOff } from "./GlobeOff";
270
271
  export { default as GlobeSpin } from "./GlobeSpin";
272
+ export { default as GoogleLogo } from "./GoogleLogo";
271
273
  export { default as Grid } from "./Grid";
272
274
  export { default as GridAlt } from "./GridAlt";
273
275
  export { default as GripHorizontal } from "./GripHorizontal";
@@ -361,6 +363,7 @@ export { default as Mic } from "./Mic";
361
363
  export { default as MicFilled } from "./MicFilled";
362
364
  export { default as MicFilledOff } from "./MicFilledOff";
363
365
  export { default as MicOff } from "./MicOff";
366
+ export { default as MicrosoftLogo } from "./MicrosoftLogo";
364
367
  export { default as MinimizeDown } from "./MinimizeDown";
365
368
  export { default as MinimizeLeft } from "./MinimizeLeft";
366
369
  export { default as MinimizeRight } from "./MinimizeRight";
package/dist/es/index.js CHANGED
@@ -14,6 +14,7 @@ export { Toolbar, } from "./components/Toolbar/Toolbar";
14
14
  export { TabBar, useTabBarMetrics, useTabBarMinimize, } from "./components/TabBar/TabBar";
15
15
  export { SegmentedControl, } from "./components/SegmentedControl/SegmentedControl";
16
16
  export { Switch } from "./components/Switch/Switch";
17
+ export { SignInButton } from "./components/SignInButton/SignInButton";
17
18
  export { Checkbox } from "./components/Checkbox/Checkbox";
18
19
  export { RadioGroup } from "./components/RadioGroup/RadioGroup";
19
20
  export { Input, InputAdornmentButton, TextField } from "./components/Input/Input";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * True inside a BottomSheet: an iOS sheet's own search field draws its magnifier and its hint in one gray, darker than
3
+ * a bar's hint (IMG_5491), where a bar's magnifier is the text color (IMG_5737).
4
+ */
5
+ export declare const InSheetContext: import("react").Context<boolean>;
@@ -15,8 +15,12 @@ export type DialogAction = {
15
15
  export type DialogProps = {
16
16
  open: boolean;
17
17
  onOpenChange: (open: boolean) => void;
18
- title: ReactNode;
19
- /** The message under the title. */
18
+ /**
19
+ * The title. Without one the dialog is its message alone: an iOS alert with only a message, a Material 3 dialog
20
+ * with only its supporting text.
21
+ */
22
+ title?: ReactNode;
23
+ /** The message under the title, or the whole text of a dialog without one. */
20
24
  description?: ReactNode;
21
25
  /** The actions; two stand side by side on iOS, three or more stack. */
22
26
  actions?: DialogAction[];
@@ -46,7 +46,7 @@ export type FieldFrame = {
46
46
  */
47
47
  export declare function useSpringColor(color: string, stiffness: number, instant: boolean): Animated.Color;
48
48
  /** The look of a field on this platform: its box, text and colors. Shared by Input, TextField and Select. */
49
- export declare function fieldLook(theme: Theme, { variant, size, pill, startAdornment, bar, label, search, }: {
49
+ export declare function fieldLook(theme: Theme, { variant, size, pill, startAdornment, bar, label, search, inSheet, }: {
50
50
  variant: InputVariant;
51
51
  size: ControlSize;
52
52
  pill: boolean;
@@ -60,6 +60,8 @@ export declare function fieldLook(theme: Theme, { variant, size, pill, startAdor
60
60
  label?: boolean;
61
61
  /** Android: the pill search field (40dp) of a screen or a sheet; a bar's own field, in or under it, is `bar`. */
62
62
  search?: boolean;
63
+ /** iOS: a bar's field inside a BottomSheet (its magnifier and hint in one gray) */
64
+ inSheet?: boolean;
63
65
  }, state: FrameState): {
64
66
  box: ViewStyle;
65
67
  glass: boolean;
@@ -0,0 +1,37 @@
1
+ import { type ComponentRef, type Ref } from "react";
2
+ import { View, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
3
+ import { type ControlSize } from "../Button/Button";
4
+ export type SignInProvider = "apple" | "google";
5
+ export type SignInAction = "sign-in" | "sign-up" | "continue";
6
+ export type SignInButtonProps = Omit<PressableProps, "children" | "style"> & {
7
+ /** Whose sign-in: Apple's (an iOS app's) or Google's (iOS and Android alike). */
8
+ provider: SignInProvider;
9
+ /** The label, one of the brands' own: Sign in with…, Sign up with… or Continue with…. @default "continue" */
10
+ action?: SignInAction;
11
+ /**
12
+ * The brand look against the screen. Apple: black in a light scheme, white in a dark one (never black on dark).
13
+ * Google: light (white with a #747775 outline) or dark (#131314 with a #8E918F outline). Defaults to the theme's.
14
+ */
15
+ scheme?: "light" | "dark";
16
+ /** Over a photo or a video: Apple's white button. */
17
+ overMedia?: boolean;
18
+ /** Google's neutral button: #F2F2F2 with no outline. */
19
+ neutral?: boolean;
20
+ /**
21
+ * Height step of the Button scale, so the button matches the screen's other buttons: iOS's large 50 and Android's
22
+ * 48 from `xl`. @default "xl"
23
+ */
24
+ size?: ControlSize;
25
+ /** Takes the whole width. @default true */
26
+ block?: boolean;
27
+ /** Keeps the brand's colors, dimmed to 40%, and takes no presses. */
28
+ disabled?: boolean;
29
+ style?: StyleProp<ViewStyle>;
30
+ ref?: Ref<ComponentRef<typeof View>>;
31
+ };
32
+ /**
33
+ * The sign-in button of a provider, drawn to its brand rules rather than to the theme: Apple's black or white button
34
+ * with the real Apple logo, Google's light, dark or neutral one with the four-color G. It takes the height and the
35
+ * shape of the screen's other buttons (a capsule on iOS, a pill on Android). Disabled keeps the brand's colors at 40%.
36
+ */
37
+ export declare function SignInButton({ provider, action, scheme, overMedia, neutral, size, block, disabled, style, onPressIn, onPressOut, accessibilityLabel, accessibilityState, ...rest }: SignInButtonProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../..").IconComponent;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../..").IconComponent;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../..").IconComponent;
2
+ export default _default;
@@ -18,6 +18,7 @@ export { default as AppPermission } from "./AppPermission";
18
18
  export { default as AppStore } from "./AppStore";
19
19
  export { default as AppStoreSquare } from "./AppStoreSquare";
20
20
  export { default as Apple } from "./Apple";
21
+ export { default as AppleLogo } from "./AppleLogo";
21
22
  export { default as Archive } from "./Archive";
22
23
  export { default as Array } from "./Array";
23
24
  export { default as ArrowBottomLeftSm } from "./ArrowBottomLeftSm";
@@ -266,6 +267,7 @@ export { default as GlobeAlt } from "./GlobeAlt";
266
267
  export { default as GlobeFilled } from "./GlobeFilled";
267
268
  export { default as GlobeOff } from "./GlobeOff";
268
269
  export { default as GlobeSpin } from "./GlobeSpin";
270
+ export { default as GoogleLogo } from "./GoogleLogo";
269
271
  export { default as Grid } from "./Grid";
270
272
  export { default as GridAlt } from "./GridAlt";
271
273
  export { default as GripHorizontal } from "./GripHorizontal";
@@ -359,6 +361,7 @@ export { default as Mic } from "./Mic";
359
361
  export { default as MicFilled } from "./MicFilled";
360
362
  export { default as MicFilledOff } from "./MicFilledOff";
361
363
  export { default as MicOff } from "./MicOff";
364
+ export { default as MicrosoftLogo } from "./MicrosoftLogo";
362
365
  export { default as MinimizeDown } from "./MinimizeDown";
363
366
  export { default as MinimizeLeft } from "./MinimizeLeft";
364
367
  export { default as MinimizeRight } from "./MinimizeRight";
@@ -13,6 +13,7 @@ export { Toolbar, type ToolbarBackground, type ToolbarContentProps, type Toolbar
13
13
  export { TabBar, useTabBarMetrics, useTabBarMinimize, type TabBarBackground, type TabBarBadgeColor, type TabBarItemProps, type TabBarProminent, type TabBarProps, type TabBarSearch, } from "./components/TabBar/TabBar";
14
14
  export { SegmentedControl, type SegmentedControlBadgeProp, type SegmentedControlOptionProps, type SegmentedControlProps, } from "./components/SegmentedControl/SegmentedControl";
15
15
  export { Switch, type SwitchProps } from "./components/Switch/Switch";
16
+ export { SignInButton, type SignInAction, type SignInButtonProps, type SignInProvider } from "./components/SignInButton/SignInButton";
16
17
  export { Checkbox, type CheckboxProps } from "./components/Checkbox/Checkbox";
17
18
  export { RadioGroup, type RadioGroupItemProps, type RadioGroupProps } from "./components/RadioGroup/RadioGroup";
18
19
  export { Input, InputAdornmentButton, TextField, type InputAdornmentButtonProps, type InputProps, type InputVariant, type TextFieldProps } from "./components/Input/Input";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/react-native",
3
- "version": "0.2.31",
3
+ "version": "0.3.0",
4
4
  "description": "Plex UI components for React Native and Expo: iOS 26 and Material 3, on the shared @plexui/styles tokens",
5
5
  "license": "MIT",
6
6
  "homepage": "https://plexui.com",
@@ -84,7 +84,7 @@
84
84
  "test": "npm run typecheck && npm run lint && npm run test:web --prefix example"
85
85
  },
86
86
  "dependencies": {
87
- "@plexui/styles": "^0.17.10",
87
+ "@plexui/styles": "^0.17.11",
88
88
  "libphonenumber-js": "^1.13.17"
89
89
  },
90
90
  "peerDependencies": {
@@ -1,4 +1,5 @@
1
1
  import { isValidElement, useId, useLayoutEffect, useMemo, useState, type ReactNode } from "react"
2
+ import { InSheetContext } from "./context"
2
3
  import { Animated, Easing, PanResponder, Platform, ScrollView, StyleSheet, View, useWindowDimensions, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, type StyleProp, type ViewStyle } from "react-native"
3
4
  import { Pressable } from "../../internal/Pressable"
4
5
  import { useSafeAreaInsets } from "react-native-safe-area-context"
@@ -349,6 +350,7 @@ export function BottomSheetBase({
349
350
  testID={testID}
350
351
  >
351
352
  {(progress, _opening, focus) => (
353
+ <InSheetContext.Provider value>
352
354
  <View pointerEvents="box-none" style={styles.bottom}>
353
355
  <Animated.View
354
356
  {...a11y}
@@ -451,6 +453,7 @@ export function BottomSheetBase({
451
453
  />
452
454
  ) : null}
453
455
  </View>
456
+ </InSheetContext.Provider>
454
457
  )}
455
458
  </Overlay>
456
459
  )
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react"
2
+
3
+ /**
4
+ * True inside a BottomSheet: an iOS sheet's own search field draws its magnifier and its hint in one gray, darker than
5
+ * a bar's hint (IMG_5491), where a bar's magnifier is the text color (IMG_5737).
6
+ */
7
+ export const InSheetContext = createContext(false)
@@ -28,8 +28,12 @@ export type DialogAction = {
28
28
  export type DialogProps = {
29
29
  open: boolean
30
30
  onOpenChange: (open: boolean) => void
31
- title: ReactNode
32
- /** The message under the title. */
31
+ /**
32
+ * The title. Without one the dialog is its message alone: an iOS alert with only a message, a Material 3 dialog
33
+ * with only its supporting text.
34
+ */
35
+ title?: ReactNode
36
+ /** The message under the title, or the whole text of a dialog without one. */
33
37
  description?: ReactNode
34
38
  /** The actions; two stand side by side on iOS, three or more stack. */
35
39
  actions?: DialogAction[]
@@ -89,7 +93,13 @@ function DialogView({ open, onOpenChange, title, description, actions = [], chil
89
93
  // The web names the alert dialog by its title and describes it by its message; a phone keeps the modal view
90
94
  const a11y =
91
95
  Platform.OS === "web"
92
- ? { role: "alertdialog" as const, "aria-modal": true, "aria-labelledby": ids.title, "aria-describedby": description != null ? ids.description : undefined }
96
+ ? {
97
+ role: "alertdialog" as const,
98
+ "aria-modal": true,
99
+ // A dialog without a title is named by its message
100
+ "aria-labelledby": title != null ? ids.title : description != null ? ids.description : undefined,
101
+ "aria-describedby": title != null && description != null ? ids.description : undefined,
102
+ }
93
103
  : { accessibilityRole: "alert" as const, accessibilityViewIsModal: true }
94
104
  if (theme.isAndroid) {
95
105
  return (
@@ -304,7 +314,7 @@ export function PickerDialog({ open, onClose, onOk, cancelLabel, okLabel, label,
304
314
 
305
315
  type PanelProps = {
306
316
  theme: Theme
307
- title: ReactNode
317
+ title?: ReactNode
308
318
  description?: ReactNode
309
319
  actions: DialogAction[]
310
320
  run: (action: DialogAction) => void
@@ -313,8 +323,7 @@ type PanelProps = {
313
323
  children?: ReactNode
314
324
  }
315
325
 
316
- type AndroidPanelProps = Omit<PanelProps, "title"> & {
317
- title?: ReactNode
326
+ type AndroidPanelProps = PanelProps & {
318
327
  /** Rows across the panel's width under the title, in place of the text (an Android dialog with a list of rows). */
319
328
  list?: ReactNode
320
329
  /** The buttons in a row or stacked; by default in a row while they fit. */
@@ -371,11 +380,18 @@ function IOSAlert({ theme, title, description, actions, run, ids, layout, childr
371
380
  <ScrollView style={styles.scroll} contentContainerStyle={{ gap: 10 }} bounces={false}>
372
381
  {/* The text 31 from the sides: 16 of padding and 15 of the header's own */}
373
382
  <View style={{ paddingTop: 5, paddingHorizontal: 15, paddingBottom: 5.5, gap: 5.67 }}>
374
- <Text nativeID={ids.title} weight="semibold" style={[type, { textAlign: description == null ? "center" : "auto" }]} accessibilityRole="header">
375
- {title}
376
- </Text>
383
+ {title != null ? (
384
+ <Text nativeID={ids.title} weight="semibold" style={[type, { textAlign: description == null ? "center" : "auto" }]} accessibilityRole="header">
385
+ {title}
386
+ </Text>
387
+ ) : null}
377
388
  {description != null ? (
378
- <Text nativeID={ids.description} color={theme.color("--dialog-alert-message-color")} style={{ fontSize: 15, lineHeight: 20 }}>
389
+ // Without a title the message is the alert's whole text, in the label color (UIAlertController with a nil title)
390
+ <Text
391
+ nativeID={ids.description}
392
+ color={title != null ? theme.color("--dialog-alert-message-color") : undefined}
393
+ style={{ fontSize: 15, lineHeight: 20 }}
394
+ >
379
395
  {description}
380
396
  </Text>
381
397
  ) : null}
@@ -501,11 +517,14 @@ function AndroidDialog({ theme, title, description, actions, run, ids, children,
501
517
  </>
502
518
  ) : (
503
519
  <ScrollView style={styles.scroll} contentContainerStyle={styles.androidText} bounces={false}>
504
- <Text nativeID={ids.title} color={m.onSurface} accessibilityRole="header" style={[styles.androidTitle, theme.font("medium")]}>
505
- {title}
506
- </Text>
520
+ {title != null ? (
521
+ <Text nativeID={ids.title} color={m.onSurface} accessibilityRole="header" style={[styles.androidTitle, theme.font("medium")]}>
522
+ {title}
523
+ </Text>
524
+ ) : null}
507
525
  {description != null ? (
508
- <Text nativeID={ids.description} color={m.onSurface} style={styles.androidMessage}>
526
+ // Material 3's dialog with no headline: the supporting text alone, in onSurfaceVariant
527
+ <Text nativeID={ids.description} color={title != null ? m.onSurface : m.onSurfaceVariant} style={styles.androidMessage}>
509
528
  {description}
510
529
  </Text>
511
530
  ) : null}
@@ -15,6 +15,7 @@ import type { Theme } from "../../theme/types"
15
15
  import { BarFieldContext, type ControlSize } from "../Button/Button"
16
16
  import { IconDefaultsProvider } from "../Icon/createIcon"
17
17
  import { MaterialCancelFilled, MaterialClose } from "../Icon/material"
18
+ import { InSheetContext } from "../BottomSheet/context"
18
19
 
19
20
  export type InputVariant = "outline" | "soft" | "ghost"
20
21
 
@@ -113,6 +114,7 @@ export function fieldLook(
113
114
  bar = null,
114
115
  label = false,
115
116
  search = false,
117
+ inSheet = false,
116
118
  }: {
117
119
  variant: InputVariant
118
120
  size: ControlSize
@@ -123,6 +125,8 @@ export function fieldLook(
123
125
  label?: boolean
124
126
  /** Android: the pill search field (40dp) of a screen or a sheet; a bar's own field, in or under it, is `bar`. */
125
127
  search?: boolean
128
+ /** iOS: a bar's field inside a BottomSheet (its magnifier and hint in one gray) */
129
+ inSheet?: boolean
126
130
  },
127
131
  state: FrameState,
128
132
  ) {
@@ -225,8 +229,8 @@ export function fieldLook(
225
229
  }
226
230
  if (bar) {
227
231
  // A Toolbar's search field (Toolbar.module.css, iOS 26 kit Search Top and Bottom): the bar's item height, the
228
- // glass of its buttons, the bar's magnifier in the hint's gray (iOS 26 draws the glyph and "Search" in one
229
- // color, typed in or not), its text Regular at the bar's label size
232
+ // glass of its buttons, the bar's magnifier in the text color (Contacts, IMG_5737), its text Regular at the bar's
233
+ // label size; in a sheet the magnifier and the hint are one darker gray, typed in or not (IMG_5491)
230
234
  const gutter = theme.length("--toolbar-search-gutter", 10.54)
231
235
  return {
232
236
  box: {
@@ -243,8 +247,12 @@ export function fieldLook(
243
247
  lineHeight: theme.length("--toolbar-label-line-height", 22),
244
248
  color: theme.color("--input-text-color", theme.colors.text),
245
249
  },
246
- placeholder: theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
247
- icon: theme.color("--toolbar-search-icon-color", theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary)),
250
+ placeholder: inSheet
251
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
252
+ : theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
253
+ icon: inSheet
254
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
255
+ : theme.color("--toolbar-search-icon-color", theme.colors.text),
248
256
  frame: null as FieldFrame | null,
249
257
  trailingIcon: theme.color("--mobile-label-secondary"),
250
258
  caret: theme.color("--color-background-accent-solid"),
@@ -578,6 +586,7 @@ export function InputField({
578
586
  // `readOnly={false}` cannot unlock a disabled field
579
587
  const locked = disabled || readOnly
580
588
  const barField = useContext(BarFieldContext)
589
+ const inSheet = useContext(InSheetContext)
581
590
  // At an iOS row's end the field is the row's value, as the web's field in a `[data-row]`: it fills the room after the
582
591
  // label, with no frame (the row's error marks it invalid), its text at the end and the placeholder in the tertiary label
583
592
  // (on Android it fills the room too, keeping its own field look)
@@ -615,7 +624,7 @@ export function InputField({
615
624
  const androidGlass = useAndroidGlass("bar", barField?.canvas)
616
625
  const fieldLookOf = fieldLook(
617
626
  theme,
618
- { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search },
627
+ { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search, inSheet },
619
628
  { focused, filled, disabled, invalid },
620
629
  )
621
630
  const look = barSearch
@@ -0,0 +1,168 @@
1
+ import { useState, type ComponentRef, type Ref } from "react"
2
+ import { Platform, StyleSheet, Text, View, type PressableProps, type StyleProp, type ViewStyle } from "react-native"
3
+ import { Pressable } from "../../internal/Pressable"
4
+ import { useRipple } from "../../internal/ripple"
5
+ import { withAlpha } from "../../theme/material"
6
+ import { useTheme } from "../../theme/ThemeProvider"
7
+ import AppleLogo from "../../icons/plex/AppleLogo"
8
+ import GoogleLogo from "../../icons/plex/GoogleLogo"
9
+ import { buttonMetrics, useMaterialPress, type ControlSize } from "../Button/Button"
10
+
11
+ export type SignInProvider = "apple" | "google"
12
+ export type SignInAction = "sign-in" | "sign-up" | "continue"
13
+
14
+ export type SignInButtonProps = Omit<PressableProps, "children" | "style"> & {
15
+ /** Whose sign-in: Apple's (an iOS app's) or Google's (iOS and Android alike). */
16
+ provider: SignInProvider
17
+ /** The label, one of the brands' own: Sign in with…, Sign up with… or Continue with…. @default "continue" */
18
+ action?: SignInAction
19
+ /**
20
+ * The brand look against the screen. Apple: black in a light scheme, white in a dark one (never black on dark).
21
+ * Google: light (white with a #747775 outline) or dark (#131314 with a #8E918F outline). Defaults to the theme's.
22
+ */
23
+ scheme?: "light" | "dark"
24
+ /** Over a photo or a video: Apple's white button. */
25
+ overMedia?: boolean
26
+ /** Google's neutral button: #F2F2F2 with no outline. */
27
+ neutral?: boolean
28
+ /**
29
+ * Height step of the Button scale, so the button matches the screen's other buttons: iOS's large 50 and Android's
30
+ * 48 from `xl`. @default "xl"
31
+ */
32
+ size?: ControlSize
33
+ /** Takes the whole width. @default true */
34
+ block?: boolean
35
+ /** Keeps the brand's colors, dimmed to 40%, and takes no presses. */
36
+ disabled?: boolean
37
+ style?: StyleProp<ViewStyle>
38
+ ref?: Ref<ComponentRef<typeof View>>
39
+ }
40
+
41
+ const LABEL: Record<SignInAction, string> = { "sign-in": "Sign in with", "sign-up": "Sign up with", continue: "Continue with" }
42
+
43
+ type Look = { background: string; text: string; border?: string }
44
+
45
+ /** Apple HIG, Sign in with Apple: black with white content, or white with black content on dark or over media. */
46
+ function appleLook(white: boolean): Look {
47
+ return white ? { background: "#FFFFFF", text: "#000000" } : { background: "#000000", text: "#FFFFFF" }
48
+ }
49
+
50
+ /** Google Sign-In branding guidelines: the light, dark and neutral buttons. */
51
+ function googleLook(dark: boolean, neutral: boolean): Look {
52
+ if (neutral) return { background: "#F2F2F2", text: "#1F1F1F" }
53
+ return dark ? { background: "#131314", text: "#E3E3E3", border: "#8E918F" } : { background: "#FFFFFF", text: "#1F1F1F", border: "#747775" }
54
+ }
55
+
56
+ // The logos' drawn ink inside their 24-unit boxes: the G spans 2.95–21.05, so at 24px it stands 2.95px in from each
57
+ // side; Apple's mark spans 3.36–20.64 of its width
58
+ const GOOGLE_ICON = 24
59
+ const GOOGLE_INSET = 2.95
60
+ const APPLE_ICON = 20
61
+
62
+ /**
63
+ * The sign-in button of a provider, drawn to its brand rules rather than to the theme: Apple's black or white button
64
+ * with the real Apple logo, Google's light, dark or neutral one with the four-color G. It takes the height and the
65
+ * shape of the screen's other buttons (a capsule on iOS, a pill on Android). Disabled keeps the brand's colors at 40%.
66
+ */
67
+ export function SignInButton({
68
+ provider,
69
+ action = "continue",
70
+ scheme,
71
+ overMedia = false,
72
+ neutral = false,
73
+ size = "xl",
74
+ block = true,
75
+ disabled = false,
76
+ style,
77
+ onPressIn,
78
+ onPressOut,
79
+ accessibilityLabel,
80
+ accessibilityState,
81
+ ...rest
82
+ }: SignInButtonProps) {
83
+ const theme = useTheme()
84
+ const dark = (scheme ?? theme.scheme) === "dark"
85
+ const apple = provider === "apple"
86
+ const look = apple ? appleLook(dark || overMedia) : googleLook(dark, neutral)
87
+ const metrics = buttonMetrics(theme, size)
88
+ const label = `${LABEL[action]} ${apple ? "Apple" : "Google"}`
89
+ const [pressed, setPressed] = useState(false)
90
+ const android = theme.isAndroid
91
+ const nativeRipple = useMaterialPress(theme)
92
+ const ripple = useRipple(withAlpha(look.text, 0.1), android && !nativeRipple, theme.reducedMotion)
93
+ // Google's spacing: 16 before the G, 12 to the text and 16 after on iOS; 12, 10 and 12 on Android
94
+ const google = android ? { start: 12, gap: 10, end: 12 } : { start: 16, gap: 12, end: 16 }
95
+ const radius = metrics.height / 2
96
+ // A compact size keeps the platform's 44pt or 48dp target, as Button does
97
+ const reach = Math.max(0, ((android ? 48 : 44) - metrics.height) / 2)
98
+ const padding = apple
99
+ ? // Apple asks for a margin of at least a tenth of the height around the logo and the title
100
+ { paddingHorizontal: Math.max(metrics.height / 10, 16) }
101
+ : { paddingLeft: google.start - GOOGLE_INSET, paddingRight: google.end }
102
+ return (
103
+ <Pressable
104
+ accessibilityRole="button"
105
+ accessibilityLabel={accessibilityLabel ?? label}
106
+ accessibilityState={{ ...accessibilityState, disabled }}
107
+ disabled={disabled}
108
+ hitSlop={reach ? { top: reach, bottom: reach } : undefined}
109
+ android_ripple={nativeRipple ? { color: withAlpha(look.text, 0.1), foreground: true } : undefined}
110
+ onPressIn={(event) => {
111
+ setPressed(true)
112
+ ripple.start(event)
113
+ onPressIn?.(event)
114
+ }}
115
+ onPressOut={(event) => {
116
+ setPressed(false)
117
+ ripple.end()
118
+ onPressOut?.(event)
119
+ }}
120
+ style={[
121
+ styles.button,
122
+ {
123
+ // At least the size's height: a larger text size grows the button instead of clipping its title
124
+ minHeight: metrics.height,
125
+ paddingVertical: 4,
126
+ minWidth: 140,
127
+ borderRadius: radius,
128
+ backgroundColor: look.background,
129
+ alignSelf: block ? "stretch" : "center",
130
+ opacity: disabled ? 0.4 : 1,
131
+ },
132
+ padding,
133
+ style,
134
+ ]}
135
+ {...rest}
136
+ >
137
+ {ripple.layer}
138
+ {/* iOS's press: a layer of the content's color, as a filled button darkens or lightens */}
139
+ {pressed && !android && <View pointerEvents="none" style={[StyleSheet.absoluteFill, { borderRadius: radius, backgroundColor: withAlpha(look.text, 0.12) }]} />}
140
+ {/* Google's outline is 1px inside the button */}
141
+ {look.border && <View pointerEvents="none" style={[StyleSheet.absoluteFill, { borderRadius: radius, borderWidth: 1, borderColor: look.border }]} />}
142
+ <View style={[styles.content, { gap: apple ? 6 : google.gap - GOOGLE_INSET }]} accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
143
+ {apple ? <AppleLogo size={APPLE_ICON} color={look.text} /> : <GoogleLogo size={GOOGLE_ICON} />}
144
+ <Text
145
+ numberOfLines={1}
146
+ allowFontScaling
147
+ style={
148
+ apple
149
+ ? // The system font, as Apple's button sets its title
150
+ { color: look.text, fontSize: metrics.fontSize, lineHeight: metrics.lineHeight, fontWeight: "500" }
151
+ : // Google Sans Medium 14/20 where the app has it, else the system font
152
+ { color: look.text, fontSize: 14, lineHeight: 20, fontWeight: "500", fontFamily: GOOGLE_FONT }
153
+ }
154
+ >
155
+ {label}
156
+ </Text>
157
+ </View>
158
+ </Pressable>
159
+ )
160
+ }
161
+
162
+ /** The font the Google button asks for: an app that bundles Google Sans gets it; elsewhere the system font stands in. */
163
+ const GOOGLE_FONT = Platform.select({ web: "'Google Sans', system-ui, sans-serif", default: undefined })
164
+
165
+ const styles = StyleSheet.create({
166
+ button: { flexDirection: "row", alignItems: "center", justifyContent: "center", overflow: "hidden" },
167
+ content: { flexDirection: "row", alignItems: "center", justifyContent: "center", flexShrink: 1 },
168
+ })
@@ -0,0 +1,4 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ import { createIcon } from "../../components/Icon/createIcon"
3
+
4
+ export default createIcon("AppleLogo", "0 0 24 24", [["path",{"d":"M20.0911 7.2368C19.3972 7.66168 18.8223 8.25568 18.4204 8.96321C18.0185 9.67075 17.8027 10.4687 17.7932 11.2823C17.7959 12.1981 18.0672 13.0929 18.5735 13.856C19.0798 14.6191 19.7988 15.2169 20.6415 15.5754C20.3093 16.6474 19.8176 17.6632 19.1829 18.5888C18.2748 19.8961 17.3253 21.2032 15.8805 21.2032C14.4358 21.2032 14.0642 20.3638 12.3992 20.3638C10.7755 20.3638 10.1976 21.2308 8.87662 21.2308C7.55564 21.2308 6.63382 20.0198 5.57424 18.5338C4.17461 16.452 3.4054 14.0106 3.35889 11.5024C3.35889 7.37443 6.04214 5.18665 8.68397 5.18665C10.0875 5.18665 11.2572 6.10847 12.1378 6.10847C12.9772 6.10847 14.2844 5.1315 15.8805 5.1315C16.7012 5.11032 17.5145 5.29127 18.2487 5.6584C18.983 6.02553 19.6157 6.56757 20.0911 7.2368ZM15.1238 3.38405C15.8274 2.55637 16.2257 1.51233 16.2521 0.426336C16.2533 0.28317 16.2395 0.140275 16.2108 0C15.0022 0.11806 13.8846 0.694096 13.0872 1.60995C12.3769 2.40465 11.9636 3.42081 11.9176 4.48573C11.9181 4.61524 11.932 4.74435 11.9589 4.87103C12.0542 4.88904 12.1509 4.89827 12.2479 4.89861C12.8049 4.85429 13.347 4.69717 13.8414 4.4368C14.3358 4.17644 14.7721 3.81826 15.1238 3.38405Z","fill":0}]])
@@ -0,0 +1,4 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ import { createIcon } from "../../components/Icon/createIcon"
3
+
4
+ export default createIcon("GoogleLogo", "0 0 24 24", [["path",{"d":"M21.0461 12.2099C21.0461 11.5553 20.9874 10.9259 20.8783 10.3217H12.1846V13.8966H17.1524C16.9342 15.0462 16.2797 16.0197 15.2979 16.6742V18.9987H18.2937C20.0391 17.3875 21.0461 15.0211 21.0461 12.2099Z","fill":"#4285F4"}],["path",{"d":"M12.1844 21.2307C14.6767 21.2307 16.7662 20.4084 18.2935 18.9986L15.2977 16.6741C14.4753 17.2279 13.4264 17.5636 12.1844 17.5636C9.78441 17.5636 7.74525 15.944 7.01518 13.7622H3.94385V16.1454C5.46273 19.158 8.57602 21.2307 12.1844 21.2307Z","fill":"#34A853"}],["path",{"d":"M7.01516 13.7539C6.83054 13.2 6.72145 12.6126 6.72145 12C6.72145 11.3874 6.83054 10.8 7.01516 10.2462V7.86295H3.94382C3.31445 9.10491 2.95361 10.5063 2.95361 12C2.95361 13.4937 3.31445 14.8951 3.94382 16.1371L6.33544 14.2741L7.01516 13.7539Z","fill":"#FBBC05"}],["path",{"d":"M12.1844 6.44475C13.5439 6.44475 14.7522 6.91469 15.7173 7.82098L18.3606 5.17762C16.7578 3.68391 14.6767 2.76923 12.1844 2.76923C8.57602 2.76923 5.46273 4.84196 3.94385 7.86294L7.01518 10.2462C7.74525 8.06434 9.78441 6.44475 12.1844 6.44475Z","fill":"#EA4335"}]])
@@ -0,0 +1,4 @@
1
+ // Generated by scripts/build-icons.mjs. Do not edit.
2
+ import { createIcon } from "../../components/Icon/createIcon"
3
+
4
+ export default createIcon("MicrosoftLogo", "0 0 24 24", [["path",{"d":"M3.25 3.25H11.25V11.25H3.25V3.25Z","fill":"#F35325"}],["path",{"d":"M12.75 3.25H20.75V11.25H12.75V3.25Z","fill":"#81BC06"}],["path",{"d":"M3.25 12.75H11.25V20.75H3.25V12.75Z","fill":"#05A6F0"}],["path",{"d":"M12.75 12.75H20.75V20.75H12.75V12.75Z","fill":"#FFBA08"}]])
@@ -20,6 +20,7 @@ export { default as AppPermission } from "./AppPermission"
20
20
  export { default as AppStore } from "./AppStore"
21
21
  export { default as AppStoreSquare } from "./AppStoreSquare"
22
22
  export { default as Apple } from "./Apple"
23
+ export { default as AppleLogo } from "./AppleLogo"
23
24
  export { default as Archive } from "./Archive"
24
25
  export { default as Array } from "./Array"
25
26
  export { default as ArrowBottomLeftSm } from "./ArrowBottomLeftSm"
@@ -268,6 +269,7 @@ export { default as GlobeAlt } from "./GlobeAlt"
268
269
  export { default as GlobeFilled } from "./GlobeFilled"
269
270
  export { default as GlobeOff } from "./GlobeOff"
270
271
  export { default as GlobeSpin } from "./GlobeSpin"
272
+ export { default as GoogleLogo } from "./GoogleLogo"
271
273
  export { default as Grid } from "./Grid"
272
274
  export { default as GridAlt } from "./GridAlt"
273
275
  export { default as GripHorizontal } from "./GripHorizontal"
@@ -361,6 +363,7 @@ export { default as Mic } from "./Mic"
361
363
  export { default as MicFilled } from "./MicFilled"
362
364
  export { default as MicFilledOff } from "./MicFilledOff"
363
365
  export { default as MicOff } from "./MicOff"
366
+ export { default as MicrosoftLogo } from "./MicrosoftLogo"
364
367
  export { default as MinimizeDown } from "./MinimizeDown"
365
368
  export { default as MinimizeLeft } from "./MinimizeLeft"
366
369
  export { default as MinimizeRight } from "./MinimizeRight"
package/src/index.ts CHANGED
@@ -61,6 +61,7 @@ export {
61
61
  } from "./components/SegmentedControl/SegmentedControl"
62
62
 
63
63
  export { Switch, type SwitchProps } from "./components/Switch/Switch"
64
+ export { SignInButton, type SignInAction, type SignInButtonProps, type SignInProvider } from "./components/SignInButton/SignInButton"
64
65
  export { Checkbox, type CheckboxProps } from "./components/Checkbox/Checkbox"
65
66
  export { RadioGroup, type RadioGroupItemProps, type RadioGroupProps } from "./components/RadioGroup/RadioGroup"
66
67
  export { Input, InputAdornmentButton, TextField, type InputAdornmentButtonProps, type InputProps, type InputVariant, type TextFieldProps } from "./components/Input/Input"