@plexui/react-native 0.2.25 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/es/components/BottomActions/BottomActions.js +2 -2
- package/dist/es/components/BottomSheet/BottomSheet.js +7 -3
- package/dist/es/components/Button/Button.js +10 -6
- package/dist/es/components/Card/Card.js +9 -2
- package/dist/es/components/Checkbox/Checkbox.js +2 -2
- package/dist/es/components/Chip/Chip.js +19 -11
- package/dist/es/components/Dialog/Dialog.js +18 -6
- package/dist/es/components/EmptyMessage/EmptyMessage.js +2 -2
- package/dist/es/components/Indicator/CircularProgress.js +11 -5
- package/dist/es/components/Input/Input.js +17 -2
- package/dist/es/components/List/List.js +77 -9
- package/dist/es/components/Menu/Menu.js +15 -5
- package/dist/es/components/PageControl/PageControl.js +7 -3
- package/dist/es/components/RadioGroup/RadioGroup.js +2 -2
- package/dist/es/components/RollingNumber/RollingNumber.js +7 -7
- package/dist/es/components/ScrollEdge/ScrollEdge.js +12 -6
- package/dist/es/components/Select/Select.js +4 -2
- package/dist/es/components/Switch/Switch.js +2 -2
- package/dist/es/components/TabBar/TabBar.js +15 -0
- package/dist/es/components/TextLink/TextLink.js +23 -3
- package/dist/es/index.js +2 -2
- package/dist/es/internal/a11y.js +12 -0
- package/dist/es/internal/row.js +13 -0
- package/dist/es/theme/ThemeProvider.js +4 -2
- package/dist/es/theme/material.js +2 -0
- package/dist/types/components/BottomActions/BottomActions.d.ts +6 -1
- package/dist/types/components/Button/Button.d.ts +5 -0
- package/dist/types/components/Card/Card.d.ts +5 -1
- package/dist/types/components/Chip/Chip.d.ts +9 -3
- package/dist/types/components/Dialog/Dialog.d.ts +7 -1
- package/dist/types/components/EmptyMessage/EmptyMessage.d.ts +4 -2
- package/dist/types/components/Indicator/CircularProgress.d.ts +10 -2
- package/dist/types/components/Input/Input.d.ts +8 -1
- package/dist/types/components/List/List.d.ts +36 -1
- package/dist/types/components/Menu/Menu.d.ts +10 -4
- package/dist/types/components/RollingNumber/RollingNumber.d.ts +3 -1
- package/dist/types/components/ScrollEdge/ScrollEdge.d.ts +7 -1
- package/dist/types/components/TabBar/TabBar.d.ts +13 -0
- package/dist/types/components/TextLink/TextLink.d.ts +7 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/internal/a11y.d.ts +22 -0
- package/dist/types/internal/row.d.ts +21 -2
- package/dist/types/theme/ThemeProvider.d.ts +3 -2
- package/dist/types/theme/material.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/BottomActions/BottomActions.tsx +7 -2
- package/src/components/BottomSheet/BottomSheet.tsx +9 -4
- package/src/components/Button/Button.tsx +19 -4
- package/src/components/Card/Card.tsx +8 -3
- package/src/components/Checkbox/Checkbox.tsx +2 -1
- package/src/components/Chip/Chip.tsx +28 -9
- package/src/components/Dialog/Dialog.tsx +30 -6
- package/src/components/EmptyMessage/EmptyMessage.tsx +12 -3
- package/src/components/Indicator/CircularProgress.tsx +27 -11
- package/src/components/Input/Input.tsx +43 -3
- package/src/components/List/List.tsx +125 -7
- package/src/components/Menu/Menu.tsx +27 -11
- package/src/components/PageControl/PageControl.tsx +7 -3
- package/src/components/RadioGroup/RadioGroup.tsx +2 -1
- package/src/components/RollingNumber/RollingNumber.tsx +10 -8
- package/src/components/ScrollEdge/ScrollEdge.tsx +19 -6
- package/src/components/Select/Select.tsx +4 -1
- package/src/components/Switch/Switch.tsx +2 -1
- package/src/components/TabBar/TabBar.tsx +15 -0
- package/src/components/TextLink/TextLink.tsx +52 -3
- package/src/index.ts +2 -2
- package/src/internal/a11y.ts +13 -0
- package/src/internal/row.ts +14 -2
- package/src/theme/ThemeProvider.tsx +7 -4
- package/src/theme/material.ts +2 -0
|
@@ -3,14 +3,14 @@ import { Image, Platform, StyleSheet, View, type ImageSourcePropType, type Style
|
|
|
3
3
|
import { Pressable } from "../../internal/Pressable"
|
|
4
4
|
import { flattenChildren } from "../../internal/children"
|
|
5
5
|
import { space } from "../../internal/spacing"
|
|
6
|
-
import { controlHighlight, withAlpha } from "../../theme/material"
|
|
6
|
+
import { barShadow, controlHighlight, elevationShadow, withAlpha } from "../../theme/material"
|
|
7
7
|
import { useTheme } from "../../theme/ThemeProvider"
|
|
8
8
|
import type { Theme } from "../../theme/types"
|
|
9
9
|
import { materialType } from "../../theme/typography"
|
|
10
10
|
import { IconDefaultsProvider } from "../Icon/createIcon"
|
|
11
11
|
import { Text, TextColorProvider } from "../Text/Text"
|
|
12
12
|
|
|
13
|
-
export type CardVariant = "outline" | "solid" | "ghost"
|
|
13
|
+
export type CardVariant = "outline" | "solid" | "ghost" | "elevated"
|
|
14
14
|
export type CardSize = "sm" | "md" | "lg"
|
|
15
15
|
/** A fill of the palette: the accent, the Plex primary, or a semantic color. */
|
|
16
16
|
export type CardColor = "accent" | "primary" | "info" | "success" | "warning" | "caution" | "danger" | "discovery"
|
|
@@ -60,6 +60,8 @@ export function cardSurface(theme: Theme, variant: CardVariant) {
|
|
|
60
60
|
// from those cards on the page
|
|
61
61
|
if (variant === "outline") return { backgroundColor: theme.colors.groupedSurface }
|
|
62
62
|
if (variant === "solid") return { backgroundColor: theme.material.surfaceContainerHigh }
|
|
63
|
+
// Material's elevated card: the low container lifted at level 1
|
|
64
|
+
if (variant === "elevated") return { backgroundColor: theme.material.surfaceContainerLow, boxShadow: elevationShadow.level1 }
|
|
63
65
|
return { backgroundColor: "transparent" }
|
|
64
66
|
}
|
|
65
67
|
// On a phone an outline card is a section of an inset grouped list (no border, the section's fill: the grouped
|
|
@@ -67,6 +69,9 @@ export function cardSurface(theme: Theme, variant: CardVariant) {
|
|
|
67
69
|
// sections (Card.module.css, touch.css)
|
|
68
70
|
if (variant === "outline") return { backgroundColor: theme.colors.groupedSurface }
|
|
69
71
|
if (variant === "solid") return { backgroundColor: theme.color("--card-solid-section-background", theme.colors.surfaceSecondary) }
|
|
72
|
+
// Lifted off the page by the soft shadow of a floating control (2 down, 8 across, 6% black; 30% on a dark screen),
|
|
73
|
+
// so a card laid over another reads as on top
|
|
74
|
+
if (variant === "elevated") return { backgroundColor: theme.colors.groupedSurface, boxShadow: barShadow(theme.scheme) }
|
|
70
75
|
return { backgroundColor: "transparent" }
|
|
71
76
|
}
|
|
72
77
|
|
|
@@ -100,7 +105,7 @@ function CardRoot({ children, variant = "outline", size = "md", color, onPress,
|
|
|
100
105
|
? cloneElement(child as ReactElement<CardMediaProps & EdgeProps>, { first: index === 0, last: index === parts.length - 1 })
|
|
101
106
|
: child,
|
|
102
107
|
)
|
|
103
|
-
const box = [styles.card, { padding, gap, borderRadius: radius }, ghost && !tint ? styles.ghost : null, tint ? { backgroundColor: tint.fill } : cardSurface(theme, variant), style]
|
|
108
|
+
const box = [styles.card, { padding, gap, borderRadius: radius }, ghost && !tint ? styles.ghost : null, tint ? { backgroundColor: tint.fill, ...(variant === "elevated" ? { boxShadow: cardSurface(theme, variant).boxShadow } : null) } : cardSurface(theme, variant), style]
|
|
104
109
|
const content = tint ? (
|
|
105
110
|
<Context.Provider value={{ padding, inset, radius, theme, ink: tint.ink }}>
|
|
106
111
|
<TextColorProvider value={tint.ink}>
|
|
@@ -6,7 +6,7 @@ import CheckMd from "../../icons/plex/CheckMd"
|
|
|
6
6
|
import Minus from "../../icons/plex/Minus"
|
|
7
7
|
import { spaceToggles, useDescription } from "../../internal/a11y"
|
|
8
8
|
import { ControlLabel, controlLabelLine } from "../../internal/ControlLabel"
|
|
9
|
-
import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHold } from "../../internal/row"
|
|
9
|
+
import { RowActionContext, RowEndContext, RowHoldContext, RowStartContext, holdProps, rowHint, rowHold } from "../../internal/row"
|
|
10
10
|
import { androidGray, withAlpha } from "../../theme/material"
|
|
11
11
|
import { useTheme } from "../../theme/ThemeProvider"
|
|
12
12
|
import { ANDROID_ROW_END, iosCheckmarkColor, selectionColor } from "../Switch/Switch"
|
|
@@ -186,6 +186,7 @@ export function Checkbox({
|
|
|
186
186
|
disabled={disabled}
|
|
187
187
|
{...rowHold(hold)}
|
|
188
188
|
{...holdProps({}, inRow || atRowStart ? rowAction : null)}
|
|
189
|
+
{...rowHint(rowAction, described)}
|
|
189
190
|
onPress={toggle}
|
|
190
191
|
testID={testID}
|
|
191
192
|
style={[
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { holdProps } from "../../internal/row"
|
|
2
2
|
import { useEffect, useState, type ReactNode } from "react"
|
|
3
3
|
import { Animated, Easing, Platform, StyleSheet, View, type StyleProp, type ViewStyle } from "react-native"
|
|
4
|
+
import { useAndroidGlass } from "../../internal/BarBackdrop"
|
|
4
5
|
import { Pressable } from "../../internal/Pressable"
|
|
5
6
|
import ChevronDownSm from "../../icons/plex/ChevronDownSm"
|
|
6
7
|
import CloseBold from "../../icons/plex/CloseBold"
|
|
@@ -37,10 +38,16 @@ export type ChipProps = {
|
|
|
37
38
|
accessibilityLabel?: string
|
|
38
39
|
/**
|
|
39
40
|
* iOS: `tag`, a capsule of the gray fill 40pt tall (a tag cloud in a sheet, as Maps' Filters), or `glass`, a glass
|
|
40
|
-
* capsule 44pt tall (a filter in a row over content, as Maps' filters under its search). Android draws
|
|
41
|
-
* either
|
|
41
|
+
* capsule 44pt tall (a filter in a row over content, as Maps' filters under its search). Android draws Material's
|
|
42
|
+
* chip with either; with `glass` it stands on a glass of its size (the bar circles'), readable over content.
|
|
43
|
+
* @default "tag"
|
|
42
44
|
*/
|
|
43
45
|
appearance?: "tag" | "glass"
|
|
46
|
+
/**
|
|
47
|
+
* iOS: `sm`, a step under the regular chip, as a filter row a step under Maps' 44: 36pt tall, the label 15/20, the
|
|
48
|
+
* insides in proportion, the target still 44. Android keeps Material's 32dp chip. @default "md"
|
|
49
|
+
*/
|
|
50
|
+
size?: "md" | "sm"
|
|
44
51
|
/** An input chip: called when the reader takes the value back (a cross on Android; see `removeStyle` on iOS). */
|
|
45
52
|
onRemove?: () => void
|
|
46
53
|
/** The remove action's name, for screen readers. @default "Remove" */
|
|
@@ -85,6 +92,7 @@ export function Chip({
|
|
|
85
92
|
expanded,
|
|
86
93
|
accessibilityLabel,
|
|
87
94
|
appearance = "tag",
|
|
95
|
+
size = "md",
|
|
88
96
|
onRemove,
|
|
89
97
|
removeLabel = "Remove",
|
|
90
98
|
removeStyle = "token",
|
|
@@ -179,13 +187,14 @@ export function Chip({
|
|
|
179
187
|
}, [blend, blends, selected])
|
|
180
188
|
const fillPaint = blends ? blend.interpolate({ inputRange: [0, 1], outputRange: [androidFill.off, androidFill.on] }) : fill
|
|
181
189
|
const labelPaint = blends ? blend.interpolate({ inputRange: [0, 1], outputRange: [androidColor.off, androidColor.on] }) : color
|
|
182
|
-
const
|
|
183
|
-
const
|
|
190
|
+
const small = !android && size === "sm"
|
|
191
|
+
const height = android ? 32 : small ? 36 : glass ? 44 : 40
|
|
192
|
+
const label = android ? { fontSize: 14, lineHeight: 18 } : small ? { fontSize: 15, lineHeight: 20 } : { fontSize: 17, lineHeight: 22 }
|
|
184
193
|
const leading = icon
|
|
185
|
-
// iOS: a 17pt symbol draws about 20 (the label's size)
|
|
186
|
-
const iconSize = android ? 18 : 20
|
|
194
|
+
// iOS: a 17pt symbol draws about 20 (the label's size), a 15pt one about 17
|
|
195
|
+
const iconSize = android ? 18 : small ? 17 : 20
|
|
187
196
|
// A menu chip's chevron: Material's 18dp arrow_drop_down, iOS's small chevron.down at the label's weight
|
|
188
|
-
const trailing = trailingIcon ?? (menu ? android ? <MaterialArrowDropDown size={18} /> : <ChevronDownSm size={16} /> : null)
|
|
197
|
+
const trailing = trailingIcon ?? (menu ? android ? <MaterialArrowDropDown size={18} /> : <ChevronDownSm size={small ? 14 : 16} /> : null)
|
|
189
198
|
const leadingColor = color
|
|
190
199
|
// A symbol alone (Maps' filter button before its chips): a circle as tall as the chip, named by accessibilityLabel
|
|
191
200
|
const symbolOnly = leading != null && (children == null || children === "") && trailing == null && !onRemove
|
|
@@ -202,6 +211,11 @@ export function Chip({
|
|
|
202
211
|
// iOS's glass filter: a glass capsule (its rim and sheen), filled with the accent once chosen
|
|
203
212
|
const glassLayer =
|
|
204
213
|
glass && !selected ? <Glass pointerEvents="none" radius={radius} style={[StyleSheet.absoluteFill, { top: inset, bottom: inset }]} /> : null
|
|
214
|
+
// Android's chip over content (`glass`): it stands on a glass of its size, the Android bar circles' (a see-through
|
|
215
|
+
// card with a rim and a soft shadow), Material's fill and label over it
|
|
216
|
+
const androidGlass = useAndroidGlass("bar")
|
|
217
|
+
const androidBacking =
|
|
218
|
+
android && appearance === "glass" ? <View pointerEvents="none" style={[StyleSheet.absoluteFill, androidGlass, { top: inset, bottom: inset, borderRadius: radius }]} /> : null
|
|
205
219
|
const layer = glassLayer ?? (
|
|
206
220
|
<Animated.View pointerEvents="none" style={[StyleSheet.absoluteFill, { top: inset, bottom: inset, borderRadius: radius, backgroundColor: fillPaint, borderCurve: "continuous" }]}>
|
|
207
221
|
{/* Android's press: the list selector over the chip, 6% black and 5% white at night (the dark theme's); over a
|
|
@@ -217,9 +231,9 @@ export function Chip({
|
|
|
217
231
|
minHeight: target,
|
|
218
232
|
paddingVertical: inset + (height - label.lineHeight) / 2,
|
|
219
233
|
// Android: 12 at the sides, 8 before an icon and 6 after it
|
|
220
|
-
paddingLeft: symbolOnly ? (height - iconSize) / 2 : leading != null ? (android ? 8 : 12) : android ? 12 : 16,
|
|
234
|
+
paddingLeft: symbolOnly ? (height - iconSize) / 2 : leading != null ? (android ? 8 : small ? 10 : 12) : android ? 12 : small ? 14 : 16,
|
|
221
235
|
// Android: 8 after a trailing icon (Compose's FilterChip), iOS 12
|
|
222
|
-
paddingRight: symbolOnly ? (height - iconSize) / 2 : cross ? 0 : trailing != null ? (android ? 8 : 12) : android ? 12 : 16,
|
|
236
|
+
paddingRight: symbolOnly ? (height - iconSize) / 2 : cross ? 0 : trailing != null ? (android ? 8 : small ? 10 : 12) : android ? 12 : small ? 14 : 16,
|
|
223
237
|
gap: 6,
|
|
224
238
|
opacity: !android && pressed ? 0.7 : 1,
|
|
225
239
|
}
|
|
@@ -260,6 +274,8 @@ export function Chip({
|
|
|
260
274
|
// Android dims a disabled chip, its fill with it, to half (as its other disabled controls)
|
|
261
275
|
const dim = android && disabled ? styles.dim : null
|
|
262
276
|
const handlers = {
|
|
277
|
+
// A symbol alone keeps the target's width past its circle (36 on iOS's small chip, 32 on Android's)
|
|
278
|
+
hitSlop: symbolOnly && height < target ? { left: (target - height) / 2, right: (target - height) / 2 } : undefined,
|
|
263
279
|
...(filter ? spaceToggles(press) : {}),
|
|
264
280
|
// A menu chip is a button that opens its menu, even when it shows a chosen filter
|
|
265
281
|
accessibilityRole: filter && !menu ? ("checkbox" as const) : ("button" as const),
|
|
@@ -305,6 +321,7 @@ export function Chip({
|
|
|
305
321
|
if (cross) {
|
|
306
322
|
return (
|
|
307
323
|
<View testID={testID} style={[styles.chip, { minHeight: target }, dim, style]}>
|
|
324
|
+
{androidBacking}
|
|
308
325
|
{layer}
|
|
309
326
|
{interactive ? (
|
|
310
327
|
<Pressable {...handlers} style={[styles.part, box]}>
|
|
@@ -328,6 +345,7 @@ export function Chip({
|
|
|
328
345
|
if (!interactive) {
|
|
329
346
|
return (
|
|
330
347
|
<View testID={testID} style={[styles.chip, styles.part, box, dim, style]}>
|
|
348
|
+
{androidBacking}
|
|
331
349
|
{layer}
|
|
332
350
|
{body}
|
|
333
351
|
</View>
|
|
@@ -335,6 +353,7 @@ export function Chip({
|
|
|
335
353
|
}
|
|
336
354
|
return (
|
|
337
355
|
<Pressable {...handlers} testID={testID} style={[styles.chip, styles.part, box, dim, style]}>
|
|
356
|
+
{androidBacking}
|
|
338
357
|
{layer}
|
|
339
358
|
{body}
|
|
340
359
|
</Pressable>
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { useId, useState, type ReactNode } from "react"
|
|
1
|
+
import { createContext, useContext, useId, useState, type ReactNode } from "react"
|
|
2
2
|
import { Animated, KeyboardAvoidingView, Platform, ScrollView, StyleSheet, View, useWindowDimensions } from "react-native"
|
|
3
3
|
import { Pressable } from "../../internal/Pressable"
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
5
5
|
import { Glass } from "../../internal/Glass"
|
|
6
6
|
import { useRipple } from "../../internal/ripple"
|
|
7
|
+
import { buttonColors } from "../Button/Button"
|
|
7
8
|
import { useKeyboardHeight } from "../../internal/keyboard"
|
|
8
9
|
import { androidDialogMotion, canTransformGlass, glassOpacity, iosDim, Overlay, ANDROID_DIALOG, ANDROID_DIM } from "../../internal/Overlay"
|
|
9
10
|
import { withAlpha, dangerText } from "../../theme/material"
|
|
@@ -41,16 +42,33 @@ export type DialogProps = {
|
|
|
41
42
|
mobileLayout?: "inline" | "stacked"
|
|
42
43
|
/** A tap outside, Android's back and Escape close it: Android's dialogs do, an iOS alert does not. @default Android true, iOS false */
|
|
43
44
|
dismissible?: boolean
|
|
45
|
+
/**
|
|
46
|
+
* The colors of the main action: `accent`, as iOS fills an alert's preferred action and Android writes its dialog
|
|
47
|
+
* buttons; `primary`, the main button's own (the solid primary button's fill and label on iOS, the primary ghost
|
|
48
|
+
* button's text on Android), for an app whose main actions are in its ink. @default "accent"
|
|
49
|
+
*/
|
|
50
|
+
actionColor?: "accent" | "primary"
|
|
44
51
|
testID?: string
|
|
45
52
|
}
|
|
46
53
|
|
|
54
|
+
/** The dialog's `actionColor`, for its action buttons. */
|
|
55
|
+
const ActionColorContext = createContext<"accent" | "primary">("accent")
|
|
56
|
+
|
|
47
57
|
/**
|
|
48
58
|
* A dialog that asks for a decision: on iOS the alert of iOS 26 (UIAlertController `.alert`: 320 wide, glass, radius
|
|
49
59
|
* 34, capsule actions 48 tall, `--dialog-alert-*`, Dialog.module.css), on Android a flat alert (at most 356 wide,
|
|
50
60
|
* radius 21, a Medium 20 title over 16 text, text buttons in the accent at the end, Android's dialog animation). The
|
|
51
61
|
* web Dialog's `mobileVariant="alert"` as one call; a sheet is `BottomSheet`.
|
|
52
62
|
*/
|
|
53
|
-
export function Dialog({
|
|
63
|
+
export function Dialog({ actionColor = "accent", ...props }: DialogProps) {
|
|
64
|
+
return (
|
|
65
|
+
<ActionColorContext.Provider value={actionColor}>
|
|
66
|
+
<DialogView {...props} />
|
|
67
|
+
</ActionColorContext.Provider>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function DialogView({ open, onOpenChange, title, description, actions = [], children, mobileLayout, dismissible, testID }: Omit<DialogProps, "actionColor">) {
|
|
54
72
|
const theme = useTheme()
|
|
55
73
|
const close = () => onOpenChange(false)
|
|
56
74
|
const run = (action: DialogAction) => {
|
|
@@ -386,18 +404,23 @@ function IOSAction({ theme, action, run, type, grow }: { theme: Theme; action: D
|
|
|
386
404
|
// a preferredAction (iOS 27.2: 0082f7 on every row); disabled, the phone's disabled fill (Button.module.css). A
|
|
387
405
|
// destructive one keeps the alert's fill and its red label
|
|
388
406
|
const accent = action.preferred && action.variant !== "destructive"
|
|
407
|
+
const primary = useContext(ActionColorContext) === "primary"
|
|
389
408
|
const height = theme.length("--dialog-alert-action-height", 48)
|
|
390
409
|
const fill = accent
|
|
391
410
|
? action.disabled
|
|
392
411
|
? theme.color("--button-mobile-disabled-background", theme.color("--color-background-disabled"))
|
|
393
|
-
:
|
|
412
|
+
: primary
|
|
413
|
+
? theme.color("--color-background-primary-solid")
|
|
414
|
+
: theme.color("--toolbar-prominent-background")
|
|
394
415
|
: theme.color("--dialog-alert-fill")
|
|
395
416
|
const text = action.disabled
|
|
396
417
|
? theme.color("--mobile-label-tertiary")
|
|
397
418
|
: action.variant === "destructive"
|
|
398
419
|
? theme.color("--color-text-danger")
|
|
399
420
|
: accent
|
|
400
|
-
?
|
|
421
|
+
? primary
|
|
422
|
+
? theme.color("--color-text-primary-solid")
|
|
423
|
+
: theme.color("--toolbar-prominent-color")
|
|
401
424
|
: theme.colors.text
|
|
402
425
|
const lit = accent && !action.disabled
|
|
403
426
|
return (
|
|
@@ -412,7 +435,7 @@ function IOSAction({ theme, action, run, type, grow }: { theme: Theme; action: D
|
|
|
412
435
|
{
|
|
413
436
|
minHeight: height,
|
|
414
437
|
borderRadius: height / 2,
|
|
415
|
-
backgroundColor: lit && pressed ? theme.color("--toolbar-prominent-background-active") : fill,
|
|
438
|
+
backgroundColor: lit && pressed ? theme.color(primary ? "--color-background-primary-solid-active" : "--toolbar-prominent-background-active") : fill,
|
|
416
439
|
opacity: pressed && !lit ? 0.7 : 1,
|
|
417
440
|
},
|
|
418
441
|
grow ? styles.grow : null,
|
|
@@ -506,7 +529,8 @@ function AndroidDialog({ theme, title, description, actions, run, ids, children,
|
|
|
506
529
|
* ripple of the label's color at 10% from the touch point, clipped to its 20dp pill (the platform's on a device).
|
|
507
530
|
*/
|
|
508
531
|
function AndroidDialogButton({ theme, action, run, onWidth }: { theme: Theme; action: DialogAction; run: (action: DialogAction) => void; onWidth: (width: number) => void }) {
|
|
509
|
-
const
|
|
532
|
+
const primary = useContext(ActionColorContext) === "primary"
|
|
533
|
+
const color = action.variant === "destructive" ? dangerText(theme) : primary ? buttonColors(theme, "primary", "ghost", false, false).text : theme.material.primary
|
|
510
534
|
const press = withAlpha(color, 0.1)
|
|
511
535
|
const nativeRipple = Platform.OS === "android"
|
|
512
536
|
const ripple = useRipple(press, !nativeRipple, theme.reducedMotion)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Children, cloneElement, createContext, isValidElement, useContext, type ReactNode } from "react"
|
|
2
|
-
import { StyleSheet, View, type StyleProp, type ViewStyle } from "react-native"
|
|
2
|
+
import { StyleSheet, View, type StyleProp, type TextStyle, type ViewStyle } from "react-native"
|
|
3
3
|
import { space } from "../../internal/spacing"
|
|
4
4
|
import { useTheme } from "../../theme/ThemeProvider"
|
|
5
5
|
import type { Theme } from "../../theme/types"
|
|
@@ -95,7 +95,16 @@ function EmptyMessageIcon({ children, color = "secondary", size }: { children: R
|
|
|
95
95
|
}
|
|
96
96
|
EmptyMessageIcon.displayName = "EmptyMessage.Icon"
|
|
97
97
|
|
|
98
|
-
function EmptyMessageTitle({
|
|
98
|
+
function EmptyMessageTitle({
|
|
99
|
+
children,
|
|
100
|
+
color,
|
|
101
|
+
style,
|
|
102
|
+
}: {
|
|
103
|
+
children: ReactNode
|
|
104
|
+
color?: Tone
|
|
105
|
+
/** Over the title's own type: a brand's display face at its size and line (`fontFamily`, `fontSize`, `lineHeight`). */
|
|
106
|
+
style?: StyleProp<TextStyle>
|
|
107
|
+
}) {
|
|
99
108
|
const { theme, size, align } = useEmpty("EmptyMessage.Title")
|
|
100
109
|
const compact = size === "sm"
|
|
101
110
|
// Android's empty view: the title Medium 20 (16 in the compact message)
|
|
@@ -113,7 +122,7 @@ function EmptyMessageTitle({ children, color }: { children: ReactNode; color?: T
|
|
|
113
122
|
color={color && color !== "secondary" ? toneColor(theme, color) : undefined}
|
|
114
123
|
// `left` is the start: React Native turns it to the right in a right-to-left layout. `auto` took the alignment of
|
|
115
124
|
// the page around it on the web, where a centered page left a start-aligned message centered
|
|
116
|
-
style={{ fontSize: type.fontSize, lineHeight: type.lineHeight, textAlign: align === "center" ? "center" : "left", marginBottom: compact ? space(theme, 1) : 0 }}
|
|
125
|
+
style={[{ fontSize: type.fontSize, lineHeight: type.lineHeight, textAlign: align === "center" ? "center" : "left", marginBottom: compact ? space(theme, 1) : 0 }, style]}
|
|
117
126
|
>
|
|
118
127
|
{children}
|
|
119
128
|
</Text>
|
|
@@ -15,8 +15,16 @@ export type CircularProgressProps = {
|
|
|
15
15
|
progress?: number
|
|
16
16
|
/** Size of the indicator, in pixels. @default 28 */
|
|
17
17
|
size?: number
|
|
18
|
-
/** Stroke width of the ring, in pixels of its 20px drawing, between 1 and 4. @default 2 */
|
|
18
|
+
/** Stroke width of the ring, in pixels of its 20px drawing, between 1 and 4 (with `ring="edge"`, in pixels of `size`). @default 2 */
|
|
19
19
|
strokeWidth?: number
|
|
20
|
+
/**
|
|
21
|
+
* Where the ring stands in its box: `"inset"`, the web's drawing (a ring of radius 8 in 20, so 28 across draws a
|
|
22
|
+
* ring of about 24); `"edge"`, the ring's outside on the box's edge, `size` the ring's own size.
|
|
23
|
+
* @default "inset"
|
|
24
|
+
*/
|
|
25
|
+
ring?: "inset" | "edge"
|
|
26
|
+
/** How long a new value takes to draw, in ms. @default 300 on iOS, 200 on Android */
|
|
27
|
+
duration?: number
|
|
20
28
|
/** Color of the active progress track (stroke): a color or a token, such as `"var(--gray-1000)"`. */
|
|
21
29
|
trackActiveColor?: string
|
|
22
30
|
/** Color of the base track (background stroke): a color or a token, such as `"var(--alpha-15)"`. */
|
|
@@ -89,6 +97,8 @@ export function CircularProgress({
|
|
|
89
97
|
progress: progressProp,
|
|
90
98
|
size = 28,
|
|
91
99
|
strokeWidth,
|
|
100
|
+
ring = "inset",
|
|
101
|
+
duration,
|
|
92
102
|
trackActiveColor,
|
|
93
103
|
trackColor,
|
|
94
104
|
"aria-label": ariaLabel,
|
|
@@ -100,11 +110,17 @@ export function CircularProgress({
|
|
|
100
110
|
const simulated = useSimulatedProgress(maxDuration, progressProp !== undefined || done)
|
|
101
111
|
const progress = Math.max(0, Math.min(100, progressProp ?? simulated))
|
|
102
112
|
const shown = useTweenedNumber(progress, {
|
|
103
|
-
duration: theme.isAndroid ? 200 : 300,
|
|
113
|
+
duration: duration ?? (theme.isAndroid ? 200 : 300),
|
|
104
114
|
easing: theme.isAndroid ? curves.decelerate : cssEase,
|
|
105
115
|
reducedMotion: theme.reducedMotion,
|
|
106
116
|
})
|
|
107
|
-
const
|
|
117
|
+
const edge = ring === "edge"
|
|
118
|
+
const stroke = edge ? Math.min(size / 2, strokeWidth ?? 2) : strokeWidth ? Math.min(4, strokeWidth) : 2
|
|
119
|
+
// The drawing: 20 units with a ring of 8 inset, or the box itself with the ring's outside on its edge
|
|
120
|
+
const box = edge ? size : 20
|
|
121
|
+
const center = box / 2
|
|
122
|
+
const radius = edge ? Math.max(0, (size - stroke) / 2) : 8
|
|
123
|
+
const dash = edge ? 2 * Math.PI * radius : DASH
|
|
108
124
|
// The web's `light-dark(#deede9, var(--green-a50))`: a light green, the green at 15% at night
|
|
109
125
|
const track = resolve(theme, trackColor, theme.scheme === "dark" ? theme.color("--green-a50") : "#DEEDE9")
|
|
110
126
|
const active = resolve(theme, trackActiveColor, theme.color("--green-500"))
|
|
@@ -120,20 +136,20 @@ export function CircularProgress({
|
|
|
120
136
|
testID={testID}
|
|
121
137
|
style={[{ width: size, height: size }, style]}
|
|
122
138
|
>
|
|
123
|
-
<Svg width={size} height={size} viewBox=
|
|
124
|
-
<Circle cx={
|
|
139
|
+
<Svg width={size} height={size} viewBox={`0 0 ${box} ${box}`}>
|
|
140
|
+
<Circle cx={center} cy={center} r={radius} fill="none" stroke={track} strokeWidth={stroke} />
|
|
125
141
|
<Circle
|
|
126
|
-
cx={
|
|
127
|
-
cy={
|
|
128
|
-
r={
|
|
142
|
+
cx={center}
|
|
143
|
+
cy={center}
|
|
144
|
+
r={radius}
|
|
129
145
|
fill="none"
|
|
130
146
|
stroke={active}
|
|
131
147
|
strokeWidth={stroke}
|
|
132
148
|
strokeLinecap="round"
|
|
133
|
-
strokeDasharray={[
|
|
134
|
-
strokeDashoffset={
|
|
149
|
+
strokeDasharray={[dash, dash]}
|
|
150
|
+
strokeDashoffset={dash - dash * (shown / 100)}
|
|
135
151
|
// The dash starts at 12 o'clock, as the web's ring turned back a quarter
|
|
136
|
-
transform=
|
|
152
|
+
transform={`rotate(-90 ${center} ${center})`}
|
|
137
153
|
/>
|
|
138
154
|
</Svg>
|
|
139
155
|
</View>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createContext, useCallback, useContext, useEffect, useRef, useState, type ComponentRef, type ReactNode, type Ref } from "react"
|
|
2
2
|
import { Animated, Easing, PixelRatio, Platform, StyleSheet, Text as NativeText, TextInput, View, processColor, type PressableProps, type StyleProp, type TextInputProps, type ViewProps, type ViewStyle } from "react-native"
|
|
3
3
|
import { Pressable } from "../../internal/Pressable"
|
|
4
|
+
import { Text } from "../Text/Text"
|
|
4
5
|
import XCircleFilled from "../../icons/plex/XCircleFilled"
|
|
5
6
|
import { useAndroidGlass } from "../../internal/BarBackdrop"
|
|
6
7
|
import { FieldStack, FloatLabelContext } from "../../internal/fieldStack"
|
|
@@ -896,6 +897,13 @@ export type TextFieldProps = InputProps & {
|
|
|
896
897
|
/** Shown under the field in place of the description, and marks it invalid. */
|
|
897
898
|
errorMessage?: ReactNode
|
|
898
899
|
required?: boolean
|
|
900
|
+
/** Content at the end of the label's line on iOS, or of the help's line on Android (where the label floats). */
|
|
901
|
+
labelAction?: ReactNode
|
|
902
|
+
/**
|
|
903
|
+
* Shows the count of characters against `maxLength` (`3/15`): Material's counter at the end of the help's line on
|
|
904
|
+
* Android, at the end of the label's line on iOS.
|
|
905
|
+
*/
|
|
906
|
+
counter?: boolean
|
|
899
907
|
}
|
|
900
908
|
|
|
901
909
|
/**
|
|
@@ -903,11 +911,39 @@ export type TextFieldProps = InputProps & {
|
|
|
903
911
|
* description or error under it (15/20, 4pt below, `--mobile-field-error-*`); Android is the outlined field with its
|
|
904
912
|
* floating label (on the line of an outlined field) and the help under it (14, 14dp in).
|
|
905
913
|
*/
|
|
906
|
-
export function TextField({ label, description, errorMessage, required, invalid, ...input }: TextFieldProps) {
|
|
914
|
+
export function TextField({ label, description, errorMessage, required, invalid, labelAction, counter = false, ...input }: TextFieldProps) {
|
|
907
915
|
const theme = useTheme()
|
|
916
|
+
const [typed, setTyped] = useState((input.defaultValue ?? "").length)
|
|
917
|
+
const count = input.value != null ? input.value.length : typed
|
|
918
|
+
const counterText =
|
|
919
|
+
counter && input.maxLength != null ? (
|
|
920
|
+
<Text
|
|
921
|
+
color="secondary"
|
|
922
|
+
accessibilityLabel={`${count} of ${input.maxLength}`}
|
|
923
|
+
style={[
|
|
924
|
+
theme.isAndroid ? styles.androidCounter : styles.iosCounter,
|
|
925
|
+
{ opacity: input.disabled ? 0.5 : 1 },
|
|
926
|
+
theme.isAndroid ? { color: theme.colors.textSecondary } : null,
|
|
927
|
+
]}
|
|
928
|
+
>
|
|
929
|
+
{count}/{input.maxLength}
|
|
930
|
+
</Text>
|
|
931
|
+
) : null
|
|
932
|
+
const end =
|
|
933
|
+
labelAction != null && counterText != null ? (
|
|
934
|
+
<View style={styles.endRow}>
|
|
935
|
+
{labelAction}
|
|
936
|
+
{counterText}
|
|
937
|
+
</View>
|
|
938
|
+
) : (
|
|
939
|
+
labelAction ?? counterText
|
|
940
|
+
)
|
|
941
|
+
// The count follows every edit, so a counter shown later reads the text as it is
|
|
942
|
+
const field: InputProps = { ...input, onChangeText: (next: string) => (setTyped(next.length), input.onChangeText?.(next)) }
|
|
908
943
|
return (
|
|
909
944
|
<FieldStack
|
|
910
945
|
label={label}
|
|
946
|
+
labelAction={end ?? undefined}
|
|
911
947
|
required={required}
|
|
912
948
|
description={description}
|
|
913
949
|
errorMessage={errorMessage}
|
|
@@ -919,10 +955,10 @@ export function TextField({ label, description, errorMessage, required, invalid,
|
|
|
919
955
|
>
|
|
920
956
|
{({ described, invalid: bad, shake }) =>
|
|
921
957
|
theme.isAndroid ? (
|
|
922
|
-
<InputField {...
|
|
958
|
+
<InputField {...field} {...described} label={label} required={required} invalid={bad} shift={shake} />
|
|
923
959
|
) : (
|
|
924
960
|
<InputField
|
|
925
|
-
{...
|
|
961
|
+
{...field}
|
|
926
962
|
{...described}
|
|
927
963
|
accessibilityLabel={input.accessibilityLabel ?? (typeof label === "string" ? label : undefined)}
|
|
928
964
|
required={required}
|
|
@@ -940,6 +976,10 @@ const ROW_START: AdornmentPlace = { side: "start", row: true }
|
|
|
940
976
|
const ROW_END: AdornmentPlace = { side: "end", row: true }
|
|
941
977
|
|
|
942
978
|
const styles = StyleSheet.create({
|
|
979
|
+
// Material's counter: the help's type, at the end of its line, 16 from the help and 14 in from the field's end
|
|
980
|
+
androidCounter: { fontSize: 14, lineHeight: 18, paddingStart: 16, paddingEnd: 14, paddingTop: 6, fontVariant: ["tabular-nums"] },
|
|
981
|
+
iosCounter: { fontSize: 15, lineHeight: 20, fontVariant: ["tabular-nums"] },
|
|
982
|
+
endRow: { flexDirection: "row", alignItems: "center", gap: 8 },
|
|
943
983
|
adornmentButton: { alignItems: "center", justifyContent: "center" },
|
|
944
984
|
// Centered in the 48dp target
|
|
945
985
|
adornmentPressed: { position: "absolute", top: 4, start: 4, width: 40, height: 40, borderRadius: 20 },
|