@plexui/react-native 0.2.12 → 0.2.14

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.
@@ -41,7 +41,7 @@ export function Dialog({ open, onOpenChange, title, description, actions = [], c
41
41
  ? { role: "alertdialog", "aria-modal": true, "aria-labelledby": ids.title, "aria-describedby": description != null ? ids.description : undefined }
42
42
  : { accessibilityRole: "alert", accessibilityViewIsModal: true };
43
43
  if (theme.isAndroid) {
44
- 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, children: children }) }));
44
+ 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 }) }));
45
45
  }
46
46
  // With reduced motion it fades in place (Dialog.module.css): no scale
47
47
  const scale = !theme.reducedMotion && canTransformGlass;
@@ -151,8 +151,10 @@ function IOSAlert({ theme, title, description, actions, run, ids, layout, childr
151
151
  // Two stacked because their labels do not fit: Cancel last, at the bottom, as UIAlertController stacks them
152
152
  const autoStacked = !inline && layout == null && actions.length === 2;
153
153
  const ordered = inline ? [...cancel, ...others] : autoStacked ? [...others, ...cancel] : indexed;
154
+ // Until both labels are measured the alert is unseen: its first frame shows the actions as they stay
155
+ const ready = !(layout == null && actions.length === 2) || actions.every((_, index) => labels[index] != null);
154
156
  const type = { fontSize: theme.length("--dialog-mobile-type-size", 17), lineHeight: theme.length("--dialog-mobile-type-leading", 22) };
155
- return (_jsxs(Glass, { radius: radius, elevation: "raised", fillToken: "--dialog-alert-background", style: { width, flexShrink: 1, padding, gap: 10 }, children: [layout == null && actions.length === 2 ? (
157
+ return (_jsxs(Glass, { radius: radius, elevation: "raised", fillToken: "--dialog-alert-background", style: { width, flexShrink: 1, padding, gap: 10, opacity: ready ? 1 : 0 }, children: [layout == null && actions.length === 2 ? (
156
158
  // The labels on one line, unseen, to tell whether two fit side by side
157
159
  _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) => {
158
160
  const next = event.nativeEvent.layout.width;
@@ -192,7 +194,7 @@ function IOSAction({ theme, action, run, type, grow }) {
192
194
  grow ? styles.grow : null,
193
195
  ], children: _jsx(Text, { color: text, weight: action.preferred ? "semibold" : "medium", style: [type, styles.centered], children: action.label }) }));
194
196
  }
195
- function AndroidDialog({ theme, title, description, actions, run, ids, children, list }) {
197
+ function AndroidDialog({ theme, title, description, actions, run, ids, children, list, layout }) {
196
198
  const m = theme.material;
197
199
  const { width: screen } = useWindowDimensions();
198
200
  // Android's alert: 48 from the screen's sides, at most 356 wide
@@ -206,16 +208,22 @@ function AndroidDialog({ theme, title, description, actions, run, ids, children,
206
208
  // Each button's own width, measured in either layout (their content's, never stretched), and the row's: they stack
207
209
  // when they do not fit side by side
208
210
  const [room, setRoom] = useState(0);
209
- const [widths, setWidths] = useState([]);
210
- const measured = bar.every((_, index) => widths[index] != null);
211
- const needed = bar.reduce((sum, _, index) => sum + (widths[index] ?? 0), 0) + GAP * Math.max(0, bar.length - 1);
212
- const stacked = room > 0 && measured && needed > room + 0.5;
211
+ // Kept by each button's key (its place in `actions`), which stays with it when the row reorders: a button that moves
212
+ // in the row keeps its element and is not measured again
213
+ const [widths, setWidths] = useState({});
214
+ const keys = bar.map((action) => actions.indexOf(action));
215
+ const measured = keys.every((key) => widths[key] != null);
216
+ const needed = keys.reduce((sum, key) => sum + (widths[key] ?? 0), 0) + GAP * Math.max(0, bar.length - 1);
217
+ // Until the buttons and the row are measured the panel is unseen: its first frame shows them as they stay
218
+ const ready = layout != null || bar.length === 0 || (room > 0 && measured);
219
+ const stacked = layout === "stacked" || (layout !== "inline" && room > 0 && measured && needed > room + 0.5);
213
220
  const order = stacked ? [...bar.keys()].reverse() : [...bar.keys()];
214
221
  const button = (index) => {
215
222
  const action = bar[index];
216
- return (_jsx(AndroidDialogButton, { theme: theme, action: action, run: run, onWidth: (next) => setWidths((current) => (current[index] === next ? current : Object.assign([...current], { [index]: next }))) }, actions.indexOf(action)));
223
+ const key = keys[index];
224
+ return (_jsx(AndroidDialogButton, { theme: theme, action: action, run: run, onWidth: (next) => setWidths((current) => (current[key] === next ? current : { ...current, [key]: next })) }, key));
217
225
  };
218
- return (_jsxs(View, { style: [styles.android, { width, backgroundColor: androidDialogBackground(theme) }], children: [list != null ? (
226
+ return (_jsxs(View, { style: [styles.android, { width, backgroundColor: androidDialogBackground(theme), opacity: ready ? 1 : 0 }], children: [list != null ? (
219
227
  // A list: the title stays, 14 over the rows, and the rows scroll under it (AlertDialog with a custom view)
220
228
  _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) =>
221
229
  // The neutral actions at the start, a space, then the negative and the positive
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Platform, View } from "react-native";
2
+ import { Platform, StyleSheet, View } from "react-native";
3
3
  import { useSafeAreaInsets } from "react-native-safe-area-context";
4
4
  import { SoftBottomVeil, SoftTopEdge } from "../../internal/BarBackdrop";
5
5
  import { useTheme } from "../../theme/ThemeProvider";
@@ -22,6 +22,11 @@ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID
22
22
  return null;
23
23
  return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", top: 0, left: 0, right: 0, height: insets.top }, style], children: _jsx(SoftTopEdge, { fill: canvas, blur: Platform.OS === "web" ? 6 : 0 }) }));
24
24
  }
25
- // The safe area at that edge; the veil reaches 34 past it, into the screen
26
- return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style], children: top ? _jsx(SoftBottomVeil, { fill: canvas, bottom: insets.top }) : _jsx(SoftBottomVeil, { fill: canvas, top: 0 }) }));
25
+ // The safe area at that edge, or the height the style gives the top edge (a bar's row of buttons under the status
26
+ // bar): the content is blurred in full down to it, and the veil and the blur ease out over the 34 past it
27
+ const height = StyleSheet.flatten(style)?.height;
28
+ const reach = top && typeof height === "number" ? height + FULL_BLUR_SHORTFALL : insets.top;
29
+ return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style], children: top ? _jsx(SoftBottomVeil, { fill: canvas, bottom: reach }) : _jsx(SoftBottomVeil, { fill: canvas, top: 0 }) }));
27
30
  }
31
+ /** The veil's blur is full 6 short of the edge it is turned over at (12 to 40 into its 34): a given height adds them. */
32
+ const FULL_BLUR_SHORTFALL = 6;
@@ -73,10 +73,8 @@ function trackingFor(theme, style, mono) {
73
73
  // On the web, Chromium and Firefox on a Mac draw text with subpixel smoothing, 11–20% heavier than an iPhone draws the
74
74
  // same words; grayscale smoothing draws them within 1–2% of it
75
75
  const WEB_SMOOTHING = (Platform.OS === "web" ? { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" } : {});
76
- // A mono face's weights: the web's 501–549 of a system face draw as a synthesized bold in Chromium, so Medium is 500
77
- const weightNumber = (weight) => (Platform.OS === "web"
78
- ? { regular: "400", medium: "500", semibold: "590", bold: "700" }
79
- : { regular: "400", medium: "500", semibold: "600", bold: "700" })[weight];
76
+ // A mono face's weights: a browser draws a weight its face lacks (510, 590) as a synthesized bold, so the named ones
77
+ const weightNumber = (weight) => ({ regular: "400", medium: "500", semibold: "600", bold: "700" }[weight]);
80
78
  /**
81
79
  * Text in the faces, sizes and colors of Plex UI. `variant` takes the platform's text styles (Body 17 on iOS, Body
82
80
  * Large 16 on Android); `size` the Plex UI scale. The tracking is the kit's Inter tracking at the size.
@@ -1,8 +1,38 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Animated, Platform, StyleSheet, View } from "react-native";
3
- import { useTheme } from "../theme/ThemeProvider";
3
+ import { useTheme, useThemeOverrides } from "../theme/ThemeProvider";
4
4
  import { blurModule, liquidGlassModule } from "./optional";
5
5
  import { useReduceTransparency } from "./reduceTransparency";
6
+ /**
7
+ * In a browser the glass is a fill over a CSS blur, which shows far more of what is under it than iOS's own: a menu is
8
+ * almost opaque there, and a chip's label must read over any photo. So on the web the plain glass and the menu take
9
+ * these denser fills and blurs (each a token a theme may set; the shared web tokens stay as they are). A brand that
10
+ * sets the shared token itself keeps it.
11
+ */
12
+ const WEB_DENSE = {
13
+ "--mobile-glass-background": {
14
+ fill: "--mobile-glass-web-background",
15
+ light: "rgba(243, 243, 243, 0.8)",
16
+ dark: "rgba(28, 28, 30, 0.7)",
17
+ filter: "--mobile-glass-web-backdrop-filter",
18
+ blur: "blur(20px)",
19
+ },
20
+ // Pressed, a step deeper, as the shared tokens step from 55% to 75%
21
+ "--mobile-glass-background-active": {
22
+ fill: "--mobile-glass-web-background-active",
23
+ light: "rgba(232, 232, 232, 0.9)",
24
+ dark: "rgba(58, 58, 60, 0.8)",
25
+ filter: "--mobile-glass-web-backdrop-filter",
26
+ blur: "blur(20px)",
27
+ },
28
+ "--menu-mobile-background": {
29
+ fill: "--menu-mobile-web-background",
30
+ light: "rgba(255, 255, 255, 0.9)",
31
+ dark: "rgba(28, 28, 30, 0.9)",
32
+ filter: "--menu-mobile-web-backdrop-filter",
33
+ blur: "blur(30px)",
34
+ },
35
+ };
6
36
  /** The filter and the shadow of the glass surfaces of the phone layer, by their fill (mobile-materials.css, touch.css). */
7
37
  const SURFACES = {
8
38
  "--menu-mobile-background": { filter: "--menu-mobile-backdrop-filter", shadow: "--menu-shadow" },
@@ -24,6 +54,7 @@ const intensityOf = (radius) => Math.max(0, Math.min(100, Math.round(radius * 5)
24
54
  export function Glass({ radius = 0, elevation = "regular", tint, interactive, fillToken, filterToken, shadowToken, blur, style, children, ...rest }) {
25
55
  const theme = useTheme();
26
56
  const reduceTransparency = useReduceTransparency();
57
+ const overrides = useThemeOverrides();
27
58
  const shape = { borderRadius: radius, borderCurve: "continuous" };
28
59
  const surface = fillToken ? SURFACES[fillToken] : undefined;
29
60
  const shadow = theme.token(shadowToken ?? surface?.shadow ?? (elevation === "raised" ? "--mobile-glass-shadow-raised" : "--mobile-glass-shadow"));
@@ -34,10 +65,15 @@ export function Glass({ radius = 0, elevation = "regular", tint, interactive, fi
34
65
  const { GlassView } = native;
35
66
  return (_jsx(GlassView, { ...rest, glassEffectStyle: "regular", colorScheme: theme.scheme, tintColor: tint, isInteractive: interactive, style: [shape, style], children: children }));
36
67
  }
37
- const fill = tint ?? theme.color(fillToken ?? "--mobile-glass-background");
38
- const filterValue = theme.token(filterToken ?? surface?.filter ?? "--mobile-glass-backdrop-filter");
39
- const filter = blur != null ? `blur(${blur}px)` : typeof filterValue === "string" ? filterValue : "blur(12px)";
40
68
  const web = Platform.OS === "web";
69
+ const fillName = fillToken ?? "--mobile-glass-background";
70
+ const filterName = filterToken ?? surface?.filter ?? "--mobile-glass-backdrop-filter";
71
+ const dense = web && !theme.isAndroid ? WEB_DENSE[fillName] : undefined;
72
+ const denseFill = dense != null && tint == null && overrides?.[fillName] == null;
73
+ const denseFilter = dense != null && filterToken == null && overrides?.[filterName] == null;
74
+ const fill = tint ?? (denseFill ? theme.color(dense.fill, theme.scheme === "dark" ? dense.dark : dense.light) : theme.color(fillName));
75
+ const filterValue = denseFilter ? (theme.token(dense.filter) ?? dense.blur) : theme.token(filterName);
76
+ const filter = blur != null ? `blur(${blur}px)` : typeof filterValue === "string" ? filterValue : "blur(12px)";
41
77
  const module = web || Platform.OS !== "ios" ? null : blurModule();
42
78
  const opaque = reduceTransparency || (!web && module == null);
43
79
  if (web && !opaque) {
@@ -35,9 +35,12 @@ const ThemeSettingsContext = createContext(null);
35
35
  const WEIGHTS = Platform.OS === "web"
36
36
  ? { regular: "400", medium: "510", semibold: "590", bold: "700" }
37
37
  : { regular: "400", medium: "500", semibold: "600", bold: "700" };
38
- // The web's system font (react-native-web's own stack, no family set): Chromium draws 501–549 of it as a synthesized bold,
39
- // heavier than 590, so Medium is 500 there; 590 is SF's own Semibold, as an iPhone draws it
40
- const SYSTEM_WEIGHTS = Platform.OS === "web" ? { ...WEIGHTS, medium: "500" } : WEIGHTS;
38
+ // The web's system font (react-native-web's own stack, or a family that names the system's: -apple-system, system-ui):
39
+ // a browser has only its 500 and 600 there and draws 510 and 590 as a synthesized bold (Chromium, Safari on an iPhone:
40
+ // 590 heavier than 700), so Medium is 500 and Semibold 600
41
+ const SYSTEM_WEIGHTS = Platform.OS === "web" ? { ...WEIGHTS, medium: "500", semibold: "600" } : WEIGHTS;
42
+ /** Whether a font family starts with the system's face (`-apple-system, system-ui, sans-serif`), not an app's own. */
43
+ const isSystemFamily = (family) => /^\s*["']?(-apple-system|system-ui|BlinkMacSystemFont|ui-sans-serif|SF Pro|sans-serif)\b/i.test(family);
41
44
  /** The platform a ThemeProvider draws by default. */
42
45
  export function defaultPlatform() {
43
46
  return Platform.OS === "android" ? "android" : "ios";
@@ -93,12 +96,12 @@ function warnUnresolvedColors(brand, resolver) {
93
96
  function fontFor(fonts, weight) {
94
97
  const sans = fonts?.sans;
95
98
  if (typeof sans === "string")
96
- return { fontFamily: sans, fontWeight: WEIGHTS[weight] };
99
+ return { fontFamily: sans, fontWeight: (isSystemFamily(sans) ? SYSTEM_WEIGHTS : WEIGHTS)[weight] };
97
100
  const family = sans?.[weight] ?? (weight === "semibold" ? sans?.bold : undefined) ?? sans?.regular;
98
101
  // A family per weight carries its weight: a weight on top would be synthesized on Android
99
102
  if (family && sans?.[weight])
100
103
  return { fontFamily: family };
101
- return family ? { fontFamily: family, fontWeight: WEIGHTS[weight] } : { fontWeight: SYSTEM_WEIGHTS[weight] };
104
+ return family ? { fontFamily: family, fontWeight: (isSystemFamily(family) ? SYSTEM_WEIGHTS : WEIGHTS)[weight] } : { fontWeight: SYSTEM_WEIGHTS[weight] };
102
105
  }
103
106
  /** Builds a theme for a scheme and a platform (ThemeProvider does it for its children). */
104
107
  export function createTheme(options) {
@@ -241,6 +244,10 @@ function defaultTheme() {
241
244
  return fallbackTheme;
242
245
  }
243
246
  /** The theme of the nearest ThemeProvider (the light default of the device's platform without one). */
247
+ /** The tokens the brands of the providers around set (internal: a default that must yield to a brand's own). */
248
+ export function useThemeOverrides() {
249
+ return useContext(ThemeSettingsContext)?.overrides;
250
+ }
244
251
  export function useTheme() {
245
252
  return useContext(ThemeContext) ?? defaultTheme();
246
253
  }
@@ -22,7 +22,10 @@ export type DialogProps = {
22
22
  actions?: DialogAction[];
23
23
  /** Content between the text and the actions, as a text field. */
24
24
  children?: ReactNode;
25
- /** `stacked` stacks two actions too; `inline` keeps more in a row. @default by count, as the web */
25
+ /**
26
+ * `stacked` stacks the actions, `inline` keeps them in a row, on iOS and Android. @default iOS: two side by side
27
+ * while their labels fit on one line, three or more stacked; Android: in a row while they fit, else stacked
28
+ */
26
29
  mobileLayout?: "inline" | "stacked";
27
30
  /** A tap outside, Android's back and Escape close it: Android's dialogs do, an iOS alert does not. @default Android true, iOS false */
28
31
  dismissible?: boolean;
@@ -77,4 +77,6 @@ export declare function createTheme(options: {
77
77
  */
78
78
  export declare function ThemeProvider({ scheme, platform, selectionColor, brand, fonts: fontsProp, viewportWidth, children }: ThemeProviderProps): import("react").JSX.Element;
79
79
  /** The theme of the nearest ThemeProvider (the light default of the device's platform without one). */
80
+ /** The tokens the brands of the providers around set (internal: a default that must yield to a brand's own). */
81
+ export declare function useThemeOverrides(): Readonly<Record<string, string>> | undefined;
80
82
  export declare function useTheme(): Theme;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/react-native",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
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",
@@ -34,7 +34,10 @@ export type DialogProps = {
34
34
  actions?: DialogAction[]
35
35
  /** Content between the text and the actions, as a text field. */
36
36
  children?: ReactNode
37
- /** `stacked` stacks two actions too; `inline` keeps more in a row. @default by count, as the web */
37
+ /**
38
+ * `stacked` stacks the actions, `inline` keeps them in a row, on iOS and Android. @default iOS: two side by side
39
+ * while their labels fit on one line, three or more stacked; Android: in a row while they fit, else stacked
40
+ */
38
41
  mobileLayout?: "inline" | "stacked"
39
42
  /** A tap outside, Android's back and Escape close it: Android's dialogs do, an iOS alert does not. @default Android true, iOS false */
40
43
  dismissible?: boolean
@@ -73,7 +76,7 @@ export function Dialog({ open, onOpenChange, title, description, actions = [], c
73
76
  if (theme.isAndroid) {
74
77
  return (
75
78
  <AndroidFrame open={open} onClose={close} dismissible={dismissible ?? true} a11y={a11y} testID={testID}>
76
- <AndroidDialog theme={theme} title={title} description={description} actions={actions} run={run} ids={ids}>
79
+ <AndroidDialog theme={theme} title={title} description={description} actions={actions} run={run} ids={ids} layout={mobileLayout}>
77
80
  {children}
78
81
  </AndroidDialog>
79
82
  </AndroidFrame>
@@ -296,6 +299,8 @@ type AndroidPanelProps = Omit<PanelProps, "title"> & {
296
299
  title?: ReactNode
297
300
  /** Rows across the panel's width under the title, in place of the text (an Android dialog with a list of rows). */
298
301
  list?: ReactNode
302
+ /** The buttons in a row or stacked; by default in a row while they fit. */
303
+ layout?: "inline" | "stacked"
299
304
  }
300
305
 
301
306
  /** An iOS alert action's label inset from its capsule's ends. */
@@ -321,9 +326,11 @@ function IOSAlert({ theme, title, description, actions, run, ids, layout, childr
321
326
  // Two stacked because their labels do not fit: Cancel last, at the bottom, as UIAlertController stacks them
322
327
  const autoStacked = !inline && layout == null && actions.length === 2
323
328
  const ordered = inline ? [...cancel, ...others] : autoStacked ? [...others, ...cancel] : indexed
329
+ // Until both labels are measured the alert is unseen: its first frame shows the actions as they stay
330
+ const ready = !(layout == null && actions.length === 2) || actions.every((_, index) => labels[index] != null)
324
331
  const type = { fontSize: theme.length("--dialog-mobile-type-size", 17), lineHeight: theme.length("--dialog-mobile-type-leading", 22) }
325
332
  return (
326
- <Glass radius={radius} elevation="raised" fillToken="--dialog-alert-background" style={{ width, flexShrink: 1, padding, gap: 10 }}>
333
+ <Glass radius={radius} elevation="raised" fillToken="--dialog-alert-background" style={{ width, flexShrink: 1, padding, gap: 10, opacity: ready ? 1 : 0 }}>
327
334
  {layout == null && actions.length === 2 ? (
328
335
  // The labels on one line, unseen, to tell whether two fit side by side
329
336
  <View pointerEvents="none" aria-hidden style={styles.measure}>
@@ -418,7 +425,7 @@ function IOSAction({ theme, action, run, type, grow }: { theme: Theme; action: D
418
425
  )
419
426
  }
420
427
 
421
- function AndroidDialog({ theme, title, description, actions, run, ids, children, list }: AndroidPanelProps) {
428
+ function AndroidDialog({ theme, title, description, actions, run, ids, children, list, layout }: AndroidPanelProps) {
422
429
  const m = theme.material
423
430
  const { width: screen } = useWindowDimensions()
424
431
  // Android's alert: 48 from the screen's sides, at most 356 wide
@@ -432,25 +439,31 @@ function AndroidDialog({ theme, title, description, actions, run, ids, children,
432
439
  // Each button's own width, measured in either layout (their content's, never stretched), and the row's: they stack
433
440
  // when they do not fit side by side
434
441
  const [room, setRoom] = useState(0)
435
- const [widths, setWidths] = useState<number[]>([])
436
- const measured = bar.every((_, index) => widths[index] != null)
437
- const needed = bar.reduce((sum, _, index) => sum + (widths[index] ?? 0), 0) + GAP * Math.max(0, bar.length - 1)
438
- const stacked = room > 0 && measured && needed > room + 0.5
442
+ // Kept by each button's key (its place in `actions`), which stays with it when the row reorders: a button that moves
443
+ // in the row keeps its element and is not measured again
444
+ const [widths, setWidths] = useState<Record<number, number>>({})
445
+ const keys = bar.map((action) => actions.indexOf(action))
446
+ const measured = keys.every((key) => widths[key] != null)
447
+ const needed = keys.reduce((sum, key) => sum + (widths[key] ?? 0), 0) + GAP * Math.max(0, bar.length - 1)
448
+ // Until the buttons and the row are measured the panel is unseen: its first frame shows them as they stay
449
+ const ready = layout != null || bar.length === 0 || (room > 0 && measured)
450
+ const stacked = layout === "stacked" || (layout !== "inline" && room > 0 && measured && needed > room + 0.5)
439
451
  const order = stacked ? [...bar.keys()].reverse() : [...bar.keys()]
440
452
  const button = (index: number) => {
441
453
  const action = bar[index]
454
+ const key = keys[index]
442
455
  return (
443
456
  <AndroidDialogButton
444
- key={actions.indexOf(action)}
457
+ key={key}
445
458
  theme={theme}
446
459
  action={action}
447
460
  run={run}
448
- onWidth={(next) => setWidths((current) => (current[index] === next ? current : Object.assign([...current], { [index]: next })))}
461
+ onWidth={(next) => setWidths((current) => (current[key] === next ? current : { ...current, [key]: next }))}
449
462
  />
450
463
  )
451
464
  }
452
465
  return (
453
- <View style={[styles.android, { width, backgroundColor: androidDialogBackground(theme) }]}>
466
+ <View style={[styles.android, { width, backgroundColor: androidDialogBackground(theme), opacity: ready ? 1 : 0 }]}>
454
467
  {list != null ? (
455
468
  // A list: the title stays, 14 over the rows, and the rows scroll under it (AlertDialog with a custom view)
456
469
  <>
@@ -1,4 +1,4 @@
1
- import { Platform, View, type StyleProp, type ViewStyle } from "react-native"
1
+ import { Platform, StyleSheet, View, type StyleProp, type ViewStyle } from "react-native"
2
2
  import { useSafeAreaInsets } from "react-native-safe-area-context"
3
3
  import { SoftBottomVeil, SoftTopEdge } from "../../internal/BarBackdrop"
4
4
  import { useTheme } from "../../theme/ThemeProvider"
@@ -35,14 +35,20 @@ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID
35
35
  </View>
36
36
  )
37
37
  }
38
- // The safe area at that edge; the veil reaches 34 past it, into the screen
38
+ // The safe area at that edge, or the height the style gives the top edge (a bar's row of buttons under the status
39
+ // bar): the content is blurred in full down to it, and the veil and the blur ease out over the 34 past it
40
+ const height = StyleSheet.flatten(style)?.height
41
+ const reach = top && typeof height === "number" ? height + FULL_BLUR_SHORTFALL : insets.top
39
42
  return (
40
43
  <View
41
44
  pointerEvents="none"
42
45
  testID={testID}
43
46
  style={[{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style]}
44
47
  >
45
- {top ? <SoftBottomVeil fill={canvas} bottom={insets.top} /> : <SoftBottomVeil fill={canvas} top={0} />}
48
+ {top ? <SoftBottomVeil fill={canvas} bottom={reach} /> : <SoftBottomVeil fill={canvas} top={0} />}
46
49
  </View>
47
50
  )
48
51
  }
52
+
53
+ /** The veil's blur is full 6 short of the edge it is turned over at (12 to 40 into its 34): a given height adds them. */
54
+ const FULL_BLUR_SHORTFALL = 6
@@ -113,11 +113,9 @@ function trackingFor(theme: Theme, style: StyleProp<TextStyle>, mono: boolean |
113
113
  // same words; grayscale smoothing draws them within 1–2% of it
114
114
  const WEB_SMOOTHING = (Platform.OS === "web" ? { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" } : {}) as TextStyle
115
115
 
116
- // A mono face's weights: the web's 501–549 of a system face draw as a synthesized bold in Chromium, so Medium is 500
116
+ // A mono face's weights: a browser draws a weight its face lacks (510, 590) as a synthesized bold, so the named ones
117
117
  const weightNumber = (weight: FontWeightName) =>
118
- (Platform.OS === "web"
119
- ? { regular: "400", medium: "500", semibold: "590", bold: "700" } as Record<FontWeightName, string>
120
- : { regular: "400", medium: "500", semibold: "600", bold: "700" })[weight] as TextStyle["fontWeight"]
118
+ ({ regular: "400", medium: "500", semibold: "600", bold: "700" } as Record<FontWeightName, string>)[weight] as TextStyle["fontWeight"]
121
119
 
122
120
  /**
123
121
  * Text in the faces, sizes and colors of Plex UI. `variant` takes the platform's text styles (Body 17 on iOS, Body
@@ -1,5 +1,5 @@
1
1
  import { Animated, Platform, StyleSheet, View, type StyleProp, type ViewProps, type ViewStyle } from "react-native"
2
- import { useTheme } from "../theme/ThemeProvider"
2
+ import { useTheme, useThemeOverrides } from "../theme/ThemeProvider"
3
3
  import { blurModule, liquidGlassModule } from "./optional"
4
4
  import { useReduceTransparency } from "./reduceTransparency"
5
5
 
@@ -29,6 +29,37 @@ export type GlassProps = ViewProps & {
29
29
  style?: StyleProp<ViewStyle>
30
30
  }
31
31
 
32
+ /**
33
+ * In a browser the glass is a fill over a CSS blur, which shows far more of what is under it than iOS's own: a menu is
34
+ * almost opaque there, and a chip's label must read over any photo. So on the web the plain glass and the menu take
35
+ * these denser fills and blurs (each a token a theme may set; the shared web tokens stay as they are). A brand that
36
+ * sets the shared token itself keeps it.
37
+ */
38
+ const WEB_DENSE: Record<string, { fill: string; light: string; dark: string; filter: string; blur: string }> = {
39
+ "--mobile-glass-background": {
40
+ fill: "--mobile-glass-web-background",
41
+ light: "rgba(243, 243, 243, 0.8)",
42
+ dark: "rgba(28, 28, 30, 0.7)",
43
+ filter: "--mobile-glass-web-backdrop-filter",
44
+ blur: "blur(20px)",
45
+ },
46
+ // Pressed, a step deeper, as the shared tokens step from 55% to 75%
47
+ "--mobile-glass-background-active": {
48
+ fill: "--mobile-glass-web-background-active",
49
+ light: "rgba(232, 232, 232, 0.9)",
50
+ dark: "rgba(58, 58, 60, 0.8)",
51
+ filter: "--mobile-glass-web-backdrop-filter",
52
+ blur: "blur(20px)",
53
+ },
54
+ "--menu-mobile-background": {
55
+ fill: "--menu-mobile-web-background",
56
+ light: "rgba(255, 255, 255, 0.9)",
57
+ dark: "rgba(28, 28, 30, 0.9)",
58
+ filter: "--menu-mobile-web-backdrop-filter",
59
+ blur: "blur(30px)",
60
+ },
61
+ }
62
+
32
63
  /** The filter and the shadow of the glass surfaces of the phone layer, by their fill (mobile-materials.css, touch.css). */
33
64
  const SURFACES: Record<string, { filter: string; shadow: string }> = {
34
65
  "--menu-mobile-background": { filter: "--menu-mobile-backdrop-filter", shadow: "--menu-shadow" },
@@ -64,6 +95,7 @@ export function Glass({
64
95
  }: GlassProps) {
65
96
  const theme = useTheme()
66
97
  const reduceTransparency = useReduceTransparency()
98
+ const overrides = useThemeOverrides()
67
99
  const shape: ViewStyle = { borderRadius: radius, borderCurve: "continuous" }
68
100
  const surface = fillToken ? SURFACES[fillToken] : undefined
69
101
  const shadow = theme.token(shadowToken ?? surface?.shadow ?? (elevation === "raised" ? "--mobile-glass-shadow-raised" : "--mobile-glass-shadow"))
@@ -85,10 +117,15 @@ export function Glass({
85
117
  </GlassView>
86
118
  )
87
119
  }
88
- const fill = tint ?? theme.color(fillToken ?? "--mobile-glass-background")
89
- const filterValue = theme.token(filterToken ?? surface?.filter ?? "--mobile-glass-backdrop-filter")
90
- const filter = blur != null ? `blur(${blur}px)` : typeof filterValue === "string" ? filterValue : "blur(12px)"
91
120
  const web = Platform.OS === "web"
121
+ const fillName = fillToken ?? "--mobile-glass-background"
122
+ const filterName = filterToken ?? surface?.filter ?? "--mobile-glass-backdrop-filter"
123
+ const dense = web && !theme.isAndroid ? WEB_DENSE[fillName] : undefined
124
+ const denseFill = dense != null && tint == null && overrides?.[fillName] == null
125
+ const denseFilter = dense != null && filterToken == null && overrides?.[filterName] == null
126
+ const fill = tint ?? (denseFill ? theme.color(dense.fill, theme.scheme === "dark" ? dense.dark : dense.light) : theme.color(fillName))
127
+ const filterValue = denseFilter ? (theme.token(dense.filter) ?? dense.blur) : theme.token(filterName)
128
+ const filter = blur != null ? `blur(${blur}px)` : typeof filterValue === "string" ? filterValue : "blur(12px)"
92
129
  const module = web || Platform.OS !== "ios" ? null : blurModule()
93
130
  const opaque = reduceTransparency || (!web && module == null)
94
131
  if (web && !opaque) {
@@ -90,10 +90,14 @@ const WEIGHTS: Record<FontWeightName, TextStyle["fontWeight"]> =
90
90
  Platform.OS === "web"
91
91
  ? { regular: "400", medium: "510" as TextStyle["fontWeight"], semibold: "590" as TextStyle["fontWeight"], bold: "700" }
92
92
  : { regular: "400", medium: "500", semibold: "600", bold: "700" }
93
- // The web's system font (react-native-web's own stack, no family set): Chromium draws 501–549 of it as a synthesized bold,
94
- // heavier than 590, so Medium is 500 there; 590 is SF's own Semibold, as an iPhone draws it
93
+ // The web's system font (react-native-web's own stack, or a family that names the system's: -apple-system, system-ui):
94
+ // a browser has only its 500 and 600 there and draws 510 and 590 as a synthesized bold (Chromium, Safari on an iPhone:
95
+ // 590 heavier than 700), so Medium is 500 and Semibold 600
95
96
  const SYSTEM_WEIGHTS: Record<FontWeightName, TextStyle["fontWeight"]> =
96
- Platform.OS === "web" ? { ...WEIGHTS, medium: "500" } : WEIGHTS
97
+ Platform.OS === "web" ? { ...WEIGHTS, medium: "500", semibold: "600" } : WEIGHTS
98
+
99
+ /** Whether a font family starts with the system's face (`-apple-system, system-ui, sans-serif`), not an app's own. */
100
+ const isSystemFamily = (family: string) => /^\s*["']?(-apple-system|system-ui|BlinkMacSystemFont|ui-sans-serif|SF Pro|sans-serif)\b/i.test(family)
97
101
 
98
102
  /** The platform a ThemeProvider draws by default. */
99
103
  export function defaultPlatform(): PlatformStyle {
@@ -148,11 +152,11 @@ function warnUnresolvedColors(brand: BrandTheme | undefined, resolver: TokenReso
148
152
 
149
153
  function fontFor(fonts: FontFamilies | undefined, weight: FontWeightName) {
150
154
  const sans = fonts?.sans
151
- if (typeof sans === "string") return { fontFamily: sans, fontWeight: WEIGHTS[weight] }
155
+ if (typeof sans === "string") return { fontFamily: sans, fontWeight: (isSystemFamily(sans) ? SYSTEM_WEIGHTS : WEIGHTS)[weight] }
152
156
  const family = sans?.[weight] ?? (weight === "semibold" ? sans?.bold : undefined) ?? sans?.regular
153
157
  // A family per weight carries its weight: a weight on top would be synthesized on Android
154
158
  if (family && sans?.[weight]) return { fontFamily: family }
155
- return family ? { fontFamily: family, fontWeight: WEIGHTS[weight] } : { fontWeight: SYSTEM_WEIGHTS[weight] }
159
+ return family ? { fontFamily: family, fontWeight: (isSystemFamily(family) ? SYSTEM_WEIGHTS : WEIGHTS)[weight] } : { fontWeight: SYSTEM_WEIGHTS[weight] }
156
160
  }
157
161
 
158
162
  /** Builds a theme for a scheme and a platform (ThemeProvider does it for its children). */
@@ -319,6 +323,11 @@ function defaultTheme(): Theme {
319
323
  }
320
324
 
321
325
  /** The theme of the nearest ThemeProvider (the light default of the device's platform without one). */
326
+ /** The tokens the brands of the providers around set (internal: a default that must yield to a brand's own). */
327
+ export function useThemeOverrides(): Readonly<Record<string, string>> | undefined {
328
+ return useContext(ThemeSettingsContext)?.overrides
329
+ }
330
+
322
331
  export function useTheme(): Theme {
323
332
  return useContext(ThemeContext) ?? defaultTheme()
324
333
  }