@plexui/react-native 0.2.25 → 0.2.26

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.
Files changed (52) hide show
  1. package/README.md +3 -0
  2. package/dist/es/components/BottomActions/BottomActions.js +2 -2
  3. package/dist/es/components/BottomSheet/BottomSheet.js +7 -3
  4. package/dist/es/components/Button/Button.js +10 -6
  5. package/dist/es/components/Card/Card.js +9 -2
  6. package/dist/es/components/Checkbox/Checkbox.js +2 -2
  7. package/dist/es/components/Indicator/CircularProgress.js +11 -5
  8. package/dist/es/components/List/List.js +44 -9
  9. package/dist/es/components/Menu/Menu.js +15 -5
  10. package/dist/es/components/PageControl/PageControl.js +7 -3
  11. package/dist/es/components/RadioGroup/RadioGroup.js +2 -2
  12. package/dist/es/components/RollingNumber/RollingNumber.js +7 -7
  13. package/dist/es/components/Select/Select.js +4 -2
  14. package/dist/es/components/Switch/Switch.js +2 -2
  15. package/dist/es/components/TextLink/TextLink.js +5 -0
  16. package/dist/es/index.js +1 -1
  17. package/dist/es/internal/a11y.js +12 -0
  18. package/dist/es/internal/row.js +13 -0
  19. package/dist/es/theme/ThemeProvider.js +4 -2
  20. package/dist/es/theme/material.js +2 -0
  21. package/dist/types/components/BottomActions/BottomActions.d.ts +6 -1
  22. package/dist/types/components/Button/Button.d.ts +5 -0
  23. package/dist/types/components/Card/Card.d.ts +5 -1
  24. package/dist/types/components/Indicator/CircularProgress.d.ts +10 -2
  25. package/dist/types/components/List/List.d.ts +11 -1
  26. package/dist/types/components/Menu/Menu.d.ts +10 -4
  27. package/dist/types/components/RollingNumber/RollingNumber.d.ts +3 -1
  28. package/dist/types/index.d.ts +1 -1
  29. package/dist/types/internal/a11y.d.ts +22 -0
  30. package/dist/types/internal/row.d.ts +21 -2
  31. package/dist/types/theme/ThemeProvider.d.ts +3 -2
  32. package/dist/types/theme/material.d.ts +2 -0
  33. package/package.json +1 -1
  34. package/src/components/BottomActions/BottomActions.tsx +7 -2
  35. package/src/components/BottomSheet/BottomSheet.tsx +9 -4
  36. package/src/components/Button/Button.tsx +19 -4
  37. package/src/components/Card/Card.tsx +8 -3
  38. package/src/components/Checkbox/Checkbox.tsx +2 -1
  39. package/src/components/Indicator/CircularProgress.tsx +27 -11
  40. package/src/components/List/List.tsx +55 -5
  41. package/src/components/Menu/Menu.tsx +27 -11
  42. package/src/components/PageControl/PageControl.tsx +7 -3
  43. package/src/components/RadioGroup/RadioGroup.tsx +2 -1
  44. package/src/components/RollingNumber/RollingNumber.tsx +10 -8
  45. package/src/components/Select/Select.tsx +4 -1
  46. package/src/components/Switch/Switch.tsx +2 -1
  47. package/src/components/TextLink/TextLink.tsx +6 -0
  48. package/src/index.ts +1 -1
  49. package/src/internal/a11y.ts +13 -0
  50. package/src/internal/row.ts +14 -2
  51. package/src/theme/ThemeProvider.tsx +7 -4
  52. package/src/theme/material.ts +2 -0
package/README.md CHANGED
@@ -59,6 +59,9 @@ export default function App() {
59
59
  >
60
60
  ```
61
61
 
62
+ A nested `ThemeProvider` keeps its parent's brand and lays its own over it; `brand={null}` draws its subtree in Plex
63
+ UI's own colors and radii (a stand-in for a system prompt, which is in the system's colors, never the app's).
64
+
62
65
  `useTheme()` gives any token resolved for the current scheme: `theme.color("--color-text")`,
63
66
  `theme.length("--button-size-md")`, and Material 3 roles on `theme.material`.
64
67
 
@@ -13,7 +13,7 @@ import { Button } from "../Button/Button";
13
13
  * action stands under it, 8 apart. Android: the Plex Android look's 48dp full-width button, 16dp from the sides and
14
14
  * 16 above the gesture bar. Each Button inside is a block of the size `3xl` unless it sets its own.
15
15
  */
16
- export function BottomActions({ children, floating = false, background = "soft", canvasColor, testID, style }) {
16
+ export function BottomActions({ children, floating = false, background = "soft", canvasColor, secondary = false, testID, style }) {
17
17
  const theme = useTheme();
18
18
  const insets = useSafeAreaInsets();
19
19
  const android = theme.isAndroid;
@@ -28,7 +28,7 @@ export function BottomActions({ children, floating = false, background = "soft",
28
28
  return child;
29
29
  const props = child.props;
30
30
  // The second action: iOS 26's glass capsule of the main one's size, Android's ghost button
31
- const second = index > 0 && props.variant === undefined
31
+ const second = (index > 0 || secondary) && props.variant === undefined
32
32
  ? android
33
33
  ? { variant: "ghost", color: props.color ?? "secondary" }
34
34
  : { variant: "soft", color: props.color ?? "secondary", mobileMaterial: props.mobileMaterial ?? "glass" }
@@ -220,6 +220,8 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
220
220
  const margin = theme.length("--mobile-layout-margin", 16);
221
221
  // Android: content scrolled under the bar fades out under it; the footer's height sets the room under the content
222
222
  const [scrolled, setScrolled] = useState(false);
223
+ // The Android bar's height: 69 with a title on one line, a line more when it wraps to a second
224
+ const [androidBarHeight, setAndroidBarHeight] = useState(ANDROID_BAR_HEIGHT);
223
225
  const [footerHeight, setFooterHeight] = useState(0);
224
226
  // Android's sheet has no handle: the whole sheet takes the drag. With a title its bar is the reference's sheet bar,
225
227
  // over the content: Close in a 46dp glass circle 12 under the top edge and 12 from the side (in line with the
@@ -227,7 +229,7 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
227
229
  // (69 in all). Content scrolled under it shows through the sheet's color at
228
230
  // 63% over a light blur, let go over its last 32dp (12 past the bar), with no line
229
231
  const barItem = useMemoBarItem(background);
230
- const header = android ? (title != null ? (_jsxs(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidBar, children: [_jsx(SheetBarFade, { fill: background, shown: scrolled }), _jsx(View, { style: styles.androidCircle, children: dismissible ? (_jsx(BarItemContext.Provider, { value: barItem, children: _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) })) : null }), _jsx(View, { style: styles.androidHeading, children: _jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "medium", align: "center", numberOfLines: 1, color: m.onSurface, style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title }) }), _jsx(View, { style: styles.androidCircle })] })) : (_jsx(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidGrip }))) : dismissible || title != null ? (
232
+ const header = android ? (title != null ? (_jsxs(View, { onStartShouldSetResponderCapture: gesture.chrome, onLayout: (event) => setAndroidBarHeight(Math.max(ANDROID_BAR_HEIGHT, event.nativeEvent.layout.height)), style: styles.androidBar, children: [_jsx(SheetBarFade, { fill: background, shown: scrolled }), _jsx(View, { style: styles.androidCircle, children: dismissible ? (_jsx(BarItemContext.Provider, { value: barItem, children: _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) })) : null }), _jsx(View, { style: styles.androidHeading, children: _jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "medium", align: "center", numberOfLines: 2, color: m.onSurface, style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title }) }), _jsx(View, { style: styles.androidCircle })] })) : (_jsx(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidGrip }))) : dismissible || title != null ? (
231
233
  // The web's phone Sheet bar: one 44 row 16 under the top edge, Close at the leading edge and the title alone centered
232
234
  // The bar is the web's Toolbar: 16 above the row and --toolbar-padding-bottom under it
233
235
  _jsxs(View, { ...responder.panHandlers, style: [styles.iosBar, { paddingTop: theme.length("--dialog-sheet-action-inset-block", 16), paddingBottom: theme.length("--toolbar-padding-bottom", 10), paddingHorizontal: margin }], children: [_jsx(View, { style: { width: closeSize, height: closeSize }, children: dismissible ? _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) : null }), _jsx(View, { style: [styles.iosHeading, { minHeight: closeSize }], children: title != null ? (_jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "semibold", align: "center", style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title })) : null }), _jsx(View, { style: { width: closeSize } })] })) : null;
@@ -282,7 +284,8 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
282
284
  styles.androidContent,
283
285
  // A screen whose gutter is Material's compact 16 sets it with --bottom-sheet-android-padding-inline
284
286
  { paddingHorizontal: androidInline },
285
- title != null ? styles.androidContentUnderBar : null,
287
+ // 2 under the bar: 71 under a one-line title
288
+ title != null ? { paddingTop: androidBarHeight + 2 } : null,
286
289
  // Over a footer: 8 above its height, which reaches over the sheet's bottom padding
287
290
  footer ? { paddingBottom: 8 + Math.max(0, footerHeight - insets.bottom - keyboard) } : null,
288
291
  ]
@@ -335,6 +338,8 @@ function SheetBarFade({ fill, shown }) {
335
338
  * `BottomSheet.Footer` pins actions under the content.
336
339
  */
337
340
  export const BottomSheet = Object.assign(BottomSheetRoot, { Footer: BottomSheetFooter });
341
+ /** An Android sheet's bar: Close's 46dp circle 12 under the top edge and 11 over the bar's end. */
342
+ const ANDROID_BAR_HEIGHT = 12 + 46 + 11;
338
343
  const styles = StyleSheet.create({
339
344
  bottom: { flex: 1, justifyContent: "flex-end", alignItems: "center" },
340
345
  sheet: { alignSelf: "stretch", overflow: "hidden", borderCurve: "continuous", marginHorizontal: "auto", width: "100%" },
@@ -353,7 +358,6 @@ const styles = StyleSheet.create({
353
358
  // The content 12 from the sides (as a page's groups), 16 over the navigation bar; under a bar 13 under its circles
354
359
  // (71 from the sheet's top, 2 under the bar)
355
360
  androidContent: { paddingHorizontal: 12, paddingTop: 4, paddingBottom: 16 },
356
- androidContentUnderBar: { paddingTop: 12 + 46 + 13 },
357
361
  iosFooter: { gap: 10, paddingTop: 12 },
358
362
  iosFooterEdge: { position: "absolute", top: -15, left: 0, right: 0, bottom: 0 },
359
363
  // Android's sheet actions: 48dp buttons 4 apart, 12 from the sides and above, 12 over the gesture bar, over the
@@ -232,13 +232,15 @@ function Spinner({ color }) {
232
232
  strokeDasharray: [SPINNER_LENGTH, SPINNER_LENGTH], strokeDashoffset: SPINNER_LENGTH * (1 - arc / 360) }) }) }));
233
233
  }
234
234
  /** Strings and numbers in a row make one label ("Pressed {count}"); an element (an icon) stands on its own. */
235
- function renderChildren(children, metrics) {
235
+ function renderChildren(children, metrics, lines = 1) {
236
236
  const out = [];
237
237
  let label = [];
238
238
  const flush = () => {
239
239
  if (!label.length)
240
240
  return;
241
- out.push(_jsx(Text, { numberOfLines: 1, weight: metrics.weight, style: { fontSize: metrics.fontSize, lineHeight: metrics.lineHeight }, children: label.join("") }, `label-${out.length}`));
241
+ out.push(_jsx(Text, { numberOfLines: lines, weight: metrics.weight,
242
+ // A label on more lines than one shrinks to the button and centers its lines
243
+ style: [{ fontSize: metrics.fontSize, lineHeight: metrics.lineHeight }, lines > 1 ? styles.wraps : null], children: label.join("") }, `label-${out.length}`));
242
244
  label = [];
243
245
  };
244
246
  flattenChildren(children).forEach((child, index) => {
@@ -275,7 +277,7 @@ export function Button(props) {
275
277
  * the title's line with a 44pt target; Android's 14sp Medium in the accent on the header's line. `style` reaches the
276
278
  * row (`justifyContent: "center"` centres the words, as the web's `data-align="center"`).
277
279
  */
278
- function ListActionButton({ place, color = "primary", disabled = false, loading = false, inert: inertProp = loading, children, style, onPressIn, onPressOut, accessibilityState, ...rest }) {
280
+ function ListActionButton({ place, color = "primary", disabled = false, loading = false, inert: inertProp = loading, labelLines, children, style, onPressIn, onPressOut, accessibilityState, ...rest }) {
279
281
  const theme = useTheme();
280
282
  const android = theme.isAndroid;
281
283
  const [pressed, setPressed] = useState(false);
@@ -304,7 +306,7 @@ function ListActionButton({ place, color = "primary", disabled = false, loading
304
306
  const parts = flattenChildren(children);
305
307
  // Words and then an icon: the words take the room, so the icon ends the row
306
308
  const trailingIcon = row && parts.length > 1 && isValidElement(parts[parts.length - 1]);
307
- const content = parts.map((part, index) => typeof part === "string" || typeof part === "number" ? (_jsx(Text, { weight: android && !row ? "medium" : "regular", numberOfLines: row ? undefined : 1, style: [type, trailingIcon && index < parts.length - 1 ? styles.grow : null], children: part }, `label-${index}`)) : (_jsx(Fragment, { children: part }, `part-${index}`)));
309
+ const content = parts.map((part, index) => typeof part === "string" || typeof part === "number" ? (_jsx(Text, { weight: android && !row ? "medium" : "regular", numberOfLines: labelLines ?? (row ? undefined : 1), style: [type, trailingIcon && index < parts.length - 1 ? styles.grow : null, labelLines != null && labelLines > 1 && !row ? styles.shrinks : null], children: part }, `label-${index}`)) : (_jsx(Fragment, { children: part }, `part-${index}`)));
308
310
  const fill = row && pressed && !inert ? (android ? controlHighlight(theme.scheme) : theme.color("--field-row-press-background")) : undefined;
309
311
  // The header's words stand on the title's line: their target reaches over and under it to 44 (48 on Android)
310
312
  const reach = row ? 0 : Math.max(0, ((android ? 48 : 44) - type.lineHeight) / 2);
@@ -324,7 +326,7 @@ function ListActionButton({ place, color = "primary", disabled = false, loading
324
326
  style,
325
327
  ], children: _jsx(TextColorProvider, { value: ink, children: _jsx(IconDefaultsProvider, { size: android ? 24 : row ? theme.length("--field-row-icon-symbol-size", 24) : theme.length("--control-icon-size-md", 20), color: ink, children: loading ? _jsx(ActivityIndicator, { color: ink, size: "small" }) : content }) }) }));
326
328
  }
327
- function ButtonBody({ color = "primary", variant = "solid", size = "md", shape = "round", mobileMaterial, uniform = false, block = false, selected = false, loading = false, disabled = false, inert: inertProp = loading, iconSize, gutterSize, opticallyAlign, children, style, onPressIn, onPressOut, accessibilityState, ...rest }) {
329
+ function ButtonBody({ color = "primary", variant = "solid", size = "md", shape = "round", mobileMaterial, uniform = false, block = false, labelLines = 1, selected = false, loading = false, disabled = false, inert: inertProp = loading, iconSize, gutterSize, opticallyAlign, children, style, onPressIn, onPressOut, accessibilityState, ...rest }) {
328
330
  const theme = useTheme();
329
331
  const bar = useContext(BarItemContext);
330
332
  const sized = buttonMetrics(theme, size, shape, uniform);
@@ -501,7 +503,7 @@ function ButtonBody({ color = "primary", variant = "solid", size = "md", shape =
501
503
  }
502
504
  : { opacity: loading ? 0 : 1 };
503
505
  const spinner = android ? (loading || leaving ? (_jsx(Animated.View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, styles.row, { opacity: swap, transform: [{ translateY: swap.interpolate({ inputRange: [0, 1], outputRange: [24, 0] }) }] }], children: _jsx(Spinner, { color: ink }) })) : null) : loading ? (_jsx(ActivityIndicator, { style: StyleSheet.absoluteFill, color: text, size: metrics.indicator > 20 ? "large" : "small" })) : null;
504
- const content = (_jsx(TextColorProvider, { value: ink, children: _jsxs(IconDefaultsProvider, { size: metrics.iconSize, color: ink, children: [_jsx(Animated.View, { style: [styles.row, android ? styles.fromTop : null, { gap: metrics.gap }, labelMotion], children: renderChildren(children, metrics) }), spinner] }) }));
506
+ const content = (_jsx(TextColorProvider, { value: ink, children: _jsxs(IconDefaultsProvider, { size: metrics.iconSize, color: ink, children: [_jsx(Animated.View, { style: [styles.row, android ? styles.fromTop : null, labelLines > 1 ? styles.shrinks : null, { gap: metrics.gap }, labelMotion], children: renderChildren(children, metrics, labelLines) }), spinner] }) }));
505
507
  const layer = ripple.layer;
506
508
  const pressable = {
507
509
  accessibilityRole: "button",
@@ -526,4 +528,6 @@ const styles = StyleSheet.create({
526
528
  row: { flexDirection: "row", alignItems: "center", justifyContent: "center" },
527
529
  fromTop: { alignSelf: "stretch", transformOrigin: "top" },
528
530
  grow: { flexGrow: 1, flexShrink: 1 },
531
+ wraps: { flexShrink: 1, minWidth: 0, textAlign: "center" },
532
+ shrinks: { flexShrink: 1, minWidth: 0, maxWidth: "100%" },
529
533
  });
@@ -4,7 +4,7 @@ import { Image, Platform, StyleSheet, View } from "react-native";
4
4
  import { Pressable } from "../../internal/Pressable";
5
5
  import { flattenChildren } from "../../internal/children";
6
6
  import { space } from "../../internal/spacing";
7
- import { controlHighlight, withAlpha } from "../../theme/material";
7
+ import { barShadow, controlHighlight, elevationShadow, withAlpha } from "../../theme/material";
8
8
  import { useTheme } from "../../theme/ThemeProvider";
9
9
  import { materialType } from "../../theme/typography";
10
10
  import { IconDefaultsProvider } from "../Icon/createIcon";
@@ -31,6 +31,9 @@ export function cardSurface(theme, variant) {
31
31
  return { backgroundColor: theme.colors.groupedSurface };
32
32
  if (variant === "solid")
33
33
  return { backgroundColor: theme.material.surfaceContainerHigh };
34
+ // Material's elevated card: the low container lifted at level 1
35
+ if (variant === "elevated")
36
+ return { backgroundColor: theme.material.surfaceContainerLow, boxShadow: elevationShadow.level1 };
34
37
  return { backgroundColor: "transparent" };
35
38
  }
36
39
  // On a phone an outline card is a section of an inset grouped list (no border, the section's fill: the grouped
@@ -40,6 +43,10 @@ export function cardSurface(theme, variant) {
40
43
  return { backgroundColor: theme.colors.groupedSurface };
41
44
  if (variant === "solid")
42
45
  return { backgroundColor: theme.color("--card-solid-section-background", theme.colors.surfaceSecondary) };
46
+ // Lifted off the page by the soft shadow of a floating control (2 down, 8 across, 6% black; 30% on a dark screen),
47
+ // so a card laid over another reads as on top
48
+ if (variant === "elevated")
49
+ return { backgroundColor: theme.colors.groupedSurface, boxShadow: barShadow(theme.scheme) };
43
50
  return { backgroundColor: "transparent" };
44
51
  }
45
52
  /**
@@ -70,7 +77,7 @@ function CardRoot({ children, variant = "outline", size = "md", color, onPress,
70
77
  const body = parts.map((child, index) => isValidElement(child) && child.type === CardMedia
71
78
  ? cloneElement(child, { first: index === 0, last: index === parts.length - 1 })
72
79
  : child);
73
- const box = [styles.card, { padding, gap, borderRadius: radius }, ghost && !tint ? styles.ghost : null, tint ? { backgroundColor: tint.fill } : cardSurface(theme, variant), style];
80
+ const box = [styles.card, { padding, gap, borderRadius: radius }, ghost && !tint ? styles.ghost : null, tint ? { backgroundColor: tint.fill, ...(variant === "elevated" ? { boxShadow: cardSurface(theme, variant).boxShadow } : null) } : cardSurface(theme, variant), style];
74
81
  const content = tint ? (_jsx(Context.Provider, { value: { padding, inset, radius, theme, ink: tint.ink }, children: _jsx(TextColorProvider, { value: tint.ink, children: _jsx(IconDefaultsProvider, { color: tint.ink, children: body }) }) })) : (_jsx(Context.Provider, { value: { padding, inset, radius, theme }, children: body }));
75
82
  if (onPress || interactive) {
76
83
  // Android: the press of a row in a section (the settings list selector), as a List row's
@@ -7,7 +7,7 @@ import CheckMd from "../../icons/plex/CheckMd";
7
7
  import Minus from "../../icons/plex/Minus";
8
8
  import { spaceToggles, useDescription } from "../../internal/a11y";
9
9
  import { ControlLabel, controlLabelLine } from "../../internal/ControlLabel";
10
- import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHold } from "../../internal/row";
10
+ import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHint, rowHold } from "../../internal/row";
11
11
  import { androidGray, withAlpha } from "../../theme/material";
12
12
  import { useTheme } from "../../theme/ThemeProvider";
13
13
  import { ANDROID_ROW_END, iosCheckmarkColor, selectionColor } from "../Switch/Switch";
@@ -126,7 +126,7 @@ export function Checkbox({ checked: checkedProp, defaultChecked = false, onCheck
126
126
  const targetSize = theme.isAndroid ? 48 : theme.length("--checkbox-target-size", 44);
127
127
  const described = useDescription(description);
128
128
  const text = _jsx(ControlLabel, { label: label, description: description, disabled: disabled, descriptionId: described.id });
129
- return (_jsxs(Pressable, { ...described.props, ...spaceToggles(toggle), accessibilityRole: "checkbox", accessibilityLabel: accessibilityLabel ?? (typeof label === "string" ? label : undefined), accessibilityState: { checked: state === "indeterminate" ? "mixed" : state, disabled }, "aria-checked": state === "indeterminate" ? "mixed" : state, "aria-invalid": invalid || undefined, disabled: disabled, ...rowHold(hold), ...holdProps({}, inRow || atRowStart ? rowAction : null), onPress: toggle, testID: testID, style: [
129
+ return (_jsxs(Pressable, { ...described.props, ...spaceToggles(toggle), accessibilityRole: "checkbox", accessibilityLabel: accessibilityLabel ?? (typeof label === "string" ? label : undefined), accessibilityState: { checked: state === "indeterminate" ? "mixed" : state, disabled }, "aria-checked": state === "indeterminate" ? "mixed" : state, "aria-invalid": invalid || undefined, disabled: disabled, ...rowHold(hold), ...holdProps({}, inRow || atRowStart ? rowAction : null), ...rowHint(rowAction, described), onPress: toggle, testID: testID, style: [
130
130
  styles.row,
131
131
  hasText ? styles.top : null,
132
132
  // Android's gap is in the target's margins
@@ -60,21 +60,27 @@ const DASH = 50;
60
60
  * of its own for this, so both draw the Plex ring; a new value moves the arc in 300ms (ease) on iOS, as the web's
61
61
  * transition, and in Android's determinate radial progress time (200ms, decelerating); at once with reduced motion.
62
62
  */
63
- export function CircularProgress({ maxDuration = 15000, done = false, progress: progressProp, size = 28, strokeWidth, trackActiveColor, trackColor, "aria-label": ariaLabel, accessibilityLabel, testID, style, }) {
63
+ export function CircularProgress({ maxDuration = 15000, done = false, progress: progressProp, size = 28, strokeWidth, ring = "inset", duration, trackActiveColor, trackColor, "aria-label": ariaLabel, accessibilityLabel, testID, style, }) {
64
64
  const theme = useTheme();
65
65
  const simulated = useSimulatedProgress(maxDuration, progressProp !== undefined || done);
66
66
  const progress = Math.max(0, Math.min(100, progressProp ?? simulated));
67
67
  const shown = useTweenedNumber(progress, {
68
- duration: theme.isAndroid ? 200 : 300,
68
+ duration: duration ?? (theme.isAndroid ? 200 : 300),
69
69
  easing: theme.isAndroid ? curves.decelerate : cssEase,
70
70
  reducedMotion: theme.reducedMotion,
71
71
  });
72
- const stroke = strokeWidth ? Math.min(4, strokeWidth) : 2;
72
+ const edge = ring === "edge";
73
+ const stroke = edge ? Math.min(size / 2, strokeWidth ?? 2) : strokeWidth ? Math.min(4, strokeWidth) : 2;
74
+ // The drawing: 20 units with a ring of 8 inset, or the box itself with the ring's outside on its edge
75
+ const box = edge ? size : 20;
76
+ const center = box / 2;
77
+ const radius = edge ? Math.max(0, (size - stroke) / 2) : 8;
78
+ const dash = edge ? 2 * Math.PI * radius : DASH;
73
79
  // The web's `light-dark(#deede9, var(--green-a50))`: a light green, the green at 15% at night
74
80
  const track = resolve(theme, trackColor, theme.scheme === "dark" ? theme.color("--green-a50") : "#DEEDE9");
75
81
  const active = resolve(theme, trackActiveColor, theme.color("--green-500"));
76
82
  const name = accessibilityLabel ?? ariaLabel;
77
- return (_jsx(View, { accessible: name != null, accessibilityRole: name != null ? "progressbar" : undefined, accessibilityLabel: name, accessibilityValue: name != null ? { min: 0, max: 100, now: Math.round(progress) } : undefined, importantForAccessibility: name != null ? undefined : "no-hide-descendants", accessibilityElementsHidden: name == null, testID: testID, style: [{ width: size, height: size }, style], children: _jsxs(Svg, { width: size, height: size, viewBox: "0 0 20 20", children: [_jsx(Circle, { cx: 10, cy: 10, r: 8, fill: "none", stroke: track, strokeWidth: stroke }), _jsx(Circle, { cx: 10, cy: 10, r: 8, fill: "none", stroke: active, strokeWidth: stroke, strokeLinecap: "round", strokeDasharray: [DASH, DASH], strokeDashoffset: DASH - DASH * (shown / 100),
83
+ return (_jsx(View, { accessible: name != null, accessibilityRole: name != null ? "progressbar" : undefined, accessibilityLabel: name, accessibilityValue: name != null ? { min: 0, max: 100, now: Math.round(progress) } : undefined, importantForAccessibility: name != null ? undefined : "no-hide-descendants", accessibilityElementsHidden: name == null, testID: testID, style: [{ width: size, height: size }, style], children: _jsxs(Svg, { width: size, height: size, viewBox: `0 0 ${box} ${box}`, children: [_jsx(Circle, { cx: center, cy: center, r: radius, fill: "none", stroke: track, strokeWidth: stroke }), _jsx(Circle, { cx: center, cy: center, r: radius, fill: "none", stroke: active, strokeWidth: stroke, strokeLinecap: "round", strokeDasharray: [dash, dash], strokeDashoffset: dash - dash * (shown / 100),
78
84
  // The dash starts at 12 o'clock, as the web's ring turned back a quarter
79
- transform: "rotate(-90 10 10)" })] }) }));
85
+ transform: `rotate(-90 ${center} ${center})` })] }) }));
80
86
  }
@@ -4,7 +4,7 @@ import { Animated, Easing, Platform, StyleSheet, View } from "react-native";
4
4
  import { Pressable } from "../../internal/Pressable";
5
5
  import Disclosure from "../../icons/plex/Disclosure";
6
6
  import ExclamationMarkCircle from "../../icons/plex/ExclamationMarkCircle";
7
- import { spaceToggles, useDescription } from "../../internal/a11y";
7
+ import { describedBy, spaceToggles, useDescription, useHint } from "../../internal/a11y";
8
8
  import { useRipple } from "../../internal/ripple";
9
9
  import { flattenChildren, textOf } from "../../internal/children";
10
10
  import { cssBox } from "../../internal/cssBox";
@@ -28,17 +28,40 @@ export function useInList() {
28
28
  const ANDROID_CARD_RADIUS = 16;
29
29
  /** The start and end of an Android row's text, 21dp in from the card's edge (`--list-row-inset`). */
30
30
  const ANDROID_INSET = 21;
31
+ /**
32
+ * Where a List's rows start their text inside the card and how round the card is, for a card built beside a List
33
+ * that must line up with it: iOS `--list-row-inset` (20) and `--field-group-radius` (26), Android 21 and 16.
34
+ */
35
+ export function useListMetrics() {
36
+ const theme = useTheme();
37
+ return theme.isAndroid
38
+ ? { rowInset: ANDROID_INSET, radius: ANDROID_CARD_RADIUS }
39
+ : { rowInset: theme.length("--list-row-inset", 20), radius: theme.length("--field-group-radius", 26) };
40
+ }
31
41
  const PlaceContext = createContext({ first: true, last: true, top: 0, bottom: 0 });
42
+ /**
43
+ * How far a line's baseline stands over the line's bottom: half the leading under the face's box, and its descent.
44
+ * The kit's faces (Inter, SF Pro, Roboto) draw about 1.21 of the size from ascent to descent, 0.24 of it a descent.
45
+ */
46
+ const baselineOverBottom = (fontSize, lineHeight) => (lineHeight - fontSize * 1.21) / 2 + fontSize * 0.24;
32
47
  /**
33
48
  * A header's action that is not a Button (a count such as "2/3") takes the header's type, so it stands on the title's
34
- * line: iOS 17/22 on its last line, Android the header's 15sp on its 40dp row. Its own style still wins.
49
+ * line: iOS 17/22 on its last line, Android the header's 15sp on its 40dp row. Its own style still wins; on iOS
50
+ * (`onBaseline`) a Text in a type of its own is lifted onto the title's baseline.
35
51
  */
36
- function headerAction(action, type, color) {
52
+ function headerAction(action, type, color, onBaseline = false) {
37
53
  if (typeof action === "string" || typeof action === "number") {
38
54
  return (_jsx(Text, { color: color, tabularNums: true, style: type, children: action }));
39
55
  }
40
56
  if (isValidElement(action) && action.type === Text) {
41
- return cloneElement(action, { style: [type, action.props.style] });
57
+ // A count in a type of its own (a 15/20 subheadline beside the 17/22 title) is lifted onto the title's baseline,
58
+ // the row still set at its bottoms so the count stays on the title's last line
59
+ const header = StyleSheet.flatten(type) ?? {};
60
+ const own = StyleSheet.flatten([type, action.props.style]) ?? {};
61
+ const lift = onBaseline && typeof header.fontSize === "number" && typeof header.lineHeight === "number" && typeof own.fontSize === "number" && typeof own.lineHeight === "number"
62
+ ? baselineOverBottom(header.fontSize, header.lineHeight) - baselineOverBottom(own.fontSize, own.lineHeight)
63
+ : 0;
64
+ return cloneElement(action, { style: [type, action.props.style, lift !== 0 ? { marginBottom: lift } : null] });
42
65
  }
43
66
  return action;
44
67
  }
@@ -95,7 +118,7 @@ export function List({ children, header, description, footer, error, surface = "
95
118
  }, children: [header != null || action != null ? (_jsxs(View, { style: action != null ? styles.iosHeaderRow : null, children: [header == null ? _jsx(View, { style: styles.grow }) : null, header == null ? null : _jsx(Text, { accessibilityRole: "header", weight: "semibold", color: increased ? theme.colors.text : theme.colors.labelSecondary, style: [
96
119
  increased ? { fontSize: 20, lineHeight: 25 } : { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) },
97
120
  action != null ? styles.grow : null,
98
- ], children: header }), action != null ? (_jsx(ListActionContext.Provider, { value: "header", children: headerAction(action, { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) }, theme.colors.labelSecondary) })) : null] })) : null, description != null ? (_jsx(Text, { color: theme.colors.labelSecondary, style: { fontSize: theme.length("--field-group-description-font-size", 15), lineHeight: theme.length("--field-group-description-line-height", 20) }, children: description })) : null] })) : null, _jsx(View, { accessibilityRole: "list", "aria-label": label, style: [styles.iosGroup, { borderRadius: theme.length("--field-group-radius", 26), backgroundColor: surface === "plain" ? theme.color("--field-group-background", theme.colors.surfaceSecondary) : theme.colors.groupedSurface }], children: _jsx(ListOptionsContext.Provider, { value: options, children: body }) }), error != null || footer != null ? (
121
+ ], children: header }), action != null ? (_jsx(ListActionContext.Provider, { value: "header", children: headerAction(action, { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) }, theme.colors.labelSecondary, true) })) : null] })) : null, description != null ? (_jsx(Text, { color: theme.colors.labelSecondary, style: { fontSize: theme.length("--field-group-description-font-size", 15), lineHeight: theme.length("--field-group-description-line-height", 20) }, children: description })) : null] })) : null, _jsx(View, { accessibilityRole: "list", "aria-label": label, style: [styles.iosGroup, { borderRadius: theme.length("--field-group-radius", 26), backgroundColor: surface === "plain" ? theme.color("--field-group-background", theme.colors.surfaceSecondary) : theme.colors.groupedSurface }], children: _jsx(ListOptionsContext.Provider, { value: options, children: body }) }), error != null || footer != null ? (
99
122
  // An error takes the footer's place and type (13/16, 8 under the section), only in the danger color
100
123
  _jsx(Text, { color: error != null ? errorColor(theme) : theme.colors.labelSecondary, accessibilityLiveRegion: error != null ? "polite" : undefined, style: {
101
124
  fontSize: theme.length("--field-group-footer-font-size", 13),
@@ -118,7 +141,7 @@ export function List({ children, header, description, footer, error, surface = "
118
141
  * in (a multi-select list); a 1px divider from the text's start to the card's end, none under a row with a tile (a
119
142
  * tiled row draws none).
120
143
  */
121
- export function ListItem({ label, description, leading, leadingColor, value, valuePlacement = "end", valueColor, trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, longPressLabel, disabled = false, destructive = false, accessibilityLabel, testID, }) {
144
+ export function ListItem({ label, description, leading, leadingColor, value, valuePlacement = "end", valueColor, trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, longPressLabel, disabled = false, destructive = false, accessibilityLabel, accessibilityHint, testID, }) {
122
145
  const theme = useTheme();
123
146
  const { last, top, bottom } = useContext(PlaceContext);
124
147
  // A menu opened from the row finds the row (Android lights it over the dim of the screen)
@@ -163,7 +186,14 @@ export function ListItem({ label, description, leading, leadingColor, value, val
163
186
  }, []);
164
187
  const handed = !switchRow && !onPress && !control && !disabled ? endPress : null;
165
188
  const press = switchRow ? toggle : (onPress ?? control?.toggle ?? handed ?? undefined);
189
+ const hinted = useHint(accessibilityHint);
190
+ // On the web the hint is an unseen text the row's element, or the control that takes its focus, is described by
191
+ const hintNode = hinted.id != null ? _jsx(Text, { nativeID: hinted.id, style: styles.unseen, children: accessibilityHint }) : null;
166
192
  const endOwnsFocus = control != null || handed != null || (endHands && press == null);
193
+ // The hint goes to the control at the end only when it takes the row's focus: a switch of its own beside a row that
194
+ // opens a page keeps to its own words
195
+ const controlHint = endOwnsFocus ? accessibilityHint : undefined;
196
+ const rowAction = useMemo(() => (onLongPress == null && controlHint == null ? null : { run: disabled ? undefined : onLongPress, label: longPressLabel, hint: controlHint, hintId: hinted.id }), [controlHint, disabled, hinted.id, longPressLabel, onLongPress]);
167
197
  // A destructive row is an action, not a page (Settings' Sign Out has no chevron)
168
198
  const chevron = disclosure ?? (!!onPress && !switchRow && trailing == null && !destructive);
169
199
  const name = accessibilityLabel ?? ([textOf(label), textOf(value)].filter(Boolean).join(", ") || undefined);
@@ -199,14 +229,18 @@ export function ListItem({ label, description, leading, leadingColor, value, val
199
229
  // Android's rows press in the list selector: the native ripple on a device, the drawn one on the web
200
230
  const highlight = controlHighlight(theme.scheme);
201
231
  const drawn = theme.isAndroid && !nativeRipple;
202
- return (_jsx(Pressable, { ref: frameNode, collapsable: false, ...described.props, ...(switchRow ? spaceToggles(toggle) : null),
232
+ return (_jsx(Pressable, { ref: frameNode, collapsable: false, ...described.props, ...(endOwnsFocus || accessibilityHint == null
233
+ ? null
234
+ : Platform.OS === "web"
235
+ ? { "aria-describedby": describedBy(described.id, hinted.id) }
236
+ : hinted.props), ...(switchRow ? spaceToggles(toggle) : null),
203
237
  // A row that toggles its control is not a second element for a screen reader or a Tab stop: the control is
204
- accessible: endOwnsFocus ? false : undefined, focusable: endOwnsFocus ? false : undefined, tabIndex: endOwnsFocus ? -1 : undefined, accessibilityRole: endOwnsFocus ? undefined : switchRow ? "switch" : "button", accessibilityLabel: endOwnsFocus ? undefined : name, accessibilityState: endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled }, "aria-checked": switchRow ? checked : undefined, disabled: disabled || (press == null && onLongPress == null), onPress: press, ...holdProps({ run: onLongPress, label: longPressLabel }, null), onPressIn: drawn ? ripple.start : undefined, onPressOut: drawn ? ripple.end : undefined, android_ripple: nativeRipple ? { color: highlight, foreground: true } : undefined, testID: testID, style: row, children: ({ pressed }) => (_jsx(RowHoldContext.Provider, { value: disabled ? null : theme.isAndroid ? hold : setHeld, children: _jsxs(RowActionContext.Provider, { value: disabled || onLongPress == null ? null : { run: onLongPress, label: longPressLabel }, children: [ripple.layer, theme.isAndroid ? null : _jsx(RowHighlight, { on: (pressed || held) && lit, last: last }), content(pressed || held)] }) })) }));
238
+ accessible: endOwnsFocus ? false : undefined, focusable: endOwnsFocus ? false : undefined, tabIndex: endOwnsFocus ? -1 : undefined, accessibilityRole: endOwnsFocus ? undefined : switchRow ? "switch" : "button", accessibilityLabel: endOwnsFocus ? undefined : name, accessibilityState: endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled }, "aria-checked": switchRow ? checked : undefined, disabled: disabled || (press == null && onLongPress == null), onPress: press, ...holdProps({ run: onLongPress, label: longPressLabel }, null), onPressIn: drawn ? ripple.start : undefined, onPressOut: drawn ? ripple.end : undefined, android_ripple: nativeRipple ? { color: highlight, foreground: true } : undefined, testID: testID, style: row, children: ({ pressed }) => (_jsx(RowHoldContext.Provider, { value: disabled ? null : theme.isAndroid ? hold : setHeld, children: _jsxs(RowActionContext.Provider, { value: rowAction, children: [hintNode, ripple.layer, theme.isAndroid ? null : _jsx(RowHighlight, { on: (pressed || held) && lit, last: last }), content(pressed || held)] }) })) }));
205
239
  }
206
240
  // A row that only shows (a detail, a value) is one element named by `accessibilityLabel` when it has one; with a
207
241
  // control at its end it stays a group, so the control is still reached
208
242
  const named = accessibilityLabel != null && trailing == null && found == null;
209
- return (_jsx(View, { ref: frameNode, collapsable: false, testID: testID, accessible: named || undefined, accessibilityLabel: accessibilityLabel, accessibilityRole: named && Platform.OS !== "web" ? "text" : undefined, role: named && Platform.OS === "web" ? "group" : undefined, style: row, children: content(false) }));
243
+ return (_jsxs(View, { ref: frameNode, collapsable: false, testID: testID, accessible: named || undefined, accessibilityLabel: accessibilityLabel, ...(named ? hinted.props : null), accessibilityRole: named && Platform.OS !== "web" ? "text" : undefined, role: named && Platform.OS === "web" ? "group" : undefined, style: row, children: [named ? hintNode : null, content(false)] }));
210
244
  }
211
245
  /** A Button among a List's rows: the row is the button (`ListActionContext`), the hairline under it from the text's start. */
212
246
  function ActionRow({ children }) {
@@ -509,6 +543,7 @@ const styles = StyleSheet.create({
509
543
  androidEndEdge: { marginStart: "auto" },
510
544
  endAtEdge: { justifyContent: "flex-end" },
511
545
  iosHeaderRow: { flexDirection: "row", alignItems: "flex-end", gap: 16 },
546
+ unseen: { display: "none" },
512
547
  androidHeaderRow: { flexDirection: "row", alignItems: "flex-start", minHeight: 40, paddingHorizontal: ANDROID_INSET, paddingTop: 14, paddingBottom: 6, gap: 16 },
513
548
  androidHeaderTitle: { flex: 1, minWidth: 0, fontSize: 15, lineHeight: 20 },
514
549
  androidHeaderTitleType: { fontSize: 15, lineHeight: 20 },
@@ -263,9 +263,11 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
263
263
  moveTo(step, 1, true);
264
264
  };
265
265
  const collapse = () => moveTo(step, 0, false, () => setSub(null));
266
- const surface = { close: onClose, check, multiple, openSub, subOpen: sub != null };
266
+ // A multiple choice keeps the submenu open: its items follow the app's state while it shows
267
+ const refreshSub = (owner, items) => setSub((current) => (current == null || current.owner !== owner || current.items === items ? current : { ...current, items }));
268
+ const surface = { close: onClose, check, multiple, openSub, refreshSub, subOpen: sub != null };
267
269
  const content = _jsx(SurfaceContext.Provider, { value: surface, children: children });
268
- const subItems = sub != null ? _jsx(SurfaceContext.Provider, { value: { close: onClose, check: hasCheckedItems(sub.items) }, children: sub.items }) : null;
270
+ const subItems = sub != null ? _jsx(SurfaceContext.Provider, { value: { close: onClose, check: hasCheckedItems(sub.items), multiple }, children: sub.items }) : null;
269
271
  const scale = !theme.reducedMotion && canTransformGlass;
270
272
  // The web's keyboard, as the WAI-ARIA menu pattern: focus starts at the chosen item (else the first), the arrows
271
273
  // move to the next one and stop at the ends, Home and End go to the first and the last
@@ -622,9 +624,10 @@ function AndroidMenuSurface({ open, anchor, row, header = false, onClose, align
622
624
  },
623
625
  });
624
626
  });
625
- const surface = { close: onClose, check, multiple, openSub, subOpen: sub != null, header };
627
+ const refreshSub = (owner, items) => setSub((current) => (current == null || current.owner !== owner || current.items === items ? current : { ...current, items }));
628
+ const surface = { close: onClose, check, multiple, openSub, refreshSub, subOpen: sub != null, header };
626
629
  // The submenu's page: Back, the 8dp band, the items
627
- const subItems = sub != null ? (_jsxs(SurfaceContext.Provider, { value: { close: onClose, check: hasCheckedItems(sub.items), header }, children: [_jsx(MenuRow, { icon: _jsx(ArrowLeftLg, {}), stay: collapse, children: sub.backLabel }), _jsx(MenuSeparator, {}), sub.items] })) : null;
630
+ const subItems = sub != null ? (_jsxs(SurfaceContext.Provider, { value: { close: onClose, check: hasCheckedItems(sub.items), multiple, header }, children: [_jsx(MenuRow, { icon: _jsx(ArrowLeftLg, {}), stay: collapse, children: sub.backLabel }), _jsx(MenuSeparator, {}), sub.items] })) : null;
628
631
  // The web's keyboard, as the WAI-ARIA menu pattern, over the page in front
629
632
  const panel = useRef(null);
630
633
  const mainPage = useRef(null);
@@ -890,8 +893,15 @@ function MenuSubTrigger({ children, icon, disabled, testID }) {
890
893
  const open = () => {
891
894
  if (!sub)
892
895
  return;
893
- measure(row.current, (box) => surface.openSub?.({ label: children, items: sub.children, backLabel: sub.backLabel ?? "Back", y: box.y }));
896
+ measure(row.current, (box) => surface.openSub?.({ label: children, items: sub.children, backLabel: sub.backLabel ?? "Back", y: box.y, owner: row }));
894
897
  };
898
+ // The submenu this row opened follows the app's state while it shows (a multiple choice keeps it open)
899
+ const items = sub?.children;
900
+ const { subOpen, refreshSub } = surface;
901
+ useEffect(() => {
902
+ if (subOpen)
903
+ refreshSub?.(row, items);
904
+ }, [items, subOpen, refreshSub]);
895
905
  return (_jsx(MenuRow, { icon: icon, disabled: disabled, testID: testID, rowRef: row, stay: open, opens: true, expanded: surface.subOpen, children: children }));
896
906
  }
897
907
  MenuSubTrigger.displayName = "Menu.SubTrigger";
@@ -124,8 +124,10 @@ export function PageControl({ count, value: valueProp, defaultValue = 0, positio
124
124
  const gap = small ? 4 : android ? ANDROID_GAP : theme.length("--page-control-gap", 8);
125
125
  const padding = small ? 6 : theme.length("--page-control-padding-inline", 12);
126
126
  const pitch = dot + gap;
127
- // Android draws every page's dot at full size; the iOS kit shrinks the ends from seven pages
128
- const sizes = android ? Array.from({ length: Math.max(0, count) }, () => "full") : pageControlDots(count, clampIndex(typeof positionProp === "number" ? Math.round(positionProp) : near, count));
127
+ // Android draws every page's dot at full size up to ANDROID_MAX_DOTS; past that, and on iOS from seven pages, the
128
+ // dots are a window that holds the current page, so a long run of pages never runs off the screen
129
+ const windowed = !android || count > ANDROID_MAX_DOTS;
130
+ const sizes = windowed ? pageControlDots(count, clampIndex(typeof positionProp === "number" ? Math.round(positionProp) : near, count)) : Array.from({ length: Math.max(0, count) }, () => "full");
129
131
  // The small and smaller ends keep their share of a full dot (6 and 4 of 8 on iOS)
130
132
  const dotSize = (kind) => kind === "full"
131
133
  ? dot
@@ -152,7 +154,7 @@ export function PageControl({ count, value: valueProp, defaultValue = 0, positio
152
154
  const off = onColor ? "rgba(255, 255, 255, 0.4)" : android ? (theme.scheme === "dark" ? "#555555" : "#BBBBBB") : theme.color("--page-control-dot-color", theme.colors.labelTertiary);
153
155
  // Android's current dot is drawn over the gray ones (it stretches between pages) unless the pages' scroll drives the
154
156
  // dots, when their color crosses over as on iOS; a pill is a dot of its own
155
- const worm = android && !pill && positionProp == null;
157
+ const worm = android && !pill && positionProp == null && !windowed;
156
158
  // Android draws no capsule, not even for `prominent`
157
159
  const capsuleHeight = small ? 16 : theme.length("--page-control-height", 24);
158
160
  const target = android ? 48 : theme.length("--page-control-target-size", 44);
@@ -234,6 +236,8 @@ const ANDROID_SLIDE = { duration: 300, easing: Easing.bezier(0.2, 0, 0, 1) };
234
236
  /** Android's page dots: 5dp, 11dp from one to the next. */
235
237
  const ANDROID_DOT = 5;
236
238
  const ANDROID_GAP = 6;
239
+ /** The most pages whose dots Android draws all; more take the window of dots the iOS kit keeps. */
240
+ const ANDROID_MAX_DOTS = 9;
237
241
  /**
238
242
  * A page change the pager settles on its own (a tap, a change from code): one page in 200ms, on an ease-out quint
239
243
  * standing in for the pager's 1 + (t − 1)⁵.
@@ -6,7 +6,7 @@ import CheckMd from "../../icons/plex/CheckMd";
6
6
  import { useDescription } from "../../internal/a11y";
7
7
  import { ControlLabel } from "../../internal/ControlLabel";
8
8
  import { isRTL, nextKey } from "../../internal/direction";
9
- import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHold } from "../../internal/row";
9
+ import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHint, rowHold } from "../../internal/row";
10
10
  import { mix } from "../../theme/material";
11
11
  import { useTheme } from "../../theme/ThemeProvider";
12
12
  import { ANDROID_ROW_END, androidEaseInOut, iosCheckmarkColor, selectionColor } from "../Switch/Switch";
@@ -90,7 +90,7 @@ function RadioGroupItem({ value, children, description, disabled: itemDisabled =
90
90
  const size = theme.length("--radio-group-indicator-size", 22);
91
91
  mark = (_jsx(View, { style: { width: size, height: size, alignItems: "center", justifyContent: "center" }, children: selected ? _jsx(CheckMd, { size: 26, color: disabled ? theme.colors.textDisabled : iosCheckmarkColor(theme) }) : null }));
92
92
  }
93
- return (_jsxs(Pressable, { ...described.props, ...radioKeys(context, value, disabled, selected), accessibilityRole: "radio", accessibilityLabel: ariaLabel ?? (typeof children === "string" ? children : undefined), accessibilityState: { checked: selected, disabled }, "aria-checked": selected, disabled: disabled, ...rowHold(hold), ...holdProps({ run: disabled ? undefined : onLongPress, label: longPressLabel }, inRow || atStart ? rowAction : null), onPress: () => !selected && context.select(value), testID: testID, style: [
93
+ return (_jsxs(Pressable, { ...described.props, ...radioKeys(context, value, disabled, selected), accessibilityRole: "radio", accessibilityLabel: ariaLabel ?? (typeof children === "string" ? children : undefined), accessibilityState: { checked: selected, disabled }, "aria-checked": selected, disabled: disabled, ...rowHold(hold), ...holdProps({ run: disabled ? undefined : onLongPress, label: longPressLabel }, inRow || atStart ? rowAction : null), ...rowHint(rowAction, described), onPress: () => !selected && context.select(value), testID: testID, style: [
94
94
  styles.item,
95
95
  // Android's gap is in the target's margins
96
96
  { gap: theme.isAndroid ? 0 : theme.length("--radio-group-item-gap", 6) + 5, minHeight: theme.isAndroid ? 48 : theme.length("--radio-group-target-size", 44) },
@@ -50,7 +50,7 @@ export const rollingNumberParts = (value, locales = "en-US", format) => {
50
50
  * 0.3 of the font size while the new one comes in, in 320ms (ease-out quint), up for a larger number. With reduced
51
51
  * motion it changes at once. A screen reader reads the written number.
52
52
  */
53
- export function RollingNumber({ value, locales, format, containerStyle, style, size, variant, weight, mono, testID, accessibilityLabel, ...text }) {
53
+ export function RollingNumber({ value, locales, format, containerStyle, duration, style, size, variant, weight, mono, testID, accessibilityLabel, ...text }) {
54
54
  const theme = useTheme();
55
55
  const { text: written, glyphs, characters } = rollingNumberParts(value, locales, format);
56
56
  const flat = StyleSheet.flatten(style);
@@ -62,14 +62,14 @@ export function RollingNumber({ value, locales, format, containerStyle, style, s
62
62
  if (last.value !== value)
63
63
  setLast({ value, up: value > last.value });
64
64
  const glyphProps = { ...text, size, variant, weight, mono, tabularNums: true, style };
65
- return (_jsx(View, { accessible: true, accessibilityRole: "text", accessibilityLabel: accessibilityLabel ?? written, testID: testID, ...(Platform.OS === "web" ? { dir: "ltr" } : null), style: [styles.row, styles.ltr, containerStyle], children: characters.map(({ character, digit, key }) => theme.isAndroid ? (_jsx(Changing, { character: character, up: last.up, lift: 0.3 * fontSize, reduced: theme.reducedMotion, text: glyphProps }, key)) : digit === null ? (_jsx(Text, { ...glyphProps, children: character }, key)) : (_jsx(Reel, { digit: digit, character: character, glyphs: glyphs, lineHeight: lineHeight, text: glyphProps }, key))) }));
65
+ return (_jsx(View, { accessible: true, accessibilityRole: "text", accessibilityLabel: accessibilityLabel ?? written, testID: testID, ...(Platform.OS === "web" ? { dir: "ltr" } : null), style: [styles.row, styles.ltr, containerStyle], children: characters.map(({ character, digit, key }) => theme.isAndroid ? (_jsx(Changing, { character: character, up: last.up, lift: 0.3 * fontSize, reduced: theme.reducedMotion, duration: duration ?? 320, text: glyphProps }, key)) : digit === null ? (_jsx(Text, { ...glyphProps, children: character }, key)) : (_jsx(Reel, { digit: digit, character: character, glyphs: glyphs, lineHeight: lineHeight, duration: duration, text: glyphProps }, key))) }));
66
66
  }
67
67
  /** iOS's reel: the digit itself, hidden, keeps the width and height; a column of 0 to 9 turns over it. */
68
- function Reel({ digit, character, glyphs, lineHeight, text }) {
68
+ function Reel({ digit, character, glyphs, lineHeight, duration, text }) {
69
69
  const theme = useTheme();
70
70
  const [line, setLine] = useState(lineHeight);
71
71
  const position = useTransitionValue(digit, {
72
- duration: theme.duration("--rolling-number-duration", 600),
72
+ duration: duration ?? theme.duration("--rolling-number-duration", 600),
73
73
  easing: cssEasing(theme.token("--rolling-number-ease"), curves.easeInOut),
74
74
  native: true,
75
75
  reducedMotion: theme.reducedMotion,
@@ -82,7 +82,7 @@ function Reel({ digit, character, glyphs, lineHeight, text }) {
82
82
  return (_jsxs(View, { style: styles.digit, children: [_jsx(Text, { ...text, onLayout: onLayout, style: [text.style, styles.ghost], children: character }), _jsx(Animated.View, { style: [styles.reel, { transform: [{ translateY: position.interpolate({ inputRange: [0, 9], outputRange: [0, -9 * line] }) }] }], children: glyphs.map((glyph) => (_jsx(Text, { ...text, style: [text.style, { height: line }], children: glyph }, glyph))) })] }));
83
83
  }
84
84
  /** Android's animated text: a new character comes in as the old one leaves, both fading and moving by `lift`. */
85
- function Changing({ character, up, lift, reduced, text }) {
85
+ function Changing({ character, up, lift, reduced, duration, text }) {
86
86
  const [pair, setPair] = useState({ old: null, now: character, up });
87
87
  if (pair.now !== character)
88
88
  setPair({ old: pair.now, now: character, up });
@@ -95,13 +95,13 @@ function Changing({ character, up, lift, reduced, text }) {
95
95
  useEffect(() => {
96
96
  if (pair.old == null || reduced)
97
97
  return;
98
- const animation = Animated.timing(progress, { toValue: 1, duration: 320, easing: curves.easeOutQuint, useNativeDriver: nativeDriver, isInteraction: false });
98
+ const animation = Animated.timing(progress, { toValue: 1, duration, easing: curves.easeOutQuint, useNativeDriver: nativeDriver, isInteraction: false });
99
99
  animation.start(({ finished }) => {
100
100
  if (finished)
101
101
  setPair((current) => (current === pair ? { ...current, old: null } : current));
102
102
  });
103
103
  return () => animation.stop();
104
- }, [pair, progress, reduced]);
104
+ }, [duration, pair, progress, reduced]);
105
105
  const direction = pair.up ? 1 : -1;
106
106
  return (_jsxs(View, { children: [_jsx(Animated.View, { style: pair.old == null
107
107
  ? null
@@ -6,7 +6,7 @@ import Svg, { Path } from "react-native-svg";
6
6
  import ChevronUpDown from "../../icons/plex/ChevronUpDown";
7
7
  import { spaceToggles } from "../../internal/a11y";
8
8
  import { useRipple } from "../../internal/ripple";
9
- import { RowEndContext, RowFrameContext, RowHoldContext, rowHold } from "../../internal/row";
9
+ import { RowActionContext, RowEndContext, RowFrameContext, RowHoldContext, rowHint, rowHold } from "../../internal/row";
10
10
  import { androidSelector, withAlpha } from "../../theme/material";
11
11
  import { MaterialArrowDropDown } from "../Icon/material";
12
12
  import { useTheme } from "../../theme/ThemeProvider";
@@ -75,6 +75,8 @@ export function Select(props) {
75
75
  const look = fieldLook(theme, { variant, size, pill }, { focused: open, filled: shownLabel != null, disabled, invalid });
76
76
  const row = useContext(RowEndContext);
77
77
  const hold = useContext(RowHoldContext);
78
+ // At a row's end the select takes the row's focus, and with it the row's hint
79
+ const rowAction = useContext(RowActionContext);
78
80
  const rowEnd = row != null;
79
81
  const inRow = rowEnd && !android;
80
82
  // At the end of an Android row the select is the row's value, as in an Android value row. On both platforms a press
@@ -102,7 +104,7 @@ export function Select(props) {
102
104
  const m = theme.material;
103
105
  return (
104
106
  // A field that moves while its menu is open takes the menu with it
105
- _jsxs(View, { ref: setTrigger, collapsable: false, onLayout: shown && !dialog ? () => place() : undefined, style: [block ? styles.block : styles.hug, style], children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: ariaLabel ? `${ariaLabel}, ${shownLabel ?? placeholder}` : undefined, accessibilityState: { disabled, expanded: open }, "aria-haspopup": dialog ? "dialog" : "menu", "aria-expanded": open, disabled: disabled, ...rowHold(hold), onPress: () => (dialog ? setOpen(true) : place(() => setOpen(true))),
107
+ _jsxs(View, { ref: setTrigger, collapsable: false, onLayout: shown && !dialog ? () => place() : undefined, style: [block ? styles.block : styles.hug, style], children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: ariaLabel ? `${ariaLabel}, ${shownLabel ?? placeholder}` : undefined, ...(row != null ? rowHint(rowAction, { props: {} }) : null), accessibilityState: { disabled, expanded: open }, "aria-haspopup": dialog ? "dialog" : "menu", "aria-expanded": open, disabled: disabled, ...rowHold(hold), onPress: () => (dialog ? setOpen(true) : place(() => setOpen(true))),
106
108
  // A row's value takes the presses of the row's height (where the row does not hand it its own)
107
109
  hitSlop: androidRow && !row?.press ? ROW_SLOP : undefined, testID: testID,
108
110
  // The arrow sits in Compose's trailing icon slot, 12 from the edge
@@ -4,7 +4,7 @@ import { Animated, Easing, StyleSheet, View } from "react-native";
4
4
  import { Pressable } from "../../internal/Pressable";
5
5
  import { spaceToggles, useDescription } from "../../internal/a11y";
6
6
  import { ControlLabel } from "../../internal/ControlLabel";
7
- import { RowActionContext, RowEndContext, RowHoldContext, holdProps, rowHold } from "../../internal/row";
7
+ import { RowActionContext, RowEndContext, RowHoldContext, holdProps, rowHint, rowHold } from "../../internal/row";
8
8
  import { androidGray } from "../../theme/material";
9
9
  import { useTheme } from "../../theme/ThemeProvider";
10
10
  /**
@@ -74,7 +74,7 @@ export function Switch({ checked: checkedProp, defaultChecked = false, onChecked
74
74
  // Disabled, the switch and its text fade to half (as a switch row's), each on its own
75
75
  const control = (pressed) => theme.isAndroid ? (_jsx(View, { style: [disabled ? styles.dim : null, rowEnd && !hasText ? styles.androidRowEnd : null], children: _jsx(AndroidTrack, { theme: theme, checked: checked, disabled: disabled, color: color, progress: progress }) })) : (_jsx(IOSTrack, { theme: theme, checked: checked, disabled: disabled, color: color, progress: progress, held: pressed && !disabled }));
76
76
  const text = _jsx(ControlLabel, { control: "switch", label: label, description: description, disabled: disabled, descriptionId: described.id });
77
- return (_jsx(Pressable, { ...described.props, ...spaceToggles(toggle), accessibilityRole: "switch", accessibilityLabel: accessibilityLabel ?? (typeof label === "string" ? label : undefined), accessibilityState: { checked, disabled }, "aria-checked": checked, disabled: disabled, ...rowHold(hold), ...holdProps({}, rowEnd ? rowAction : null), onPress: toggle, testID: testID,
77
+ return (_jsx(Pressable, { ...described.props, ...spaceToggles(toggle), accessibilityRole: "switch", accessibilityLabel: accessibilityLabel ?? (typeof label === "string" ? label : undefined), accessibilityState: { checked, disabled }, "aria-checked": checked, disabled: disabled, ...rowHold(hold), ...holdProps({}, rowEnd ? rowAction : null), ...rowHint(rowAction, described), onPress: toggle, testID: testID,
78
78
  // Android's switch row: 50dp, the text ending 11dp before the switch's 37dp view
79
79
  style: [styles.row, { gap: theme.isAndroid ? 11 : theme.length("--switch-label-gap", 8), minHeight: theme.isAndroid ? 50 : 44 }, style], children: ({ pressed }) => (_jsxs(_Fragment, { children: [labelPosition === "start" && hasText ? _jsx(View, { style: styles.grow, children: text }) : null, control(pressed), labelPosition === "end" && hasText ? _jsx(View, { style: styles.grow, children: text }) : null] })) }));
80
80
  }
@@ -4,6 +4,8 @@ import { Linking, Platform, Text as RNText } from "react-native";
4
4
  import { controlHighlight } from "../../theme/material";
5
5
  import { useTheme } from "../../theme/ThemeProvider";
6
6
  const EXTERNAL = /^https?:\/\//;
7
+ /** The underline's distance under the letters on the web: the token, else a tenth of the type. */
8
+ const underlineOffset = (value) => (typeof value === "number" ? value : typeof value === "string" && value !== "" ? value : "0.1em");
7
9
  /**
8
10
  * A link in running text, as @plexui/ui's TextLink: put it inside a `Text`, whose face, size and color it takes
9
11
  * (the web's `currentcolor`), underlined; `primary` colors it with `--link-primary-text-color` and drops the underline.
@@ -30,6 +32,9 @@ export function TextLink({ children, href, primary = false, underline = !primary
30
32
  return (_jsx(RNText, { ...anchor, accessibilityRole: href ? "link" : onPress ? "button" : undefined, accessibilityLabel: accessibilityLabel, testID: testID, onPress: actionable ? press : undefined, onPressIn: actionable ? () => setPressed(true) : undefined, onPressOut: actionable ? () => setPressed(false) : undefined, style: [
31
33
  primary ? { color: theme.color("--link-primary-text-color", theme.colors.textAccent) } : null,
32
34
  underline ? { textDecorationLine: "underline" } : null,
35
+ // The web sets the line a tenth of the type under the letters (`--link-underline-decoration-offset`), clear of
36
+ // the descenders; a phone draws it where the platform does
37
+ underline && Platform.OS === "web" ? { textUnderlineOffset: underlineOffset(theme.token("--link-underline-decoration-offset")) } : null,
33
38
  weight ? theme.font(weight) : null,
34
39
  highlight,
35
40
  style,