@plexui/react-native 0.1.1 → 0.2.1
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 +34 -0
- package/dist/es/components/ActionSheet/ActionSheet.js +67 -19
- package/dist/es/components/Alert/Alert.js +163 -0
- package/dist/es/components/Avatar/Avatar.js +20 -8
- package/dist/es/components/BottomActions/BottomActions.js +34 -0
- package/dist/es/components/BottomSheet/BottomSheet.js +85 -17
- package/dist/es/components/Button/Button.js +108 -28
- package/dist/es/components/Card/Card.js +16 -8
- package/dist/es/components/Checkbox/Checkbox.js +67 -99
- package/dist/es/components/Chip/Chip.js +39 -19
- package/dist/es/components/Dialog/Dialog.js +38 -24
- package/dist/es/components/Field/Field.js +91 -0
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +59 -0
- package/dist/es/components/Icon/createIcon.js +13 -2
- package/dist/es/components/Indicator/CircularProgress.js +80 -0
- package/dist/es/components/Indicator/LoadingDots.js +46 -0
- package/dist/es/components/Indicator/LoadingIndicator.js +101 -0
- package/dist/es/components/Indicator/index.js +3 -0
- package/dist/es/components/Input/Input.js +69 -60
- package/dist/es/components/InputGroup/InputGroup.js +130 -0
- package/dist/es/components/List/List.js +175 -59
- package/dist/es/components/Menu/Menu.js +69 -40
- package/dist/es/components/NavigationButton/NavigationButton.js +20 -4
- package/dist/es/components/OTPInput/OTPInput.js +9 -3
- package/dist/es/components/PageControl/PageControl.js +13 -7
- package/dist/es/components/Popover/Popover.js +128 -0
- package/dist/es/components/Progress/Progress.js +142 -0
- package/dist/es/components/ProgressSteps/ProgressSteps.js +207 -0
- package/dist/es/components/RollingNumber/RollingNumber.js +125 -0
- package/dist/es/components/Select/Select.js +97 -34
- package/dist/es/components/Separator/Separator.js +31 -0
- package/dist/es/components/ShimmerText/ShimmerText.js +98 -0
- package/dist/es/components/Stepper/Stepper.js +219 -0
- package/dist/es/components/Switch/Switch.js +26 -12
- package/dist/es/components/TagInput/TagInput.js +121 -0
- package/dist/es/components/Text/Text.js +7 -4
- package/dist/es/components/TextLink/TextLink.js +42 -0
- package/dist/es/components/Textarea/Textarea.js +12 -0
- package/dist/es/components/Tip/Tip.js +193 -0
- package/dist/es/components/Toolbar/Toolbar.js +6 -2
- package/dist/es/components/Tooltip/Tooltip.js +272 -0
- package/dist/es/index.js +20 -2
- package/dist/es/internal/FloatingPanel.js +111 -0
- package/dist/es/internal/fieldStack.js +73 -0
- package/dist/es/internal/floating.js +97 -0
- package/dist/es/internal/ripple.js +119 -0
- package/dist/es/internal/row.js +2 -1
- package/dist/es/internal/transition.js +113 -0
- package/dist/es/theme/ThemeProvider.js +41 -9
- package/dist/es/theme/material.js +37 -7
- package/dist/types/components/ActionSheet/ActionSheet.d.ts +15 -7
- package/dist/types/components/Alert/Alert.d.ts +51 -0
- package/dist/types/components/Avatar/Avatar.d.ts +4 -2
- package/dist/types/components/BottomActions/BottomActions.d.ts +18 -0
- package/dist/types/components/BottomSheet/BottomSheet.d.ts +4 -2
- package/dist/types/components/Button/Button.d.ts +20 -5
- package/dist/types/components/Card/Card.d.ts +14 -1
- package/dist/types/components/Checkbox/Checkbox.d.ts +4 -3
- package/dist/types/components/Chip/Chip.d.ts +23 -4
- package/dist/types/components/Dialog/Dialog.d.ts +9 -5
- package/dist/types/components/Field/Field.d.ts +64 -0
- package/dist/types/components/FloatingLabelInput/FloatingLabelInput.d.ts +42 -0
- package/dist/types/components/Indicator/CircularProgress.d.ts +34 -0
- package/dist/types/components/Indicator/LoadingDots.d.ts +17 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +46 -0
- package/dist/types/components/Indicator/index.d.ts +3 -0
- package/dist/types/components/Input/Input.d.ts +13 -3
- package/dist/types/components/InputGroup/InputGroup.d.ts +71 -0
- package/dist/types/components/List/List.d.ts +57 -14
- package/dist/types/components/Menu/Menu.d.ts +4 -0
- package/dist/types/components/NavigationButton/NavigationButton.d.ts +11 -3
- package/dist/types/components/OTPInput/OTPInput.d.ts +10 -1
- package/dist/types/components/PageControl/PageControl.d.ts +11 -1
- package/dist/types/components/Popover/Popover.d.ts +86 -0
- package/dist/types/components/Progress/Progress.d.ts +56 -0
- package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +61 -0
- package/dist/types/components/RollingNumber/RollingNumber.d.ts +36 -0
- package/dist/types/components/Select/Select.d.ts +36 -8
- package/dist/types/components/Separator/Separator.d.ts +19 -0
- package/dist/types/components/ShimmerText/ShimmerText.d.ts +28 -0
- package/dist/types/components/Stepper/Stepper.d.ts +61 -0
- package/dist/types/components/Switch/Switch.d.ts +5 -5
- package/dist/types/components/TagInput/TagInput.d.ts +44 -0
- package/dist/types/components/TextLink/TextLink.d.ts +30 -0
- package/dist/types/components/Textarea/Textarea.d.ts +19 -0
- package/dist/types/components/Tip/Tip.d.ts +71 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +9 -1
- package/dist/types/components/Tooltip/Tooltip.d.ts +84 -0
- package/dist/types/index.d.ts +20 -2
- package/dist/types/internal/FloatingPanel.d.ts +70 -0
- package/dist/types/internal/fieldStack.d.ts +48 -0
- package/dist/types/internal/floating.d.ts +71 -0
- package/dist/types/internal/ripple.d.ts +17 -0
- package/dist/types/internal/row.d.ts +15 -3
- package/dist/types/internal/transition.d.ts +37 -0
- package/dist/types/theme/ThemeProvider.d.ts +28 -4
- package/dist/types/theme/material.d.ts +20 -6
- package/dist/types/theme/types.d.ts +8 -0
- package/package.json +2 -2
- package/src/components/ActionSheet/ActionSheet.tsx +123 -38
- package/src/components/Alert/Alert.tsx +279 -0
- package/src/components/Avatar/Avatar.tsx +21 -9
- package/src/components/BottomActions/BottomActions.tsx +54 -0
- package/src/components/BottomSheet/BottomSheet.tsx +111 -25
- package/src/components/Button/Button.tsx +170 -35
- package/src/components/Card/Card.tsx +33 -9
- package/src/components/Checkbox/Checkbox.tsx +89 -124
- package/src/components/Chip/Chip.tsx +83 -20
- package/src/components/Dialog/Dialog.tsx +68 -37
- package/src/components/Field/Field.tsx +227 -0
- package/src/components/FloatingLabelInput/FloatingLabelInput.tsx +144 -0
- package/src/components/Icon/createIcon.tsx +16 -6
- package/src/components/Indicator/CircularProgress.tsx +141 -0
- package/src/components/Indicator/LoadingDots.tsx +79 -0
- package/src/components/Indicator/LoadingIndicator.tsx +166 -0
- package/src/components/Indicator/index.ts +3 -0
- package/src/components/Input/Input.tsx +126 -97
- package/src/components/InputGroup/InputGroup.tsx +261 -0
- package/src/components/List/List.tsx +345 -88
- package/src/components/Menu/Menu.tsx +83 -41
- package/src/components/NavigationButton/NavigationButton.tsx +35 -5
- package/src/components/OTPInput/OTPInput.tsx +21 -2
- package/src/components/PageControl/PageControl.tsx +36 -8
- package/src/components/Popover/Popover.tsx +261 -0
- package/src/components/Progress/Progress.tsx +255 -0
- package/src/components/ProgressSteps/ProgressSteps.tsx +415 -0
- package/src/components/RollingNumber/RollingNumber.tsx +189 -0
- package/src/components/Select/Select.tsx +175 -71
- package/src/components/Separator/Separator.tsx +51 -0
- package/src/components/ShimmerText/ShimmerText.tsx +144 -0
- package/src/components/Stepper/Stepper.tsx +386 -0
- package/src/components/Switch/Switch.tsx +26 -12
- package/src/components/TagInput/TagInput.tsx +227 -0
- package/src/components/Text/Text.tsx +8 -4
- package/src/components/TextLink/TextLink.tsx +77 -0
- package/src/components/Textarea/Textarea.tsx +23 -0
- package/src/components/Tip/Tip.tsx +410 -0
- package/src/components/Toolbar/Toolbar.tsx +27 -2
- package/src/components/Tooltip/Tooltip.tsx +478 -0
- package/src/index.ts +36 -2
- package/src/internal/FloatingPanel.tsx +199 -0
- package/src/internal/fieldStack.tsx +179 -0
- package/src/internal/floating.ts +131 -0
- package/src/internal/ripple.tsx +132 -0
- package/src/internal/row.ts +16 -3
- package/src/internal/transition.ts +124 -0
- package/src/theme/ThemeProvider.tsx +65 -15
- package/src/theme/material.ts +39 -7
- package/src/theme/types.ts +8 -0
|
@@ -4,35 +4,63 @@ import { Platform, Pressable, StyleSheet, View } from "react-native";
|
|
|
4
4
|
import Disclosure from "../../icons/plex/Disclosure";
|
|
5
5
|
import ExclamationMarkCircle from "../../icons/plex/ExclamationMarkCircle";
|
|
6
6
|
import { spaceToggles, useDescription } from "../../internal/a11y";
|
|
7
|
+
import { useRipple } from "../../internal/ripple";
|
|
7
8
|
import { flattenChildren, textOf } from "../../internal/children";
|
|
8
9
|
import { cssBox } from "../../internal/cssBox";
|
|
9
10
|
import { mirrored, useRTL } from "../../internal/direction";
|
|
10
11
|
import { RowEndContext, RowFrameContext, RowHoldContext, RowStartContext } from "../../internal/row";
|
|
11
12
|
import { accentText, controlHighlight, dangerText, divider, withAlpha } from "../../theme/material";
|
|
12
13
|
import { useTheme } from "../../theme/ThemeProvider";
|
|
14
|
+
import { Button, ListActionContext } from "../Button/Button";
|
|
13
15
|
import { Checkbox } from "../Checkbox/Checkbox";
|
|
14
16
|
import { IconDefaultsProvider } from "../Icon/createIcon";
|
|
15
17
|
import { RadioContext, RadioGroup } from "../RadioGroup/RadioGroup";
|
|
16
18
|
import { Switch, SwitchTrack } from "../Switch/Switch";
|
|
17
19
|
import { Text } from "../Text/Text";
|
|
20
|
+
/** What a List tells its rows; null outside a List. */
|
|
21
|
+
const ListOptionsContext = createContext(null);
|
|
22
|
+
/** Whether a control stands in a List's rows (a FloatingLabelInput is a row there, a List of its own elsewhere). */
|
|
23
|
+
export function useInList() {
|
|
24
|
+
return useContext(ListOptionsContext) != null;
|
|
25
|
+
}
|
|
18
26
|
/** The corners of Android's card of rows. */
|
|
19
27
|
const ANDROID_CARD_RADIUS = 16;
|
|
28
|
+
/** The start and end of an Android row's text, 21dp in from the card's edge (`--list-row-inset`). */
|
|
29
|
+
const ANDROID_INSET = 21;
|
|
20
30
|
const PlaceContext = createContext({ first: true, last: true, top: 0, bottom: 0 });
|
|
31
|
+
/**
|
|
32
|
+
* A header's action that is not a Button (a count such as "2/3") takes the header's type, so it stands on the title's
|
|
33
|
+
* line: iOS 17/22 on its last line, Android the header's 15sp on its 40dp row. Its own style still wins.
|
|
34
|
+
*/
|
|
35
|
+
function headerAction(action, type, color) {
|
|
36
|
+
if (typeof action === "string" || typeof action === "number") {
|
|
37
|
+
return (_jsx(Text, { color: color, tabularNums: true, style: type, children: action }));
|
|
38
|
+
}
|
|
39
|
+
if (isValidElement(action) && action.type === Text) {
|
|
40
|
+
return cloneElement(action, { style: [type, action.props.style] });
|
|
41
|
+
}
|
|
42
|
+
return action;
|
|
43
|
+
}
|
|
21
44
|
/**
|
|
22
45
|
* A section of rows. iOS 26: a section of an inset grouped list, as @plexui/ui's FieldGroup on a phone
|
|
23
46
|
* (`--field-group-radius` 26, the grouped secondary surface, rows 20 in from its edges, hairlines between rows from
|
|
24
47
|
* the text's start; the header 17/22 at 590 in the secondary label over its description 15/20, the footer 13/16, an
|
|
25
|
-
* error
|
|
26
|
-
* 16dp round, a 1px divider between rows from the text's start; the header inside the card, a 40dp
|
|
27
|
-
* in the accent
|
|
28
|
-
* secondary label
|
|
29
|
-
* error the same in the error color. The screen sets the cards 12 from its edges and 12 apart. On a plain canvas
|
|
48
|
+
* error in its place and type in the danger color). Android: a section of a settings screen: one card of the section's rows,
|
|
49
|
+
* 16dp round, a 1px divider between rows from the text's start to the card's end; the header inside the card, a 40dp
|
|
50
|
+
* row of 15sp Medium in the accent 21 in (14 above it), its description 14sp in the secondary label under it; the
|
|
51
|
+
* footer under the card, 14sp in the secondary label 13 in (25 from the screen's edge, as the screen insets the card
|
|
52
|
+
* 12), 11 above and 17 below, an error the same in the error color (the web's FieldGroup on Android). The screen sets the cards 12 from its edges and 12 apart. On a plain canvas
|
|
30
53
|
* Android draws a plain list: the rows across the screen with no card, the header a 32dp band of the grouped gray,
|
|
31
54
|
* the footer on that gray.
|
|
32
55
|
*/
|
|
33
|
-
export function List({ children, header, description, footer, error, surface = "grouped", "aria-label": ariaLabel, testID, style }) {
|
|
56
|
+
export function List({ children, header, description, footer, error, surface = "grouped", action, headerProminence = "standard", columns = false, "aria-label": ariaLabel, testID, style, }) {
|
|
34
57
|
const theme = useTheme();
|
|
35
|
-
|
|
58
|
+
// A Button among the rows is an action row, as the web's ghost Button in a `[data-row]`
|
|
59
|
+
const rows = flattenChildren(children)
|
|
60
|
+
.filter(isValidElement)
|
|
61
|
+
.map((row) => (row.type === Button ? _jsx(ActionRow, { children: row }, row.key ?? undefined) : row));
|
|
62
|
+
const options = useMemo(() => ({ columns }), [columns]);
|
|
63
|
+
const increased = headerProminence === "increased";
|
|
36
64
|
const fill = surface === "plain" ? theme.color("--field-group-background", theme.colors.surfaceSecondary) : theme.colors.groupedSurface;
|
|
37
65
|
// The card's corners: Android's 16dp card (a header or description inside it stands over the first row), iOS's group
|
|
38
66
|
const corner = surface === "plain" && theme.isAndroid ? 0 : theme.isAndroid ? ANDROID_CARD_RADIUS : theme.length("--field-group-radius", 26);
|
|
@@ -49,44 +77,43 @@ export function List({ children, header, description, footer, error, surface = "
|
|
|
49
77
|
// too), and its header is a band of the grouped canvas across them, 14sp Medium in the secondary label 16 in
|
|
50
78
|
const plain = surface === "plain";
|
|
51
79
|
const band = theme.colors.groupedBackground;
|
|
52
|
-
return (_jsxs(View, { testID: testID, style: style, children: [_jsxs(View, { style: plain ? { backgroundColor: theme.colors.groupedSurface } : [styles.androidCard, { backgroundColor: fill }], children: [header == null ? null : plain ? (
|
|
80
|
+
return (_jsxs(View, { testID: testID, style: style, children: [_jsxs(View, { style: plain ? { backgroundColor: theme.colors.groupedSurface } : [styles.androidCard, { backgroundColor: fill }], children: [header == null && action == null ? null : plain ? (_jsxs(View, { style: [styles.androidBand, action != null ? styles.androidBandRow : null, { backgroundColor: band }], children: [header != null ? (_jsx(Text, { accessibilityRole: "header", color: theme.colors.labelSecondary, weight: "medium", numberOfLines: 1, style: [styles.androidBandText, action != null ? styles.grow : null], children: header })) : (_jsx(View, { style: styles.grow })), action != null ? _jsx(ListActionContext.Provider, { value: "header", children: headerAction(action, styles.androidBandText, theme.colors.labelSecondary) }) : null] })) : action != null ? (_jsxs(View, { style: styles.androidHeaderRow, children: [header != null ? (_jsx(Text, { accessibilityRole: "header", color: increased ? theme.colors.text : accentText(theme), weight: "medium", style: [styles.androidHeaderTitle, increased ? styles.androidHeaderIncreased : null], children: header })) : (_jsx(View, { style: styles.grow })), _jsx(ListActionContext.Provider, { value: "header", children: headerAction(action, styles.androidHeaderTitleType, theme.colors.labelSecondary) })] })) : (_jsx(Text, { accessibilityRole: "header", color: increased ? theme.colors.text : accentText(theme), weight: "medium", style: [styles.androidHeader, increased ? styles.androidHeaderIncreased : null], children: header })), description != null ? (_jsx(Text, { color: theme.colors.labelSecondary, style: [styles.androidDescriptionLine, plain ? styles.androidDescriptionPlain : header == null ? styles.androidDescriptionAlone : null], children: description })) : null, _jsx(View, { accessibilityRole: "list", "aria-label": label, children: _jsx(ListOptionsContext.Provider, { value: options, children: body }) })] }), error != null ? (_jsx(Text, { color: dangerText(theme), accessibilityLiveRegion: "polite", style: [styles.androidFooter, plain ? [styles.androidFooterPlain, { backgroundColor: band }] : null], children: error })) : footer != null ? (_jsx(Text, { color: theme.colors.labelSecondary, style: [styles.androidFooter, plain ? [styles.androidFooterPlain, { backgroundColor: band }] : null], children: footer })) : null] }));
|
|
53
81
|
}
|
|
54
82
|
const inset = theme.length("--list-row-inset", 20);
|
|
55
83
|
const footerBox = cssBox(theme, "--field-group-footer-padding", [8, inset, 6, inset]);
|
|
56
|
-
return (_jsxs(View, { testID: testID, style: style, children: [header != null || description != null ? (_jsxs(View, { style: {
|
|
57
|
-
|
|
84
|
+
return (_jsxs(View, { testID: testID, style: style, children: [header != null || description != null || action != null ? (_jsxs(View, { style: {
|
|
85
|
+
// The prominent header: 20/25 Semibold in the primary label, 10 above and below (45 at least), as the kit's
|
|
86
|
+
// Prominent list header
|
|
87
|
+
minHeight: increased ? 45 : theme.length("--field-group-header-min-height", 39),
|
|
58
88
|
justifyContent: "flex-end",
|
|
59
|
-
paddingTop: theme.length("--field-group-header-padding-top", 11),
|
|
60
|
-
paddingBottom: theme.length("--field-group-header-padding-bottom", 6),
|
|
89
|
+
paddingTop: increased ? 10 : theme.length("--field-group-header-padding-top", 11),
|
|
90
|
+
paddingBottom: increased ? 10 : theme.length("--field-group-header-padding-bottom", 6),
|
|
61
91
|
paddingHorizontal: theme.length("--field-group-title-padding-inline", inset),
|
|
62
|
-
}, children: [header != null ? (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
paddingEnd: footerBox.right,
|
|
69
|
-
paddingBottom: footerBox.bottom,
|
|
70
|
-
paddingStart: footerBox.left,
|
|
71
|
-
}, children: error })) : footer != null ? (_jsx(Text, { color: theme.colors.labelSecondary, style: {
|
|
92
|
+
}, children: [header != null || action != null ? (_jsxs(View, { style: action != null ? styles.iosHeaderRow : null, children: [header == null ? _jsx(View, { style: styles.grow }) : null, header == null ? null : _jsx(Text, { accessibilityRole: "header", weight: "semibold", color: increased ? theme.colors.text : theme.colors.labelSecondary, style: [
|
|
93
|
+
increased ? { fontSize: 20, lineHeight: 25 } : { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) },
|
|
94
|
+
action != null ? styles.grow : null,
|
|
95
|
+
], children: header }), action != null ? (_jsx(ListActionContext.Provider, { value: "header", children: headerAction(action, { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) }, theme.colors.labelSecondary) })) : null] })) : null, description != null ? (_jsx(Text, { color: theme.colors.labelSecondary, style: { fontSize: theme.length("--field-group-description-font-size", 15), lineHeight: theme.length("--field-group-description-line-height", 20) }, children: description })) : null] })) : null, _jsx(View, { accessibilityRole: "list", "aria-label": label, style: [styles.iosGroup, { borderRadius: theme.length("--field-group-radius", 26), backgroundColor: surface === "plain" ? theme.color("--field-group-background", theme.colors.surfaceSecondary) : theme.colors.groupedSurface }], children: _jsx(ListOptionsContext.Provider, { value: options, children: body }) }), error != null || footer != null ? (
|
|
96
|
+
// An error takes the footer's place and type (13/16, 8 under the section), only in the danger color
|
|
97
|
+
_jsx(Text, { color: error != null ? errorColor(theme) : theme.colors.labelSecondary, accessibilityLiveRegion: error != null ? "polite" : undefined, style: {
|
|
72
98
|
fontSize: theme.length("--field-group-footer-font-size", 13),
|
|
73
99
|
lineHeight: theme.length("--field-group-footer-line-height", 16),
|
|
74
100
|
paddingTop: footerBox.top,
|
|
75
101
|
paddingEnd: footerBox.right,
|
|
76
102
|
paddingBottom: footerBox.bottom,
|
|
77
103
|
paddingStart: footerBox.left,
|
|
78
|
-
}, children: footer })) : null] }));
|
|
104
|
+
}, children: error ?? footer })) : null] }));
|
|
79
105
|
}
|
|
80
106
|
/**
|
|
81
107
|
* A row of a List: the label (17/22, `--field-row-*`: 52 tall, 70 with a description, 12 above and below the text at
|
|
82
108
|
* least) with a description, a leading symbol, a value (wrapping within 60% of the row, or under the label: `valuePlacement`) or a control, and the chevron
|
|
83
109
|
* of a drill-in (`Disclosure`, in the tertiary label, turned over right to left). A row with `checked` is a switch
|
|
84
|
-
* row. On Android a row of a settings screen: 50dp tall at least (
|
|
85
|
-
* description 13sp in the secondary label under it, the value 16sp in the accent
|
|
86
|
-
* with a tile), no chevron; the text
|
|
87
|
-
* `leadingColor` at 18 with a 24dp symbol (the tile's corners 10), or 64 after a RadioGroup
|
|
88
|
-
*
|
|
89
|
-
*
|
|
110
|
+
* row. On Android a row of a settings screen: 50dp tall at least (64 with a description, its text 12 from the row's
|
|
111
|
+
* top and bottom), the label 16sp, the description 13sp in the secondary label under it, the value 16sp in the accent
|
|
112
|
+
* at the end, 17 from it (20 in a row with a tile), no chevron; the text 21 in, or 64 after a 24dp symbol at 20, or 64
|
|
113
|
+
* after a 28dp tile of `leadingColor` at 18 with a 24dp symbol (the tile's corners 10), or 64 after a RadioGroup
|
|
114
|
+
* option's 20dp ring at 22; a lone Checkbox at the end of a row with no `leading` leads it instead, its 20dp circle 22
|
|
115
|
+
* 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
|
|
116
|
+
* tiled row draws none).
|
|
90
117
|
*/
|
|
91
118
|
export function ListItem({ label, description, leading, leadingColor, value, valuePlacement = "end", trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, disabled = false, destructive = false, accessibilityLabel, testID, }) {
|
|
92
119
|
const theme = useTheme();
|
|
@@ -114,6 +141,8 @@ export function ListItem({ label, description, leading, leadingColor, value, val
|
|
|
114
141
|
const atStart = !switchRow && !onPress && !atEnd && radios != null && isValidElement(leading) && leading.type === RadioGroup.Item
|
|
115
142
|
? { kind: "radio", element: leading }
|
|
116
143
|
: null;
|
|
144
|
+
// Android's multi-select row: a lone checkbox (no text of its own) at the end of a row with no symbol leads the row
|
|
145
|
+
const checkLeads = theme.isAndroid && atEnd?.kind === "checkbox" && leading == null && atEnd.element.props.label == null && atEnd.element.props.description == null;
|
|
117
146
|
const found = atEnd ?? atStart;
|
|
118
147
|
const [controlOwn, setControlOwn] = useState(() => (found && found.kind !== "radio" ? (found.element.props.defaultChecked ?? false) : false));
|
|
119
148
|
const rowName = textOf(label) || undefined;
|
|
@@ -136,22 +165,79 @@ export function ListItem({ label, description, leading, leadingColor, value, val
|
|
|
136
165
|
const row = (pressed) => theme.isAndroid ? styles.androidRow : iosRow(theme, pressed && lit, last, description != null || error != null);
|
|
137
166
|
// A finger on the control at the end holds the row, as one on the row's text does
|
|
138
167
|
const [held, setHeld] = useState(false);
|
|
168
|
+
// Android's press is the list selector's ripple from the touch point, clipped to the row (and the card's corners):
|
|
169
|
+
// the platform's on a device; drawn here on the web, and for a row held through the control at its end
|
|
170
|
+
const ripple = useRipple(controlHighlight(theme.scheme), theme.isAndroid, theme.reducedMotion);
|
|
171
|
+
const hold = (next, event) => {
|
|
172
|
+
setHeld(next);
|
|
173
|
+
if (!theme.isAndroid)
|
|
174
|
+
return;
|
|
175
|
+
if (next)
|
|
176
|
+
ripple.start(event);
|
|
177
|
+
else
|
|
178
|
+
ripple.end();
|
|
179
|
+
};
|
|
139
180
|
const content = (pressed) => {
|
|
140
181
|
// The row's switch is drawn only: the row is the control
|
|
141
182
|
const track = _jsx(SwitchTrack, { checked: checked, disabled: disabled, pressed: pressed });
|
|
142
|
-
const end = !switchRow ? (atStart ? trailing : (control?.node ?? trailing)) : trailing != null ? (_jsxs(View, { style: [styles.pair, { gap: theme.isAndroid ? 16 : theme.length("--field-row-disclosure-gap", 8) }], children: [trailing, track] })) : (track);
|
|
143
|
-
const start = atStart && control ? _jsx(RowStartContext.Provider, { value: true, children: control.node }) : leading;
|
|
144
|
-
const startColor = atStart ? undefined : leadingColor;
|
|
145
|
-
return (_jsx(RowFrameContext.Provider, { value: frame, children: theme.isAndroid ? (_jsx(AndroidContent, { handPress: handPress, theme: theme, label: label, description: description, descriptionId: described.id, leading: start, leadingColor: startColor, leadingMark: atStart != null, value: value, valuePlacement: valuePlacement, trailing: end, error: error, disabled: disabled, destructive: destructive, last: last })) : (_jsx(IOSContent, { theme: theme, label: label, description: description, descriptionId: described.id, leading: start, leadingColor: startColor, value: value, valuePlacement: valuePlacement, trailing: end, error: error, chevron: chevron, disabled: disabled, destructive: destructive, last: last })) }));
|
|
183
|
+
const end = !switchRow ? (atStart ? trailing : checkLeads ? null : (control?.node ?? trailing)) : trailing != null ? (_jsxs(View, { style: [styles.pair, { gap: theme.isAndroid ? 16 : theme.length("--field-row-disclosure-gap", 8) }], children: [trailing, track] })) : (track);
|
|
184
|
+
const start = (atStart || checkLeads) && control ? _jsx(RowStartContext.Provider, { value: true, children: control.node }) : leading;
|
|
185
|
+
const startColor = atStart || checkLeads ? undefined : leadingColor;
|
|
186
|
+
return (_jsx(RowFrameContext.Provider, { value: frame, children: theme.isAndroid ? (_jsx(AndroidContent, { handPress: handPress, theme: theme, label: label, description: description, descriptionId: described.id, leading: start, leadingColor: startColor, leadingMark: atStart != null || checkLeads, value: value, valuePlacement: valuePlacement, trailing: end, edgeControl: found != null || switchRow, error: error, disabled: disabled, destructive: destructive, last: last })) : (_jsx(IOSContent, { theme: theme, label: label, description: description, descriptionId: described.id, leading: start, leadingColor: startColor, value: value, valuePlacement: valuePlacement, trailing: end, edgeControl: found != null || switchRow, error: error, chevron: chevron, disabled: disabled, destructive: destructive, last: last })) }));
|
|
146
187
|
};
|
|
147
188
|
if (press) {
|
|
148
|
-
// Android's rows press in the list selector: the native ripple on a device,
|
|
189
|
+
// Android's rows press in the list selector: the native ripple on a device, the drawn one on the web
|
|
149
190
|
const highlight = controlHighlight(theme.scheme);
|
|
191
|
+
const drawn = theme.isAndroid && !nativeRipple;
|
|
150
192
|
return (_jsx(Pressable, { ref: frameNode, collapsable: false, ...described.props, ...(switchRow ? spaceToggles(toggle) : null),
|
|
151
193
|
// A row that toggles its control is not a second element for a screen reader or a Tab stop: the control is
|
|
152
|
-
accessible: endOwnsFocus ? false : undefined, focusable: endOwnsFocus ? false : undefined, tabIndex: endOwnsFocus ? -1 : undefined, accessibilityRole: endOwnsFocus ? undefined : switchRow ? "switch" : "button", accessibilityLabel: endOwnsFocus ? undefined : name, accessibilityState: endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled }, "aria-checked": switchRow ? checked : undefined, disabled: disabled, onPress: press, android_ripple: nativeRipple ? { color: highlight, foreground: true } : undefined, testID: testID, style: ({ pressed }) => row(pressed || held), children: ({ pressed }) => (_jsxs(RowHoldContext.Provider, { value: disabled ? null :
|
|
194
|
+
accessible: endOwnsFocus ? false : undefined, focusable: endOwnsFocus ? false : undefined, tabIndex: endOwnsFocus ? -1 : undefined, accessibilityRole: endOwnsFocus ? undefined : switchRow ? "switch" : "button", accessibilityLabel: endOwnsFocus ? undefined : name, accessibilityState: endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled }, "aria-checked": switchRow ? checked : undefined, disabled: disabled, onPress: press, onPressIn: drawn ? ripple.start : undefined, onPressOut: drawn ? ripple.end : undefined, android_ripple: nativeRipple ? { color: highlight, foreground: true } : undefined, testID: testID, style: ({ pressed }) => row(pressed || held), children: ({ pressed }) => (_jsxs(RowHoldContext.Provider, { value: disabled ? null : theme.isAndroid ? hold : setHeld, children: [ripple.layer, content(pressed || held)] })) }));
|
|
153
195
|
}
|
|
154
|
-
|
|
196
|
+
// A row that only shows (a detail, a value) is one element named by `accessibilityLabel` when it has one; with a
|
|
197
|
+
// control at its end it stays a group, so the control is still reached
|
|
198
|
+
const named = accessibilityLabel != null && trailing == null && found == null;
|
|
199
|
+
return (_jsx(View, { ref: frameNode, collapsable: false, testID: testID, accessible: named || undefined, accessibilityLabel: accessibilityLabel, accessibilityRole: named && Platform.OS !== "web" ? "text" : undefined, role: named && Platform.OS === "web" ? "group" : undefined, style: row(false), children: content(false) }));
|
|
200
|
+
}
|
|
201
|
+
/** A Button among a List's rows: the row is the button (`ListActionContext`), the hairline under it from the text's start. */
|
|
202
|
+
function ActionRow({ children }) {
|
|
203
|
+
const theme = useTheme();
|
|
204
|
+
const { last } = useContext(PlaceContext);
|
|
205
|
+
return (_jsxs(View, { style: styles.actionRow, children: [_jsx(ListActionContext.Provider, { value: "row", children: children }), last ? null : (_jsx(View, { pointerEvents: "none", style: [styles.actionSeparator, { start: theme.isAndroid ? ANDROID_INSET : theme.length("--list-row-inset", 20), backgroundColor: theme.isAndroid ? divider(theme) : theme.colors.separator }] }))] }));
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* A field row whose value is a line of its own, as the web's `Field row` with `orientation="vertical"` or `hideLabel`
|
|
209
|
+
* on a phone. iOS: the label 15/20 in the secondary label (`--field-row-above-*`), the value under it in the row's
|
|
210
|
+
* 17/22, 13 above and below (68 for one line); with no label the value alone, centred in the row's 52. The error 4
|
|
211
|
+
* under the value, as a row's. Android: the label 13sp in the secondary label, 4 over the bare value (17sp, as a card's
|
|
212
|
+
* text field), 10 above and below, 21 in; with no label the value alone 17 above and below and 22 in, a 54dp row (the
|
|
213
|
+
* reference's card input), the line above the row starting there too.
|
|
214
|
+
*/
|
|
215
|
+
export function ListStackedRow({ label, description, error, disabled = false, action, children, testID }) {
|
|
216
|
+
const theme = useTheme();
|
|
217
|
+
const { last } = useContext(PlaceContext);
|
|
218
|
+
const rowEnd = useMemo(() => ({ fill: () => { }, stacked: true }), []);
|
|
219
|
+
const android = theme.isAndroid;
|
|
220
|
+
const hidden = label == null;
|
|
221
|
+
const rowLine = theme.length("--field-row-label-line-height", 22);
|
|
222
|
+
// iOS: a row with words under its value (a description or an error) keeps the insets of a row with text, 12, as
|
|
223
|
+
// the web's phone rows do; an error stands 4 under the value and the value 4 under the label
|
|
224
|
+
const texted = description != null || error != null;
|
|
225
|
+
// Android: a field alone in its row (no label, no words under it) is the reference's card input, 17 above and below
|
|
226
|
+
// and 22 in; with words under it 15 above and below
|
|
227
|
+
const alone = android && hidden && !texted;
|
|
228
|
+
const inset = android ? (alone ? 22 : ANDROID_INSET) : theme.length("--list-row-inset", 20);
|
|
229
|
+
const padding = android
|
|
230
|
+
? alone ? 17 : hidden ? 15 : 10
|
|
231
|
+
: texted ? theme.length("--field-row-text-padding-block", 12) : hidden ? (theme.length("--field-row-min-height", 52) - rowLine) / 2 : theme.length("--field-row-above-padding-block", 13);
|
|
232
|
+
const secondary = disabled ? (android ? withAlpha(theme.colors.labelSecondary, 0.5) : theme.colors.labelTertiary) : theme.colors.labelSecondary;
|
|
233
|
+
const labelType = android
|
|
234
|
+
? styles.androidDescription
|
|
235
|
+
: { fontSize: theme.length("--field-row-above-font-size", 15), lineHeight: theme.length("--field-row-above-line-height", 20) };
|
|
236
|
+
const labelText = hidden ? null : (_jsx(Text, { color: secondary, style: [labelType, action != null ? styles.grow : null, !android && error != null && action == null ? { marginBottom: theme.length("--mobile-field-error-offset", 4) } : null], children: label }));
|
|
237
|
+
const errorOffset = theme.length("--mobile-field-error-offset", 4);
|
|
238
|
+
const errorLine = theme.length("--mobile-field-error-line-height", 20);
|
|
239
|
+
const iconSize = theme.length("--mobile-field-error-icon-size", 16);
|
|
240
|
+
return (_jsx(View, { testID: testID, style: [styles.stackedRow, { paddingStart: inset }], children: _jsxs(View, { style: [styles.stackedColumn, { paddingEnd: inset, paddingVertical: padding, gap: android ? 4 : 0 }], children: [last ? null : _jsx(View, { pointerEvents: "none", style: [styles.iosSeparator, { backgroundColor: android ? divider(theme) : theme.colors.separator }] }), labelText != null && action != null ? (_jsxs(View, { style: [styles.pair, { gap: 8 }, !android && error != null ? { marginBottom: theme.length("--mobile-field-error-offset", 4) } : null], children: [labelText, action] })) : (labelText), _jsx(RowEndContext.Provider, { value: rowEnd, children: children }), description != null ? (_jsx(Text, { color: secondary, style: android ? styles.androidDescription : { fontSize: theme.length("--field-row-description-font-size", 15), lineHeight: theme.length("--field-row-description-line-height", 20) }, children: description })) : null, error == null ? null : android ? (_jsx(Text, { color: dangerText(theme), accessibilityLiveRegion: "polite", style: styles.androidDescription, children: error })) : (_jsxs(View, { accessibilityLiveRegion: "polite", style: [styles.iosError, { marginTop: errorOffset, gap: theme.length("--mobile-field-error-icon-gap", 4) }], children: [_jsx(ExclamationMarkCircle, { size: iconSize, color: errorColor(theme), style: { marginTop: (errorLine - iconSize) / 2 } }), _jsx(Text, { color: errorColor(theme), style: [styles.shrink, { fontSize: theme.length("--mobile-field-error-font-size", 15), lineHeight: errorLine }], children: error })] }))] }) }));
|
|
155
241
|
}
|
|
156
242
|
/** A Switch, a Checkbox or (inside its RadioGroup) an option given as a row's `trailing`, which the row's press toggles. */
|
|
157
243
|
function rowControl(trailing, inGroup) {
|
|
@@ -226,7 +312,7 @@ function useValueBelow(placement, label, value, type, fits) {
|
|
|
226
312
|
const probe = auto ? (_jsxs(View, { pointerEvents: "none", "aria-hidden": true, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: styles.probe, children: [_jsx(Text, { numberOfLines: 1, style: type.label, onLayout: measure("label"), children: label }), _jsx(Text, { numberOfLines: 1, style: type.value, onLayout: measure("value"), children: value })] })) : null;
|
|
227
313
|
return { below, probe, onRowLayout: auto ? measure("row") : undefined, onTrailingLayout: auto ? measure("trailing") : undefined };
|
|
228
314
|
}
|
|
229
|
-
function IOSContent({ theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, error, chevron, disabled, destructive, last }) {
|
|
315
|
+
function IOSContent({ theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, edgeControl = false, error, chevron, disabled, destructive, last }) {
|
|
230
316
|
const inset = theme.length("--list-row-inset", 20);
|
|
231
317
|
const tile = theme.length("--field-row-icon-size", 28);
|
|
232
318
|
const gap = theme.length("--field-row-gap", 16);
|
|
@@ -251,7 +337,11 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
|
|
|
251
337
|
: Math.max(theme.length("--field-row-text-padding-block", 12), (iosMinHeight(theme, description != null) - labelType.lineHeight - (description != null ? descriptionLine : 0)) / 2);
|
|
252
338
|
// A field at the end fills the room after the label (`RowEnd.fill`)
|
|
253
339
|
const [fill, setFill] = useState(false);
|
|
254
|
-
|
|
340
|
+
// In a List with `columns` a field's value starts at one column, 40% into the row (`--field-row-column-width`)
|
|
341
|
+
// A switch, a checkbox and a radio stay at the row's edge
|
|
342
|
+
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null;
|
|
343
|
+
const startsColumn = columns && !edgeControl;
|
|
344
|
+
const rowEnd = useMemo(() => ({ fill: setFill, align: startsColumn ? "start" : "end" }), [startsColumn]);
|
|
255
345
|
const errorOffset = theme.length("--mobile-field-error-offset", 4);
|
|
256
346
|
const errorLine = theme.length("--mobile-field-error-line-height", 20);
|
|
257
347
|
// With an error the label and the control stand on a line of their own over it
|
|
@@ -272,16 +362,16 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
|
|
|
272
362
|
error != null
|
|
273
363
|
? { paddingVertical: Math.max(theme.length("--field-row-text-padding-block", 12), (iosMinHeight(theme, true) - labelType.lineHeight - errorOffset - errorLine) / 2) }
|
|
274
364
|
: { gap: below ? disclosureGap : gap },
|
|
275
|
-
], children: [last ? null : _jsx(View, { pointerEvents: "none", style: [styles.iosSeparator, { backgroundColor: theme.colors.separator }] }), probe, line(_jsxs(_Fragment, { children: [_jsxs(View, { style: [fill ? styles.iosTextHug : styles.iosText, { paddingVertical: error != null ? 0 : textPadding }, formRow && description == null && error == null ? { minHeight: target, justifyContent: "center" } : null], children: [_jsx(Text, { color: labelColor, style: labelType, children: label }), below ? (
|
|
365
|
+
], children: [last ? null : _jsx(View, { pointerEvents: "none", style: [styles.iosSeparator, { backgroundColor: theme.colors.separator }] }), probe, line(_jsxs(_Fragment, { children: [_jsxs(View, { style: [columns ? styles.column : fill ? styles.iosTextHug : styles.iosText, { paddingVertical: error != null ? 0 : textPadding }, formRow && description == null && error == null ? { minHeight: target, justifyContent: "center" } : null], children: [_jsx(Text, { color: labelColor, style: labelType, children: label }), below ? (
|
|
276
366
|
// Under the label, the lines touching as a subtitle cell's, at the text's start
|
|
277
|
-
_jsx(Text, { color: secondary, style: labelType, children: value })) : null, description != null ? (_jsx(Text, { nativeID: descriptionId, color: secondary, style: { fontSize: theme.length("--field-row-description-font-size", 15), lineHeight: descriptionLine }, children: description })) : null] }), (value != null && !below) || trailing != null || chevron ? (_jsxs(View, { style: [fill ? styles.endFill : styles.end, { gap: disclosureGap }], children: [value != null && !below ? (
|
|
367
|
+
_jsx(Text, { color: secondary, style: labelType, children: value })) : null, description != null ? (_jsx(Text, { nativeID: descriptionId, color: secondary, style: { fontSize: theme.length("--field-row-description-font-size", 15), lineHeight: descriptionLine }, children: description })) : null] }), (value != null && !below) || trailing != null || chevron ? (_jsxs(View, { style: [fill || columns ? styles.endFill : styles.end, columns && !startsColumn ? styles.endAtEdge : null, { gap: disclosureGap }], children: [value != null && !below ? (
|
|
278
368
|
// A long value wraps within the 60% the end takes, as the web's, rather than losing its end; set at the
|
|
279
369
|
// row's end (a phone turns "right" over in a right-to-left layout itself, the web does not)
|
|
280
|
-
_jsx(Text, { color: secondary, style: [labelType, styles.shrink, { textAlign: Platform.OS === "web" && rtl ? "left" : "right" }], children: value })) : null, trailing != null ? (_jsx(View, { style: fill ? styles.grow : styles.keep, onLayout: onTrailingLayout, children: _jsx(RowEndContext.Provider, { value: rowEnd, children: trailing }) })) : null, chevron ? _jsx(Disclosure, { size: 20, color: theme.colors.labelTertiary, style: [styles.disclosure, mirrored(rtl)] }) : null] })) : null] })), error != null ? (_jsxs(View, { accessibilityLiveRegion: "polite", style: [styles.iosError, { marginTop: errorOffset, gap: theme.length("--mobile-field-error-icon-gap", 4) }], children: [_jsx(ExclamationMarkCircle, { size: theme.length("--mobile-field-error-icon-size", 16), color: errorColor(theme), style: { marginTop: (errorLine - theme.length("--mobile-field-error-icon-size", 16)) / 2 } }), _jsx(Text, { color: errorColor(theme), style: [styles.shrink, { fontSize: theme.length("--mobile-field-error-font-size", 15), lineHeight: errorLine }], children: error })] })) : null] })] }));
|
|
370
|
+
_jsx(Text, { color: secondary, style: [labelType, styles.shrink, { textAlign: Platform.OS === "web" && rtl ? "left" : "right" }], children: value })) : null, trailing != null ? (_jsx(View, { style: fill ? styles.grow : startsColumn ? styles.keepStart : styles.keep, onLayout: onTrailingLayout, children: _jsx(RowEndContext.Provider, { value: rowEnd, children: trailing }) })) : null, chevron ? _jsx(Disclosure, { size: 20, color: theme.colors.labelTertiary, style: [styles.disclosure, mirrored(rtl)] }) : null] })) : null] })), error != null ? (_jsxs(View, { accessibilityLiveRegion: "polite", style: [styles.iosError, { marginTop: errorOffset, gap: theme.length("--mobile-field-error-icon-gap", 4) }], children: [_jsx(ExclamationMarkCircle, { size: theme.length("--mobile-field-error-icon-size", 16), color: errorColor(theme), style: { marginTop: (errorLine - theme.length("--mobile-field-error-icon-size", 16)) / 2 } }), _jsx(Text, { color: errorColor(theme), style: [styles.shrink, { fontSize: theme.length("--mobile-field-error-font-size", 15), lineHeight: errorLine }], children: error })] })) : null] })] }));
|
|
281
371
|
}
|
|
282
372
|
/** The danger ink of a form's error, as the web's FieldError (`--field-error-color`). */
|
|
283
373
|
const errorColor = (theme) => theme.color("--field-error-color", theme.color("--color-text-danger-outline", theme.color("--color-text-danger")));
|
|
284
|
-
function AndroidContent({ handPress, theme, label, description, descriptionId, leading, leadingColor, leadingMark = false, value, valuePlacement, trailing, error, disabled, destructive, last, }) {
|
|
374
|
+
function AndroidContent({ handPress, theme, label, description, descriptionId, leading, leadingColor, leadingMark = false, value, valuePlacement, trailing, edgeControl = false, error, disabled, destructive, last, }) {
|
|
285
375
|
// A disabled row fades to half, as Android's rows do
|
|
286
376
|
const dim = (color) => (disabled ? withAlpha(color, 0.5) : color);
|
|
287
377
|
const danger = dangerText(theme);
|
|
@@ -289,24 +379,30 @@ function AndroidContent({ handPress, theme, label, description, descriptionId, l
|
|
|
289
379
|
// Android's row symbols are the text's ink over a light card and a gray over a dark one
|
|
290
380
|
const symbol = dim(destructive ? danger : theme.scheme === "dark" ? theme.colors.labelSecondary : theme.colors.text);
|
|
291
381
|
const tile = leading != null && !!leadingColor;
|
|
292
|
-
//
|
|
293
|
-
const textStart = leading == null ?
|
|
382
|
+
// The text (and the divider) 21 in, or 64 after a symbol, a tile or a choice's mark (its 20dp circle 22 in)
|
|
383
|
+
const textStart = leading == null ? ANDROID_INSET : 64;
|
|
294
384
|
// A value that ends the row stands 17 from the end (a value row), 20 in a row with a tile (a tiled row)
|
|
295
385
|
const valueEnd = trailing == null && !tile ? 17 : 20;
|
|
296
386
|
// At the end the value takes half the row at most, 16 from the label and from a control
|
|
297
387
|
const { below, probe, onRowLayout, onTrailingLayout } = useValueBelow(valuePlacement, label, value, { label: styles.androidLabel, value: styles.androidLabel }, (widths) => {
|
|
298
388
|
const end = 16 + widths.value + (trailing != null ? 16 + widths.trailing : 0);
|
|
299
|
-
return widths.value <= (widths.row -
|
|
389
|
+
return widths.value <= (widths.row - 2 * ANDROID_INSET) * 0.5 + 0.5 && widths.label + end <= widths.row - textStart - valueEnd + 0.5;
|
|
300
390
|
});
|
|
301
391
|
// A field at the end fills the room after the label, as on iOS; a select opens from the whole row
|
|
302
392
|
const [fill, setFill] = useState(false);
|
|
303
|
-
const
|
|
393
|
+
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null;
|
|
394
|
+
const startsColumn = columns && !edgeControl;
|
|
395
|
+
const rowEnd = useMemo(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end" }), [handPress, startsColumn]);
|
|
304
396
|
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, children: _jsx(IconDefaultsProvider, { size: 24, color: tile ? "#ffffff" : symbol, children: leading }) })), _jsxs(View, { style: [
|
|
305
|
-
fill ? styles.androidTextHug : styles.androidText,
|
|
306
|
-
|
|
397
|
+
columns ? [styles.androidTextHug, styles.column] : fill ? styles.androidTextHug : styles.androidText,
|
|
398
|
+
// One line centred in the 50dp row (54 beside a text field: a card's input row); with a second line 12 above
|
|
399
|
+
// and below (a 64dp row)
|
|
400
|
+
{ paddingVertical: error != null ? 0 : description != null || below ? 12 : fill ? 17 : 15 },
|
|
307
401
|
], children: [_jsx(Text, { color: ink, style: styles.androidLabel, children: label }), below ? (
|
|
308
402
|
// A detail row: the value a 13sp gray line under the label
|
|
309
|
-
_jsx(Text, { color: dim(theme.colors.labelSecondary), style: styles.androidDescription, children: value })) : null, description != null ? (_jsx(Text, { nativeID: descriptionId, color: dim(theme.colors.labelSecondary), style: styles.androidDescription, children: description })) : null] }), value != null && !below ? (_jsx(Text, { color: dim(accentText(theme)), numberOfLines: 1, style: [styles.androidLabel, styles.androidValue, { marginEnd: valueEnd -
|
|
403
|
+
_jsx(Text, { color: dim(theme.colors.labelSecondary), style: styles.androidDescription, children: value })) : null, description != null ? (_jsx(Text, { nativeID: descriptionId, color: dim(theme.colors.labelSecondary), style: styles.androidDescription, children: description })) : null] }), value != null && !below ? (_jsx(Text, { color: dim(accentText(theme)), numberOfLines: 1, style: [styles.androidLabel, styles.androidValue, { marginEnd: valueEnd - ANDROID_INSET }], children: value })) : null, trailing != null ? (_jsx(View, { style:
|
|
404
|
+
// A switch or a checkbox stays at the row's edge after the label's column (it stretches in a column cell)
|
|
405
|
+
fill || startsColumn ? [styles.androidEndFill, startsColumn ? styles.androidEndStart : null] : columns ? [styles.androidEnd, styles.androidEndEdge] : styles.androidEnd, onLayout: onTrailingLayout, children: _jsx(RowEndContext.Provider, { value: rowEnd, children: trailing }) })) : null] }));
|
|
310
406
|
return (_jsxs(_Fragment, { children: [onRowLayout ? _jsx(View, { pointerEvents: "none", onLayout: onRowLayout, style: styles.androidSpan }) : null, probe, error != null ? (
|
|
311
407
|
// The error a 13sp line of its own across the row, under the label and the field
|
|
312
408
|
_jsxs(View, { style: styles.androidColumn, children: [_jsx(View, { style: styles.androidLine, children: parts }), _jsx(Text, { color: danger, accessibilityLiveRegion: "polite", style: [styles.androidDescription, { marginTop: 4 }], children: error })] })) : (parts), last || tile ? null : _jsx(View, { pointerEvents: "none", style: [styles.androidDivider, { start: textStart, backgroundColor: divider(theme) }] })] }));
|
|
@@ -328,21 +424,22 @@ const styles = StyleSheet.create({
|
|
|
328
424
|
// Android's section: one card, 16 round; the header a 40dp row inside it (a header row), the footer under it
|
|
329
425
|
// (a footer: 24 from the screen's edge, 10 above, 17 below)
|
|
330
426
|
androidCard: { borderRadius: ANDROID_CARD_RADIUS, overflow: "hidden" },
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
427
|
+
// The header: 15/20 Medium 14 under the card's top and 21 in, 6 under it to close its 40dp line
|
|
428
|
+
androidHeader: { minHeight: 40, paddingHorizontal: ANDROID_INSET, paddingTop: 14, paddingBottom: 6, fontSize: 15, lineHeight: 20 },
|
|
429
|
+
androidDescriptionLine: { paddingHorizontal: ANDROID_INSET, paddingBottom: 6, fontSize: 14, lineHeight: 18 },
|
|
430
|
+
androidDescriptionAlone: { paddingTop: 14 },
|
|
431
|
+
androidFooter: { paddingHorizontal: 13, paddingTop: 11, paddingBottom: 17, fontSize: 14, lineHeight: 18 },
|
|
335
432
|
// A plain list's header band (32dp, its text 16 in), its description and its footer 20 in as the rows' text, the
|
|
336
433
|
// footer on the band's gray as the space between sections
|
|
337
434
|
androidBand: { height: 32, justifyContent: "center", paddingHorizontal: 16 },
|
|
338
435
|
androidBandText: { fontSize: 14, lineHeight: 18 },
|
|
339
436
|
androidDescriptionPlain: { paddingTop: 10 },
|
|
340
|
-
androidFooterPlain: { paddingHorizontal:
|
|
341
|
-
androidRow: { flexDirection: "row", alignItems: "center", minHeight: 50, paddingStart:
|
|
342
|
-
// A symbol at
|
|
343
|
-
androidIcon: { width: 24, height: 24, alignItems: "center", justifyContent: "center", marginStart: 1, marginEnd:
|
|
344
|
-
androidMark: { width: 20, alignItems: "center", justifyContent: "center", marginStart:
|
|
345
|
-
androidTile: { width: 28, height: 28, borderRadius: 10, alignItems: "center", justifyContent: "center", marginStart: -
|
|
437
|
+
androidFooterPlain: { paddingHorizontal: ANDROID_INSET },
|
|
438
|
+
androidRow: { flexDirection: "row", alignItems: "center", minHeight: 50, paddingStart: ANDROID_INSET, paddingEnd: ANDROID_INSET },
|
|
439
|
+
// 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
|
|
440
|
+
androidIcon: { width: 24, height: 24, alignItems: "center", justifyContent: "center", marginStart: -1, marginEnd: 20 },
|
|
441
|
+
androidMark: { width: 20, alignItems: "center", justifyContent: "center", marginStart: 1, marginEnd: 22 },
|
|
442
|
+
androidTile: { width: 28, height: 28, borderRadius: 10, alignItems: "center", justifyContent: "center", marginStart: -3, marginEnd: 18 },
|
|
346
443
|
androidText: { flex: 1, minWidth: 0, gap: 4 },
|
|
347
444
|
androidTextHug: { flexShrink: 1, minWidth: 0, gap: 4 },
|
|
348
445
|
androidColumn: { flex: 1, minWidth: 0, paddingVertical: 10 },
|
|
@@ -362,4 +459,23 @@ const styles = StyleSheet.create({
|
|
|
362
459
|
shrink: { flexShrink: 1 },
|
|
363
460
|
keep: { flexShrink: 0 },
|
|
364
461
|
grow: { flex: 1, minWidth: 0 },
|
|
462
|
+
// The label's column of a List with `columns`, the value starting after it
|
|
463
|
+
column: { width: "40%", flexGrow: 0, flexShrink: 0 },
|
|
464
|
+
keepStart: { flexShrink: 1, minWidth: 0, alignItems: "flex-start" },
|
|
465
|
+
androidEndStart: { alignItems: "flex-start" },
|
|
466
|
+
androidEndEdge: { marginStart: "auto" },
|
|
467
|
+
endAtEdge: { justifyContent: "flex-end" },
|
|
468
|
+
iosHeaderRow: { flexDirection: "row", alignItems: "flex-end", gap: 16 },
|
|
469
|
+
androidHeaderRow: { flexDirection: "row", alignItems: "flex-start", minHeight: 40, paddingHorizontal: ANDROID_INSET, paddingTop: 14, paddingBottom: 6, gap: 16 },
|
|
470
|
+
androidHeaderTitle: { flex: 1, minWidth: 0, fontSize: 15, lineHeight: 20 },
|
|
471
|
+
androidHeaderTitleType: { fontSize: 15, lineHeight: 20 },
|
|
472
|
+
// A prominent header: the title 16sp in the text color
|
|
473
|
+
androidHeaderIncreased: { fontSize: 16, lineHeight: 20 },
|
|
474
|
+
androidBandRow: { flexDirection: "row", alignItems: "center", gap: 16 },
|
|
475
|
+
// A row that is a Button: the button fills it, the hairline under it from the text's start
|
|
476
|
+
actionRow: { alignSelf: "stretch" },
|
|
477
|
+
actionSeparator: { position: "absolute", end: 0, bottom: 0, height: StyleSheet.hairlineWidth },
|
|
478
|
+
// A field row whose value is a line of its own
|
|
479
|
+
stackedRow: { alignSelf: "stretch", flexDirection: "row", alignItems: "center" },
|
|
480
|
+
stackedColumn: { flex: 1, minWidth: 0, alignSelf: "stretch" },
|
|
365
481
|
});
|