@plexui/react-native 0.2.26 → 0.2.28
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/Button/Button.js +9 -5
- 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/Input/Input.js +17 -2
- package/dist/es/components/List/List.js +35 -2
- package/dist/es/components/ScrollEdge/ScrollEdge.js +12 -6
- package/dist/es/components/TabBar/TabBar.js +15 -0
- package/dist/es/components/TextLink/TextLink.js +18 -3
- package/dist/es/index.js +2 -2
- 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/Input/Input.d.ts +8 -1
- package/dist/types/components/List/List.d.ts +26 -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/package.json +2 -2
- package/src/components/Button/Button.tsx +10 -5
- 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/Input/Input.tsx +43 -3
- package/src/components/List/List.tsx +70 -2
- package/src/components/ScrollEdge/ScrollEdge.tsx +19 -6
- package/src/components/TabBar/TabBar.tsx +15 -0
- package/src/components/TextLink/TextLink.tsx +46 -3
- package/src/index.ts +2 -2
|
@@ -65,6 +65,25 @@ export declare function useListMetrics(): {
|
|
|
65
65
|
* the footer on that gray.
|
|
66
66
|
*/
|
|
67
67
|
export declare function List({ children, header, description, footer, error, surface, action, headerProminence, columns, "aria-label": ariaLabel, testID, style, }: ListProps): import("react").JSX.Element;
|
|
68
|
+
export type ListStackProps = {
|
|
69
|
+
/** The sections (`List`) and any blocks between them (a note, a button). */
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
/** The space between two blocks that are not both sections, as the screen's own. @default 0 */
|
|
72
|
+
gap?: number;
|
|
73
|
+
/**
|
|
74
|
+
* Keeps the room under the last section (iOS 35 over the home indicator, Android at least 16 over the system's bar).
|
|
75
|
+
* Off for a stack that is not the screen's end. @default true
|
|
76
|
+
*/
|
|
77
|
+
end?: boolean;
|
|
78
|
+
style?: StyleProp<ViewStyle>;
|
|
79
|
+
testID?: string;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Sections one under another, as SwiftUI's Form and the web's stacked FieldGroups space them: on iOS 35 rows to rows,
|
|
83
|
+
* less what a footer's block (17.33) and a header's (18.67, a prominent one 18, after a footer 11.33) take; on Android
|
|
84
|
+
* 12 apart, none after a footer. Blocks that are not sections keep `gap`; the stack ends with the last section's room.
|
|
85
|
+
*/
|
|
86
|
+
export declare function ListStack({ children, gap, end, style, testID }: ListStackProps): import("react").JSX.Element;
|
|
68
87
|
export type ListItemProps = {
|
|
69
88
|
/** The row's text, as @plexui/ui's NavigationRow `label`. */
|
|
70
89
|
label: ReactNode;
|
|
@@ -97,6 +116,12 @@ export type ListItemProps = {
|
|
|
97
116
|
* control stays the one element for a screen reader, named by the label when it has no name of its own.
|
|
98
117
|
*/
|
|
99
118
|
trailing?: ReactNode;
|
|
119
|
+
/**
|
|
120
|
+
* A row of a list to pick one from (countries with their codes, a sound): `true` draws the check at its end (the
|
|
121
|
+
* accent's checkmark), `false` keeps the check's room, so the values of every row stand in one column and a pick
|
|
122
|
+
* moves no text. Read as selected. Leave `trailing` out.
|
|
123
|
+
*/
|
|
124
|
+
selected?: boolean;
|
|
100
125
|
/**
|
|
101
126
|
* An error under the row, as the web's FieldError in a form row: on iOS a line of its own across the row, 4 under the
|
|
102
127
|
* label, 15/20 in the danger color after a 16pt exclamation mark; on Android under the label, 13sp in the error color.
|
|
@@ -141,7 +166,7 @@ export type ListItemProps = {
|
|
|
141
166
|
* in (a multi-select list); a 1px divider from the text's start to the card's end, none under a row with a tile (a
|
|
142
167
|
* tiled row draws none).
|
|
143
168
|
*/
|
|
144
|
-
export declare function ListItem({ label, description, leading, leadingColor, value, valuePlacement, valueColor, trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, longPressLabel, disabled, destructive, accessibilityLabel, accessibilityHint, testID, }: ListItemProps): import("react").JSX.Element;
|
|
169
|
+
export declare function ListItem({ label, description, leading, leadingColor, value, valuePlacement, valueColor, trailing: trailingProp, selected, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, longPressLabel, disabled, destructive, accessibilityLabel, accessibilityHint, testID, }: ListItemProps): import("react").JSX.Element;
|
|
145
170
|
export type StackedRowProps = {
|
|
146
171
|
/** The label over the value; none for a row whose placeholder names the field (`hideLabel`). */
|
|
147
172
|
label?: ReactNode;
|
|
@@ -6,6 +6,12 @@ export type ScrollEdgeProps = {
|
|
|
6
6
|
scrolled?: boolean;
|
|
7
7
|
/** The color of the screen it fades into (a grouped screen's canvas). @default the theme's background */
|
|
8
8
|
canvasColor?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Top edge under a floating row (filters, tabs): where the fade ends, from the screen's top. Only what went under the
|
|
11
|
+
* row is muted, the content below it stays sharp: pass the row's bottom. On Android, too, the edge then is the row's
|
|
12
|
+
* (iOS 27.2's), not the status bar's alone.
|
|
13
|
+
*/
|
|
14
|
+
fadeEnd?: number;
|
|
9
15
|
testID?: string;
|
|
10
16
|
style?: StyleProp<ViewStyle>;
|
|
11
17
|
};
|
|
@@ -16,4 +22,4 @@ export type ScrollEdgeProps = {
|
|
|
16
22
|
* the screen's color that grows to 46% at the screen's edge. On Android the top edge is the soft edge of its top bar
|
|
17
23
|
* over the status bar alone, the bottom one draws nothing. Lay it over the screen, after the scroll view.
|
|
18
24
|
*/
|
|
19
|
-
export declare function ScrollEdge({ edge, scrolled, canvasColor, testID, style }: ScrollEdgeProps): import("react").JSX.Element | null;
|
|
25
|
+
export declare function ScrollEdge({ edge, scrolled, canvasColor, fadeEnd, testID, style }: ScrollEdgeProps): import("react").JSX.Element | null;
|
|
@@ -107,6 +107,19 @@ declare namespace TabBarRoot {
|
|
|
107
107
|
export declare const TabBar: typeof TabBarRoot & {
|
|
108
108
|
Item: typeof TabBarItem;
|
|
109
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Where the tab bar's capsule stands, for what floats over it (a screen's floating buttons a set gap above it, a
|
|
112
|
+
* scroll that ends over it): `capsuleHeight`, and `bottom`, from the screen's bottom edge to the capsule's. iOS 26: the
|
|
113
|
+
* 54pt tabs in a capsule 4 above and below (62), 21 over the screen's bottom (or over the home indicator); Android:
|
|
114
|
+
* 56dp, 8 over the gesture bar. The bar itself (its soft edge) reaches higher. Pass the bar's `safeArea`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function useTabBarMetrics({ safeArea, minimized }?: {
|
|
117
|
+
safeArea?: boolean;
|
|
118
|
+
minimized?: boolean;
|
|
119
|
+
}): {
|
|
120
|
+
capsuleHeight: number;
|
|
121
|
+
bottom: number;
|
|
122
|
+
};
|
|
110
123
|
/**
|
|
111
124
|
* Minimizes a TabBar while the screen scrolls down and expands it when it scrolls back up, as iOS 26
|
|
112
125
|
* `tabBarMinimizeBehavior(.onScrollDown)`: pass `onScroll` to the ScrollView and `minimized` and
|
|
@@ -16,6 +16,12 @@ export type TextLinkProps = {
|
|
|
16
16
|
onPress?: (event: GestureResponderEvent) => void;
|
|
17
17
|
/** The weight of the link's text; it takes the text's own around it by default (`--link-font-weight: inherit`). */
|
|
18
18
|
weight?: FontWeightName;
|
|
19
|
+
/**
|
|
20
|
+
* A small action of its own outside running text (Restore Purchases under a store's plans): on iOS the text alone
|
|
21
|
+
* at the subheadline (15/20, regular) in the link color with a 44pt target and the system's pressed fade; on Android
|
|
22
|
+
* Material's small text button. @default false
|
|
23
|
+
*/
|
|
24
|
+
standalone?: boolean;
|
|
19
25
|
accessibilityLabel?: string;
|
|
20
26
|
testID?: string;
|
|
21
27
|
style?: StyleProp<TextStyle>;
|
|
@@ -27,4 +33,4 @@ export type TextLinkProps = {
|
|
|
27
33
|
* row in the Plex Android look (the text's ink at 11%, white at 5% at night). With `href` it is a `link` and opens the
|
|
28
34
|
* URL (an `<a>` on the web, a new tab for an external one); with only `onPress` it is a `button`.
|
|
29
35
|
*/
|
|
30
|
-
export declare function TextLink({ children, href, primary, underline, forceExternal, onPress, weight, accessibilityLabel, testID, style }: TextLinkProps): import("react").JSX.Element;
|
|
36
|
+
export declare function TextLink({ children, href, primary, underline, forceExternal, onPress, weight, standalone, accessibilityLabel, testID, style }: TextLinkProps): import("react").JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { Glass, type GlassProps } from "./internal/Glass";
|
|
|
10
10
|
export { BarItemContext, type BarItemStyle } from "./components/Button/Button";
|
|
11
11
|
export { NavigationButton, type NavigationAction, type NavigationButtonProps } from "./components/NavigationButton/NavigationButton";
|
|
12
12
|
export { Toolbar, type ToolbarBackground, type ToolbarContentProps, type ToolbarPlacement, type ToolbarProps, type ToolbarTitleAlign, type ToolbarTitleProps, type ToolbarTitleStyle, } from "./components/Toolbar/Toolbar";
|
|
13
|
-
export { TabBar, useTabBarMinimize, type TabBarBackground, type TabBarBadgeColor, type TabBarItemProps, type TabBarProminent, type TabBarProps, type TabBarSearch, } from "./components/TabBar/TabBar";
|
|
13
|
+
export { TabBar, useTabBarMetrics, useTabBarMinimize, type TabBarBackground, type TabBarBadgeColor, type TabBarItemProps, type TabBarProminent, type TabBarProps, type TabBarSearch, } from "./components/TabBar/TabBar";
|
|
14
14
|
export { SegmentedControl, type SegmentedControlBadgeProp, type SegmentedControlOptionProps, type SegmentedControlProps, } from "./components/SegmentedControl/SegmentedControl";
|
|
15
15
|
export { Switch, type SwitchProps } from "./components/Switch/Switch";
|
|
16
16
|
export { Checkbox, type CheckboxProps } from "./components/Checkbox/Checkbox";
|
|
@@ -37,7 +37,7 @@ export { Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVari
|
|
|
37
37
|
export { BottomActions, type BottomActionsBackground, type BottomActionsProps } from "./components/BottomActions/BottomActions";
|
|
38
38
|
export { IntroHeader, type IntroHeaderAlign, type IntroHeaderProps } from "./components/IntroHeader/IntroHeader";
|
|
39
39
|
export { Card, cardColors, type CardColor, type CardMediaProps, type CardProps, type CardSize, type CardVariant } from "./components/Card/Card";
|
|
40
|
-
export { List, ListItem, useListMetrics, type ListItemProps, type ListProps } from "./components/List/List";
|
|
40
|
+
export { List, ListItem, ListStack, useListMetrics, type ListItemProps, type ListProps, type ListStackProps } from "./components/List/List";
|
|
41
41
|
export { Chip, type ChipProps } from "./components/Chip/Chip";
|
|
42
42
|
export { Skeleton, type SkeletonProps } from "./components/Skeleton/Skeleton";
|
|
43
43
|
export { Progress, progressSegments, type ProgressColor, type ProgressProps, type ProgressSegment, type ProgressSize } from "./components/Progress/Progress";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/react-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.28",
|
|
4
4
|
"description": "Plex UI components for React Native and Expo: iOS 26 and Material 3, on the shared @plexui/styles tokens",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://plexui.com",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"test": "npm run typecheck && npm run lint && npm run test:web --prefix example"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@plexui/styles": "^0.17.
|
|
87
|
+
"@plexui/styles": "^0.17.6",
|
|
88
88
|
"libphonenumber-js": "^1.13.17"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
@@ -211,6 +211,11 @@ function iosPress(theme: Theme, variant: ButtonVariant, colors: Colors): Colors
|
|
|
211
211
|
return { ...colors, pressed, pressedText: lighten(theme, colors.text) }
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
/** iOS: a disabled button's label, the tertiary label unless a brand sets its own (`--button-mobile-disabled-color`). */
|
|
215
|
+
function disabledLabel(theme: Theme) {
|
|
216
|
+
return theme.color("--button-mobile-disabled-color", theme.colors.labelTertiary)
|
|
217
|
+
}
|
|
218
|
+
|
|
214
219
|
export function buttonColors(theme: Theme, color: ButtonColor, variant: ButtonVariant, disabled: boolean, selected: boolean): Colors {
|
|
215
220
|
const c = (name: string) => theme.color(`--color-${name}`)
|
|
216
221
|
if (disabled) {
|
|
@@ -223,13 +228,13 @@ export function buttonColors(theme: Theme, color: ButtonColor, variant: ButtonVa
|
|
|
223
228
|
const flat = variant === "ghost" || variant === "outline"
|
|
224
229
|
return { background: flat ? "transparent" : veil, pressed: flat ? "transparent" : veil, text: withAlpha(onSurface, 0.38), border: variant === "outline" ? veil : undefined }
|
|
225
230
|
}
|
|
226
|
-
// The phone CSS: the tertiary label in every style (iOS 27's disabled content-area button),
|
|
227
|
-
// button behind a solid or soft one
|
|
231
|
+
// The phone CSS: the tertiary label in every style (iOS 27's disabled content-area button), or a brand's own
|
|
232
|
+
// disabled label (`--button-mobile-disabled-color`); the fill of a gray button behind a solid or soft one
|
|
228
233
|
// An outline button is iOS's Gray (below): disabled, the gray fill as the others
|
|
229
234
|
return {
|
|
230
235
|
background: variant === "ghost" ? "transparent" : theme.color("--button-mobile-disabled-background"),
|
|
231
236
|
pressed: "transparent",
|
|
232
|
-
text: theme
|
|
237
|
+
text: disabledLabel(theme),
|
|
233
238
|
}
|
|
234
239
|
}
|
|
235
240
|
const colors = ((): Colors => {
|
|
@@ -303,7 +308,7 @@ function barColors(
|
|
|
303
308
|
// replace the fill
|
|
304
309
|
if (neutral && !selected && (bar.inGroup || !flat)) {
|
|
305
310
|
const pressed = bar.inGroup ? theme.color("--toolbar-group-item-active") : theme.color("--mobile-glass-background-active")
|
|
306
|
-
return { background: "transparent", pressed, text: disabled ? theme
|
|
311
|
+
return { background: "transparent", pressed, text: disabled ? disabledLabel(theme) : colors.text }
|
|
307
312
|
}
|
|
308
313
|
return colors
|
|
309
314
|
}
|
|
@@ -468,7 +473,7 @@ function ListActionButton({
|
|
|
468
473
|
: // The web's phone rows tint an action with the info text (#0169cc, blue-200 in the dark)
|
|
469
474
|
theme.color("--color-text-info", theme.colors.accent)
|
|
470
475
|
: buttonColors(theme, color, "ghost", false, false).text
|
|
471
|
-
const ink = disabled ? (android ? withAlpha(base, 0.5) : theme
|
|
476
|
+
const ink = disabled ? (android ? withAlpha(base, 0.5) : disabledLabel(theme)) : !row && pressed && !android ? lighten(theme, base) : base
|
|
472
477
|
// Android: a row's words 16/20, a header's 15/20 Medium (the web's FieldGroup header action)
|
|
473
478
|
const type = android
|
|
474
479
|
? row
|
|
@@ -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>
|
|
@@ -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 },
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useState, type ComponentRef, type ReactElement, type ReactNode } from "react"
|
|
2
2
|
import { Animated, Easing, Platform, StyleSheet, View, type GestureResponderEvent, type LayoutChangeEvent, type StyleProp, type TextStyle, type ViewStyle } from "react-native"
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
3
4
|
import { Pressable } from "../../internal/Pressable"
|
|
5
|
+
import CheckMd from "../../icons/plex/CheckMd"
|
|
4
6
|
import Disclosure from "../../icons/plex/Disclosure"
|
|
5
7
|
import ExclamationMarkCircle from "../../icons/plex/ExclamationMarkCircle"
|
|
6
8
|
import { describedBy, spaceToggles, useDescription, useHint } from "../../internal/a11y"
|
|
@@ -316,6 +318,51 @@ export function List({
|
|
|
316
318
|
)
|
|
317
319
|
}
|
|
318
320
|
|
|
321
|
+
export type ListStackProps = {
|
|
322
|
+
/** The sections (`List`) and any blocks between them (a note, a button). */
|
|
323
|
+
children: ReactNode
|
|
324
|
+
/** The space between two blocks that are not both sections, as the screen's own. @default 0 */
|
|
325
|
+
gap?: number
|
|
326
|
+
/**
|
|
327
|
+
* Keeps the room under the last section (iOS 35 over the home indicator, Android at least 16 over the system's bar).
|
|
328
|
+
* Off for a stack that is not the screen's end. @default true
|
|
329
|
+
*/
|
|
330
|
+
end?: boolean
|
|
331
|
+
style?: StyleProp<ViewStyle>
|
|
332
|
+
testID?: string
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Sections one under another, as SwiftUI's Form and the web's stacked FieldGroups space them: on iOS 35 rows to rows,
|
|
337
|
+
* less what a footer's block (17.33) and a header's (18.67, a prominent one 18, after a footer 11.33) take; on Android
|
|
338
|
+
* 12 apart, none after a footer. Blocks that are not sections keep `gap`; the stack ends with the last section's room.
|
|
339
|
+
*/
|
|
340
|
+
export function ListStack({ children, gap = 0, end = true, style, testID }: ListStackProps) {
|
|
341
|
+
const theme = useTheme()
|
|
342
|
+
const insets = useSafeAreaInsets()
|
|
343
|
+
const items = flattenChildren(children)
|
|
344
|
+
const section = (node: ReactNode): ListProps | null => (isValidElement(node) && node.type === List ? (node.props as ListProps) : null)
|
|
345
|
+
const space = (before: ListProps | null, after: ListProps | null) => {
|
|
346
|
+
if (before == null || after == null) return gap
|
|
347
|
+
const footer = before.footer != null || before.error != null
|
|
348
|
+
const header = after.header != null || after.description != null || after.action != null
|
|
349
|
+
if (theme.isAndroid) return footer ? 0 : 12
|
|
350
|
+
const prominent = after.headerProminence === "increased"
|
|
351
|
+
return 35 - (footer ? 17.33 : 0) - (header ? (prominent ? 18 : footer ? 11.33 : 18.67) : 0)
|
|
352
|
+
}
|
|
353
|
+
const last = section(items[items.length - 1])
|
|
354
|
+
const bottom = !end ? 0 : theme.isAndroid ? Math.max(16, insets.bottom) : last != null ? 35 + insets.bottom : insets.bottom
|
|
355
|
+
return (
|
|
356
|
+
<View style={[{ paddingBottom: bottom }, style]} testID={testID}>
|
|
357
|
+
{items.map((child, index) => (
|
|
358
|
+
<View key={isValidElement(child) && child.key != null ? child.key : index} style={index > 0 ? { marginTop: space(section(items[index - 1]), section(child)) } : null}>
|
|
359
|
+
{child}
|
|
360
|
+
</View>
|
|
361
|
+
))}
|
|
362
|
+
</View>
|
|
363
|
+
)
|
|
364
|
+
}
|
|
365
|
+
|
|
319
366
|
export type ListItemProps = {
|
|
320
367
|
/** The row's text, as @plexui/ui's NavigationRow `label`. */
|
|
321
368
|
label: ReactNode
|
|
@@ -348,6 +395,12 @@ export type ListItemProps = {
|
|
|
348
395
|
* control stays the one element for a screen reader, named by the label when it has no name of its own.
|
|
349
396
|
*/
|
|
350
397
|
trailing?: ReactNode
|
|
398
|
+
/**
|
|
399
|
+
* A row of a list to pick one from (countries with their codes, a sound): `true` draws the check at its end (the
|
|
400
|
+
* accent's checkmark), `false` keeps the check's room, so the values of every row stand in one column and a pick
|
|
401
|
+
* moves no text. Read as selected. Leave `trailing` out.
|
|
402
|
+
*/
|
|
403
|
+
selected?: boolean
|
|
351
404
|
/**
|
|
352
405
|
* An error under the row, as the web's FieldError in a form row: on iOS a line of its own across the row, 4 under the
|
|
353
406
|
* label, 15/20 in the danger color after a 16pt exclamation mark; on Android under the label, 13sp in the error color.
|
|
@@ -401,7 +454,8 @@ export function ListItem({
|
|
|
401
454
|
value,
|
|
402
455
|
valuePlacement = "end",
|
|
403
456
|
valueColor,
|
|
404
|
-
trailing,
|
|
457
|
+
trailing: trailingProp,
|
|
458
|
+
selected,
|
|
405
459
|
error,
|
|
406
460
|
checked: checkedProp,
|
|
407
461
|
defaultChecked,
|
|
@@ -421,6 +475,7 @@ export function ListItem({
|
|
|
421
475
|
// A menu opened from the row finds the row (Android lights it over the dim of the screen)
|
|
422
476
|
const frameNode = useRef<unknown>(null)
|
|
423
477
|
const frame = useMemo<RowFrame>(() => ({ node: frameNode, radius: { top, bottom } }), [top, bottom])
|
|
478
|
+
const trailing = trailingProp ?? (selected === undefined ? undefined : <CheckSlot selected={selected} />)
|
|
424
479
|
const switchRow = checkedProp !== undefined || defaultChecked !== undefined || onCheckedChange !== undefined
|
|
425
480
|
const [own, setOwn] = useState(defaultChecked ?? false)
|
|
426
481
|
const checked = checkedProp ?? own
|
|
@@ -538,8 +593,10 @@ export function ListItem({
|
|
|
538
593
|
tabIndex={endOwnsFocus ? -1 : undefined}
|
|
539
594
|
accessibilityRole={endOwnsFocus ? undefined : switchRow ? "switch" : "button"}
|
|
540
595
|
accessibilityLabel={endOwnsFocus ? undefined : name}
|
|
541
|
-
accessibilityState={endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled }}
|
|
596
|
+
accessibilityState={endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled, ...(selected !== undefined ? { selected } : null) }}
|
|
542
597
|
aria-checked={switchRow ? checked : undefined}
|
|
598
|
+
// React Native Web drops a button's selected state: the web reads a chosen row as a pressed button
|
|
599
|
+
{...(Platform.OS === "web" && !endOwnsFocus && !switchRow && selected !== undefined ? ({ "aria-pressed": selected } as object) : null)}
|
|
543
600
|
disabled={disabled || (press == null && onLongPress == null)}
|
|
544
601
|
onPress={press}
|
|
545
602
|
{...holdProps({ run: onLongPress, label: longPressLabel }, null)}
|
|
@@ -583,6 +640,17 @@ export function ListItem({
|
|
|
583
640
|
)
|
|
584
641
|
}
|
|
585
642
|
|
|
643
|
+
/** The check of a choice row, or its empty room: the accent's checkmark, 20 on iOS (a 17pt symbol), 24 on Android. */
|
|
644
|
+
function CheckSlot({ selected }: { selected: boolean }) {
|
|
645
|
+
const theme = useTheme()
|
|
646
|
+
const size = theme.isAndroid ? 24 : 20
|
|
647
|
+
return (
|
|
648
|
+
<View style={{ width: size, height: size }} accessibilityElementsHidden importantForAccessibility="no-hide-descendants">
|
|
649
|
+
{selected ? <CheckMd size={size} color={theme.isAndroid ? theme.material.primary : theme.colors.accent} /> : null}
|
|
650
|
+
</View>
|
|
651
|
+
)
|
|
652
|
+
}
|
|
653
|
+
|
|
586
654
|
/** A Button among a List's rows: the row is the button (`ListActionContext`), the hairline under it from the text's start. */
|
|
587
655
|
function ActionRow({ children }: { children: ReactNode }) {
|
|
588
656
|
const theme = useTheme()
|