@plexui/react-native 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +34 -0
  2. package/dist/es/components/ActionSheet/ActionSheet.js +53 -19
  3. package/dist/es/components/Alert/Alert.js +163 -0
  4. package/dist/es/components/Avatar/Avatar.js +20 -8
  5. package/dist/es/components/BottomActions/BottomActions.js +34 -0
  6. package/dist/es/components/BottomSheet/BottomSheet.js +85 -17
  7. package/dist/es/components/Button/Button.js +108 -28
  8. package/dist/es/components/Card/Card.js +16 -8
  9. package/dist/es/components/Checkbox/Checkbox.js +67 -99
  10. package/dist/es/components/Chip/Chip.js +16 -7
  11. package/dist/es/components/Dialog/Dialog.js +38 -24
  12. package/dist/es/components/Field/Field.js +91 -0
  13. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +59 -0
  14. package/dist/es/components/Icon/createIcon.js +13 -2
  15. package/dist/es/components/Indicator/CircularProgress.js +80 -0
  16. package/dist/es/components/Indicator/LoadingDots.js +46 -0
  17. package/dist/es/components/Indicator/LoadingIndicator.js +101 -0
  18. package/dist/es/components/Indicator/index.js +3 -0
  19. package/dist/es/components/Input/Input.js +69 -60
  20. package/dist/es/components/InputGroup/InputGroup.js +130 -0
  21. package/dist/es/components/List/List.js +175 -59
  22. package/dist/es/components/Menu/Menu.js +69 -40
  23. package/dist/es/components/NavigationButton/NavigationButton.js +20 -4
  24. package/dist/es/components/OTPInput/OTPInput.js +9 -3
  25. package/dist/es/components/PageControl/PageControl.js +13 -7
  26. package/dist/es/components/Popover/Popover.js +128 -0
  27. package/dist/es/components/Progress/Progress.js +142 -0
  28. package/dist/es/components/ProgressSteps/ProgressSteps.js +207 -0
  29. package/dist/es/components/RollingNumber/RollingNumber.js +125 -0
  30. package/dist/es/components/Select/Select.js +97 -34
  31. package/dist/es/components/Separator/Separator.js +31 -0
  32. package/dist/es/components/ShimmerText/ShimmerText.js +98 -0
  33. package/dist/es/components/Stepper/Stepper.js +219 -0
  34. package/dist/es/components/Switch/Switch.js +26 -12
  35. package/dist/es/components/TagInput/TagInput.js +121 -0
  36. package/dist/es/components/Text/Text.js +7 -4
  37. package/dist/es/components/TextLink/TextLink.js +42 -0
  38. package/dist/es/components/Textarea/Textarea.js +12 -0
  39. package/dist/es/components/Tip/Tip.js +193 -0
  40. package/dist/es/components/Toolbar/Toolbar.js +6 -2
  41. package/dist/es/components/Tooltip/Tooltip.js +272 -0
  42. package/dist/es/index.js +20 -2
  43. package/dist/es/internal/FloatingPanel.js +111 -0
  44. package/dist/es/internal/fieldStack.js +73 -0
  45. package/dist/es/internal/floating.js +97 -0
  46. package/dist/es/internal/ripple.js +119 -0
  47. package/dist/es/internal/row.js +2 -1
  48. package/dist/es/internal/transition.js +113 -0
  49. package/dist/es/theme/ThemeProvider.js +41 -9
  50. package/dist/es/theme/material.js +37 -7
  51. package/dist/types/components/ActionSheet/ActionSheet.d.ts +15 -7
  52. package/dist/types/components/Alert/Alert.d.ts +51 -0
  53. package/dist/types/components/Avatar/Avatar.d.ts +4 -2
  54. package/dist/types/components/BottomActions/BottomActions.d.ts +18 -0
  55. package/dist/types/components/BottomSheet/BottomSheet.d.ts +4 -2
  56. package/dist/types/components/Button/Button.d.ts +20 -5
  57. package/dist/types/components/Card/Card.d.ts +14 -1
  58. package/dist/types/components/Checkbox/Checkbox.d.ts +4 -3
  59. package/dist/types/components/Chip/Chip.d.ts +12 -1
  60. package/dist/types/components/Dialog/Dialog.d.ts +9 -5
  61. package/dist/types/components/Field/Field.d.ts +64 -0
  62. package/dist/types/components/FloatingLabelInput/FloatingLabelInput.d.ts +42 -0
  63. package/dist/types/components/Indicator/CircularProgress.d.ts +34 -0
  64. package/dist/types/components/Indicator/LoadingDots.d.ts +17 -0
  65. package/dist/types/components/Indicator/LoadingIndicator.d.ts +46 -0
  66. package/dist/types/components/Indicator/index.d.ts +3 -0
  67. package/dist/types/components/Input/Input.d.ts +13 -3
  68. package/dist/types/components/InputGroup/InputGroup.d.ts +71 -0
  69. package/dist/types/components/List/List.d.ts +57 -14
  70. package/dist/types/components/Menu/Menu.d.ts +4 -0
  71. package/dist/types/components/NavigationButton/NavigationButton.d.ts +11 -3
  72. package/dist/types/components/OTPInput/OTPInput.d.ts +10 -1
  73. package/dist/types/components/PageControl/PageControl.d.ts +11 -1
  74. package/dist/types/components/Popover/Popover.d.ts +86 -0
  75. package/dist/types/components/Progress/Progress.d.ts +56 -0
  76. package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +61 -0
  77. package/dist/types/components/RollingNumber/RollingNumber.d.ts +36 -0
  78. package/dist/types/components/Select/Select.d.ts +36 -8
  79. package/dist/types/components/Separator/Separator.d.ts +19 -0
  80. package/dist/types/components/ShimmerText/ShimmerText.d.ts +28 -0
  81. package/dist/types/components/Stepper/Stepper.d.ts +61 -0
  82. package/dist/types/components/Switch/Switch.d.ts +5 -5
  83. package/dist/types/components/TagInput/TagInput.d.ts +44 -0
  84. package/dist/types/components/TextLink/TextLink.d.ts +30 -0
  85. package/dist/types/components/Textarea/Textarea.d.ts +19 -0
  86. package/dist/types/components/Tip/Tip.d.ts +71 -0
  87. package/dist/types/components/Toolbar/Toolbar.d.ts +9 -1
  88. package/dist/types/components/Tooltip/Tooltip.d.ts +84 -0
  89. package/dist/types/index.d.ts +20 -2
  90. package/dist/types/internal/FloatingPanel.d.ts +70 -0
  91. package/dist/types/internal/fieldStack.d.ts +48 -0
  92. package/dist/types/internal/floating.d.ts +71 -0
  93. package/dist/types/internal/ripple.d.ts +17 -0
  94. package/dist/types/internal/row.d.ts +15 -3
  95. package/dist/types/internal/transition.d.ts +37 -0
  96. package/dist/types/theme/ThemeProvider.d.ts +28 -4
  97. package/dist/types/theme/material.d.ts +20 -6
  98. package/dist/types/theme/types.d.ts +8 -0
  99. package/package.json +2 -2
  100. package/src/components/ActionSheet/ActionSheet.tsx +107 -38
  101. package/src/components/Alert/Alert.tsx +279 -0
  102. package/src/components/Avatar/Avatar.tsx +21 -9
  103. package/src/components/BottomActions/BottomActions.tsx +54 -0
  104. package/src/components/BottomSheet/BottomSheet.tsx +111 -25
  105. package/src/components/Button/Button.tsx +170 -35
  106. package/src/components/Card/Card.tsx +33 -9
  107. package/src/components/Checkbox/Checkbox.tsx +89 -124
  108. package/src/components/Chip/Chip.tsx +49 -6
  109. package/src/components/Dialog/Dialog.tsx +68 -37
  110. package/src/components/Field/Field.tsx +227 -0
  111. package/src/components/FloatingLabelInput/FloatingLabelInput.tsx +144 -0
  112. package/src/components/Icon/createIcon.tsx +16 -6
  113. package/src/components/Indicator/CircularProgress.tsx +141 -0
  114. package/src/components/Indicator/LoadingDots.tsx +79 -0
  115. package/src/components/Indicator/LoadingIndicator.tsx +166 -0
  116. package/src/components/Indicator/index.ts +3 -0
  117. package/src/components/Input/Input.tsx +126 -97
  118. package/src/components/InputGroup/InputGroup.tsx +261 -0
  119. package/src/components/List/List.tsx +345 -88
  120. package/src/components/Menu/Menu.tsx +83 -41
  121. package/src/components/NavigationButton/NavigationButton.tsx +35 -5
  122. package/src/components/OTPInput/OTPInput.tsx +21 -2
  123. package/src/components/PageControl/PageControl.tsx +36 -8
  124. package/src/components/Popover/Popover.tsx +261 -0
  125. package/src/components/Progress/Progress.tsx +255 -0
  126. package/src/components/ProgressSteps/ProgressSteps.tsx +415 -0
  127. package/src/components/RollingNumber/RollingNumber.tsx +189 -0
  128. package/src/components/Select/Select.tsx +175 -71
  129. package/src/components/Separator/Separator.tsx +51 -0
  130. package/src/components/ShimmerText/ShimmerText.tsx +144 -0
  131. package/src/components/Stepper/Stepper.tsx +386 -0
  132. package/src/components/Switch/Switch.tsx +26 -12
  133. package/src/components/TagInput/TagInput.tsx +227 -0
  134. package/src/components/Text/Text.tsx +8 -4
  135. package/src/components/TextLink/TextLink.tsx +77 -0
  136. package/src/components/Textarea/Textarea.tsx +23 -0
  137. package/src/components/Tip/Tip.tsx +410 -0
  138. package/src/components/Toolbar/Toolbar.tsx +27 -2
  139. package/src/components/Tooltip/Tooltip.tsx +478 -0
  140. package/src/index.ts +36 -2
  141. package/src/internal/FloatingPanel.tsx +199 -0
  142. package/src/internal/fieldStack.tsx +179 -0
  143. package/src/internal/floating.ts +131 -0
  144. package/src/internal/ripple.tsx +132 -0
  145. package/src/internal/row.ts +16 -3
  146. package/src/internal/transition.ts +124 -0
  147. package/src/theme/ThemeProvider.tsx +65 -15
  148. package/src/theme/material.ts +39 -7
  149. package/src/theme/types.ts +8 -0
package/README.md CHANGED
@@ -92,6 +92,14 @@ const minimize = useTabBarMinimize()
92
92
  or filled (`soft`) text field with its floating label.
93
93
  - `OTPInput` (`length`, `value`, `onChange`, `onComplete`, `grouping`, `invalid`, `errorMessage`): a one-time code,
94
94
  one digit per cell, autofilled from the keyboard; the web's phone cells on iOS, outlined code boxes on Android.
95
+ - `Field` (`label`, `description`, `errorMessage`, `required`, `hideLabel`, `orientation`, `row`) and `FieldError`: a
96
+ label, help and an error around a control, on its own or as a row of a `List` (`columns`, `headerProminence`,
97
+ `action`; a ghost `Button` among the rows is an action row), as the cells of an iOS form.
98
+ - `Textarea` (`rows`, `autoResize`, `maxRows`, `autoSelect`), `FloatingLabelInput` (`label`, `type`, `revealable`,
99
+ `multiline`, `labelPlacement`): several lines; a label floating onto the Android outline, a cell named by its
100
+ placeholder on iOS.
101
+ - `InputGroup` with `.Input`, `.Textarea`, `.Addon` (`align`), `.Button`, `.Text`: a field with a prefix, a unit, a
102
+ menu or a button; `TagInput` (`value`, `onChange`, `validator`, `maxTags`, `delimiters`): typed words as tags.
95
103
  - `Select` (`options`, `value`, `onChange(option)`): the field and a menu with a checkmark at the chosen option.
96
104
  - `Menu` (`Trigger`, `Content`, `Item`, `Separator`, `Label`): iOS 26 glass menu; Material 3 dropdown menu.
97
105
  - `Dialog` (`title`, `description`, `actions`): the iOS 26 alert; Material 3's basic dialog.
@@ -125,6 +133,32 @@ toast.success("Payment sent", { description: "$24.00 to Jane", action: { label:
125
133
  - `Slider` (`label`, `value`, `onChange`, `min`, `max`, `step`, `unit`, `marks`, `resetValue`; `range` with a value
126
134
  for each thumb; `orientation="vertical"`): the iOS 26 slider; Material 3's Slider, RangeSlider and VerticalSlider.
127
135
  - `PageControl` (`count`, `value`, `onChange`): the iOS page dots, tapped or scrubbed.
136
+ - `Separator` (`orientation`, `decorative`) and `TextLink` (`href`, `primary`, `underline`, `onPress`), a link inside
137
+ a `Text`.
138
+
139
+ ### Progress
140
+
141
+ - `Progress` (`value`, `max`, `segments`, `size`, `color`; `value={null}` sweeps): the iOS progress view; Material 3's
142
+ linear progress indicator.
143
+ - `ProgressSteps` with `.Step` (`icon`), `.Title` (`visuallyHidden`), `.Description` (`current`, `orientation`, `size`,
144
+ `color`, `connectorStyle`; `variant="minimal"` with `total`): the steps of a flow, a check once completed.
145
+ - `Stepper` (`value`, `onChange`, `min`, `max`, `step`, `wrap`, `autoRepeat`, `showValue`, `onRemove`): UIStepper's
146
+ two segments, or a cart's quantity with a trash can at one; adjustable for screen readers.
147
+ - `LoadingIndicator` (`size`, `color`, `duration`), `CircularProgress` (`progress`, `done`, `maxDuration`),
148
+ `LoadingDots`: the iOS spinner and Material 3's circular indicator, a progress ring, three pulsing dots.
149
+ - `ShimmerText` and `ShimmerableText` (`shimmer`): a highlight sweeping across a label; `RollingNumber` (`value`,
150
+ `format`, `locales`): each changed digit rolls to the new value. All of them stand still with reduced motion.
151
+
152
+ ### Messages
153
+
154
+ - `Alert` (`color`, `variant`, `title`, `description`, `actions`, `mobileActions`, `indicator`, `onDismiss`, `banner`):
155
+ an inline message in the shape of an iOS tip, its actions as capsules.
156
+ - `Tip` (`title`, `description`, `icon`, `actions`, `mobileActions`, `onClose`, `arrowEdge`) and `Tip.Popover`: TipKit's
157
+ inline and popover tips; on Android a card with Material 3's rich tooltip layout.
158
+ - `Popover` with `Popover.Trigger`, `.Content` and `usePopoverController()`: the compact glass panel of an iPhone
159
+ popover; a popup on Android.
160
+ - `Tooltip` (`content`, `compact`, `side`, `forceOpen`) with `Tooltip.TriggerDecorator`, and `CopyTooltip`
161
+ (`copyValue`): shown on a long press; Material 3's plain and rich tooltips on Android.
128
162
 
129
163
  ```tsx
130
164
  <List header="General" footer="Notifications show on the lock screen.">
@@ -2,20 +2,24 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useId, useRef, useState } from "react";
3
3
  import { Animated, Platform, Pressable, ScrollView, StyleSheet, View, useWindowDimensions } from "react-native";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
+ import { FloatingPanel } from "../../internal/FloatingPanel";
5
6
  import { Glass } from "../../internal/Glass";
6
7
  import { glassOpacity, iosDim, Overlay } from "../../internal/Overlay";
7
8
  import { dangerText } from "../../theme/material";
8
9
  import { useTheme } from "../../theme/ThemeProvider";
9
10
  import { BottomSheetBase } from "../BottomSheet/BottomSheet";
10
11
  import { IconDefaultsProvider } from "../Icon/createIcon";
12
+ import { measure } from "../Menu/Menu";
11
13
  import { Text } from "../Text/Text";
12
14
  /**
13
- * A choice of actions from the bottom of the screen (React Native only: the web has a Menu). iOS 26 draws
14
- * UIAlertController's `.actionSheet` on an iPhone: a glass panel of 48pt capsule actions with the title and message
15
- * over them, and the cancel capsule apart under it; Android a menu sheet (its items: 48dp rows of Regular 16, the
16
- * icon in a 56dp slot in the ink, gray at night, the text 16 in with no icons, a gray title of 16 over them).
15
+ * A choice of actions (React Native only: the web has a Menu, a Popover or an alert Dialog). iOS 26 draws
16
+ * UIAlertController's `.actionSheet` on an iPhone: with a `source`, a glass panel at that control (as the web's
17
+ * Popover "Confirmation"), its 48pt capsule actions under the title and message, no Cancel, closed by a tap outside;
18
+ * with no source, the same panel in the middle of the screen, Cancel its last capsule (as the web's alert Dialog with a
19
+ * stacked footer). Android a menu sheet (its items: 48dp rows of Regular 16, the icon in a 56dp slot in the ink, gray
20
+ * at night, the text 16 in with no icons, a gray title of 16 over them).
17
21
  */
18
- export function ActionSheet({ open, onOpenChange, title, message, actions, cancelLabel = "Cancel", testID }) {
22
+ export function ActionSheet({ open, onOpenChange, title, message, actions, cancelLabel = "Cancel", source, testID }) {
19
23
  const theme = useTheme();
20
24
  const insets = useSafeAreaInsets();
21
25
  const { height: screen } = useWindowDimensions();
@@ -52,6 +56,29 @@ export function ActionSheet({ open, onOpenChange, title, message, actions, cance
52
56
  close();
53
57
  };
54
58
  const ids = { title: useId(), message: useId() };
59
+ // The source's place, measured as the sheet opens (and again when the window turns)
60
+ const [anchor, setAnchor] = useState(null);
61
+ // A source that measures to nothing (no view yet, or one with no size): the sheet stands in the middle instead
62
+ const [unplaced, setUnplaced] = useState(false);
63
+ const { width: windowWidth } = useWindowDimensions();
64
+ const sourced = !theme.isAndroid && source != null && !unplaced;
65
+ useEffect(() => {
66
+ if (!open || theme.isAndroid || source == null)
67
+ return;
68
+ let live = true;
69
+ // A new opening measures again: the panel never shows at the source's last place first
70
+ setAnchor(null);
71
+ measure(source.current, (box) => {
72
+ if (!live)
73
+ return;
74
+ const placed = box.width > 0 || box.height > 0;
75
+ setAnchor(placed ? box : null);
76
+ setUnplaced(!placed);
77
+ });
78
+ return () => {
79
+ live = false;
80
+ };
81
+ }, [open, theme.isAndroid, source, windowWidth, screen]);
55
82
  if (theme.isAndroid) {
56
83
  const m = theme.material;
57
84
  const icons = actions.some((action) => action.icon);
@@ -80,7 +107,12 @@ export function ActionSheet({ open, onOpenChange, title, message, actions, cance
80
107
  backgroundColor: theme.color("--dialog-alert-fill"),
81
108
  opacity: pressed ? 0.7 : 1,
82
109
  },
83
- ], children: _jsx(Text, { weight: preferred ? "semibold" : "medium", color: item.disabled ? theme.color("--mobile-label-tertiary") : item.destructive ? theme.color("--color-text-danger") : theme.colors.text, style: styles.iosLabel, children: item.label }) }, key));
110
+ ], children: _jsx(Text, { weight: "semibold", color: item.disabled ? theme.color("--mobile-label-tertiary") : item.destructive ? theme.color("--color-background-danger-solid") : theme.colors.text, style: styles.iosLabel, children: item.label }) }, key));
111
+ const header = title != null || message != null ? (_jsxs(View, { style: styles.iosHeader, children: [title != null ? (_jsx(Text, { nativeID: ids.title, weight: "semibold", accessibilityRole: "header", style: styles.iosHeaderText, children: title })) : null, message != null ? (_jsx(Text, { nativeID: ids.message, style: styles.iosHeaderText, children: message })) : null] })) : null;
112
+ if (sourced) {
113
+ // At its source: the phone popover's glass and corners (the web's Popover "Confirmation"), no Cancel
114
+ return (_jsx(FloatingPanel, { open: open && anchor != null, onDismiss: close, anchor: anchor, side: "top", align: "center", sideOffset: 8, collisionPadding: { top: Math.max(insets.top, 8), bottom: Math.max(insets.bottom, 8), left: 8, right: 8 }, glass: true, role: "dialog", "aria-label": typeof title === "string" ? title : undefined, testID: testID, style: { width: Math.min(windowWidth - 16, theme.length("--action-sheet-source-width", 300)), maxHeight: screen - insets.top - insets.bottom - 16 }, children: () => (_jsx(Glass, { radius: theme.length("--popover-radius", 34), elevation: "raised", fillToken: "--popover-mobile-background", filterToken: "--popover-mobile-backdrop-filter", shadowToken: "--menu-shadow", style: styles.iosPanel, children: _jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.iosList, bounces: false, children: [header, actions.map((item, index) => action(item, index))] }) })) }));
115
+ }
84
116
  // The web names the sheet by its title and describes it by its message; a phone keeps the modal view
85
117
  const a11y = Platform.OS === "web"
86
118
  ? {
@@ -90,35 +122,37 @@ export function ActionSheet({ open, onOpenChange, title, message, actions, cance
90
122
  "aria-describedby": message != null ? ids.message : undefined,
91
123
  }
92
124
  : { accessibilityViewIsModal: true };
93
- return (_jsx(Overlay, { open: open, onDismiss: close, scrim: iosDim(theme), motion: "sheet", testID: testID, children: (progress, opening, focus) => (_jsx(View, { pointerEvents: "box-none", style: styles.bottom, children: _jsxs(Animated.View, { ...a11y,
125
+ return (_jsx(Overlay, { open: open, onDismiss: close, scrim: iosDim(theme), testID: testID, children: (progress, opening, focus) => (_jsx(View, { pointerEvents: "box-none", style: styles.center, children: _jsx(Animated.View, { ...a11y,
94
126
  // On the web the sheet itself takes the first focus, not its first action with a ring
95
127
  tabIndex: focus.tabIndex, onBlur: focus.onBlur, style: [
96
128
  focus.style,
97
129
  styles.iosStack,
98
- // An offset, not a transform: a transform would stop the glass's blur on the web
99
130
  {
100
- maxHeight: screen - insets.top - 8,
101
- paddingBottom: Math.max(insets.bottom, 8),
131
+ maxHeight: screen - insets.top - insets.bottom - 16,
102
132
  opacity: glassOpacity(progress, opening),
103
- // With reduced motion it fades in place
104
- top: theme.reducedMotion ? 0 : progress.interpolate({ inputRange: [0, 1], outputRange: [80, 0] }),
133
+ // An alert's entrance: it grows from 1.1 as it fades in; with reduced motion it fades in place. A
134
+ // transform would stop the glass's blur on the web, so the web only fades
135
+ transform: theme.reducedMotion || Platform.OS === "web" ? undefined : [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [1.1, 1] }) }],
105
136
  },
106
- ], children: [_jsx(Glass, { radius: theme.length("--dialog-alert-radius", 34), elevation: "raised", fillToken: "--dialog-alert-background", style: [styles.iosPanel, styles.shrink], children: _jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.iosList, bounces: false, children: [title != null || message != null ? (_jsxs(View, { style: styles.iosHeader, children: [title != null ? (_jsx(Text, { nativeID: ids.title, weight: "semibold", color: theme.color("--dialog-alert-message-color"), accessibilityRole: "header", style: styles.iosHeaderText, children: title })) : null, message != null ? (_jsx(Text, { nativeID: ids.message, color: theme.color("--dialog-alert-message-color"), style: styles.iosHeaderText, children: message })) : null] })) : null, actions.map((item, index) => action(item, index))] }) }), _jsx(Glass, { radius: theme.length("--dialog-alert-radius", 34), elevation: "raised", fillToken: "--dialog-alert-background", style: styles.iosPanel, children: action({
137
+ ], children: _jsxs(Glass, { radius: theme.length("--dialog-alert-radius", 34), elevation: "raised", fillToken: "--dialog-alert-background", style: [styles.iosPanel, styles.shrink], children: [_jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.iosList, bounces: false, children: [header, actions.map((item, index) => action(item, index))] }), action({
107
138
  label: cancelLabel,
108
139
  testID: testID ? `${testID}-cancel` : undefined,
109
- }, "cancel", true) })] }) })) }));
140
+ }, "cancel", true)] }) }) })) }));
110
141
  }
111
142
  /** How fast Android's menu sheet leaves after an item's tap, in ms. */
112
143
  const ANDROID_PICK_EXIT = 180;
113
144
  const styles = StyleSheet.create({
114
- bottom: { flex: 1, justifyContent: "flex-end" },
115
- iosStack: { paddingHorizontal: 8, gap: 8 },
116
- iosPanel: { padding: 16, gap: 8 },
145
+ center: { flex: 1, justifyContent: "center", alignItems: "center" },
146
+ // An alert's width at most (the kit's 300), 8 from the screen's edges on a narrow phone
147
+ iosStack: { width: "100%", maxWidth: 316, paddingHorizontal: 8 },
148
+ // iOS 27's action sheet (the iOS kit): 14 around, the actions 8 apart
149
+ iosPanel: { padding: 14, gap: 8 },
117
150
  iosList: { gap: 8 },
118
151
  shrink: { flexShrink: 1 },
119
152
  scroll: { flexGrow: 0 },
120
- iosHeader: { paddingHorizontal: 15, paddingTop: 4, paddingBottom: 6, gap: 2 },
121
- iosHeaderText: { fontSize: 13, lineHeight: 18, textAlign: "center" },
153
+ // The title Semibold and the message Regular, both Body 17/22 in the label color at the start, 8 in, 24 over the actions
154
+ iosHeader: { paddingHorizontal: 8, paddingTop: 8, paddingBottom: 16, gap: 10 },
155
+ iosHeaderText: { fontSize: 17, lineHeight: 22 },
122
156
  iosAction: {
123
157
  alignItems: "center",
124
158
  justifyContent: "center",
@@ -0,0 +1,163 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cloneElement, isValidElement, useState } from "react";
3
+ import { Pressable, StyleSheet, View } from "react-native";
4
+ import CheckCircle from "../../icons/plex/CheckCircle";
5
+ import InfoCircle from "../../icons/plex/InfoCircle";
6
+ import Warning from "../../icons/plex/Warning";
7
+ import X from "../../icons/plex/X";
8
+ import { flattenChildren, isRenderable } from "../../internal/children";
9
+ import { useTheme } from "../../theme/ThemeProvider";
10
+ import { Button, buttonColors } from "../Button/Button";
11
+ import { IconDefaultsProvider } from "../Icon/createIcon";
12
+ import { Text, TextColorProvider } from "../Text/Text";
13
+ /** The icon of a color, as the web chooses it: a warning for warning, caution and danger, a check for success. */
14
+ function DefaultIndicator({ color }) {
15
+ if (color === "warning" || color === "caution" || color === "danger")
16
+ return _jsx(Warning, {});
17
+ if (color === "success")
18
+ return _jsx(CheckCircle, {});
19
+ return _jsx(InfoCircle, {});
20
+ }
21
+ /** The icon's color on a gray alert: the color's text, lighter in the dark where the text would read under 3:1. */
22
+ function tintOf(theme, color) {
23
+ const dark = theme.scheme === "dark";
24
+ switch (color) {
25
+ case "primary":
26
+ return theme.color("--mobile-label-secondary", theme.colors.textSecondary);
27
+ case "warning":
28
+ return theme.color(dark ? "--orange-300" : "--color-text-warning");
29
+ case "danger":
30
+ return theme.color(dark ? "--red-300" : "--color-text-danger");
31
+ case "discovery":
32
+ return theme.color(dark ? "--purple-200" : "--color-text-discovery");
33
+ default:
34
+ return theme.color(`--color-text-${color}`);
35
+ }
36
+ }
37
+ /** The colors of an alert on a phone (Alert.module.css, `max-width: 767px`). */
38
+ export function alertColors(theme, color, variant) {
39
+ if (variant === "solid") {
40
+ const text = theme.color(`--color-text-${color}-solid`);
41
+ return { background: theme.color(`--color-background-${color}-solid`), title: text, description: text, icon: text };
42
+ }
43
+ return {
44
+ background: theme.color("--alert-phone-background", theme.color("--color-background-secondary-soft-alpha")),
45
+ title: theme.colors.text,
46
+ // The secondary label at its native 60%, 70% in the dark
47
+ description: theme.color("--alert-phone-description-color", theme.color(theme.scheme === "dark" ? "--alpha-70" : "--alpha-60")),
48
+ icon: theme.color("--alert-phone-indicator-color", tintOf(theme, color)),
49
+ };
50
+ }
51
+ /**
52
+ * The phone's numbers of each platform. iOS: an inline tip of TipKit as Alert.module.css draws it at 767px and below
53
+ * (26 corners, 17/16 padding, a 22 symbol drawn at 26.4 6 in, the text at 56, 18 above the actions, 50pt capsules 8
54
+ * apart, a 26 close circle in a 44 target 5 from the corner). Android: the same card in the Plex Android look (16dp
55
+ * corners as its cards, 16 padding, a 24dp icon 16 from the text, Title M and Body M, 40dp buttons, the close glyph
56
+ * 24dp in a 48dp target).
57
+ */
58
+ function metricsOf(theme) {
59
+ if (theme.isAndroid) {
60
+ return { radius: 16, paddingTop: 16, paddingBottom: 16, paddingBottomActions: 16, paddingX: 16, glyph: 24, iconBox: 24, iconStart: 0, iconEnd: 0, gap: 16, rowGap: 16, close: { target: 48, circle: 0, icon: 24, offset: 4, room: 32 }, capsule: "lg" };
61
+ }
62
+ const glyph = 22;
63
+ return {
64
+ radius: 26,
65
+ paddingTop: 17,
66
+ paddingBottom: 17,
67
+ paddingBottomActions: 16,
68
+ paddingX: 16,
69
+ glyph,
70
+ // A Plex icon draws its circle 20 of its 24: the icon is 26.4 so that its circle is TipKit's 22
71
+ iconBox: (glyph * 24) / 20,
72
+ iconStart: 6,
73
+ iconEnd: 4,
74
+ gap: 8,
75
+ rowGap: 18,
76
+ close: { target: 44, circle: 26, icon: 19, offset: 5, room: 34 },
77
+ capsule: "xl",
78
+ };
79
+ }
80
+ /**
81
+ * An inline message (a notice, a warning), as @plexui/ui's Alert on a phone: the shape and text of an iOS tip
82
+ * (TipKit), the system's message inside a screen. A soft or outline alert is gray with the icon in its color, a solid
83
+ * one keeps its color; the actions stand under the message as capsules side by side; `onDismiss` puts a close button
84
+ * in the corner. Neither platform has an inline alert of its own: Android draws the same card in its own sizes. A
85
+ * danger alert is announced as an `alert`.
86
+ */
87
+ export function Alert({ color = "primary", variant = "outline", title, description, actions, mobileActions = "capsules", indicator, onDismiss, dismissLabel = "Dismiss", banner = false, testID, style, actionsStyle, }) {
88
+ const theme = useTheme();
89
+ const android = theme.isAndroid;
90
+ const m = metricsOf(theme);
91
+ const colors = alertColors(theme, color, variant);
92
+ const [actionsWidth, setActionsWidth] = useState(0);
93
+ const hasTitle = isRenderable(title);
94
+ const hasDescription = isRenderable(description);
95
+ const hasIndicator = indicator !== false;
96
+ const items = flattenChildren(actions).filter(isRenderable);
97
+ const hasActions = items.length > 0;
98
+ const own = mobileActions === "own";
99
+ const dismissible = onDismiss != null;
100
+ // The first line of text stands on the middle of the icon: TipKit's 5 above and below a 22 symbol on iOS; on
101
+ // Android the icon sits on the title's 24 line, or 2 above a description's 20
102
+ const firstLine = hasTitle ? (android ? 24 : 22) : 20;
103
+ const iconMargin = android ? { top: (firstLine - m.glyph) / 2, bottom: 0 } : hasTitle && hasDescription ? { top: 0, bottom: 10 } : { top: 5, bottom: 5 };
104
+ const messageAlign = android
105
+ ? {}
106
+ : hasTitle && !hasDescription
107
+ ? { alignSelf: "center" }
108
+ : !hasTitle && hasIndicator
109
+ ? { marginTop: 5 + m.glyph / 2 - 10 }
110
+ : {};
111
+ // The first line stops short of the close button
112
+ const closeRoom = dismissible ? { paddingEnd: m.close.room } : null;
113
+ // Capsules share the row, each at least half of it; `own` buttons keep their size and start under the text
114
+ const half = actionsWidth > 0 ? (actionsWidth - 8) / 2 : undefined;
115
+ const actionItems = items.map((item, index) => {
116
+ if (own || !isValidElement(item) || item.type !== Button)
117
+ return item;
118
+ const button = item;
119
+ return cloneElement(button, {
120
+ key: button.key ?? index,
121
+ size: m.capsule,
122
+ pill: true,
123
+ style: [button.props.style, styles.capsule, { minWidth: half }],
124
+ });
125
+ });
126
+ const textStart = hasIndicator ? m.iconStart + m.glyph + m.iconEnd + m.gap : android ? 0 : 6;
127
+ return (_jsxs(View, { testID: testID, role: color === "danger" ? "alert" : undefined, style: [
128
+ styles.alert,
129
+ {
130
+ columnGap: m.gap,
131
+ rowGap: m.rowGap,
132
+ paddingTop: m.paddingTop,
133
+ paddingBottom: hasActions ? m.paddingBottomActions : m.paddingBottom,
134
+ paddingHorizontal: m.paddingX,
135
+ borderRadius: banner ? 0 : m.radius,
136
+ backgroundColor: colors.background,
137
+ },
138
+ style,
139
+ ], children: [hasIndicator ? (_jsx(View, { style: [
140
+ styles.indicator,
141
+ { paddingStart: m.iconStart, paddingEnd: m.iconEnd, marginTop: iconMargin.top, marginBottom: iconMargin.bottom, minHeight: m.glyph, minWidth: m.glyph },
142
+ ], children: _jsx(IconDefaultsProvider, { size: m.iconBox, color: colors.icon, children: _jsx(View, { style: { width: m.glyph, height: m.glyph, alignItems: "center", justifyContent: "center" }, children: _jsx(View, { style: { margin: (m.glyph - m.iconBox) / 2 }, children: indicator ?? _jsx(DefaultIndicator, { color: color }) }) }) }) })) : null, _jsxs(View, { style: [styles.message, { paddingStart: hasIndicator || android ? 0 : 6 }, messageAlign], children: [hasTitle ? (_jsx(Text, { variant: "headline", color: colors.title, style: closeRoom, children: title })) : null, hasDescription ? (_jsx(TextColorProvider, { value: colors.description, children: _jsx(Text, { variant: "subheadline", color: colors.description, style: [hasTitle ? (android ? styles.androidDescription : styles.description) : closeRoom], children: description }) })) : null] }), hasActions ? (_jsx(View, { onLayout: (event) => setActionsWidth(event.nativeEvent.layout.width), style: [styles.actions, { paddingStart: own ? textStart : 0 }, actionsStyle], children: actionItems })) : null, dismissible ? _jsx(CloseButton, { onPress: onDismiss, label: dismissLabel, close: m.close }) : null] }));
143
+ }
144
+ /**
145
+ * The close button of a phone alert: on iOS a 26 circle of a soft secondary button with a 19 cross, in a 44 target 5
146
+ * from the corner (Alert.module.css); on Android the cross alone, 24dp in a 48dp target, in the secondary ink.
147
+ */
148
+ function CloseButton({ onPress, label, close }) {
149
+ const theme = useTheme();
150
+ const colors = buttonColors(theme, "secondary", "soft", false, false);
151
+ return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress: onPress, style: [styles.close, { width: close.target, height: close.target, top: close.offset, end: close.offset }], children: ({ pressed }) => close.circle > 0 ? (_jsx(View, { style: { width: close.circle, height: close.circle, borderRadius: close.circle / 2, alignItems: "center", justifyContent: "center", backgroundColor: pressed ? colors.pressed : colors.background }, children: _jsx(X, { size: close.icon, color: pressed && colors.pressedText ? colors.pressedText : colors.text }) })) : (_jsx(X, { size: close.icon, color: theme.colors.labelSecondary, style: pressed ? styles.pressed : undefined })) }));
152
+ }
153
+ const styles = StyleSheet.create({
154
+ alert: { position: "relative", flexDirection: "row", flexWrap: "wrap", alignItems: "flex-start", alignSelf: "stretch", borderCurve: "continuous" },
155
+ indicator: { flexShrink: 0, alignItems: "center", justifyContent: "center" },
156
+ message: { flex: 1, minWidth: 0 },
157
+ description: { marginTop: 2, marginBottom: 4 },
158
+ androidDescription: { marginTop: 2 },
159
+ actions: { flexBasis: "100%", flexGrow: 1, flexDirection: "row", flexWrap: "wrap", gap: 8 },
160
+ capsule: { flexGrow: 1, flexShrink: 0, flexBasis: "auto", maxWidth: "100%" },
161
+ close: { position: "absolute", alignItems: "center", justifyContent: "center" },
162
+ pressed: { opacity: 0.6 },
163
+ });
@@ -70,13 +70,15 @@ export function avatarColors(theme, color, variant) {
70
70
  * `variant="gradient"` it is a gradient of one of seven colors from top to bottom with up to two white initials,
71
71
  * Medium at 18/50 of the circle.
72
72
  */
73
- export function Avatar({ name, imageUrl, color = "secondary", variant = "soft", size: sizeProp, Icon, overflowCount, onPress, accessibilityLabel, testID, style }) {
73
+ export function Avatar({ name, imageUrl, source: sourceProp, color = "secondary", variant = "soft", size: sizeProp, Icon, overflowCount, onPress, accessibilityLabel, testID, style }) {
74
74
  const theme = useTheme();
75
75
  const [failed, setFailed] = useState(false);
76
+ const source = sourceProp ?? (imageUrl ? { uri: imageUrl } : undefined);
76
77
  // A new picture gets its own try, even one that failed before
77
- const [shown, setShown] = useState(imageUrl);
78
- if (shown !== imageUrl) {
79
- setShown(imageUrl);
78
+ const pictureKey = sourceKey(source);
79
+ const [shown, setShown] = useState(pictureKey);
80
+ if (shown !== pictureKey) {
81
+ setShown(pictureKey);
80
82
  setFailed(false);
81
83
  }
82
84
  const size = sizeProp ?? theme.length("--avatar-size", 28);
@@ -92,8 +94,8 @@ export function Avatar({ name, imageUrl, color = "secondary", variant = "soft",
92
94
  const placeholder = label ? (_jsxs(Text, { weight: "semibold", maxFontSizeMultiplier: 1.3, color: colors.text, style: { fontSize, lineHeight: fontSize * 1.2 }, children: ["+", label] })) : Icon ? (
93
95
  // The web's icon is 0.7 of the circle (`.AvatarIcon`, 1em of a 0.7 font size)
94
96
  _jsx(Icon, { size: size * 0.7, color: colors.text })) : gradient ? (_jsx(Text, { weight: "medium", maxFontSizeMultiplier: 1.3, color: colors.text, style: { fontSize: size * 0.36, lineHeight: size * 0.36 * 1.2 }, children: twoInitials(name ?? "") })) : (_jsx(Text, { weight: "semibold", maxFontSizeMultiplier: 1.3, color: colors.text, style: { fontSize, lineHeight: fontSize * 1.2 }, children: initialOf(name ?? "") }));
95
- const showImage = !!imageUrl && !failed;
96
- const body = (_jsxs(_Fragment, { children: [fill ? (_jsxs(Svg, { pointerEvents: "none", width: size, height: size, style: StyleSheet.absoluteFill, children: [_jsx(Defs, { children: _jsxs(LinearGradient, { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx(Stop, { offset: "0", stopColor: fill[0] }), _jsx(Stop, { offset: "1", stopColor: fill[1] })] }) }), _jsx(Circle, { cx: size / 2, cy: size / 2, r: size / 2, fill: `url(#${gradientId})` })] })) : null, fill ? _jsx(View, { pointerEvents: "none", children: placeholder }) : placeholder, showImage ? (_jsxs(View, { style: [StyleSheet.absoluteFill, { borderRadius: size / 2, overflow: "hidden" }], children: [_jsx(Picture, { uri: imageUrl, fade: theme.isAndroid ? (theme.reducedMotion ? 0 : 150) : undefined, onError: () => setFailed(true) }, imageUrl), _jsx(View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { borderRadius: size / 2, borderWidth: 1, borderColor: theme.color("--avatar-image-border-color") }] })] })) : null] }));
97
+ const showImage = source != null && !failed;
98
+ const body = (_jsxs(_Fragment, { children: [fill ? (_jsxs(Svg, { pointerEvents: "none", width: size, height: size, style: StyleSheet.absoluteFill, children: [_jsx(Defs, { children: _jsxs(LinearGradient, { id: gradientId, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx(Stop, { offset: "0", stopColor: fill[0] }), _jsx(Stop, { offset: "1", stopColor: fill[1] })] }) }), _jsx(Circle, { cx: size / 2, cy: size / 2, r: size / 2, fill: `url(#${gradientId})` })] })) : null, fill ? _jsx(View, { pointerEvents: "none", children: placeholder }) : placeholder, showImage ? (_jsxs(View, { style: [StyleSheet.absoluteFill, { borderRadius: size / 2, overflow: "hidden" }], children: [_jsx(Picture, { source: source, fade: theme.isAndroid ? (theme.reducedMotion ? 0 : 150) : undefined, onError: () => setFailed(true) }, pictureKey), _jsx(View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { borderRadius: size / 2, borderWidth: 1, borderColor: theme.color("--avatar-image-border-color") }] })] })) : null] }));
97
99
  const box = [styles.avatar, { width: size, height: size, borderRadius: size / 2, backgroundColor: colors.background }, style];
98
100
  if (onPress) {
99
101
  return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel ?? name,
@@ -106,10 +108,20 @@ export function Avatar({ name, imageUrl, color = "secondary", variant = "soft",
106
108
  * The picture. Android fades it in over `fade` ms, linear, once it has loaded: a device's Image does it itself (its
107
109
  * own fade is 300ms), elsewhere the picture's opacity runs. Left out, the platform's own way stays.
108
110
  */
109
- function Picture({ uri, fade, onError }) {
111
+ /** What tells one picture from another: its address, or the asset a `require()` gives. */
112
+ function sourceKey(source) {
113
+ if (source == null)
114
+ return undefined;
115
+ if (typeof source === "number")
116
+ return `asset:${source}`;
117
+ if (Array.isArray(source))
118
+ return source.map((item) => item.uri ?? "").join("|");
119
+ return source.uri ?? JSON.stringify(source);
120
+ }
121
+ function Picture({ source, fade, onError }) {
110
122
  const fades = fade != null && fade > 0 && Platform.OS !== "android";
111
123
  const [opacity] = useState(() => new Animated.Value(fades ? 0 : 1));
112
- return (_jsx(Animated.Image, { source: { uri }, onError: onError, fadeDuration: Platform.OS === "android" ? fade : undefined, onLoad: fades ? () => Animated.timing(opacity, { toValue: 1, duration: fade, easing: Easing.linear, useNativeDriver: false }).start() : undefined, style: [StyleSheet.absoluteFill, { opacity }], accessibilityIgnoresInvertColors: true }));
124
+ return (_jsx(Animated.Image, { source: source, onError: onError, fadeDuration: Platform.OS === "android" ? fade : undefined, onLoad: fades ? () => Animated.timing(opacity, { toValue: 1, duration: fade, easing: Easing.linear, useNativeDriver: false }).start() : undefined, style: [StyleSheet.absoluteFill, { opacity }], accessibilityIgnoresInvertColors: true }));
113
125
  }
114
126
  /**
115
127
  * Avatars that overlap, the first on top and each cutting the next by a ring of the screen's background
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, cloneElement, isValidElement } from "react";
3
+ import { StyleSheet, View } from "react-native";
4
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
5
+ import { useTheme } from "../../theme/ThemeProvider";
6
+ import { Button } from "../Button/Button";
7
+ /**
8
+ * The main action at the bottom of a phone screen: an onboarding's "Continue", a form's "Create account". iOS 26: a
9
+ * capsule across the screen, 36pt from its sides, 52pt tall, its bottom just over the home indicator (2pt above the
10
+ * safe area, about 36pt from the screen's edge on a Face ID iPhone), as iOS 26's own setup screens set it; a second
11
+ * action stands under it, 8 apart. Android: the Plex Android look's 48dp full-width button, 16dp from the sides and
12
+ * 16 above the gesture bar. Each Button inside is a block of the size `3xl` unless it sets its own.
13
+ */
14
+ export function BottomActions({ children, floating = false, testID, style }) {
15
+ const theme = useTheme();
16
+ const insets = useSafeAreaInsets();
17
+ const android = theme.isAndroid;
18
+ const side = android ? 16 : 36;
19
+ // iOS: 2pt over the safe area (34 on a Face ID iPhone); a phone with a home button has none, so 16 there
20
+ const bottom = android ? Math.max(insets.bottom, 0) + 16 : insets.bottom > 0 ? insets.bottom + 2 : 16;
21
+ const height = android ? 48 : 52;
22
+ const actions = Children.toArray(children).map((child) => isValidElement(child) && child.type === Button
23
+ ? cloneElement(child, {
24
+ block: child.props.block ?? true,
25
+ size: child.props.size ?? "3xl",
26
+ style: [{ minHeight: height, borderRadius: height / 2 }, child.props.style],
27
+ })
28
+ : child);
29
+ return (_jsx(View, { testID: testID, pointerEvents: "box-none", style: [styles.bar, { paddingHorizontal: side, paddingBottom: bottom, gap: 8 }, floating ? styles.floating : null, style], children: actions }));
30
+ }
31
+ const styles = StyleSheet.create({
32
+ bar: { alignSelf: "stretch", paddingTop: 8 },
33
+ floating: { position: "absolute", left: 0, right: 0, bottom: 0 },
34
+ });
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { isValidElement, useId, useLayoutEffect, useState } from "react";
2
+ import { isValidElement, useId, useLayoutEffect, useMemo, useState } from "react";
3
3
  import { Animated, Easing, PanResponder, Platform, Pressable, ScrollView, StyleSheet, View, useWindowDimensions } from "react-native";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
  import { childrenOfType, flattenChildren } from "../../internal/children";
@@ -7,6 +7,7 @@ import { useKeyboardHeight } from "../../internal/keyboard";
7
7
  import { iosDim, Overlay, ANDROID_DIM } from "../../internal/Overlay";
8
8
  import { withAlpha } from "../../theme/material";
9
9
  import { useTheme } from "../../theme/ThemeProvider";
10
+ import { BarItemContext } from "../Button/Button";
10
11
  import { NavigationButton } from "../NavigationButton/NavigationButton";
11
12
  import { Text } from "../Text/Text";
12
13
  /**
@@ -188,8 +189,9 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
188
189
  }, [open, drag]);
189
190
  const keyboard = useKeyboardHeight(open);
190
191
  const m = theme.material;
191
- // Android's sheet: 24dp top corners (measured on a Pixel), the dialog's background (white, near-black in dark mode)
192
- const radius = android ? 24 : theme.length("--dialog-sheet-radius", 38);
192
+ // Android's sheet: 35dp top corners, concentric with its bar's 46dp circles 12 in from its top and sides (23 + 12),
193
+ // the dialog's background (white, near-black in dark mode)
194
+ const radius = android ? 35 : theme.length("--dialog-sheet-radius", 38);
193
195
  // iOS: the panel of the phone layer, --mobile-surface-elevated-plain-primary (Dialog.module.css), white in light and
194
196
  // the elevated near-black in dark
195
197
  const background = android
@@ -197,7 +199,8 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
197
199
  ? m.surfaceContainer
198
200
  : m.surfaceContainerLowest
199
201
  : theme.color("--mobile-surface-elevated-plain-primary", theme.color("--color-surface-elevated", theme.colors.background));
200
- const titleType = android ? { fontSize: 20, lineHeight: 24 } : { fontSize: theme.length("--toolbar-title-font-size", 17), lineHeight: theme.length("--toolbar-title-line-height", 22) };
202
+ // Android's sheet title: 17/22 Medium, centered in its bar, as iOS's
203
+ const titleType = android ? { fontSize: 17, lineHeight: 22 } : { fontSize: theme.length("--toolbar-title-font-size", 17), lineHeight: theme.length("--toolbar-title-line-height", 22) };
201
204
  const titleId = useId();
202
205
  const web = Platform.OS === "web";
203
206
  // The web names the dialog by its title; a phone keeps the modal view
@@ -210,8 +213,16 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
210
213
  const maxWidth = android && width > screen ? Math.max(width * 0.8, Math.min(480, width)) : undefined;
211
214
  const closeSize = theme.length("--dialog-sheet-close-size", 44);
212
215
  const margin = theme.length("--mobile-layout-margin", 16);
213
- // Android's sheet has no handle: the whole sheet takes the drag, its top with the title (Medium 20, 21 in)
214
- const header = android ? (_jsx(View, { onStartShouldSetResponderCapture: gesture.chrome, style: title != null ? styles.androidHeader : styles.androidGrip, children: title != null ? (_jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "medium", color: m.onSurface, style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title })) : null })) : dismissible || title != null ? (
216
+ // Android: content scrolled under the bar fades out under it; the footer's height sets the room under the content
217
+ const [scrolled, setScrolled] = useState(false);
218
+ const [footerHeight, setFooterHeight] = useState(0);
219
+ // Android's sheet has no handle: the whole sheet takes the drag. With a title its bar is the reference's sheet bar,
220
+ // over the content: Close in a 46dp glass circle 12 under the top edge and 12 from the side (in line with the
221
+ // content's cards), concentric with the sheet's corner, the title 17/22 Medium centered between the circles' places
222
+ // (69 in all). Content scrolled under it shows through the sheet's color at
223
+ // 63% over a light blur, let go over its last 32dp (12 past the bar), with no line
224
+ const barItem = useMemoBarItem(background);
225
+ const header = android ? (title != null ? (_jsxs(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidBar, children: [_jsx(SheetBarFade, { fill: background, shown: scrolled }), _jsx(View, { style: styles.androidCircle, children: dismissible ? (_jsx(BarItemContext.Provider, { value: barItem, children: _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) })) : null }), _jsx(View, { style: styles.androidHeading, children: _jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "medium", align: "center", numberOfLines: 1, color: m.onSurface, style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title }) }), _jsx(View, { style: styles.androidCircle })] })) : (_jsx(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidGrip }))) : dismissible || title != null ? (
215
226
  // The web's phone Sheet bar: one 44 row 16 under the top edge, Close at the leading edge and the title alone centered
216
227
  // The bar is the web's Toolbar: 16 above the row and --toolbar-padding-bottom under it
217
228
  _jsxs(View, { ...responder.panHandlers, style: [styles.iosBar, { paddingTop: theme.length("--dialog-sheet-action-inset-block", 16), paddingBottom: theme.length("--toolbar-padding-bottom", 10), paddingHorizontal: margin }], children: [_jsx(View, { style: { width: closeSize, height: closeSize }, children: dismissible ? _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) : null }), _jsx(View, { style: [styles.iosHeading, { minHeight: closeSize }], children: title != null ? (_jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "semibold", align: "center", style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title })) : null }), _jsx(View, { style: { width: closeSize } })] })) : null;
@@ -243,17 +254,68 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
243
254
  opacity: reduced ? progress : undefined,
244
255
  transform: [{ translateY: reduced ? drag : slide(progress) }],
245
256
  },
246
- ], children: [header, _jsx(ScrollView, { style: styles.scroll, ...(android ? { ...gesture.content, scrollEventThrottle: 16 } : null), contentContainerStyle: [android ? [styles.androidContent, footer ? styles.androidContentOverFooter : null] : iosContent, contentStyle], keyboardShouldPersistTaps: "handled", bounces: false, children: content }), footer ? (_jsxs(View, { onStartShouldSetResponderCapture: android ? gesture.chrome : undefined, style: [
247
- android ? styles.androidFooter : [styles.iosFooter, { paddingHorizontal: margin, paddingBottom: keyboard ? 16 : Math.max(16, insets.bottom) }],
257
+ ], children: [android && title != null ? null : header, _jsx(ScrollView, { style: styles.scroll, ...(android
258
+ ? {
259
+ ...gesture.content,
260
+ onScroll: (event) => {
261
+ gesture.content.onScroll(event);
262
+ const under = event.nativeEvent.contentOffset.y > 0;
263
+ if (under !== scrolled)
264
+ setScrolled(under);
265
+ },
266
+ scrollEventThrottle: 16,
267
+ }
268
+ : null), contentContainerStyle: [
269
+ android
270
+ ? [
271
+ styles.androidContent,
272
+ title != null ? styles.androidContentUnderBar : null,
273
+ // Over a footer: 8 above its height, which reaches over the sheet's bottom padding
274
+ footer ? { paddingBottom: 8 + Math.max(0, footerHeight - insets.bottom - keyboard) } : null,
275
+ ]
276
+ : iosContent,
277
+ contentStyle,
278
+ ], keyboardShouldPersistTaps: "handled", bounces: false, children: content }), android && title != null ? header : null, footer ? (_jsxs(View, { onStartShouldSetResponderCapture: android ? gesture.chrome : undefined, onLayout: android ? (event) => setFooterHeight(event.nativeEvent.layout.height) : undefined, style: [
279
+ android
280
+ ? [
281
+ styles.androidFooter,
282
+ // Over the sheet's color at 80%, faded in over its top 24dp, down over the gesture bar
283
+ { paddingBottom: 12 + insets.bottom + keyboard, backgroundImage: `linear-gradient(to bottom, ${withAlpha(background, 0)}, ${withAlpha(background, 0.8)} 24px)` },
284
+ ]
285
+ : [styles.iosFooter, { paddingHorizontal: margin, paddingBottom: keyboard ? 16 : Math.max(16, insets.bottom) }],
248
286
  footer.props.style,
249
287
  ], children: [android ? null : (_jsx(View, { pointerEvents: "none", style: [styles.iosFooterEdge, { backgroundImage: `linear-gradient(${withAlpha(background, 0)}, ${background} 27px)` }] })), footer.props.children] })) : null] }), android && Platform.OS === "android" && dismissible ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel, onPress: close, style: [styles.scrimTarget, { bottom: height }] })) : null] })) }));
250
288
  }
251
289
  const isFooter = (child) => isValidElement(child) && child.type === BottomSheetFooter;
290
+ /** The item of an Android sheet's bar: a 46dp glass circle solved against the sheet's color. */
291
+ function useMemoBarItem(canvas) {
292
+ return useMemo(() => ({ height: 46, fontSize: 15, lineHeight: 20, weight: "medium", prominentWeight: "medium", iconSize: 24, gutter: 16, canvas }), [canvas]);
293
+ }
294
+ /**
295
+ * The fade under an Android sheet's bar once content is under it: the sheet's color at 63% over a light blur (8),
296
+ * reaching 12 past the bar and let go over its last 32 (a mask on the web; a gradient of the color where there is no
297
+ * mask or blur).
298
+ */
299
+ function SheetBarFade({ fill, shown }) {
300
+ const veil = withAlpha(fill, 0.63);
301
+ const style = Platform.OS === "web"
302
+ ? {
303
+ backgroundColor: veil,
304
+ backdropFilter: "blur(8px)",
305
+ WebkitBackdropFilter: "blur(8px)",
306
+ maskImage: "linear-gradient(to bottom, #000 calc(100% - 32px), transparent)",
307
+ WebkitMaskImage: "linear-gradient(to bottom, #000 calc(100% - 32px), transparent)",
308
+ }
309
+ : { backgroundImage: `linear-gradient(to bottom, ${veil} calc(100% - 32px), ${withAlpha(fill, 0)})` };
310
+ return _jsx(View, { pointerEvents: "none", style: [styles.androidBarFade, style, { opacity: shown ? 1 : 0 }] });
311
+ }
252
312
  /**
253
313
  * A sheet from the bottom edge: on iOS 26 the sheet of the phone layer (`--dialog-sheet-radius` 38 on its top corners,
254
314
  * a bar 16 under its top edge with Close at the leading edge and the title centered, as the web's phone Sheet; no
255
- * grabber, since its height does not change), on Android a flat sheet (24dp top corners, white, a Medium 20 title
256
- * at 21, no handle, a 20% dim, the screen's width in portrait). Drag it down to close it: its bar on iOS, anywhere on
315
+ * grabber, since its height does not change), on Android the reference's sheet (35dp top corners, white, no handle,
316
+ * a bar of 46dp glass circles 12 under the top edge and 12 from the sides, concentric with the corners, with the title
317
+ * 17 Medium centered, the
318
+ * content 12 from the sides, a 20% dim, the screen's width in portrait). Drag it down to close it: its bar on iOS, anywhere on
257
319
  * Android (from content that scrolls once it is at its top, and on a phone only from its rows and fields, since its
258
320
  * plain parts keep the drag for the scroll).
259
321
  * `BottomSheet.Footer` pins actions under the content.
@@ -266,14 +328,20 @@ const styles = StyleSheet.create({
266
328
  iosBar: { flexDirection: "row", alignItems: "center", gap: 8 },
267
329
  iosHeading: { flex: 1, alignItems: "center", justifyContent: "center" },
268
330
  scrimTarget: { position: "absolute", top: 0, left: 0, right: 0 },
269
- // The title's 24 line 20 from the top edge and 8 over the content; with no title the top 8 of the sheet's padding
270
- androidHeader: { paddingTop: 20, paddingBottom: 8, paddingHorizontal: 21 },
331
+ // The bar: 46dp circles 12 under the top edge and 12 from the sides, 11 under them; with no title the top 8 of the
332
+ // sheet's padding
333
+ androidBar: { position: "absolute", top: 0, left: 0, right: 0, zIndex: 1, flexDirection: "row", alignItems: "center", paddingTop: 12, paddingBottom: 11, paddingHorizontal: 12, gap: 6 },
334
+ androidBarFade: { position: "absolute", top: 0, left: 0, right: 0, bottom: -12 },
335
+ androidCircle: { width: 46, height: 46 },
336
+ androidHeading: { flex: 1, minWidth: 0, alignItems: "center", justifyContent: "center" },
271
337
  androidGrip: { height: 8 },
272
- // The content at the title's 21, with the sheet's 8 under it (16 over the navigation bar)
273
- androidContent: { paddingHorizontal: 21, paddingTop: 4, paddingBottom: 16 },
274
- androidContentOverFooter: { paddingBottom: 8 },
338
+ // The content 12 from the sides (as a page's groups), 16 over the navigation bar; under a bar 13 under its circles
339
+ // (71 from the sheet's top, 2 under the bar)
340
+ androidContent: { paddingHorizontal: 12, paddingTop: 4, paddingBottom: 16 },
341
+ androidContentUnderBar: { paddingTop: 12 + 46 + 13 },
275
342
  iosFooter: { gap: 10, paddingTop: 12 },
276
343
  iosFooterEdge: { position: "absolute", top: -15, left: 0, right: 0, bottom: 0 },
277
- // Android's sheet actions: a 48dp button 16 from the sides, a text button under it, 16 under the last
278
- androidFooter: { gap: 4, paddingHorizontal: 16, paddingTop: 8, paddingBottom: 16 },
344
+ // Android's sheet actions: 48dp buttons 4 apart, 12 from the sides and above, 12 over the gesture bar, over the
345
+ // content that scrolls under them
346
+ androidFooter: { position: "absolute", left: 0, right: 0, bottom: 0, gap: 4, paddingHorizontal: 12, paddingTop: 12 },
279
347
  });