@plexui/react-native 0.2.25 → 0.2.27

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 (71) 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/Chip/Chip.js +19 -11
  8. package/dist/es/components/Dialog/Dialog.js +18 -6
  9. package/dist/es/components/EmptyMessage/EmptyMessage.js +2 -2
  10. package/dist/es/components/Indicator/CircularProgress.js +11 -5
  11. package/dist/es/components/Input/Input.js +17 -2
  12. package/dist/es/components/List/List.js +77 -9
  13. package/dist/es/components/Menu/Menu.js +15 -5
  14. package/dist/es/components/PageControl/PageControl.js +7 -3
  15. package/dist/es/components/RadioGroup/RadioGroup.js +2 -2
  16. package/dist/es/components/RollingNumber/RollingNumber.js +7 -7
  17. package/dist/es/components/ScrollEdge/ScrollEdge.js +12 -6
  18. package/dist/es/components/Select/Select.js +4 -2
  19. package/dist/es/components/Switch/Switch.js +2 -2
  20. package/dist/es/components/TabBar/TabBar.js +15 -0
  21. package/dist/es/components/TextLink/TextLink.js +23 -3
  22. package/dist/es/index.js +2 -2
  23. package/dist/es/internal/a11y.js +12 -0
  24. package/dist/es/internal/row.js +13 -0
  25. package/dist/es/theme/ThemeProvider.js +4 -2
  26. package/dist/es/theme/material.js +2 -0
  27. package/dist/types/components/BottomActions/BottomActions.d.ts +6 -1
  28. package/dist/types/components/Button/Button.d.ts +5 -0
  29. package/dist/types/components/Card/Card.d.ts +5 -1
  30. package/dist/types/components/Chip/Chip.d.ts +9 -3
  31. package/dist/types/components/Dialog/Dialog.d.ts +7 -1
  32. package/dist/types/components/EmptyMessage/EmptyMessage.d.ts +4 -2
  33. package/dist/types/components/Indicator/CircularProgress.d.ts +10 -2
  34. package/dist/types/components/Input/Input.d.ts +8 -1
  35. package/dist/types/components/List/List.d.ts +36 -1
  36. package/dist/types/components/Menu/Menu.d.ts +10 -4
  37. package/dist/types/components/RollingNumber/RollingNumber.d.ts +3 -1
  38. package/dist/types/components/ScrollEdge/ScrollEdge.d.ts +7 -1
  39. package/dist/types/components/TabBar/TabBar.d.ts +13 -0
  40. package/dist/types/components/TextLink/TextLink.d.ts +7 -1
  41. package/dist/types/index.d.ts +2 -2
  42. package/dist/types/internal/a11y.d.ts +22 -0
  43. package/dist/types/internal/row.d.ts +21 -2
  44. package/dist/types/theme/ThemeProvider.d.ts +3 -2
  45. package/dist/types/theme/material.d.ts +2 -0
  46. package/package.json +1 -1
  47. package/src/components/BottomActions/BottomActions.tsx +7 -2
  48. package/src/components/BottomSheet/BottomSheet.tsx +9 -4
  49. package/src/components/Button/Button.tsx +19 -4
  50. package/src/components/Card/Card.tsx +8 -3
  51. package/src/components/Checkbox/Checkbox.tsx +2 -1
  52. package/src/components/Chip/Chip.tsx +28 -9
  53. package/src/components/Dialog/Dialog.tsx +30 -6
  54. package/src/components/EmptyMessage/EmptyMessage.tsx +12 -3
  55. package/src/components/Indicator/CircularProgress.tsx +27 -11
  56. package/src/components/Input/Input.tsx +43 -3
  57. package/src/components/List/List.tsx +125 -7
  58. package/src/components/Menu/Menu.tsx +27 -11
  59. package/src/components/PageControl/PageControl.tsx +7 -3
  60. package/src/components/RadioGroup/RadioGroup.tsx +2 -1
  61. package/src/components/RollingNumber/RollingNumber.tsx +10 -8
  62. package/src/components/ScrollEdge/ScrollEdge.tsx +19 -6
  63. package/src/components/Select/Select.tsx +4 -1
  64. package/src/components/Switch/Switch.tsx +2 -1
  65. package/src/components/TabBar/TabBar.tsx +15 -0
  66. package/src/components/TextLink/TextLink.tsx +52 -3
  67. package/src/index.ts +2 -2
  68. package/src/internal/a11y.ts +13 -0
  69. package/src/internal/row.ts +14 -2
  70. package/src/theme/ThemeProvider.tsx +7 -4
  71. package/src/theme/material.ts +2 -0
@@ -1,9 +1,11 @@
1
1
  import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState, type ComponentRef, type ReactElement, type ReactNode } from "react"
2
2
  import { Animated, Easing, Platform, StyleSheet, View, type GestureResponderEvent, type LayoutChangeEvent, type StyleProp, type TextStyle, type ViewStyle } from "react-native"
3
+ import { useSafeAreaInsets } from "react-native-safe-area-context"
3
4
  import { Pressable } from "../../internal/Pressable"
5
+ import CheckMd from "../../icons/plex/CheckMd"
4
6
  import Disclosure from "../../icons/plex/Disclosure"
5
7
  import ExclamationMarkCircle from "../../icons/plex/ExclamationMarkCircle"
6
- import { spaceToggles, useDescription } from "../../internal/a11y"
8
+ import { describedBy, spaceToggles, useDescription, useHint } from "../../internal/a11y"
7
9
  import { useRipple } from "../../internal/ripple"
8
10
  import { flattenChildren, textOf } from "../../internal/children"
9
11
  import { cssBox } from "../../internal/cssBox"
@@ -75,15 +77,33 @@ const ANDROID_CARD_RADIUS = 16
75
77
  /** The start and end of an Android row's text, 21dp in from the card's edge (`--list-row-inset`). */
76
78
  const ANDROID_INSET = 21
77
79
 
80
+ /**
81
+ * Where a List's rows start their text inside the card and how round the card is, for a card built beside a List
82
+ * that must line up with it: iOS `--list-row-inset` (20) and `--field-group-radius` (26), Android 21 and 16.
83
+ */
84
+ export function useListMetrics(): { rowInset: number; radius: number } {
85
+ const theme = useTheme()
86
+ return theme.isAndroid
87
+ ? { rowInset: ANDROID_INSET, radius: ANDROID_CARD_RADIUS }
88
+ : { rowInset: theme.length("--list-row-inset", 20), radius: theme.length("--field-group-radius", 26) }
89
+ }
90
+
78
91
  /** A row's place in its section, and the radius of the corners it shares with the section's card (none in a plain list). */
79
92
  type RowPlace = { first: boolean; last: boolean; top: number; bottom: number }
80
93
  const PlaceContext = createContext<RowPlace>({ first: true, last: true, top: 0, bottom: 0 })
81
94
 
95
+ /**
96
+ * How far a line's baseline stands over the line's bottom: half the leading under the face's box, and its descent.
97
+ * 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.
98
+ */
99
+ const baselineOverBottom = (fontSize: number, lineHeight: number) => (lineHeight - fontSize * 1.21) / 2 + fontSize * 0.24
100
+
82
101
  /**
83
102
  * 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
84
- * line: iOS 17/22 on its last line, Android the header's 15sp on its 40dp row. Its own style still wins.
103
+ * line: iOS 17/22 on its last line, Android the header's 15sp on its 40dp row. Its own style still wins; on iOS
104
+ * (`onBaseline`) a Text in a type of its own is lifted onto the title's baseline.
85
105
  */
86
- function headerAction(action: ReactNode, type: StyleProp<TextStyle>, color: string): ReactNode {
106
+ function headerAction(action: ReactNode, type: StyleProp<TextStyle>, color: string, onBaseline = false): ReactNode {
87
107
  if (typeof action === "string" || typeof action === "number") {
88
108
  return (
89
109
  <Text color={color} tabularNums style={type}>
@@ -92,7 +112,15 @@ function headerAction(action: ReactNode, type: StyleProp<TextStyle>, color: stri
92
112
  )
93
113
  }
94
114
  if (isValidElement<{ style?: StyleProp<TextStyle> }>(action) && action.type === Text) {
95
- return cloneElement(action, { style: [type, action.props.style] })
115
+ // A count in a type of its own (a 15/20 subheadline beside the 17/22 title) is lifted onto the title's baseline,
116
+ // the row still set at its bottoms so the count stays on the title's last line
117
+ const header = StyleSheet.flatten(type) ?? {}
118
+ const own = StyleSheet.flatten([type, action.props.style]) ?? {}
119
+ const lift =
120
+ onBaseline && typeof header.fontSize === "number" && typeof header.lineHeight === "number" && typeof own.fontSize === "number" && typeof own.lineHeight === "number"
121
+ ? baselineOverBottom(header.fontSize, header.lineHeight) - baselineOverBottom(own.fontSize, own.lineHeight)
122
+ : 0
123
+ return cloneElement(action, { style: [type, action.props.style, lift !== 0 ? { marginBottom: lift } : null] })
96
124
  }
97
125
  return action
98
126
  }
@@ -246,6 +274,7 @@ export function List({
246
274
  action,
247
275
  { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) },
248
276
  theme.colors.labelSecondary,
277
+ true,
249
278
  )}
250
279
  </ListActionContext.Provider>
251
280
  ) : null}
@@ -289,6 +318,51 @@ export function List({
289
318
  )
290
319
  }
291
320
 
321
+ export type ListStackProps = {
322
+ /** The sections (`List`) and any blocks between them (a note, a button). */
323
+ children: ReactNode
324
+ /** The space between two blocks that are not both sections, as the screen's own. @default 0 */
325
+ gap?: number
326
+ /**
327
+ * Keeps the room under the last section (iOS 35 over the home indicator, Android at least 16 over the system's bar).
328
+ * Off for a stack that is not the screen's end. @default true
329
+ */
330
+ end?: boolean
331
+ style?: StyleProp<ViewStyle>
332
+ testID?: string
333
+ }
334
+
335
+ /**
336
+ * Sections one under another, as SwiftUI's Form and the web's stacked FieldGroups space them: on iOS 35 rows to rows,
337
+ * less what a footer's block (17.33) and a header's (18.67, a prominent one 18, after a footer 11.33) take; on Android
338
+ * 12 apart, none after a footer. Blocks that are not sections keep `gap`; the stack ends with the last section's room.
339
+ */
340
+ export function ListStack({ children, gap = 0, end = true, style, testID }: ListStackProps) {
341
+ const theme = useTheme()
342
+ const insets = useSafeAreaInsets()
343
+ const items = flattenChildren(children)
344
+ const section = (node: ReactNode): ListProps | null => (isValidElement(node) && node.type === List ? (node.props as ListProps) : null)
345
+ const space = (before: ListProps | null, after: ListProps | null) => {
346
+ if (before == null || after == null) return gap
347
+ const footer = before.footer != null || before.error != null
348
+ const header = after.header != null || after.description != null || after.action != null
349
+ if (theme.isAndroid) return footer ? 0 : 12
350
+ const prominent = after.headerProminence === "increased"
351
+ return 35 - (footer ? 17.33 : 0) - (header ? (prominent ? 18 : footer ? 11.33 : 18.67) : 0)
352
+ }
353
+ const last = section(items[items.length - 1])
354
+ const bottom = !end ? 0 : theme.isAndroid ? Math.max(16, insets.bottom) : last != null ? 35 + insets.bottom : insets.bottom
355
+ return (
356
+ <View style={[{ paddingBottom: bottom }, style]} testID={testID}>
357
+ {items.map((child, index) => (
358
+ <View key={isValidElement(child) && child.key != null ? child.key : index} style={index > 0 ? { marginTop: space(section(items[index - 1]), section(child)) } : null}>
359
+ {child}
360
+ </View>
361
+ ))}
362
+ </View>
363
+ )
364
+ }
365
+
292
366
  export type ListItemProps = {
293
367
  /** The row's text, as @plexui/ui's NavigationRow `label`. */
294
368
  label: ReactNode
@@ -321,6 +395,12 @@ export type ListItemProps = {
321
395
  * control stays the one element for a screen reader, named by the label when it has no name of its own.
322
396
  */
323
397
  trailing?: ReactNode
398
+ /**
399
+ * A row of a list to pick one from (countries with their codes, a sound): `true` draws the check at its end (the
400
+ * accent's checkmark), `false` keeps the check's room, so the values of every row stand in one column and a pick
401
+ * moves no text. Read as selected. Leave `trailing` out.
402
+ */
403
+ selected?: boolean
324
404
  /**
325
405
  * An error under the row, as the web's FieldError in a form row: on iOS a line of its own across the row, 4 under the
326
406
  * label, 15/20 in the danger color after a 16pt exclamation mark; on Android under the label, 13sp in the error color.
@@ -349,6 +429,8 @@ export type ListItemProps = {
349
429
  /** A row in red, as a destructive action row. */
350
430
  destructive?: boolean
351
431
  accessibilityLabel?: string
432
+ /** What a press does, read after the name ("Edit date of birth"): on the row, or on the control that takes its focus. */
433
+ accessibilityHint?: string
352
434
  testID?: string
353
435
  }
354
436
 
@@ -372,7 +454,8 @@ export function ListItem({
372
454
  value,
373
455
  valuePlacement = "end",
374
456
  valueColor,
375
- trailing,
457
+ trailing: trailingProp,
458
+ selected,
376
459
  error,
377
460
  checked: checkedProp,
378
461
  defaultChecked,
@@ -384,6 +467,7 @@ export function ListItem({
384
467
  disabled = false,
385
468
  destructive = false,
386
469
  accessibilityLabel,
470
+ accessibilityHint,
387
471
  testID,
388
472
  }: ListItemProps) {
389
473
  const theme = useTheme()
@@ -391,6 +475,7 @@ export function ListItem({
391
475
  // A menu opened from the row finds the row (Android lights it over the dim of the screen)
392
476
  const frameNode = useRef<unknown>(null)
393
477
  const frame = useMemo<RowFrame>(() => ({ node: frameNode, radius: { top, bottom } }), [top, bottom])
478
+ const trailing = trailingProp ?? (selected === undefined ? undefined : <CheckSlot selected={selected} />)
394
479
  const switchRow = checkedProp !== undefined || defaultChecked !== undefined || onCheckedChange !== undefined
395
480
  const [own, setOwn] = useState(defaultChecked ?? false)
396
481
  const checked = checkedProp ?? own
@@ -429,7 +514,17 @@ export function ListItem({
429
514
  }, [])
430
515
  const handed = !switchRow && !onPress && !control && !disabled ? endPress : null
431
516
  const press = switchRow ? toggle : (onPress ?? control?.toggle ?? handed ?? undefined)
517
+ const hinted = useHint(accessibilityHint)
518
+ // On the web the hint is an unseen text the row's element, or the control that takes its focus, is described by
519
+ const hintNode = hinted.id != null ? <Text nativeID={hinted.id} style={styles.unseen}>{accessibilityHint}</Text> : null
432
520
  const endOwnsFocus = control != null || handed != null || (endHands && press == null)
521
+ // 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
522
+ // opens a page keeps to its own words
523
+ const controlHint = endOwnsFocus ? accessibilityHint : undefined
524
+ const rowAction = useMemo(
525
+ () => (onLongPress == null && controlHint == null ? null : { run: disabled ? undefined : onLongPress, label: longPressLabel, hint: controlHint, hintId: hinted.id }),
526
+ [controlHint, disabled, hinted.id, longPressLabel, onLongPress],
527
+ )
433
528
  // A destructive row is an action, not a page (Settings' Sign Out has no chevron)
434
529
  const chevron = disclosure ?? (!!onPress && !switchRow && trailing == null && !destructive)
435
530
  const name = accessibilityLabel ?? ([textOf(label), textOf(value)].filter(Boolean).join(", ") || undefined)
@@ -485,6 +580,12 @@ export function ListItem({
485
580
  ref={frameNode as never}
486
581
  collapsable={false}
487
582
  {...described.props}
583
+ // The hint over the description's (a phone's one hint), or beside it on the web
584
+ {...(endOwnsFocus || accessibilityHint == null
585
+ ? null
586
+ : Platform.OS === "web"
587
+ ? { "aria-describedby": describedBy(described.id, hinted.id) }
588
+ : hinted.props)}
488
589
  {...(switchRow ? spaceToggles(toggle) : null)}
489
590
  // A row that toggles its control is not a second element for a screen reader or a Tab stop: the control is
490
591
  accessible={endOwnsFocus ? false : undefined}
@@ -492,8 +593,10 @@ export function ListItem({
492
593
  tabIndex={endOwnsFocus ? -1 : undefined}
493
594
  accessibilityRole={endOwnsFocus ? undefined : switchRow ? "switch" : "button"}
494
595
  accessibilityLabel={endOwnsFocus ? undefined : name}
495
- accessibilityState={endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled }}
596
+ accessibilityState={endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled, ...(selected !== undefined ? { selected } : null) }}
496
597
  aria-checked={switchRow ? checked : undefined}
598
+ // React Native Web drops a button's selected state: the web reads a chosen row as a pressed button
599
+ {...(Platform.OS === "web" && !endOwnsFocus && !switchRow && selected !== undefined ? ({ "aria-pressed": selected } as object) : null)}
497
600
  disabled={disabled || (press == null && onLongPress == null)}
498
601
  onPress={press}
499
602
  {...holdProps({ run: onLongPress, label: longPressLabel }, null)}
@@ -505,7 +608,8 @@ export function ListItem({
505
608
  >
506
609
  {({ pressed }) => (
507
610
  <RowHoldContext.Provider value={disabled ? null : theme.isAndroid ? hold : setHeld}>
508
- <RowActionContext.Provider value={disabled || onLongPress == null ? null : { run: onLongPress, label: longPressLabel }}>
611
+ <RowActionContext.Provider value={rowAction}>
612
+ {hintNode}
509
613
  {ripple.layer}
510
614
  {theme.isAndroid ? null : <RowHighlight on={(pressed || held) && lit} last={last} />}
511
615
  {content(pressed || held)}
@@ -525,15 +629,28 @@ export function ListItem({
525
629
  testID={testID}
526
630
  accessible={named || undefined}
527
631
  accessibilityLabel={accessibilityLabel}
632
+ {...(named ? hinted.props : null)}
528
633
  accessibilityRole={named && Platform.OS !== "web" ? "text" : undefined}
529
634
  role={named && Platform.OS === "web" ? "group" : undefined}
530
635
  style={row}
531
636
  >
637
+ {named ? hintNode : null}
532
638
  {content(false)}
533
639
  </View>
534
640
  )
535
641
  }
536
642
 
643
+ /** The check of a choice row, or its empty room: the accent's checkmark, 20 on iOS (a 17pt symbol), 24 on Android. */
644
+ function CheckSlot({ selected }: { selected: boolean }) {
645
+ const theme = useTheme()
646
+ const size = theme.isAndroid ? 24 : 20
647
+ return (
648
+ <View style={{ width: size, height: size }} accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
649
+ {selected ? <CheckMd size={size} color={theme.isAndroid ? theme.material.primary : theme.colors.accent} /> : null}
650
+ </View>
651
+ )
652
+ }
653
+
537
654
  /** A Button among a List's rows: the row is the button (`ListActionContext`), the hairline under it from the text's start. */
538
655
  function ActionRow({ children }: { children: ReactNode }) {
539
656
  const theme = useTheme()
@@ -1096,6 +1213,7 @@ const styles = StyleSheet.create({
1096
1213
  androidEndEdge: { marginStart: "auto" },
1097
1214
  endAtEdge: { justifyContent: "flex-end" },
1098
1215
  iosHeaderRow: { flexDirection: "row", alignItems: "flex-end", gap: 16 },
1216
+ unseen: { display: "none" },
1099
1217
  androidHeaderRow: { flexDirection: "row", alignItems: "flex-start", minHeight: 40, paddingHorizontal: ANDROID_INSET, paddingTop: 14, paddingBottom: 6, gap: 16 },
1100
1218
  androidHeaderTitle: { flex: 1, minWidth: 0, fontSize: 15, lineHeight: 20 },
1101
1219
  androidHeaderTitleType: { fontSize: 15, lineHeight: 20 },
@@ -50,7 +50,7 @@ type MenuContextValue = {
50
50
  const MenuContext = createContext<MenuContextValue | null>(null)
51
51
 
52
52
  /** Closes the menu once an item is chosen; also used by Select. */
53
- const SurfaceContext = createContext<{ close: () => void; check: boolean; multiple?: boolean; openSub?: (sub: OpenSub) => void; subOpen?: boolean; header?: boolean }>({ close: () => {}, check: false })
53
+ const SurfaceContext = createContext<{ close: () => void; check: boolean; multiple?: boolean; openSub?: (sub: OpenSub) => void; refreshSub?: (owner: object, items: ReactNode) => void; subOpen?: boolean; header?: boolean }>({ close: () => {}, check: false })
54
54
 
55
55
  export type MenuProps = {
56
56
  children: ReactNode
@@ -190,6 +190,16 @@ export type MenuContentProps = {
190
190
  align?: "start" | "end"
191
191
  /** @default 250 on iOS; on Android the popup fits its items, 196 to 288 */
192
192
  width?: number
193
+ /**
194
+ * Several options to pick: a press on an item with `checked` checks or unchecks it and the menu stays open; its items
195
+ * read as checkboxes. @default false
196
+ */
197
+ multiple?: boolean
198
+ /**
199
+ * The menu opens over its trigger, as Android's popup and the web's phone menu; `false` opens it under the trigger,
200
+ * its top at the trigger's bottom edge, as Material's dropdown menu under a chip. @default true
201
+ */
202
+ cover?: boolean
193
203
  "aria-label"?: string
194
204
  testID?: string
195
205
  }
@@ -212,10 +222,6 @@ type SurfaceProps = MenuContentProps & {
212
222
  anchor: MenuAnchor | null
213
223
  onClose: () => void
214
224
  check?: boolean
215
- /** Select's `multiple`: a press checks or unchecks an option and the menu stays open. */
216
- multiple?: boolean
217
- /** The menu opens over its trigger, as Android's popup and the web's phone menu (a dropdown field's list opens under it). @default true */
218
- cover?: boolean
219
225
  /** The List row the menu opens from: on Android the screen dims around it and the popup stands under it. */
220
226
  row?: MenuRow | null
221
227
  /** Opened from a bar's button: on Android the header menu, in the bar's glass. */
@@ -329,9 +335,11 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
329
335
  moveTo(step, 1, true)
330
336
  }
331
337
  const collapse = () => moveTo(step, 0, false, () => setSub(null))
332
- const surface = { close: onClose, check, multiple, openSub, subOpen: sub != null }
338
+ // A multiple choice keeps the submenu open: its items follow the app's state while it shows
339
+ const refreshSub = (owner: object, items: ReactNode) => setSub((current) => (current == null || current.owner !== owner || current.items === items ? current : { ...current, items }))
340
+ const surface = { close: onClose, check, multiple, openSub, refreshSub, subOpen: sub != null }
333
341
  const content = <SurfaceContext.Provider value={surface}>{children}</SurfaceContext.Provider>
334
- const subItems = sub != null ? <SurfaceContext.Provider value={{ close: onClose, check: hasCheckedItems(sub.items) }}>{sub.items}</SurfaceContext.Provider> : null
342
+ const subItems = sub != null ? <SurfaceContext.Provider value={{ close: onClose, check: hasCheckedItems(sub.items), multiple }}>{sub.items}</SurfaceContext.Provider> : null
335
343
  const scale = !theme.reducedMotion && canTransformGlass
336
344
  // The web's keyboard, as the WAI-ARIA menu pattern: focus starts at the chosen item (else the first), the arrows
337
345
  // move to the next one and stop at the ends, Home and End go to the first and the last
@@ -808,11 +816,12 @@ function AndroidMenuSurface({ open, anchor, row, header = false, onClose, align
808
816
  },
809
817
  })
810
818
  })
811
- const surface = { close: onClose, check, multiple, openSub, subOpen: sub != null, header }
819
+ const refreshSub = (owner: object, items: ReactNode) => setSub((current) => (current == null || current.owner !== owner || current.items === items ? current : { ...current, items }))
820
+ const surface = { close: onClose, check, multiple, openSub, refreshSub, subOpen: sub != null, header }
812
821
  // The submenu's page: Back, the 8dp band, the items
813
822
  const subItems =
814
823
  sub != null ? (
815
- <SurfaceContext.Provider value={{ close: onClose, check: hasCheckedItems(sub.items), header }}>
824
+ <SurfaceContext.Provider value={{ close: onClose, check: hasCheckedItems(sub.items), multiple, header }}>
816
825
  <MenuRow icon={<ArrowLeftLg />} stay={collapse}>
817
826
  {sub.backLabel}
818
827
  </MenuRow>
@@ -1235,7 +1244,8 @@ function MenuRow({ children, icon, description, danger = false, disabled = false
1235
1244
  const inlineExtra = (theme: Theme) => theme.length("--menu-padding-inline", 16) - theme.length("--menu-gutter", 10)
1236
1245
 
1237
1246
  /** The heading of a submenu stays and its items scroll; the menu's own items are a submenu's `items`. */
1238
- type OpenSub = { label: ReactNode; items: ReactNode; backLabel: string; y: number }
1247
+ /** An open submenu; `owner` is the row that opened it, the only one whose items it follows. */
1248
+ type OpenSub = { label: ReactNode; items: ReactNode; backLabel: string; y: number; owner?: object }
1239
1249
 
1240
1250
  export type MenuSubContentProps = {
1241
1251
  /** The submenu's items: Menu.Item, Menu.Separator, Menu.Label. */
@@ -1270,8 +1280,14 @@ function MenuSubTrigger({ children, icon, disabled, testID }: MenuSubTriggerProp
1270
1280
  const row = useRef<unknown>(null)
1271
1281
  const open = () => {
1272
1282
  if (!sub) return
1273
- measure(row.current as Measurable | null, (box) => surface.openSub?.({ label: children, items: sub.children, backLabel: sub.backLabel ?? "Back", y: box.y }))
1283
+ measure(row.current as Measurable | null, (box) => surface.openSub?.({ label: children, items: sub.children, backLabel: sub.backLabel ?? "Back", y: box.y, owner: row }))
1274
1284
  }
1285
+ // The submenu this row opened follows the app's state while it shows (a multiple choice keeps it open)
1286
+ const items = sub?.children
1287
+ const { subOpen, refreshSub } = surface
1288
+ useEffect(() => {
1289
+ if (subOpen) refreshSub?.(row, items)
1290
+ }, [items, subOpen, refreshSub])
1275
1291
  return (
1276
1292
  <MenuRow icon={icon} disabled={disabled} testID={testID} rowRef={row} stay={open} opens expanded={surface.subOpen}>
1277
1293
  {children}
@@ -199,8 +199,10 @@ export function PageControl({
199
199
  const gap = small ? 4 : android ? ANDROID_GAP : theme.length("--page-control-gap", 8)
200
200
  const padding = small ? 6 : theme.length("--page-control-padding-inline", 12)
201
201
  const pitch = dot + gap
202
- // Android draws every page's dot at full size; the iOS kit shrinks the ends from seven pages
203
- const sizes = android ? Array.from({ length: Math.max(0, count) }, (): PageControlDotSize => "full") : pageControlDots(count, clampIndex(typeof positionProp === "number" ? Math.round(positionProp) : near, count))
202
+ // Android draws every page's dot at full size up to ANDROID_MAX_DOTS; past that, and on iOS from seven pages, the
203
+ // dots are a window that holds the current page, so a long run of pages never runs off the screen
204
+ const windowed = !android || count > ANDROID_MAX_DOTS
205
+ const sizes = windowed ? pageControlDots(count, clampIndex(typeof positionProp === "number" ? Math.round(positionProp) : near, count)) : Array.from({ length: Math.max(0, count) }, (): PageControlDotSize => "full")
204
206
  // The small and smaller ends keep their share of a full dot (6 and 4 of 8 on iOS)
205
207
  const dotSize = (kind: PageControlDotSize) =>
206
208
  kind === "full"
@@ -226,7 +228,7 @@ export function PageControl({
226
228
  const off = onColor ? "rgba(255, 255, 255, 0.4)" : android ? (theme.scheme === "dark" ? "#555555" : "#BBBBBB") : theme.color("--page-control-dot-color", theme.colors.labelTertiary)
227
229
  // Android's current dot is drawn over the gray ones (it stretches between pages) unless the pages' scroll drives the
228
230
  // dots, when their color crosses over as on iOS; a pill is a dot of its own
229
- const worm = android && !pill && positionProp == null
231
+ const worm = android && !pill && positionProp == null && !windowed
230
232
  // Android draws no capsule, not even for `prominent`
231
233
  const capsuleHeight = small ? 16 : theme.length("--page-control-height", 24)
232
234
  const target = android ? 48 : theme.length("--page-control-target-size", 44)
@@ -345,6 +347,8 @@ const ANDROID_SLIDE = { duration: 300, easing: Easing.bezier(0.2, 0, 0, 1) }
345
347
  /** Android's page dots: 5dp, 11dp from one to the next. */
346
348
  const ANDROID_DOT = 5
347
349
  const ANDROID_GAP = 6
350
+ /** The most pages whose dots Android draws all; more take the window of dots the iOS kit keeps. */
351
+ const ANDROID_MAX_DOTS = 9
348
352
  /**
349
353
  * A page change the pager settles on its own (a tap, a change from code): one page in 200ms, on an ease-out quint
350
354
  * standing in for the pager's 1 + (t − 1)⁵.
@@ -5,7 +5,7 @@ import CheckMd from "../../icons/plex/CheckMd"
5
5
  import { useDescription } from "../../internal/a11y"
6
6
  import { ControlLabel } from "../../internal/ControlLabel"
7
7
  import { isRTL, nextKey } from "../../internal/direction"
8
- import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHold } from "../../internal/row"
8
+ import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHint, rowHold } from "../../internal/row"
9
9
  import { mix } from "../../theme/material"
10
10
  import { useTheme } from "../../theme/ThemeProvider"
11
11
  import { ANDROID_ROW_END, androidEaseInOut, iosCheckmarkColor, selectionColor } from "../Switch/Switch"
@@ -150,6 +150,7 @@ function RadioGroupItem({ value, children, description, disabled: itemDisabled =
150
150
  disabled={disabled}
151
151
  {...rowHold(hold)}
152
152
  {...holdProps({ run: disabled ? undefined : onLongPress, label: longPressLabel }, inRow || atStart ? rowAction : null)}
153
+ {...rowHint(rowAction, described)}
153
154
  onPress={() => !selected && context.select(value)}
154
155
  testID={testID}
155
156
  style={[
@@ -14,6 +14,8 @@ export type RollingNumberProps = Omit<TextProps, "children"> & {
14
14
  format?: Intl.NumberFormatOptions
15
15
  /** The style of the row of characters. */
16
16
  containerStyle?: StyleProp<ViewStyle>
17
+ /** How long a change takes, in ms. @default `--rolling-number-duration` (600) on iOS, 320 on Android */
18
+ duration?: number
17
19
  }
18
20
 
19
21
  type Character = { character: string; digit: number | null; key: string }
@@ -63,7 +65,7 @@ export const rollingNumberParts = (value: number, locales: Intl.LocalesArgument
63
65
  * 0.3 of the font size while the new one comes in, in 320ms (ease-out quint), up for a larger number. With reduced
64
66
  * motion it changes at once. A screen reader reads the written number.
65
67
  */
66
- export function RollingNumber({ value, locales, format, containerStyle, style, size, variant, weight, mono, testID, accessibilityLabel, ...text }: RollingNumberProps) {
68
+ export function RollingNumber({ value, locales, format, containerStyle, duration, style, size, variant, weight, mono, testID, accessibilityLabel, ...text }: RollingNumberProps) {
67
69
  const theme = useTheme()
68
70
  const { text: written, glyphs, characters } = rollingNumberParts(value, locales, format)
69
71
  const flat = StyleSheet.flatten(style) as TextStyle | undefined
@@ -86,13 +88,13 @@ export function RollingNumber({ value, locales, format, containerStyle, style, s
86
88
  >
87
89
  {characters.map(({ character, digit, key }) =>
88
90
  theme.isAndroid ? (
89
- <Changing key={key} character={character} up={last.up} lift={0.3 * fontSize} reduced={theme.reducedMotion} text={glyphProps} />
91
+ <Changing key={key} character={character} up={last.up} lift={0.3 * fontSize} reduced={theme.reducedMotion} duration={duration ?? 320} text={glyphProps} />
90
92
  ) : digit === null ? (
91
93
  <Text key={key} {...glyphProps}>
92
94
  {character}
93
95
  </Text>
94
96
  ) : (
95
- <Reel key={key} digit={digit} character={character} glyphs={glyphs} lineHeight={lineHeight} text={glyphProps} />
97
+ <Reel key={key} digit={digit} character={character} glyphs={glyphs} lineHeight={lineHeight} duration={duration} text={glyphProps} />
96
98
  ),
97
99
  )}
98
100
  </View>
@@ -100,11 +102,11 @@ export function RollingNumber({ value, locales, format, containerStyle, style, s
100
102
  }
101
103
 
102
104
  /** iOS's reel: the digit itself, hidden, keeps the width and height; a column of 0 to 9 turns over it. */
103
- function Reel({ digit, character, glyphs, lineHeight, text }: { digit: number; character: string; glyphs: string[]; lineHeight: number; text: TextProps }) {
105
+ function Reel({ digit, character, glyphs, lineHeight, duration, text }: { digit: number; character: string; glyphs: string[]; lineHeight: number; duration?: number; text: TextProps }) {
104
106
  const theme = useTheme()
105
107
  const [line, setLine] = useState(lineHeight)
106
108
  const position = useTransitionValue(digit, {
107
- duration: theme.duration("--rolling-number-duration", 600),
109
+ duration: duration ?? theme.duration("--rolling-number-duration", 600),
108
110
  easing: cssEasing(theme.token("--rolling-number-ease"), curves.easeInOut),
109
111
  native: true,
110
112
  reducedMotion: theme.reducedMotion,
@@ -132,7 +134,7 @@ function Reel({ digit, character, glyphs, lineHeight, text }: { digit: number; c
132
134
  }
133
135
 
134
136
  /** Android's animated text: a new character comes in as the old one leaves, both fading and moving by `lift`. */
135
- function Changing({ character, up, lift, reduced, text }: { character: string; up: boolean; lift: number; reduced: boolean; text: TextProps }) {
137
+ function Changing({ character, up, lift, reduced, duration, text }: { character: string; up: boolean; lift: number; reduced: boolean; duration: number; text: TextProps }) {
136
138
  const [pair, setPair] = useState({ old: null as string | null, now: character, up })
137
139
  if (pair.now !== character) setPair({ old: pair.now, now: character, up })
138
140
  const [progress] = useState(() => new Animated.Value(1))
@@ -142,12 +144,12 @@ function Changing({ character, up, lift, reduced, text }: { character: string; u
142
144
  }, [pair, progress, reduced])
143
145
  useEffect(() => {
144
146
  if (pair.old == null || reduced) return
145
- const animation = Animated.timing(progress, { toValue: 1, duration: 320, easing: curves.easeOutQuint, useNativeDriver: nativeDriver, isInteraction: false })
147
+ const animation = Animated.timing(progress, { toValue: 1, duration, easing: curves.easeOutQuint, useNativeDriver: nativeDriver, isInteraction: false })
146
148
  animation.start(({ finished }) => {
147
149
  if (finished) setPair((current) => (current === pair ? { ...current, old: null } : current))
148
150
  })
149
151
  return () => animation.stop()
150
- }, [pair, progress, reduced])
152
+ }, [duration, pair, progress, reduced])
151
153
  const direction = pair.up ? 1 : -1
152
154
  return (
153
155
  <View>
@@ -10,6 +10,12 @@ export type ScrollEdgeProps = {
10
10
  scrolled?: boolean
11
11
  /** The color of the screen it fades into (a grouped screen's canvas). @default the theme's background */
12
12
  canvasColor?: string
13
+ /**
14
+ * Top edge under a floating row (filters, tabs): where the fade ends, from the screen's top. Only what went under the
15
+ * row is muted, the content below it stays sharp: pass the row's bottom. On Android, too, the edge then is the row's
16
+ * (iOS 27.2's), not the status bar's alone.
17
+ */
18
+ fadeEnd?: number
13
19
  testID?: string
14
20
  style?: StyleProp<ViewStyle>
15
21
  }
@@ -21,13 +27,17 @@ export type ScrollEdgeProps = {
21
27
  * the screen's color that grows to 46% at the screen's edge. On Android the top edge is the soft edge of its top bar
22
28
  * over the status bar alone, the bottom one draws nothing. Lay it over the screen, after the scroll view.
23
29
  */
24
- export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID, style }: ScrollEdgeProps) {
30
+ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, fadeEnd, testID, style }: ScrollEdgeProps) {
25
31
  const theme = useTheme()
26
32
  const insets = useSafeAreaInsets()
27
33
  const canvas = canvasColor ?? theme.colors.background
28
34
  const top = edge === "top"
29
35
  if (top && !scrolled) return null
30
- if (theme.isAndroid) {
36
+ const height = StyleSheet.flatten(style)?.height
37
+ // A row under the status bar (a height or a fade's end given): Android takes iOS's edge for it, as a row over
38
+ // content reads on neither platform under the status bar's edge alone
39
+ const row = top && (fadeEnd != null || typeof height === "number")
40
+ if (theme.isAndroid && !row) {
31
41
  if (!top) return null
32
42
  return (
33
43
  <View pointerEvents="none" testID={testID} style={[{ position: "absolute", top: 0, left: 0, right: 0, height: insets.top }, style]}>
@@ -36,14 +46,15 @@ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID
36
46
  )
37
47
  }
38
48
  // 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
49
+ // bar): the content is blurred in full down to it, and the veil and the blur ease out over the 34 past it. A fade's
50
+ // end is where the veil's 34 end, so the content under it shows clear
51
+ const reach =
52
+ top && fadeEnd != null ? fadeEnd - FADE_PAST - FULL_BLUR_SHORTFALL : top && typeof height === "number" ? height + FULL_BLUR_SHORTFALL : insets.top
42
53
  return (
43
54
  <View
44
55
  pointerEvents="none"
45
56
  testID={testID}
46
- style={[{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style]}
57
+ style={[{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: fadeEnd ?? insets.top } : { bottom: 0, height: insets.bottom }, style]}
47
58
  >
48
59
  {top ? <SoftBottomVeil fill={canvas} bottom={reach} /> : <SoftBottomVeil fill={canvas} top={0} />}
49
60
  </View>
@@ -52,3 +63,5 @@ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID
52
63
 
53
64
  /** 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
65
  const FULL_BLUR_SHORTFALL = 6
66
+ /** From the height where the blur is whole, the fade runs on 28 more (the 34 of the veil less its shortfall). */
67
+ const FADE_PAST = 28
@@ -5,7 +5,7 @@ import Svg, { Path } from "react-native-svg"
5
5
  import ChevronUpDown from "../../icons/plex/ChevronUpDown"
6
6
  import { spaceToggles } from "../../internal/a11y"
7
7
  import { useRipple } from "../../internal/ripple"
8
- import { RowEndContext, RowFrameContext, RowHoldContext, rowHold } from "../../internal/row"
8
+ import { RowActionContext, RowEndContext, RowFrameContext, RowHoldContext, rowHint, rowHold } from "../../internal/row"
9
9
  import { androidSelector, withAlpha } from "../../theme/material"
10
10
  import { MaterialArrowDropDown } from "../Icon/material"
11
11
  import { useTheme } from "../../theme/ThemeProvider"
@@ -147,6 +147,8 @@ export function Select<T extends SelectOption>(props: SelectProps<T>) {
147
147
  const look = fieldLook(theme, { variant, size, pill }, { focused: open, filled: shownLabel != null, disabled, invalid })
148
148
  const row = useContext(RowEndContext)
149
149
  const hold = useContext(RowHoldContext)
150
+ // At a row's end the select takes the row's focus, and with it the row's hint
151
+ const rowAction = useContext(RowActionContext)
150
152
  const rowEnd = row != null
151
153
  const inRow = rowEnd && !android
152
154
  // 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
@@ -177,6 +179,7 @@ export function Select<T extends SelectOption>(props: SelectProps<T>) {
177
179
  <Pressable
178
180
  accessibilityRole="button"
179
181
  accessibilityLabel={ariaLabel ? `${ariaLabel}, ${shownLabel ?? placeholder}` : undefined}
182
+ {...(row != null ? rowHint(rowAction, { props: {} }) : null)}
180
183
  accessibilityState={{ disabled, expanded: open }}
181
184
  aria-haspopup={dialog ? "dialog" : "menu"}
182
185
  aria-expanded={open}
@@ -3,7 +3,7 @@ import { Animated, Easing, StyleSheet, View, type StyleProp, type ViewStyle } fr
3
3
  import { Pressable } from "../../internal/Pressable"
4
4
  import { spaceToggles, useDescription } from "../../internal/a11y"
5
5
  import { ControlLabel } from "../../internal/ControlLabel"
6
- import { RowActionContext, RowEndContext, RowHoldContext, holdProps, rowHold } from "../../internal/row"
6
+ import { RowActionContext, RowEndContext, RowHoldContext, holdProps, rowHint, rowHold } from "../../internal/row"
7
7
  import { androidGray } from "../../theme/material"
8
8
  import { useTheme } from "../../theme/ThemeProvider"
9
9
  import type { SelectionColor, Theme } from "../../theme/types"
@@ -128,6 +128,7 @@ export function Switch({
128
128
  disabled={disabled}
129
129
  {...rowHold(hold)}
130
130
  {...holdProps({}, rowEnd ? rowAction : null)}
131
+ {...rowHint(rowAction, described)}
131
132
  onPress={toggle}
132
133
  testID={testID}
133
134
  // Android's switch row: 50dp, the text ending 11dp before the switch's 37dp view
@@ -884,6 +884,21 @@ export const TabBar = Object.assign(TabBarRoot, { Item: TabBarItem })
884
884
  /** A scroll of at least this many points in one direction minimizes or expands the bar, as on the web. */
885
885
  const MINIMIZE_AFTER = 8
886
886
 
887
+ /**
888
+ * Where the tab bar's capsule stands, for what floats over it (a screen's floating buttons a set gap above it, a
889
+ * scroll that ends over it): `capsuleHeight`, and `bottom`, from the screen's bottom edge to the capsule's. iOS 26: the
890
+ * 54pt tabs in a capsule 4 above and below (62), 21 over the screen's bottom (or over the home indicator); Android:
891
+ * 56dp, 8 over the gesture bar. The bar itself (its soft edge) reaches higher. Pass the bar's `safeArea`.
892
+ */
893
+ export function useTabBarMetrics({ safeArea = true, minimized = false }: { safeArea?: boolean; minimized?: boolean } = {}): { capsuleHeight: number; bottom: number } {
894
+ const theme = useTheme()
895
+ const insets = useSafeAreaInsets()
896
+ if (theme.isAndroid) return { capsuleHeight: 56, bottom: 8 + (safeArea ? insets.bottom : 0) }
897
+ const padBottom = minimized ? theme.length("--tab-bar-minimized-padding-bottom", 28) : theme.length("--tab-bar-padding-bottom", 21)
898
+ const capsuleHeight = minimized ? theme.length("--tab-bar-minimized-size", 48) : theme.length("--tab-bar-item-height", 54) + 2 * theme.length("--tab-bar-capsule-padding-block", 4)
899
+ return { capsuleHeight, bottom: safeArea ? Math.max(padBottom, insets.bottom - 13) : padBottom }
900
+ }
901
+
887
902
  /**
888
903
  * Minimizes a TabBar while the screen scrolls down and expands it when it scrolls back up, as iOS 26
889
904
  * `tabBarMinimizeBehavior(.onScrollDown)`: pass `onScroll` to the ScrollView and `minimized` and