@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,10 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
3
3
  import { Animated, Easing, Platform, StyleSheet, View } from "react-native";
4
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
4
5
  import { Pressable } from "../../internal/Pressable";
6
+ import CheckMd from "../../icons/plex/CheckMd";
5
7
  import Disclosure from "../../icons/plex/Disclosure";
6
8
  import ExclamationMarkCircle from "../../icons/plex/ExclamationMarkCircle";
7
- import { spaceToggles, useDescription } from "../../internal/a11y";
9
+ import { describedBy, spaceToggles, useDescription, useHint } from "../../internal/a11y";
8
10
  import { useRipple } from "../../internal/ripple";
9
11
  import { flattenChildren, textOf } from "../../internal/children";
10
12
  import { cssBox } from "../../internal/cssBox";
@@ -28,17 +30,40 @@ export function useInList() {
28
30
  const ANDROID_CARD_RADIUS = 16;
29
31
  /** The start and end of an Android row's text, 21dp in from the card's edge (`--list-row-inset`). */
30
32
  const ANDROID_INSET = 21;
33
+ /**
34
+ * Where a List's rows start their text inside the card and how round the card is, for a card built beside a List
35
+ * that must line up with it: iOS `--list-row-inset` (20) and `--field-group-radius` (26), Android 21 and 16.
36
+ */
37
+ export function useListMetrics() {
38
+ const theme = useTheme();
39
+ return theme.isAndroid
40
+ ? { rowInset: ANDROID_INSET, radius: ANDROID_CARD_RADIUS }
41
+ : { rowInset: theme.length("--list-row-inset", 20), radius: theme.length("--field-group-radius", 26) };
42
+ }
31
43
  const PlaceContext = createContext({ first: true, last: true, top: 0, bottom: 0 });
44
+ /**
45
+ * How far a line's baseline stands over the line's bottom: half the leading under the face's box, and its descent.
46
+ * 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.
47
+ */
48
+ const baselineOverBottom = (fontSize, lineHeight) => (lineHeight - fontSize * 1.21) / 2 + fontSize * 0.24;
32
49
  /**
33
50
  * 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.
51
+ * line: iOS 17/22 on its last line, Android the header's 15sp on its 40dp row. Its own style still wins; on iOS
52
+ * (`onBaseline`) a Text in a type of its own is lifted onto the title's baseline.
35
53
  */
36
- function headerAction(action, type, color) {
54
+ function headerAction(action, type, color, onBaseline = false) {
37
55
  if (typeof action === "string" || typeof action === "number") {
38
56
  return (_jsx(Text, { color: color, tabularNums: true, style: type, children: action }));
39
57
  }
40
58
  if (isValidElement(action) && action.type === Text) {
41
- return cloneElement(action, { style: [type, action.props.style] });
59
+ // A count in a type of its own (a 15/20 subheadline beside the 17/22 title) is lifted onto the title's baseline,
60
+ // the row still set at its bottoms so the count stays on the title's last line
61
+ const header = StyleSheet.flatten(type) ?? {};
62
+ const own = StyleSheet.flatten([type, action.props.style]) ?? {};
63
+ const lift = onBaseline && typeof header.fontSize === "number" && typeof header.lineHeight === "number" && typeof own.fontSize === "number" && typeof own.lineHeight === "number"
64
+ ? baselineOverBottom(header.fontSize, header.lineHeight) - baselineOverBottom(own.fontSize, own.lineHeight)
65
+ : 0;
66
+ return cloneElement(action, { style: [type, action.props.style, lift !== 0 ? { marginBottom: lift } : null] });
42
67
  }
43
68
  return action;
44
69
  }
@@ -95,7 +120,7 @@ export function List({ children, header, description, footer, error, surface = "
95
120
  }, 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
121
  increased ? { fontSize: 20, lineHeight: 25 } : { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) },
97
122
  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 ? (
123
+ ], 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
124
  // An error takes the footer's place and type (13/16, 8 under the section), only in the danger color
100
125
  _jsx(Text, { color: error != null ? errorColor(theme) : theme.colors.labelSecondary, accessibilityLiveRegion: error != null ? "polite" : undefined, style: {
101
126
  fontSize: theme.length("--field-group-footer-font-size", 13),
@@ -106,6 +131,30 @@ export function List({ children, header, description, footer, error, surface = "
106
131
  paddingStart: footerBox.left,
107
132
  }, children: error ?? footer })) : null] }));
108
133
  }
134
+ /**
135
+ * Sections one under another, as SwiftUI's Form and the web's stacked FieldGroups space them: on iOS 35 rows to rows,
136
+ * 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
137
+ * 12 apart, none after a footer. Blocks that are not sections keep `gap`; the stack ends with the last section's room.
138
+ */
139
+ export function ListStack({ children, gap = 0, end = true, style, testID }) {
140
+ const theme = useTheme();
141
+ const insets = useSafeAreaInsets();
142
+ const items = flattenChildren(children);
143
+ const section = (node) => (isValidElement(node) && node.type === List ? node.props : null);
144
+ const space = (before, after) => {
145
+ if (before == null || after == null)
146
+ return gap;
147
+ const footer = before.footer != null || before.error != null;
148
+ const header = after.header != null || after.description != null || after.action != null;
149
+ if (theme.isAndroid)
150
+ return footer ? 0 : 12;
151
+ const prominent = after.headerProminence === "increased";
152
+ return 35 - (footer ? 17.33 : 0) - (header ? (prominent ? 18 : footer ? 11.33 : 18.67) : 0);
153
+ };
154
+ const last = section(items[items.length - 1]);
155
+ const bottom = !end ? 0 : theme.isAndroid ? Math.max(16, insets.bottom) : last != null ? 35 + insets.bottom : insets.bottom;
156
+ return (_jsx(View, { style: [{ paddingBottom: bottom }, style], testID: testID, children: items.map((child, index) => (_jsx(View, { style: index > 0 ? { marginTop: space(section(items[index - 1]), section(child)) } : null, children: child }, isValidElement(child) && child.key != null ? child.key : index))) }));
157
+ }
109
158
  /**
110
159
  * A row of a List: the label (17/22, `--field-row-*`: 52 tall, 62 with a description, 12 above and below the text at
111
160
  * least) with a description, a leading symbol, a value (wrapping within 60% of the row, or under the label: `valuePlacement`) or a control, and the chevron
@@ -118,12 +167,13 @@ export function List({ children, header, description, footer, error, surface = "
118
167
  * 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
168
  * tiled row draws none).
120
169
  */
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, }) {
170
+ export function ListItem({ label, description, leading, leadingColor, value, valuePlacement = "end", valueColor, trailing: trailingProp, selected, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, longPressLabel, disabled = false, destructive = false, accessibilityLabel, accessibilityHint, testID, }) {
122
171
  const theme = useTheme();
123
172
  const { last, top, bottom } = useContext(PlaceContext);
124
173
  // A menu opened from the row finds the row (Android lights it over the dim of the screen)
125
174
  const frameNode = useRef(null);
126
175
  const frame = useMemo(() => ({ node: frameNode, radius: { top, bottom } }), [top, bottom]);
176
+ const trailing = trailingProp ?? (selected === undefined ? undefined : _jsx(CheckSlot, { selected: selected }));
127
177
  const switchRow = checkedProp !== undefined || defaultChecked !== undefined || onCheckedChange !== undefined;
128
178
  const [own, setOwn] = useState(defaultChecked ?? false);
129
179
  const checked = checkedProp ?? own;
@@ -163,7 +213,14 @@ export function ListItem({ label, description, leading, leadingColor, value, val
163
213
  }, []);
164
214
  const handed = !switchRow && !onPress && !control && !disabled ? endPress : null;
165
215
  const press = switchRow ? toggle : (onPress ?? control?.toggle ?? handed ?? undefined);
216
+ const hinted = useHint(accessibilityHint);
217
+ // On the web the hint is an unseen text the row's element, or the control that takes its focus, is described by
218
+ const hintNode = hinted.id != null ? _jsx(Text, { nativeID: hinted.id, style: styles.unseen, children: accessibilityHint }) : null;
166
219
  const endOwnsFocus = control != null || handed != null || (endHands && press == null);
220
+ // 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
221
+ // opens a page keeps to its own words
222
+ const controlHint = endOwnsFocus ? accessibilityHint : undefined;
223
+ 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
224
  // A destructive row is an action, not a page (Settings' Sign Out has no chevron)
168
225
  const chevron = disclosure ?? (!!onPress && !switchRow && trailing == null && !destructive);
169
226
  const name = accessibilityLabel ?? ([textOf(label), textOf(value)].filter(Boolean).join(", ") || undefined);
@@ -199,14 +256,24 @@ export function ListItem({ label, description, leading, leadingColor, value, val
199
256
  // Android's rows press in the list selector: the native ripple on a device, the drawn one on the web
200
257
  const highlight = controlHighlight(theme.scheme);
201
258
  const drawn = theme.isAndroid && !nativeRipple;
202
- return (_jsx(Pressable, { ref: frameNode, collapsable: false, ...described.props, ...(switchRow ? spaceToggles(toggle) : null),
259
+ return (_jsx(Pressable, { ref: frameNode, collapsable: false, ...described.props, ...(endOwnsFocus || accessibilityHint == null
260
+ ? null
261
+ : Platform.OS === "web"
262
+ ? { "aria-describedby": describedBy(described.id, hinted.id) }
263
+ : hinted.props), ...(switchRow ? spaceToggles(toggle) : null),
203
264
  // 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)] }) })) }));
265
+ 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, ...(selected !== undefined ? { selected } : null) }, "aria-checked": switchRow ? checked : undefined, ...(Platform.OS === "web" && !endOwnsFocus && !switchRow && selected !== undefined ? { "aria-pressed": selected } : null), 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
266
  }
206
267
  // A row that only shows (a detail, a value) is one element named by `accessibilityLabel` when it has one; with a
207
268
  // control at its end it stays a group, so the control is still reached
208
269
  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) }));
270
+ 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)] }));
271
+ }
272
+ /** The check of a choice row, or its empty room: the accent's checkmark, 20 on iOS (a 17pt symbol), 24 on Android. */
273
+ function CheckSlot({ selected }) {
274
+ const theme = useTheme();
275
+ const size = theme.isAndroid ? 24 : 20;
276
+ return (_jsx(View, { style: { width: size, height: size }, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: selected ? _jsx(CheckMd, { size: size, color: theme.isAndroid ? theme.material.primary : theme.colors.accent }) : null }));
210
277
  }
211
278
  /** A Button among a List's rows: the row is the button (`ListActionContext`), the hairline under it from the text's start. */
212
279
  function ActionRow({ children }) {
@@ -509,6 +576,7 @@ const styles = StyleSheet.create({
509
576
  androidEndEdge: { marginStart: "auto" },
510
577
  endAtEdge: { justifyContent: "flex-end" },
511
578
  iosHeaderRow: { flexDirection: "row", alignItems: "flex-end", gap: 16 },
579
+ unseen: { display: "none" },
512
580
  androidHeaderRow: { flexDirection: "row", alignItems: "flex-start", minHeight: 40, paddingHorizontal: ANDROID_INSET, paddingTop: 14, paddingBottom: 6, gap: 16 },
513
581
  androidHeaderTitle: { flex: 1, minWidth: 0, fontSize: 15, lineHeight: 20 },
514
582
  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
@@ -10,23 +10,29 @@ import { useTheme } from "../../theme/ThemeProvider";
10
10
  * 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
11
11
  * over the status bar alone, the bottom one draws nothing. Lay it over the screen, after the scroll view.
12
12
  */
13
- export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID, style }) {
13
+ export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, fadeEnd, testID, style }) {
14
14
  const theme = useTheme();
15
15
  const insets = useSafeAreaInsets();
16
16
  const canvas = canvasColor ?? theme.colors.background;
17
17
  const top = edge === "top";
18
18
  if (top && !scrolled)
19
19
  return null;
20
- if (theme.isAndroid) {
20
+ const height = StyleSheet.flatten(style)?.height;
21
+ // 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
22
+ // content reads on neither platform under the status bar's edge alone
23
+ const row = top && (fadeEnd != null || typeof height === "number");
24
+ if (theme.isAndroid && !row) {
21
25
  if (!top)
22
26
  return null;
23
27
  return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", top: 0, left: 0, right: 0, height: insets.top }, style], children: _jsx(SoftTopEdge, { fill: canvas, blur: Platform.OS === "web" ? 6 : 0 }) }));
24
28
  }
25
29
  // The safe area at that edge, or the height the style gives the top edge (a bar's row of buttons under the status
26
- // bar): the content is blurred in full down to it, and the veil and the blur ease out over the 34 past it
27
- const height = StyleSheet.flatten(style)?.height;
28
- const reach = top && typeof height === "number" ? height + FULL_BLUR_SHORTFALL : insets.top;
29
- return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style], children: top ? _jsx(SoftBottomVeil, { fill: canvas, bottom: reach }) : _jsx(SoftBottomVeil, { fill: canvas, top: 0 }) }));
30
+ // 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
31
+ // end is where the veil's 34 end, so the content under it shows clear
32
+ const reach = top && fadeEnd != null ? fadeEnd - FADE_PAST - FULL_BLUR_SHORTFALL : top && typeof height === "number" ? height + FULL_BLUR_SHORTFALL : insets.top;
33
+ return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: fadeEnd ?? insets.top } : { bottom: 0, height: insets.bottom }, style], children: top ? _jsx(SoftBottomVeil, { fill: canvas, bottom: reach }) : _jsx(SoftBottomVeil, { fill: canvas, top: 0 }) }));
30
34
  }
31
35
  /** The veil's blur is full 6 short of the edge it is turned over at (12 to 40 into its 34): a given height adds them. */
32
36
  const FULL_BLUR_SHORTFALL = 6;
37
+ /** From the height where the blur is whole, the fade runs on 28 more (the 34 of the veil less its shortfall). */
38
+ const FADE_PAST = 28;
@@ -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
  }
@@ -459,6 +459,21 @@ TabBarRoot.displayName = "TabBar";
459
459
  export const TabBar = Object.assign(TabBarRoot, { Item: TabBarItem });
460
460
  /** A scroll of at least this many points in one direction minimizes or expands the bar, as on the web. */
461
461
  const MINIMIZE_AFTER = 8;
462
+ /**
463
+ * Where the tab bar's capsule stands, for what floats over it (a screen's floating buttons a set gap above it, a
464
+ * scroll that ends over it): `capsuleHeight`, and `bottom`, from the screen's bottom edge to the capsule's. iOS 26: the
465
+ * 54pt tabs in a capsule 4 above and below (62), 21 over the screen's bottom (or over the home indicator); Android:
466
+ * 56dp, 8 over the gesture bar. The bar itself (its soft edge) reaches higher. Pass the bar's `safeArea`.
467
+ */
468
+ export function useTabBarMetrics({ safeArea = true, minimized = false } = {}) {
469
+ const theme = useTheme();
470
+ const insets = useSafeAreaInsets();
471
+ if (theme.isAndroid)
472
+ return { capsuleHeight: 56, bottom: 8 + (safeArea ? insets.bottom : 0) };
473
+ const padBottom = minimized ? theme.length("--tab-bar-minimized-padding-bottom", 28) : theme.length("--tab-bar-padding-bottom", 21);
474
+ 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);
475
+ return { capsuleHeight, bottom: safeArea ? Math.max(padBottom, insets.bottom - 13) : padBottom };
476
+ }
462
477
  /**
463
478
  * Minimizes a TabBar while the screen scrolls down and expands it when it scrolls back up, as iOS 26
464
479
  * `tabBarMinimizeBehavior(.onScrollDown)`: pass `onScroll` to the ScrollView and `minimized` and
@@ -1,9 +1,13 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { Linking, Platform, Text as RNText } from "react-native";
3
+ import { Linking, Platform, Pressable, Text as RNText } from "react-native";
4
4
  import { controlHighlight } from "../../theme/material";
5
5
  import { useTheme } from "../../theme/ThemeProvider";
6
+ import { Button, buttonColors } from "../Button/Button";
7
+ import { Text } from "../Text/Text";
6
8
  const EXTERNAL = /^https?:\/\//;
9
+ /** The underline's distance under the letters on the web: the token, else a tenth of the type. */
10
+ const underlineOffset = (value) => (typeof value === "number" ? value : typeof value === "string" && value !== "" ? value : "0.1em");
7
11
  /**
8
12
  * A link in running text, as @plexui/ui's TextLink: put it inside a `Text`, whose face, size and color it takes
9
13
  * (the web's `currentcolor`), underlined; `primary` colors it with `--link-primary-text-color` and drops the underline.
@@ -11,25 +15,41 @@ const EXTERNAL = /^https?:\/\//;
11
15
  * row in the Plex Android look (the text's ink at 11%, white at 5% at night). With `href` it is a `link` and opens the
12
16
  * URL (an `<a>` on the web, a new tab for an external one); with only `onPress` it is a `button`.
13
17
  */
14
- export function TextLink({ children, href, primary = false, underline = !primary, forceExternal, onPress, weight, accessibilityLabel, testID, style }) {
18
+ export function TextLink({ children, href, primary = false, underline = !primary, forceExternal, onPress, weight, standalone = false, accessibilityLabel, testID, style }) {
15
19
  const theme = useTheme();
16
20
  const [pressed, setPressed] = useState(false);
17
21
  const external = forceExternal ?? EXTERNAL.test(href ?? "");
18
22
  const web = Platform.OS === "web";
19
23
  const press = (event) => {
20
24
  onPress?.(event);
25
+ // On the web the link is an anchor the browser opens (a new tab for an external one)
21
26
  if (!href || web || prevented(event))
22
27
  return;
23
28
  void Linking.openURL(href).catch(() => { });
24
29
  };
25
- const actionable = href != null || onPress != null;
26
30
  // react-native-web draws a Text with `href` as an anchor: the browser opens it, a new tab for an external one
27
31
  const anchor = web && href ? { href, hrefAttrs: external ? { target: "_blank", rel: "noopener noreferrer" } : undefined } : null;
32
+ if (standalone) {
33
+ const role = href ? "link" : "button";
34
+ // A pressable is a View, which react-native-web draws as an anchor with the same `href`
35
+ const link = anchor;
36
+ if (theme.isAndroid)
37
+ return (_jsx(Button, { ...link, variant: "ghost", color: "primary", size: "sm", onPress: press, accessibilityRole: role, accessibilityLabel: accessibilityLabel, testID: testID, children: weight != null || style != null ? (
38
+ // A caller's face or type over the button's label (14/20 Medium in the primary)
39
+ _jsx(Text, { weight: weight ?? "medium", color: buttonColors(theme, "primary", "ghost", false, false).text, style: [{ fontSize: 14, lineHeight: 20 }, style], children: children })) : (children) }));
40
+ return (
41
+ // UIButton's plain style: no frame, the text faded while held, the target 44 tall
42
+ _jsx(Pressable, { ...link, onPress: press, accessibilityRole: role, accessibilityLabel: accessibilityLabel, testID: testID, hitSlop: { left: 8, right: 8 }, style: ({ pressed: held }) => ({ minHeight: 44, justifyContent: "center", alignSelf: "flex-start", opacity: held ? 0.35 : 1 }), children: _jsx(Text, { weight: weight ?? "regular", color: theme.color("--link-primary-text-color", theme.colors.textAccent), style: [{ fontSize: 15, lineHeight: 20 }, style], children: children }) }));
43
+ }
44
+ const actionable = href != null || onPress != null;
28
45
  // iOS's own Text highlights a press (as UITextView's links); elsewhere the press layer of a row
29
46
  const highlight = theme.isIOS && !web ? null : pressed ? { backgroundColor: controlHighlight(theme.scheme) } : null;
30
47
  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
48
  primary ? { color: theme.color("--link-primary-text-color", theme.colors.textAccent) } : null,
32
49
  underline ? { textDecorationLine: "underline" } : null,
50
+ // The web sets the line a tenth of the type under the letters (`--link-underline-decoration-offset`), clear of
51
+ // the descenders; a phone draws it where the platform does
52
+ underline && Platform.OS === "web" ? { textUnderlineOffset: underlineOffset(theme.token("--link-underline-decoration-offset")) } : null,
33
53
  weight ? theme.font(weight) : null,
34
54
  highlight,
35
55
  style,
package/dist/es/index.js CHANGED
@@ -11,7 +11,7 @@ export { Glass } from "./internal/Glass";
11
11
  export { BarItemContext } from "./components/Button/Button";
12
12
  export { NavigationButton } from "./components/NavigationButton/NavigationButton";
13
13
  export { Toolbar, } from "./components/Toolbar/Toolbar";
14
- export { TabBar, useTabBarMinimize, } from "./components/TabBar/TabBar";
14
+ export { TabBar, useTabBarMetrics, useTabBarMinimize, } from "./components/TabBar/TabBar";
15
15
  export { SegmentedControl, } from "./components/SegmentedControl/SegmentedControl";
16
16
  export { Switch } from "./components/Switch/Switch";
17
17
  export { Checkbox } from "./components/Checkbox/Checkbox";
@@ -38,7 +38,7 @@ export { Badge } from "./components/Badge/Badge";
38
38
  export { BottomActions } from "./components/BottomActions/BottomActions";
39
39
  export { IntroHeader } from "./components/IntroHeader/IntroHeader";
40
40
  export { Card, cardColors } from "./components/Card/Card";
41
- export { List, ListItem } from "./components/List/List";
41
+ export { List, ListItem, ListStack, useListMetrics } from "./components/List/List";
42
42
  export { Chip } from "./components/Chip/Chip";
43
43
  export { Skeleton } from "./components/Skeleton/Skeleton";
44
44
  export { Progress, progressSegments } from "./components/Progress/Progress";
@@ -1,6 +1,18 @@
1
1
  import { useId } from "react";
2
2
  import { Platform } from "react-native";
3
3
  import { textOf } from "./children";
4
+ /**
5
+ * A hint (what a press does) for a screen reader: `accessibilityHint` on a phone; on the web, where React Native Web
6
+ * drops that prop, the id of an unseen text (`nodeProps`, the text's `nativeID`) that `aria-describedby` points at.
7
+ */
8
+ export function useHint(hint) {
9
+ const id = useId();
10
+ if (hint == null || hint === "")
11
+ return { id: undefined, props: {} };
12
+ return { id: Platform.OS === "web" ? id : undefined, props: Platform.OS === "web" ? { "aria-describedby": id } : { accessibilityHint: hint } };
13
+ }
14
+ /** Ids for `aria-describedby`, the empty ones left out. */
15
+ export const describedBy = (...ids) => ids.filter(Boolean).join(" ") || undefined;
4
16
  /**
5
17
  * The description of a control for a screen reader: read after its label and state, as VoiceOver and TalkBack
6
18
  * read a hint, and tied to the text by `aria-describedby` on the web. Give `id` to the description's text as its
@@ -1,4 +1,5 @@
1
1
  import { createContext } from "react";
2
+ import { Platform } from "react-native";
2
3
  /**
3
4
  * Inside the end of a List row. On iOS a control there takes the row's look, as the web's controls in a `[data-row]` do.
4
5
  * A pop-up shows its value in the row's type with the menu picker's chevrons and no field of its own; a field is the
@@ -50,3 +51,15 @@ export function holdProps(own, row, actions = [], onAction) {
50
51
  },
51
52
  };
52
53
  }
54
+ /**
55
+ * The row's hint on the control that takes the row's focus, kept with the control's own description: a phone reads
56
+ * both as one hint; on the web the control is described by its description and the row's unseen hint text.
57
+ */
58
+ export function rowHint(row, described) {
59
+ if (row?.hint == null)
60
+ return null;
61
+ if (Platform.OS === "web")
62
+ return row.hintId != null ? { "aria-describedby": [described.id, row.hintId].filter(Boolean).join(" ") } : null;
63
+ const own = described.props.accessibilityHint;
64
+ return { accessibilityHint: own ? `${own}. ${row.hint}` : row.hint };
65
+ }
@@ -196,8 +196,10 @@ export function ThemeProvider({ scheme, platform, selectionColor, brand, fonts:
196
196
  // The phone layers of the CSS apply up to 767px: a tablet keeps the touch sizes. Only the bands of the CSS matter.
197
197
  const band = width >= 414 ? 414 : 393;
198
198
  const highDensity = PixelRatio.get() >= 1.5;
199
- const own = brandOverrides(brand);
200
- const overrides = parent?.overrides || own ? { ...parent?.overrides, ...own } : undefined;
199
+ const own = brandOverrides(brand ?? undefined);
200
+ // `brand={null}` starts again from Plex UI's tokens rather than from the parent's brand
201
+ const inherited = brand === null ? undefined : parent?.overrides;
202
+ const overrides = inherited || own ? { ...inherited, ...own } : undefined;
201
203
  const overridesKey = JSON.stringify(overrides ?? null);
202
204
  const resolver = useMemo(() => {
203
205
  const context = { width: band, highDensity, reducedMotion };
@@ -219,6 +219,8 @@ export const elevationShadow = {
219
219
  bar: "0 2px 8px rgba(0, 0, 0, 0.06)",
220
220
  /** The same over a dark screen, where a light shadow does not show: the controls stand apart by their fill. */
221
221
  barDark: "0 2px 8px rgba(0, 0, 0, 0.3)",
222
+ /** Level 1: an elevated card. */
223
+ level1: "0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15)",
222
224
  level2: "0 2px 6px 2px rgba(0, 0, 0, 0.15), 0 1px 2px rgba(0, 0, 0, 0.3)",
223
225
  level3: "0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 8px 3px rgba(0, 0, 0, 0.15)",
224
226
  };
@@ -24,6 +24,11 @@ export type BottomActionsProps = {
24
24
  background?: BottomActionsBackground;
25
25
  /** The color the floating edge fades into: the screen's (a grouped screen's gray). @default the theme's background */
26
26
  canvasColor?: string;
27
+ /**
28
+ * No main action: the lone Button takes the second action's look (iOS 26's glass capsule, Android's ghost button),
29
+ * as a step whose rows move on by themselves keeps only its way past ("Skip"). @default false
30
+ */
31
+ secondary?: boolean;
27
32
  testID?: string;
28
33
  style?: StyleProp<ViewStyle>;
29
34
  };
@@ -34,4 +39,4 @@ export type BottomActionsProps = {
34
39
  * action stands under it, 8 apart. Android: the Plex Android look's 48dp full-width button, 16dp from the sides and
35
40
  * 16 above the gesture bar. Each Button inside is a block of the size `3xl` unless it sets its own.
36
41
  */
37
- export declare function BottomActions({ children, floating, background, canvasColor, testID, style }: BottomActionsProps): import("react").JSX.Element;
42
+ export declare function BottomActions({ children, floating, background, canvasColor, secondary, testID, style }: BottomActionsProps): import("react").JSX.Element;