@plexui/react-native 0.2.32 → 0.4.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.
- package/dist/es/components/ActionSheet/ActionSheet.js +1 -1
- package/dist/es/components/BottomSheet/BottomSheet.js +34 -6
- package/dist/es/components/Button/Button.js +21 -4
- package/dist/es/components/Dialog/Dialog.js +13 -3
- package/dist/es/components/List/List.js +15 -1
- package/dist/es/components/Menu/Menu.js +24 -10
- package/dist/es/components/SignInButton/SignInButton.js +85 -0
- package/dist/es/components/Tip/Tip.js +29 -12
- package/dist/es/icons/plex/AppleLogo.js +3 -0
- package/dist/es/icons/plex/GoogleLogo.js +3 -0
- package/dist/es/icons/plex/MicrosoftLogo.js +3 -0
- package/dist/es/icons/plex/index.js +3 -0
- package/dist/es/index.js +1 -0
- package/dist/es/internal/Glass.js +15 -8
- package/dist/types/components/BottomSheet/BottomSheet.d.ts +22 -1
- package/dist/types/components/Button/Button.d.ts +6 -2
- package/dist/types/components/Dialog/Dialog.d.ts +6 -2
- package/dist/types/components/SignInButton/SignInButton.d.ts +37 -0
- package/dist/types/icons/plex/AppleLogo.d.ts +2 -0
- package/dist/types/icons/plex/GoogleLogo.d.ts +2 -0
- package/dist/types/icons/plex/MicrosoftLogo.d.ts +2 -0
- package/dist/types/icons/plex/index.d.ts +3 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/internal/Glass.d.ts +7 -1
- package/package.json +2 -2
- package/src/components/ActionSheet/ActionSheet.tsx +1 -0
- package/src/components/BottomSheet/BottomSheet.tsx +93 -8
- package/src/components/Button/Button.tsx +26 -6
- package/src/components/Dialog/Dialog.tsx +33 -14
- package/src/components/List/List.tsx +13 -1
- package/src/components/Menu/Menu.tsx +24 -10
- package/src/components/SignInButton/SignInButton.tsx +168 -0
- package/src/components/Tip/Tip.tsx +68 -12
- package/src/icons/plex/AppleLogo.ts +4 -0
- package/src/icons/plex/GoogleLogo.ts +4 -0
- package/src/icons/plex/MicrosoftLogo.ts +4 -0
- package/src/icons/plex/index.ts +3 -0
- package/src/index.ts +2 -1
- package/src/internal/Glass.tsx +22 -8
|
@@ -99,7 +99,7 @@ export function ActionSheet({ open, onOpenChange, title, message, actions, cance
|
|
|
99
99
|
const icons = actions.some((action) => action.icon);
|
|
100
100
|
return (_jsxs(BottomSheetBase, { open: open, onOpenChange: onOpenChange, testID: testID, contentStyle: styles.androidList, "aria-label": typeof title === "string" ? title : undefined,
|
|
101
101
|
// With reduced motion the exit is at once either way
|
|
102
|
-
exit: quick && !theme.reducedMotion ? ANDROID_PICK_EXIT : undefined, onExited: runPicked, children: [title != null || message != null ? (_jsxs(View, { style: styles.androidHeader, children: [title != null ? (_jsx(Text, { nativeID: ids.title, accessibilityRole: "header", color: theme.colors.labelSecondary, style: styles.androidTitle, children: title })) : null, message != null ? (_jsx(Text, { nativeID: ids.message, color: theme.colors.labelSecondary, style: styles.androidMessage, children: message })) : null] })) : null, actions.map((action, index) => {
|
|
102
|
+
exit: quick && !theme.reducedMotion ? ANDROID_PICK_EXIT : undefined, onExited: runPicked, androidClose: false, children: [title != null || message != null ? (_jsxs(View, { style: styles.androidHeader, children: [title != null ? (_jsx(Text, { nativeID: ids.title, accessibilityRole: "header", color: theme.colors.labelSecondary, style: styles.androidTitle, children: title })) : null, message != null ? (_jsx(Text, { nativeID: ids.message, color: theme.colors.labelSecondary, style: styles.androidMessage, children: message })) : null] })) : null, actions.map((action, index) => {
|
|
103
103
|
const color = action.destructive ? dangerText(theme) : m.onSurface;
|
|
104
104
|
return (_jsxs(Pressable
|
|
105
105
|
// Two actions may share a label: each keeps its place in `actions`
|
|
@@ -11,6 +11,7 @@ import { withAlpha } from "../../theme/material";
|
|
|
11
11
|
import { useTheme } from "../../theme/ThemeProvider";
|
|
12
12
|
import { BarItemContext } from "../Button/Button";
|
|
13
13
|
import { NavigationButton } from "../NavigationButton/NavigationButton";
|
|
14
|
+
import { IconDefaultsProvider } from "../Icon/createIcon";
|
|
14
15
|
import { Text } from "../Text/Text";
|
|
15
16
|
/**
|
|
16
17
|
* The actions of a sheet, pinned under its content, which scrolls above them: the web's `Dialog.Footer` (12 above,
|
|
@@ -168,8 +169,10 @@ function BottomSheetRoot(props) {
|
|
|
168
169
|
return _jsx(BottomSheetBase, { ...props });
|
|
169
170
|
}
|
|
170
171
|
/** The sheet with an exit of its own (ActionSheet's item tap); not part of the public API. */
|
|
171
|
-
export function BottomSheetBase({ open, onOpenChange, title, children, dismissible = true, "aria-label": ariaLabel, testID, contentStyle, closeLabel = "Close", detent = "content", exit, onExited, }) {
|
|
172
|
+
export function BottomSheetBase({ open, onOpenChange, title: titleProp, hero, children, dismissible = true, "aria-label": ariaLabel, testID, contentStyle, closeLabel = "Close", detent = "content", exit, onExited, androidClose = true, }) {
|
|
172
173
|
const theme = useTheme();
|
|
174
|
+
// A hero names the sheet from its content: the bar keeps Close alone
|
|
175
|
+
const title = hero ? undefined : titleProp;
|
|
173
176
|
const insets = useSafeAreaInsets();
|
|
174
177
|
const { width, height: screen } = useWindowDimensions();
|
|
175
178
|
const [height, setHeight] = useState(0);
|
|
@@ -209,7 +212,7 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
209
212
|
const web = Platform.OS === "web";
|
|
210
213
|
// The web names the dialog by its title; a phone keeps the modal view
|
|
211
214
|
const a11y = web
|
|
212
|
-
? { role: "dialog", "aria-modal": true, "aria-labelledby": title != null ? titleId : undefined, "aria-label": title != null ? undefined : ariaLabel }
|
|
215
|
+
? { role: "dialog", "aria-modal": true, "aria-labelledby": title != null || hero ? titleId : undefined, "aria-label": title != null || hero ? undefined : ariaLabel }
|
|
213
216
|
: { accessibilityViewIsModal: true, "aria-label": ariaLabel };
|
|
214
217
|
// Android's sheet stands under the status bar at most; the phone layer's 16 under the top inset
|
|
215
218
|
const maxHeight = screen - insets.top - (android ? 0 : 16);
|
|
@@ -230,7 +233,9 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
230
233
|
// (69 in all). Content scrolled under it shows through the sheet's color at
|
|
231
234
|
// 63% over a light blur, let go over its last 32dp (12 past the bar), with no line
|
|
232
235
|
const barItem = useMemoBarItem(background);
|
|
233
|
-
|
|
236
|
+
// Android's bar stands with a title, or with Close alone where the sheet can be closed (as iOS's)
|
|
237
|
+
const androidBar = android && (title != null || (dismissible && androidClose));
|
|
238
|
+
const header = android ? (androidBar ? (_jsxs(View, { onStartShouldSetResponderCapture: gesture.chrome, onLayout: (event) => setAndroidBarHeight(Math.max(ANDROID_BAR_HEIGHT, event.nativeEvent.layout.height)), style: [styles.androidBar, { paddingHorizontal: androidInline }], 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: title == null ? null : _jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "medium", align: "center", numberOfLines: 2, color: m.onSurface, style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title }) }), _jsx(View, { style: styles.androidCircle })] })) : (_jsx(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidGrip }))) : dismissible || title != null ? (
|
|
234
239
|
// The web's phone Sheet bar: one 44 row 16 under the top edge, Close at the leading edge and the title alone centered
|
|
235
240
|
// The bar is the web's Toolbar: 16 above the row and --toolbar-padding-bottom under it
|
|
236
241
|
_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;
|
|
@@ -264,7 +269,7 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
264
269
|
opacity: reduced ? progress : undefined,
|
|
265
270
|
transform: [{ translateY: reduced ? drag : slide(progress) }],
|
|
266
271
|
},
|
|
267
|
-
], children: [
|
|
272
|
+
], children: [androidBar ? null : header, _jsxs(ScrollView
|
|
268
273
|
// A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
|
|
269
274
|
, {
|
|
270
275
|
// A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
|
|
@@ -286,13 +291,13 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
286
291
|
// A screen whose gutter is Material's compact 16 sets it with --bottom-sheet-android-padding-inline
|
|
287
292
|
{ paddingHorizontal: androidInline },
|
|
288
293
|
// 2 under the bar: 71 under a one-line title
|
|
289
|
-
|
|
294
|
+
androidBar ? { paddingTop: androidBarHeight + 2 } : null,
|
|
290
295
|
// Over a footer: 8 above its height, which reaches over the sheet's bottom padding
|
|
291
296
|
footer ? { paddingBottom: 8 + Math.max(0, footerHeight - insets.bottom - keyboard) } : null,
|
|
292
297
|
]
|
|
293
298
|
: iosContent,
|
|
294
299
|
contentStyle,
|
|
295
|
-
], keyboardShouldPersistTaps: "handled", bounces: false, children:
|
|
300
|
+
], keyboardShouldPersistTaps: "handled", bounces: false, children: [hero ? _jsx(SheetHero, { hero: hero, id: titleId }) : null, content] }), androidBar ? header : null, footer ? (_jsxs(View, { onStartShouldSetResponderCapture: android ? gesture.chrome : undefined, onLayout: android ? (event) => setFooterHeight(event.nativeEvent.layout.height) : undefined, style: [
|
|
296
301
|
android
|
|
297
302
|
? [
|
|
298
303
|
styles.androidFooter,
|
|
@@ -304,6 +309,28 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
304
309
|
footer.props.style,
|
|
305
310
|
], 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] }) })) }));
|
|
306
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* A sheet's hero header. iOS: a 56pt symbol, 12 over a centered Title 1 bold (28/34, 4 more over a 17/22 secondary
|
|
314
|
+
* description), 24 over the content, as Apple's setup sheets. Android: Material's dialog hero, a 24dp icon in the
|
|
315
|
+
* secondary color 16 over a centered headline small (24/32), 16 over a 14/20 onSurfaceVariant text, 24 over the content.
|
|
316
|
+
*/
|
|
317
|
+
function SheetHero({ hero, id }) {
|
|
318
|
+
const theme = useTheme();
|
|
319
|
+
const android = theme.isAndroid;
|
|
320
|
+
const m = theme.material;
|
|
321
|
+
const tone = hero.tone ?? "accent";
|
|
322
|
+
const ink = tone === "accent"
|
|
323
|
+
? android
|
|
324
|
+
? m.secondary
|
|
325
|
+
: theme.colors.accent
|
|
326
|
+
: tone === "secondary"
|
|
327
|
+
? android
|
|
328
|
+
? m.onSurfaceVariant
|
|
329
|
+
: theme.colors.labelSecondary
|
|
330
|
+
: theme.color(`--color-text-${tone}-ghost`, theme.colors.accent);
|
|
331
|
+
const size = android ? 24 : theme.length("--bottom-sheet-hero-icon-size", 56);
|
|
332
|
+
return (_jsxs(View, { style: [styles.hero, { paddingBottom: 24 }], children: [hero.icon != null ? (_jsx(View, { style: { marginBottom: android ? 16 : 12 }, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: _jsx(IconDefaultsProvider, { size: size, color: ink, children: hero.icon }) })) : null, _jsx(Text, { nativeID: id, accessibilityRole: "header", align: "center", weight: android ? "regular" : "bold", color: android ? m.onSurface : undefined, style: android ? { fontSize: 24, lineHeight: 32 } : { fontSize: theme.length("--bottom-sheet-hero-title-font-size", 28), lineHeight: theme.length("--bottom-sheet-hero-title-line-height", 34) }, children: hero.title }), hero.description != null ? (_jsx(Text, { align: "center", color: android ? m.onSurfaceVariant : theme.colors.labelSecondary, style: android ? { fontSize: 14, lineHeight: 20, marginTop: 16 } : { fontSize: 17, lineHeight: 22, marginTop: 4 }, children: hero.description })) : null] }));
|
|
333
|
+
}
|
|
307
334
|
const isFooter = (child) => isValidElement(child) && child.type === BottomSheetFooter;
|
|
308
335
|
/** The item of an Android sheet's bar: a 46dp glass circle solved against the sheet's color. */
|
|
309
336
|
function useMemoBarItem(canvas) {
|
|
@@ -356,6 +383,7 @@ const styles = StyleSheet.create({
|
|
|
356
383
|
androidCircle: { width: 46, height: 46 },
|
|
357
384
|
androidHeading: { flex: 1, minWidth: 0, alignItems: "center", justifyContent: "center" },
|
|
358
385
|
androidGrip: { height: 8 },
|
|
386
|
+
hero: { alignItems: "center" },
|
|
359
387
|
// The content 12 from the sides (as a page's groups), 16 over the navigation bar; under a bar 13 under its circles
|
|
360
388
|
// (71 from the sheet's top, 2 under the bar)
|
|
361
389
|
androidContent: { paddingHorizontal: 12, paddingTop: 4, paddingBottom: 16 },
|
|
@@ -365,22 +365,39 @@ function ButtonBody({ color = "primary", variant = "solid", size = "md", shape =
|
|
|
365
365
|
// its buttons on glass and its plain ones; the token alone gives the Regular of the plain button
|
|
366
366
|
weight: theme.isIOS && variant !== "ghost" ? "medium" : base.weight,
|
|
367
367
|
};
|
|
368
|
-
const
|
|
368
|
+
const barred = barColors(theme, buttonColors(theme, color, variant, disabled, selected), { bar, prominent: accentAction, neutral, disabled, selected, flat: mobileMaterial === "flat" });
|
|
369
|
+
// Clear glass over a photo, a video or a color: the kit's #f5f5f5 label in both themes, on iOS clear glass and on
|
|
370
|
+
// Android (no glass) its gray at 17%, a little more when pressed
|
|
371
|
+
const clear = mobileMaterial === "clear" && neutral && !bar;
|
|
372
|
+
const clearLabel = clear ? theme.color("--mobile-glass-clear-label", "#f5f5f5") : "";
|
|
373
|
+
const colors = clear
|
|
374
|
+
? {
|
|
375
|
+
...barred,
|
|
376
|
+
text: disabled ? withAlpha(clearLabel, 0.4) : clearLabel,
|
|
377
|
+
pressedText: undefined,
|
|
378
|
+
background: theme.color("--mobile-glass-clear-background", "rgba(153, 153, 153, 0.17)"),
|
|
379
|
+
pressed: theme.color("--mobile-glass-clear-background-active", "rgba(153, 153, 153, 0.28)"),
|
|
380
|
+
border: undefined,
|
|
381
|
+
}
|
|
382
|
+
: barred;
|
|
369
383
|
// In a bar every neutral soft or ghost button is glass, as on iOS 26, unless it asks to stay flat or is selected.
|
|
370
384
|
// A disabled glass button keeps its glass, as the phone CSS's
|
|
371
385
|
const wantsGlass = bar ? mobileMaterial !== "flat" && neutral && !selected && !bar.inGroup : mobileMaterial === "glass" && neutral;
|
|
372
|
-
const glass = theme.isIOS && wantsGlass;
|
|
386
|
+
const glass = theme.isIOS && (wantsGlass || clear);
|
|
373
387
|
// On Android the same button stands on a glass of its own, as the Android bar circles: a see-through card with a
|
|
374
388
|
// rim and a soft shadow (the glass of a plain bar)
|
|
375
389
|
const card = theme.isAndroid && !!bar && !bar.plain && (wantsGlass || (accentAction && disabled && !bar.inGroup));
|
|
376
390
|
const androidGlass = useAndroidGlass("bar", bar?.canvas);
|
|
377
391
|
if (glass && !bar) {
|
|
378
|
-
// The Liquid Glass text button of the iOS 27 kit: Medium (`--button-glass-font-weight`), 17/22 at md and lg
|
|
392
|
+
// The Liquid Glass text button of the iOS 27 kit: Medium (`--button-glass-font-weight`), 17/22 at md and lg, 12 a side
|
|
379
393
|
const glassWeight = theme.length("--button-glass-font-weight", 510);
|
|
380
394
|
metrics.weight = glassWeight >= 590 ? "semibold" : glassWeight >= 500 ? "medium" : "regular";
|
|
381
395
|
if (size === "md" || size === "lg") {
|
|
382
396
|
metrics.fontSize = theme.length("--button-glass-font-size", metrics.fontSize);
|
|
383
397
|
metrics.lineHeight = theme.length("--button-glass-line-height", metrics.lineHeight);
|
|
398
|
+
// 12 each side, where a bordered medium button's Subheadline label takes 14
|
|
399
|
+
if (!gutterSize)
|
|
400
|
+
metrics.gutter = theme.length("--button-glass-gutter", metrics.gutter);
|
|
384
401
|
}
|
|
385
402
|
}
|
|
386
403
|
const nativeRipple = useMaterialPress(theme);
|
|
@@ -522,7 +539,7 @@ function ButtonBody({ color = "primary", variant = "solid", size = "md", shape =
|
|
|
522
539
|
...rest,
|
|
523
540
|
};
|
|
524
541
|
if (glass) {
|
|
525
|
-
return (_jsx(Pressable, { ...pressable, style: [{ alignSelf: block ? "stretch" : "flex-start" }, style], children: _jsx(Glass, { interactive: !inert, elevation: bar?.raised ? "raised" : "regular", radius: metrics.radius, fillToken: pressed && !inert ? "--mobile-glass-background-active" : undefined, style: [body, { borderRadius: metrics.radius }], children: content }) }));
|
|
542
|
+
return (_jsx(Pressable, { ...pressable, style: [{ alignSelf: block ? "stretch" : "flex-start" }, style], children: _jsx(Glass, { interactive: !inert, clear: clear, elevation: bar?.raised ? "raised" : "regular", radius: metrics.radius, fillToken: pressed && !inert ? (clear ? "--mobile-glass-clear-background-active" : "--mobile-glass-background-active") : undefined, style: [body, { borderRadius: metrics.radius }], children: content }) }));
|
|
526
543
|
}
|
|
527
544
|
// The pressable is the body: the native ripple is drawn and clipped by the view that has the (animated) corners
|
|
528
545
|
return (_jsxs(AnimatedPressable, { ...pressable, android_ripple: nativeRipple ? { color: pressLayer, foreground: true, ...(dot ? { borderless: true, radius: dot / 2 } : null) } : undefined, style: [body, card ? androidGlass : null, { borderRadius: corners }, scales ? { transform: [{ scale }] } : null, style], children: [layer, content] }));
|
|
@@ -44,7 +44,13 @@ function DialogView({ open, onOpenChange, title, description, actions = [], chil
|
|
|
44
44
|
const ids = { title: useId(), description: useId() };
|
|
45
45
|
// The web names the alert dialog by its title and describes it by its message; a phone keeps the modal view
|
|
46
46
|
const a11y = Platform.OS === "web"
|
|
47
|
-
? {
|
|
47
|
+
? {
|
|
48
|
+
role: "alertdialog",
|
|
49
|
+
"aria-modal": true,
|
|
50
|
+
// A dialog without a title is named by its message
|
|
51
|
+
"aria-labelledby": title != null ? ids.title : description != null ? ids.description : undefined,
|
|
52
|
+
"aria-describedby": title != null && description != null ? ids.description : undefined,
|
|
53
|
+
}
|
|
48
54
|
: { accessibilityRole: "alert", accessibilityViewIsModal: true };
|
|
49
55
|
if (theme.isAndroid) {
|
|
50
56
|
return (_jsx(AndroidFrame, { open: open, onClose: close, dismissible: dismissible ?? true, a11y: a11y, testID: testID, children: _jsx(AndroidDialog, { theme: theme, title: title, description: description, actions: actions, run: run, ids: ids, layout: mobileLayout, children: children }) }));
|
|
@@ -165,7 +171,9 @@ function IOSAlert({ theme, title, description, actions, run, ids, layout, childr
|
|
|
165
171
|
_jsx(View, { pointerEvents: "none", "aria-hidden": true, style: styles.measure, children: actions.map((action, index) => (_jsx(Text, { weight: action.preferred ? "semibold" : "medium", numberOfLines: 1, style: type, onLayout: (event) => {
|
|
166
172
|
const next = event.nativeEvent.layout.width;
|
|
167
173
|
setLabels((current) => (current[index] === next ? current : Object.assign([...current], { [index]: next })));
|
|
168
|
-
}, children: action.label }, index))) })) : null, _jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: { gap: 10 }, bounces: false, children: [_jsxs(View, { style: { paddingTop: 5, paddingHorizontal: 15, paddingBottom: 5.5, gap: 5.67 }, children: [_jsx(Text, { nativeID: ids.title, weight: "semibold", style: [type, { textAlign: description == null ? "center" : "auto" }], accessibilityRole: "header", children: title })
|
|
174
|
+
}, children: action.label }, index))) })) : null, _jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: { gap: 10 }, bounces: false, children: [_jsxs(View, { style: { paddingTop: 5, paddingHorizontal: 15, paddingBottom: 5.5, gap: 5.67 }, children: [title != null ? (_jsx(Text, { nativeID: ids.title, weight: "semibold", style: [type, { textAlign: description == null ? "center" : "auto" }], accessibilityRole: "header", children: title })) : null, description != null ? (
|
|
175
|
+
// Without a title the message is the alert's whole text, in the label color (UIAlertController with a nil title)
|
|
176
|
+
_jsx(Text, { nativeID: ids.description, color: title != null ? theme.color("--dialog-alert-message-color") : undefined, style: { fontSize: 15, lineHeight: 20 }, children: description })) : null] }), children != null ? (
|
|
169
177
|
// A field fills the alert as its actions do: the largest control size is the alert's 48 there
|
|
170
178
|
// (Dialog.module.css sets --control-size-3xl to --dialog-alert-field-height in the alert's body)
|
|
171
179
|
_jsx(ThemeProvider, { brand: { tokens: { "--control-size-3xl": `${theme.length("--dialog-alert-field-height", 48)}px` } }, children: _jsx(View, { style: { paddingBottom: 10, marginHorizontal: -1 }, children: children }) })) : null] }), ordered.length ? (_jsx(View, { style: [{ gap, marginTop: children != null ? 0 : 4 }, inline ? styles.row : null], children: ordered.map(({ action, index }) => (_jsx(IOSAction, { theme: theme, action: action, run: run, type: type, grow: inline }, index))) })) : null] }));
|
|
@@ -236,7 +244,9 @@ function AndroidDialog({ theme, title, description, actions, run, ids, children,
|
|
|
236
244
|
};
|
|
237
245
|
return (_jsxs(View, { style: [styles.android, { width, backgroundColor: androidDialogBackground(theme), opacity: ready ? 1 : 0 }], children: [list != null ? (
|
|
238
246
|
// A list: the title stays, 14 over the rows, and the rows scroll under it (AlertDialog with a custom view)
|
|
239
|
-
_jsxs(_Fragment, { children: [title != null ? (_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, styles.androidListTitle, theme.font("medium")], children: title })) : null, _jsx(ScrollView, { style: styles.scroll, contentContainerStyle: title != null ? null : styles.androidListTop, bounces: false, children: list })] })) : (_jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.androidText, bounces: false, children: [_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, theme.font("medium")], children: title })
|
|
247
|
+
_jsxs(_Fragment, { children: [title != null ? (_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, styles.androidListTitle, theme.font("medium")], children: title })) : null, _jsx(ScrollView, { style: styles.scroll, contentContainerStyle: title != null ? null : styles.androidListTop, bounces: false, children: list })] })) : (_jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.androidText, bounces: false, children: [title != null ? (_jsx(Text, { nativeID: ids.title, color: m.onSurface, accessibilityRole: "header", style: [styles.androidTitle, theme.font("medium")], children: title })) : null, description != null ? (
|
|
248
|
+
// Material 3's dialog with no headline: the supporting text alone, in onSurfaceVariant
|
|
249
|
+
_jsx(Text, { nativeID: ids.description, color: title != null ? m.onSurface : m.onSurfaceVariant, style: styles.androidMessage, children: description })) : null, children != null ? _jsx(View, { style: styles.androidContent, children: children }) : null] })), bar.length ? (_jsx(View, { onLayout: (event) => setRoom(event.nativeEvent.layout.width - 16), style: stacked ? styles.androidStack : styles.androidActions, children: order.map((index) =>
|
|
240
250
|
// The neutral actions at the start, a space, then the negative and the positive
|
|
241
251
|
!stacked && index === neutral.length && neutral.length ? [_jsx(View, { style: styles.grow }, "space"), button(index)] : button(index)) })) : null] }));
|
|
242
252
|
}
|
|
@@ -443,6 +443,9 @@ function IOSContent({ handPress, valueColor, theme, label, description, descript
|
|
|
443
443
|
// A picture wider than the tile (a photo, an avatar) keeps its own size: it starts at the row's inset, where the
|
|
444
444
|
// header and the footer stand, and the text follows 14 past it, as UIKit's image to text padding
|
|
445
445
|
const [wide, setWide] = useState(false);
|
|
446
|
+
// A picture taller than the tile (a 40 photo) keeps the cell's margins over and under it, 10 as UIKit's content
|
|
447
|
+
// configuration keeps them: a 40 photo makes a 60 row
|
|
448
|
+
const [tall, setTall] = useState(false);
|
|
446
449
|
// In a List with `columns` a field's value starts at one column, 40% into the row (`--field-row-column-width`)
|
|
447
450
|
// A switch, a checkbox and a radio stay at the row's edge
|
|
448
451
|
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null;
|
|
@@ -461,11 +464,15 @@ function IOSContent({ handPress, valueColor, theme, label, description, descript
|
|
|
461
464
|
return (_jsxs(_Fragment, { children: [leading != null ? (_jsx(View, { style: [
|
|
462
465
|
styles.tile,
|
|
463
466
|
{ minWidth: tile, minHeight: tile, marginStart: wide ? 0 : theme.length("--field-row-icon-offset", -2), marginEnd: theme.length("--field-row-icon-gap", 14) },
|
|
467
|
+
tall ? { marginVertical: theme.length("--field-row-picture-margin-block", 10) } : null,
|
|
464
468
|
leadingColor ? { backgroundColor: leadingColor, borderRadius: theme.length("--field-row-icon-radius", 7) } : null,
|
|
465
469
|
], onLayout: (event) => {
|
|
466
470
|
const next = event.nativeEvent.layout.width > tile + 0.5;
|
|
467
471
|
if (next !== wide)
|
|
468
472
|
setWide(next);
|
|
473
|
+
const taller = event.nativeEvent.layout.height > tile + 0.5;
|
|
474
|
+
if (taller !== tall)
|
|
475
|
+
setTall(taller);
|
|
469
476
|
}, children: _jsx(IconDefaultsProvider, { size: leadingColor ? 20 : theme.length("--field-row-icon-symbol-size", 24), color: leadingColor ? "#ffffff" : disabled ? theme.colors.labelTertiary : theme.colors.accent, children: leading }) })) : null, _jsxs(View, { ref: ref, onLayout: onRowLayout, style: [
|
|
470
477
|
error != null ? styles.iosColumn : styles.iosMain,
|
|
471
478
|
{ minHeight: iosMinHeight(theme, description != null || error != null), paddingEnd: inset },
|
|
@@ -492,6 +499,9 @@ function AndroidContent({ handPress, valueColor, theme, label, description, desc
|
|
|
492
499
|
// A picture wider than the symbol's 24 (a photo, an avatar) keeps its own size from the rows' inset (21, where the
|
|
493
500
|
// header and the footer stand), the text 16 past it, as Material's list item with a leading avatar; 0 for a symbol
|
|
494
501
|
const [wide, setWide] = useState(0);
|
|
502
|
+
// A picture taller than the symbol's 24 (a 40 avatar) keeps 8 over and under it, Material's list item with a leading
|
|
503
|
+
// avatar: a 40 photo makes a 56 row
|
|
504
|
+
const [tall, setTall] = useState(false);
|
|
495
505
|
// The text (and the divider) 21 in, or 64 after a symbol, a tile or a choice's mark (its 20dp circle 22 in)
|
|
496
506
|
const textStart = leading == null ? ANDROID_INSET : wide > 0 && !tile && !leadingMark ? ANDROID_INSET + wide + 16 : 64;
|
|
497
507
|
// A value that ends the row stands 17 from the end (a value row), 20 in a row with a tile (a tiled row)
|
|
@@ -506,13 +516,16 @@ function AndroidContent({ handPress, valueColor, theme, label, description, desc
|
|
|
506
516
|
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null;
|
|
507
517
|
const startsColumn = columns && !edgeControl;
|
|
508
518
|
const rowEnd = useMemo(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end", valueColor }), [handPress, startsColumn, valueColor]);
|
|
509
|
-
const parts = (_jsxs(_Fragment, { children: [leading == null ? null : leadingMark ? (_jsx(View, { style: styles.androidMark, children: leading })) : (_jsx(View, { style: tile ? [styles.androidTile, { backgroundColor: leadingColor, opacity: disabled ? 0.5 : 1 }] : [styles.androidIcon, wide > 0 ? styles.androidWide : null], onLayout: tile
|
|
519
|
+
const parts = (_jsxs(_Fragment, { children: [leading == null ? null : leadingMark ? (_jsx(View, { style: styles.androidMark, children: leading })) : (_jsx(View, { style: tile ? [styles.androidTile, { backgroundColor: leadingColor, opacity: disabled ? 0.5 : 1 }] : [styles.androidIcon, wide > 0 ? styles.androidWide : null, tall ? styles.androidTall : null], onLayout: tile
|
|
510
520
|
? undefined
|
|
511
521
|
: (event) => {
|
|
512
522
|
const width = event.nativeEvent.layout.width;
|
|
513
523
|
const next = width > 24.5 ? width : 0;
|
|
514
524
|
if (Math.abs(next - wide) > 0.5)
|
|
515
525
|
setWide(next);
|
|
526
|
+
const taller = event.nativeEvent.layout.height > 24.5;
|
|
527
|
+
if (taller !== tall)
|
|
528
|
+
setTall(taller);
|
|
516
529
|
}, children: _jsx(IconDefaultsProvider, { size: 24, color: tile ? "#ffffff" : symbol, children: leading }) })), _jsxs(View, { style: [
|
|
517
530
|
columns ? [styles.androidTextHug, styles.column] : fill ? styles.androidTextHug : styles.androidText,
|
|
518
531
|
// One line centred in the 50dp row (54 beside a text field: a card's input row); with a second line 12 above
|
|
@@ -557,6 +570,7 @@ const styles = StyleSheet.create({
|
|
|
557
570
|
androidFooterPlain: { paddingHorizontal: ANDROID_INSET },
|
|
558
571
|
androidRow: { flexDirection: "row", alignItems: "center", minHeight: 50, paddingStart: ANDROID_INSET, paddingEnd: ANDROID_INSET },
|
|
559
572
|
// A 24dp symbol at 20, a 28dp tile at 18 with a 24dp symbol, or a choice's 20dp mark at 22: the text at 64
|
|
573
|
+
androidTall: { marginVertical: 8 },
|
|
560
574
|
androidIcon: { minWidth: 24, minHeight: 24, alignItems: "center", justifyContent: "center", marginStart: -1, marginEnd: 20 },
|
|
561
575
|
androidWide: { marginStart: 0, marginEnd: 16 },
|
|
562
576
|
androidMark: { width: 20, alignItems: "center", justifyContent: "center", marginStart: 1, marginEnd: 22 },
|
|
@@ -213,18 +213,30 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
213
213
|
const fitsBelow = below + height <= window.height - bottomEdge;
|
|
214
214
|
const above = over ? box.y + box.height - height : box.y - gap - height;
|
|
215
215
|
let top = size == null ? -window.height - 1000 : fitsBelow ? below : Math.max(topEdge, above);
|
|
216
|
-
|
|
216
|
+
// A preview wider than the screen less 16 a side is scaled down about its middle to fit, as iOS 27.2 shrinks a
|
|
217
|
+
// lifted cell or card, and one that would cross the 16 is moved in: `seen` is where it shows
|
|
218
|
+
const fit = 16;
|
|
219
|
+
const fitScale = context && box.width > window.width - fit * 2 ? (window.width - fit * 2) / box.width : 1;
|
|
220
|
+
const seenWidth = box.width * fitScale;
|
|
221
|
+
const seenHeight = box.height * fitScale;
|
|
222
|
+
const seen = {
|
|
223
|
+
x: context && box.width > 0 ? Math.max(fit, Math.min(box.x + (box.width - seenWidth) / 2, window.width - fit - seenWidth)) : box.x,
|
|
224
|
+
y: box.y + (box.height - seenHeight) / 2,
|
|
225
|
+
width: seenWidth,
|
|
226
|
+
height: seenHeight,
|
|
227
|
+
};
|
|
228
|
+
let previewTop = seen.y;
|
|
217
229
|
if (context) {
|
|
218
230
|
// iOS 27.2 places a context menu by where the element stands (ref-app menus-context): in the left third at its
|
|
219
231
|
// left edge, in the right third at its right edge, else at its centre; 16 under it, or over it when the element
|
|
220
232
|
// is in the lower half and the menu fits there (the web's ContextMenu, contextMenuPreview)
|
|
221
|
-
const centre =
|
|
222
|
-
left = centre < window.width / 3 ?
|
|
233
|
+
const centre = seen.x + seen.width / 2;
|
|
234
|
+
left = centre < window.width / 3 ? seen.x : centre > (window.width * 2) / 3 ? seen.x + seen.width - measured : centre - measured / 2;
|
|
223
235
|
left = Math.max(margin, Math.min(left, window.width - measured - margin));
|
|
224
236
|
const lift = 16;
|
|
225
|
-
const overIt =
|
|
226
|
-
const underIt =
|
|
227
|
-
const lower =
|
|
237
|
+
const overIt = seen.y - lift - height;
|
|
238
|
+
const underIt = seen.y + seen.height + lift;
|
|
239
|
+
const lower = seen.y + seen.height / 2 > window.height / 2;
|
|
228
240
|
if (size != null) {
|
|
229
241
|
if (lower && overIt >= topEdge)
|
|
230
242
|
top = overIt;
|
|
@@ -232,8 +244,8 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
232
244
|
// Where the menu does not fit under the element it lifts the element up with it, as iOS moves the preview, so
|
|
233
245
|
// the menu never covers it
|
|
234
246
|
const overflow = underIt + height - (window.height - bottomEdge);
|
|
235
|
-
previewTop = overflow > 0 ? Math.max(topEdge,
|
|
236
|
-
top = Math.max(topEdge, Math.min(previewTop +
|
|
247
|
+
previewTop = overflow > 0 ? Math.max(topEdge, seen.y - overflow) : seen.y;
|
|
248
|
+
top = Math.max(topEdge, Math.min(previewTop + seen.height + lift, window.height - bottomEdge - height));
|
|
237
249
|
}
|
|
238
250
|
}
|
|
239
251
|
}
|
|
@@ -320,11 +332,13 @@ function IOSMenuSurface({ open, anchor, onClose, align = "start", width, check =
|
|
|
320
332
|
web ? { backdropFilter: "blur(30px)", WebkitBackdropFilter: "blur(30px)" } : null,
|
|
321
333
|
] }), _jsx(View, { pointerEvents: "none", style: [
|
|
322
334
|
styles.preview,
|
|
323
|
-
|
|
335
|
+
// Drawn at its own size and scaled about its middle onto where it is seen
|
|
336
|
+
swap ? { right: seen.x + (seen.width - box.width) / 2 } : { left: seen.x + (seen.width - box.width) / 2 },
|
|
324
337
|
{
|
|
325
|
-
top: previewTop,
|
|
338
|
+
top: previewTop + (seen.height - box.height) / 2,
|
|
326
339
|
width: box.width,
|
|
327
340
|
height: box.height,
|
|
341
|
+
transform: fitScale < 1 ? [{ scale: fitScale }] : undefined,
|
|
328
342
|
borderRadius: context.radius,
|
|
329
343
|
backgroundColor: theme.colors.groupedSurface,
|
|
330
344
|
boxShadow: String(theme.token("--context-menu-preview-shadow") ?? "0 0 32px rgba(0, 0, 0, 0.2)"),
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Platform, StyleSheet, Text, View } from "react-native";
|
|
4
|
+
import { Pressable } from "../../internal/Pressable";
|
|
5
|
+
import { useRipple } from "../../internal/ripple";
|
|
6
|
+
import { withAlpha } from "../../theme/material";
|
|
7
|
+
import { useTheme } from "../../theme/ThemeProvider";
|
|
8
|
+
import AppleLogo from "../../icons/plex/AppleLogo";
|
|
9
|
+
import GoogleLogo from "../../icons/plex/GoogleLogo";
|
|
10
|
+
import { buttonMetrics, useMaterialPress } from "../Button/Button";
|
|
11
|
+
const LABEL = { "sign-in": "Sign in with", "sign-up": "Sign up with", continue: "Continue with" };
|
|
12
|
+
/** Apple HIG, Sign in with Apple: black with white content, or white with black content on dark or over media. */
|
|
13
|
+
function appleLook(white) {
|
|
14
|
+
return white ? { background: "#FFFFFF", text: "#000000" } : { background: "#000000", text: "#FFFFFF" };
|
|
15
|
+
}
|
|
16
|
+
/** Google Sign-In branding guidelines: the light, dark and neutral buttons. */
|
|
17
|
+
function googleLook(dark, neutral) {
|
|
18
|
+
if (neutral)
|
|
19
|
+
return { background: "#F2F2F2", text: "#1F1F1F" };
|
|
20
|
+
return dark ? { background: "#131314", text: "#E3E3E3", border: "#8E918F" } : { background: "#FFFFFF", text: "#1F1F1F", border: "#747775" };
|
|
21
|
+
}
|
|
22
|
+
// The logos' drawn ink inside their 24-unit boxes: the G spans 2.95–21.05, so at 24px it stands 2.95px in from each
|
|
23
|
+
// side; Apple's mark spans 3.36–20.64 of its width
|
|
24
|
+
const GOOGLE_ICON = 24;
|
|
25
|
+
const GOOGLE_INSET = 2.95;
|
|
26
|
+
const APPLE_ICON = 20;
|
|
27
|
+
/**
|
|
28
|
+
* The sign-in button of a provider, drawn to its brand rules rather than to the theme: Apple's black or white button
|
|
29
|
+
* with the real Apple logo, Google's light, dark or neutral one with the four-color G. It takes the height and the
|
|
30
|
+
* shape of the screen's other buttons (a capsule on iOS, a pill on Android). Disabled keeps the brand's colors at 40%.
|
|
31
|
+
*/
|
|
32
|
+
export function SignInButton({ provider, action = "continue", scheme, overMedia = false, neutral = false, size = "xl", block = true, disabled = false, style, onPressIn, onPressOut, accessibilityLabel, accessibilityState, ...rest }) {
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
const dark = (scheme ?? theme.scheme) === "dark";
|
|
35
|
+
const apple = provider === "apple";
|
|
36
|
+
const look = apple ? appleLook(dark || overMedia) : googleLook(dark, neutral);
|
|
37
|
+
const metrics = buttonMetrics(theme, size);
|
|
38
|
+
const label = `${LABEL[action]} ${apple ? "Apple" : "Google"}`;
|
|
39
|
+
const [pressed, setPressed] = useState(false);
|
|
40
|
+
const android = theme.isAndroid;
|
|
41
|
+
const nativeRipple = useMaterialPress(theme);
|
|
42
|
+
const ripple = useRipple(withAlpha(look.text, 0.1), android && !nativeRipple, theme.reducedMotion);
|
|
43
|
+
// Google's spacing: 16 before the G, 12 to the text and 16 after on iOS; 12, 10 and 12 on Android
|
|
44
|
+
const google = android ? { start: 12, gap: 10, end: 12 } : { start: 16, gap: 12, end: 16 };
|
|
45
|
+
const radius = metrics.height / 2;
|
|
46
|
+
// A compact size keeps the platform's 44pt or 48dp target, as Button does
|
|
47
|
+
const reach = Math.max(0, ((android ? 48 : 44) - metrics.height) / 2);
|
|
48
|
+
const padding = apple
|
|
49
|
+
? // Apple asks for a margin of at least a tenth of the height around the logo and the title
|
|
50
|
+
{ paddingHorizontal: Math.max(metrics.height / 10, 16) }
|
|
51
|
+
: { paddingLeft: google.start - GOOGLE_INSET, paddingRight: google.end };
|
|
52
|
+
return (_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel ?? label, accessibilityState: { ...accessibilityState, disabled }, disabled: disabled, hitSlop: reach ? { top: reach, bottom: reach } : undefined, android_ripple: nativeRipple ? { color: withAlpha(look.text, 0.1), foreground: true } : undefined, onPressIn: (event) => {
|
|
53
|
+
setPressed(true);
|
|
54
|
+
ripple.start(event);
|
|
55
|
+
onPressIn?.(event);
|
|
56
|
+
}, onPressOut: (event) => {
|
|
57
|
+
setPressed(false);
|
|
58
|
+
ripple.end();
|
|
59
|
+
onPressOut?.(event);
|
|
60
|
+
}, style: [
|
|
61
|
+
styles.button,
|
|
62
|
+
{
|
|
63
|
+
// At least the size's height: a larger text size grows the button instead of clipping its title
|
|
64
|
+
minHeight: metrics.height,
|
|
65
|
+
paddingVertical: 4,
|
|
66
|
+
minWidth: 140,
|
|
67
|
+
borderRadius: radius,
|
|
68
|
+
backgroundColor: look.background,
|
|
69
|
+
alignSelf: block ? "stretch" : "center",
|
|
70
|
+
opacity: disabled ? 0.4 : 1,
|
|
71
|
+
},
|
|
72
|
+
padding,
|
|
73
|
+
style,
|
|
74
|
+
], ...rest, children: [ripple.layer, pressed && !android && _jsx(View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { borderRadius: radius, backgroundColor: withAlpha(look.text, 0.12) }] }), look.border && _jsx(View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, { borderRadius: radius, borderWidth: 1, borderColor: look.border }] }), _jsxs(View, { style: [styles.content, { gap: apple ? 6 : google.gap - GOOGLE_INSET }], accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: [apple ? _jsx(AppleLogo, { size: APPLE_ICON, color: look.text }) : _jsx(GoogleLogo, { size: GOOGLE_ICON }), _jsx(Text, { numberOfLines: 1, allowFontScaling: true, style: apple
|
|
75
|
+
? // The system font, as Apple's button sets its title
|
|
76
|
+
{ color: look.text, fontSize: metrics.fontSize, lineHeight: metrics.lineHeight, fontWeight: "500" }
|
|
77
|
+
: // Google Sans Medium 14/20 where the app has it, else the system font
|
|
78
|
+
{ color: look.text, fontSize: 14, lineHeight: 20, fontWeight: "500", fontFamily: GOOGLE_FONT }, children: label })] })] }));
|
|
79
|
+
}
|
|
80
|
+
/** The font the Google button asks for: an app that bundles Google Sans gets it; elsewhere the system font stands in. */
|
|
81
|
+
const GOOGLE_FONT = Platform.select({ web: "'Google Sans', system-ui, sans-serif", default: undefined });
|
|
82
|
+
const styles = StyleSheet.create({
|
|
83
|
+
button: { flexDirection: "row", alignItems: "center", justifyContent: "center", overflow: "hidden" },
|
|
84
|
+
content: { flexDirection: "row", alignItems: "center", justifyContent: "center", flexShrink: 1 },
|
|
85
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { cloneElement, isValidElement, useState } from "react";
|
|
3
|
-
import { StyleSheet, View, useWindowDimensions } from "react-native";
|
|
3
|
+
import { ActivityIndicator, StyleSheet, View, useWindowDimensions } from "react-native";
|
|
4
4
|
import { Pressable } from "../../internal/Pressable";
|
|
5
5
|
import Svg, { Path } from "react-native-svg";
|
|
6
6
|
import X from "../../icons/plex/X";
|
|
@@ -8,7 +8,7 @@ import { flattenChildren, isRenderable, textOf } from "../../internal/children";
|
|
|
8
8
|
import { FloatingPanel } from "../../internal/FloatingPanel";
|
|
9
9
|
import { anchorProps } from "../../internal/floating";
|
|
10
10
|
import { Glass } from "../../internal/Glass";
|
|
11
|
-
import { accentText, barSurface, controlHighlight, dangerText, elevationShadow } from "../../theme/material";
|
|
11
|
+
import { accentText, barSurface, controlHighlight, dangerText, elevationShadow, withAlpha } from "../../theme/material";
|
|
12
12
|
import { useTheme } from "../../theme/ThemeProvider";
|
|
13
13
|
import { Button } from "../Button/Button";
|
|
14
14
|
import { IconDefaultsProvider } from "../Icon/createIcon";
|
|
@@ -66,37 +66,50 @@ function TipBody({ title, description, icon, actions, mobileActions = "rows", on
|
|
|
66
66
|
const closable = onClose != null;
|
|
67
67
|
const descriptionColor = android ? theme.colors.textSecondary : theme.color("--tip-description-color", theme.colors.textSecondary);
|
|
68
68
|
const paddingBottom = !hasActions ? m.bottomNone : buttons ? m.bottomButtons : m.bottomRows;
|
|
69
|
+
// iOS's tip with button actions is TipKit's mini tip (its kit's Hint View): 22 over the title, 4 between the title
|
|
70
|
+
// and the message, 22 from the words to the action and 16 under it
|
|
71
|
+
const miniTip = !android && hasActions && buttons;
|
|
69
72
|
const textStart = hasIcon ? m.iconFrame + m.iconGap : 0;
|
|
70
73
|
return (_jsxs(View, { role: role, "aria-label": role ? textOf(title) || undefined : undefined, testID: testID, style: [
|
|
71
74
|
styles.tip,
|
|
72
75
|
{
|
|
73
76
|
borderRadius: m.radius,
|
|
74
|
-
paddingTop: m.top,
|
|
77
|
+
paddingTop: miniTip ? 22 : m.top,
|
|
75
78
|
paddingHorizontal: m.inline,
|
|
76
79
|
paddingBottom,
|
|
77
80
|
columnGap: m.iconGap,
|
|
78
|
-
rowGap: hasActions && buttons ? m.gapButtons : m.gap,
|
|
81
|
+
rowGap: miniTip ? 22 : hasActions && buttons ? m.gapButtons : m.gap,
|
|
79
82
|
backgroundColor: background ?? theme.colors.groupedSurface,
|
|
80
83
|
},
|
|
81
84
|
style,
|
|
82
|
-
], children: [children, hasIcon ? (_jsx(View, { style: [styles.icon, { width: m.iconFrame, height: m.iconFrame }], children: _jsx(IconDefaultsProvider, { size: m.icon, color: descriptionColor, children: icon }) })) : null, _jsxs(View, { style: [styles.message, closable ? { paddingEnd: m.messageEnd } : null], children: [_jsx(Text, { variant: "headline", children: title }), isRenderable(description) ? (_jsx(TextColorProvider, { value: descriptionColor, children: _jsx(Text, { variant: "subheadline", color: descriptionColor, style: android ? styles.androidDescription : null, children: description }) })) : null] }), hasActions ? (_jsx(View, { style: [
|
|
85
|
+
], children: [children, hasIcon ? (_jsx(View, { style: [styles.icon, { width: m.iconFrame, height: m.iconFrame }], children: _jsx(IconDefaultsProvider, { size: m.icon, color: descriptionColor, children: icon }) })) : null, _jsxs(View, { style: [styles.message, closable ? { paddingEnd: m.messageEnd } : null], children: [_jsx(Text, { variant: "headline", children: title }), isRenderable(description) ? (_jsx(TextColorProvider, { value: descriptionColor, children: _jsx(Text, { variant: "subheadline", color: descriptionColor, style: android ? styles.androidDescription : miniTip ? styles.miniDescription : null, children: description }) })) : null] }), hasActions ? (_jsx(View, { style: [
|
|
83
86
|
styles.actions,
|
|
84
87
|
buttons ? styles.buttons : android ? [styles.androidActions, { marginStart: textStart - ANDROID_TEXT_BUTTON_INSET }] : { paddingStart: textStart },
|
|
85
88
|
], children: items.map((item, index) => (buttons ? _jsx(ActionButton, { item: item }, index) : _jsx(ActionRow, { item: item }, index))) })) : null, closable ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel, onPress: onClose, style: [styles.close, { width: m.closeTarget, height: m.closeTarget, top: m.closeTop, end: m.closeEnd, borderRadius: m.closeTarget / 2 }], children: ({ pressed }) => (_jsx(View, { style: [styles.closeGlyph, android && pressed ? { backgroundColor: controlHighlight(theme.scheme), borderRadius: m.closeTarget / 2 } : null], children: _jsx(X, { size: m.closeIcon, color: android ? theme.colors.labelSecondary : theme.colors.labelTertiary, style: !android && pressed ? styles.pressed : undefined }) })) })) : null] }));
|
|
86
89
|
}
|
|
87
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* An action as a capsule across the tip. On iOS it is TipKit's action (the kit's Hint View): 50 tall, a 17 Semibold
|
|
92
|
+
* label in the action's color (the accent for a primary one) on that color at 8% over the gray fill at 8%. On Android
|
|
93
|
+
* the Button keeps its color and variant, a 40dp capsule.
|
|
94
|
+
*/
|
|
88
95
|
function ActionButton({ item }) {
|
|
89
96
|
const theme = useTheme();
|
|
90
97
|
if (!isValidElement(item) || item.type !== Button)
|
|
91
98
|
return _jsx(_Fragment, { children: item });
|
|
92
99
|
const button = item;
|
|
93
|
-
|
|
94
|
-
size:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
if (theme.isAndroid)
|
|
101
|
+
return cloneElement(button, { size: "lg", pill: true, block: true });
|
|
102
|
+
// The Button's look props stay here; its handlers, ref and accessibility props pass on to the capsule
|
|
103
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
104
|
+
const { color = "primary", children, disabled = false, loading = false, inert: inertProp = loading, variant, size, pill, shape, mobileMaterial, uniform, block, labelLines, selected, iconSize, gutterSize, opticallyAlign, style, accessibilityState, ...pressable } = button.props;
|
|
105
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
106
|
+
// As the Button: a loading or inert action takes no presses and keeps its look; a disabled one dims
|
|
107
|
+
const inert = disabled || inertProp;
|
|
108
|
+
const ink = color === "primary" ? theme.colors.accent : theme.color(`--color-text-${color}-ghost`, theme.colors.accent);
|
|
109
|
+
return (_jsxs(Pressable, { accessibilityRole: "button", ...pressable, accessibilityState: { ...accessibilityState, disabled: inert, busy: loading }, "aria-busy": loading, disabled: inert, style: ({ pressed }) => [styles.miniAction, { backgroundColor: MINI_GRAY, opacity: disabled ? 0.4 : 1 }, pressed && !inert ? styles.pressed : null], children: [_jsx(View, { pointerEvents: "none", style: [StyleSheet.absoluteFill, styles.miniActionTint, { backgroundColor: withAlpha(ink, 0.08) }] }), loading ? (_jsx(ActivityIndicator, { color: ink })) : (_jsx(Text, { variant: "body", weight: "semibold", numberOfLines: 2, style: styles.miniLabel, color: ink, children: children }))] }));
|
|
99
110
|
}
|
|
111
|
+
/** The gray under a TipKit action's tint: the kit's rgba(116, 116, 128, 0.08). */
|
|
112
|
+
const MINI_GRAY = "rgba(116, 116, 128, 0.08)";
|
|
100
113
|
/**
|
|
101
114
|
* An action as a row of text in its Button's color under a separator, 46 tall, as iOS tips list them; on Android a
|
|
102
115
|
* text button in the accent, as Material 3's rich tooltip sets its actions. Other elements stand as given.
|
|
@@ -182,6 +195,10 @@ const styles = StyleSheet.create({
|
|
|
182
195
|
androidDescription: { marginTop: 2 },
|
|
183
196
|
actions: { flexBasis: "100%", flexGrow: 1, flexDirection: "column" },
|
|
184
197
|
buttons: { gap: 10 },
|
|
198
|
+
miniDescription: { marginTop: 4 },
|
|
199
|
+
miniAction: { minHeight: 50, paddingHorizontal: 20, paddingVertical: 14, borderRadius: 25, borderCurve: "continuous", alignItems: "center", justifyContent: "center", overflow: "hidden" },
|
|
200
|
+
miniActionTint: { borderRadius: 25 },
|
|
201
|
+
miniLabel: { lineHeight: 18, textAlign: "center" },
|
|
185
202
|
androidActions: { flexDirection: "row", flexWrap: "wrap", gap: 8 },
|
|
186
203
|
row: { minHeight: 46, paddingVertical: 12, borderTopWidth: 1, justifyContent: "center" },
|
|
187
204
|
androidRow: { alignSelf: "flex-start", minHeight: 40, paddingHorizontal: 12, borderRadius: 20, justifyContent: "center" },
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Generated by scripts/build-icons.mjs. Do not edit.
|
|
2
|
+
import { createIcon } from "../../components/Icon/createIcon";
|
|
3
|
+
export default createIcon("AppleLogo", "0 0 24 24", [["path", { "d": "M20.0911 7.2368C19.3972 7.66168 18.8223 8.25568 18.4204 8.96321C18.0185 9.67075 17.8027 10.4687 17.7932 11.2823C17.7959 12.1981 18.0672 13.0929 18.5735 13.856C19.0798 14.6191 19.7988 15.2169 20.6415 15.5754C20.3093 16.6474 19.8176 17.6632 19.1829 18.5888C18.2748 19.8961 17.3253 21.2032 15.8805 21.2032C14.4358 21.2032 14.0642 20.3638 12.3992 20.3638C10.7755 20.3638 10.1976 21.2308 8.87662 21.2308C7.55564 21.2308 6.63382 20.0198 5.57424 18.5338C4.17461 16.452 3.4054 14.0106 3.35889 11.5024C3.35889 7.37443 6.04214 5.18665 8.68397 5.18665C10.0875 5.18665 11.2572 6.10847 12.1378 6.10847C12.9772 6.10847 14.2844 5.1315 15.8805 5.1315C16.7012 5.11032 17.5145 5.29127 18.2487 5.6584C18.983 6.02553 19.6157 6.56757 20.0911 7.2368ZM15.1238 3.38405C15.8274 2.55637 16.2257 1.51233 16.2521 0.426336C16.2533 0.28317 16.2395 0.140275 16.2108 0C15.0022 0.11806 13.8846 0.694096 13.0872 1.60995C12.3769 2.40465 11.9636 3.42081 11.9176 4.48573C11.9181 4.61524 11.932 4.74435 11.9589 4.87103C12.0542 4.88904 12.1509 4.89827 12.2479 4.89861C12.8049 4.85429 13.347 4.69717 13.8414 4.4368C14.3358 4.17644 14.7721 3.81826 15.1238 3.38405Z", "fill": 0 }]]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Generated by scripts/build-icons.mjs. Do not edit.
|
|
2
|
+
import { createIcon } from "../../components/Icon/createIcon";
|
|
3
|
+
export default createIcon("GoogleLogo", "0 0 24 24", [["path", { "d": "M21.0461 12.2099C21.0461 11.5553 20.9874 10.9259 20.8783 10.3217H12.1846V13.8966H17.1524C16.9342 15.0462 16.2797 16.0197 15.2979 16.6742V18.9987H18.2937C20.0391 17.3875 21.0461 15.0211 21.0461 12.2099Z", "fill": "#4285F4" }], ["path", { "d": "M12.1844 21.2307C14.6767 21.2307 16.7662 20.4084 18.2935 18.9986L15.2977 16.6741C14.4753 17.2279 13.4264 17.5636 12.1844 17.5636C9.78441 17.5636 7.74525 15.944 7.01518 13.7622H3.94385V16.1454C5.46273 19.158 8.57602 21.2307 12.1844 21.2307Z", "fill": "#34A853" }], ["path", { "d": "M7.01516 13.7539C6.83054 13.2 6.72145 12.6126 6.72145 12C6.72145 11.3874 6.83054 10.8 7.01516 10.2462V7.86295H3.94382C3.31445 9.10491 2.95361 10.5063 2.95361 12C2.95361 13.4937 3.31445 14.8951 3.94382 16.1371L6.33544 14.2741L7.01516 13.7539Z", "fill": "#FBBC05" }], ["path", { "d": "M12.1844 6.44475C13.5439 6.44475 14.7522 6.91469 15.7173 7.82098L18.3606 5.17762C16.7578 3.68391 14.6767 2.76923 12.1844 2.76923C8.57602 2.76923 5.46273 4.84196 3.94385 7.86294L7.01518 10.2462C7.74525 8.06434 9.78441 6.44475 12.1844 6.44475Z", "fill": "#EA4335" }]]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Generated by scripts/build-icons.mjs. Do not edit.
|
|
2
|
+
import { createIcon } from "../../components/Icon/createIcon";
|
|
3
|
+
export default createIcon("MicrosoftLogo", "0 0 24 24", [["path", { "d": "M3.25 3.25H11.25V11.25H3.25V3.25Z", "fill": "#F35325" }], ["path", { "d": "M12.75 3.25H20.75V11.25H12.75V3.25Z", "fill": "#81BC06" }], ["path", { "d": "M3.25 12.75H11.25V20.75H3.25V12.75Z", "fill": "#05A6F0" }], ["path", { "d": "M12.75 12.75H20.75V20.75H12.75V12.75Z", "fill": "#FFBA08" }]]);
|
|
@@ -20,6 +20,7 @@ export { default as AppPermission } from "./AppPermission";
|
|
|
20
20
|
export { default as AppStore } from "./AppStore";
|
|
21
21
|
export { default as AppStoreSquare } from "./AppStoreSquare";
|
|
22
22
|
export { default as Apple } from "./Apple";
|
|
23
|
+
export { default as AppleLogo } from "./AppleLogo";
|
|
23
24
|
export { default as Archive } from "./Archive";
|
|
24
25
|
export { default as Array } from "./Array";
|
|
25
26
|
export { default as ArrowBottomLeftSm } from "./ArrowBottomLeftSm";
|
|
@@ -268,6 +269,7 @@ export { default as GlobeAlt } from "./GlobeAlt";
|
|
|
268
269
|
export { default as GlobeFilled } from "./GlobeFilled";
|
|
269
270
|
export { default as GlobeOff } from "./GlobeOff";
|
|
270
271
|
export { default as GlobeSpin } from "./GlobeSpin";
|
|
272
|
+
export { default as GoogleLogo } from "./GoogleLogo";
|
|
271
273
|
export { default as Grid } from "./Grid";
|
|
272
274
|
export { default as GridAlt } from "./GridAlt";
|
|
273
275
|
export { default as GripHorizontal } from "./GripHorizontal";
|
|
@@ -361,6 +363,7 @@ export { default as Mic } from "./Mic";
|
|
|
361
363
|
export { default as MicFilled } from "./MicFilled";
|
|
362
364
|
export { default as MicFilledOff } from "./MicFilledOff";
|
|
363
365
|
export { default as MicOff } from "./MicOff";
|
|
366
|
+
export { default as MicrosoftLogo } from "./MicrosoftLogo";
|
|
364
367
|
export { default as MinimizeDown } from "./MinimizeDown";
|
|
365
368
|
export { default as MinimizeLeft } from "./MinimizeLeft";
|
|
366
369
|
export { default as MinimizeRight } from "./MinimizeRight";
|
package/dist/es/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export { Toolbar, } from "./components/Toolbar/Toolbar";
|
|
|
14
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
|
+
export { SignInButton } from "./components/SignInButton/SignInButton";
|
|
17
18
|
export { Checkbox } from "./components/Checkbox/Checkbox";
|
|
18
19
|
export { RadioGroup } from "./components/RadioGroup/RadioGroup";
|
|
19
20
|
export { Input, InputAdornmentButton, TextField } from "./components/Input/Input";
|