@plexui/react-native 0.2.16 → 0.2.17
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/BottomSheet/BottomSheet.js +11 -2
- package/dist/es/components/List/List.js +19 -12
- package/dist/es/components/Select/Select.js +5 -4
- package/dist/es/internal/Glass.js +6 -2
- package/dist/types/components/BottomSheet/BottomSheet.d.ts +7 -1
- package/dist/types/components/List/List.d.ts +6 -1
- package/dist/types/internal/row.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/BottomSheet/BottomSheet.tsx +15 -1
- package/src/components/List/List.tsx +25 -12
- package/src/components/Select/Select.tsx +6 -5
- package/src/internal/Glass.tsx +6 -2
- package/src/internal/row.ts +2 -0
|
@@ -167,7 +167,7 @@ function BottomSheetRoot(props) {
|
|
|
167
167
|
return _jsx(BottomSheetBase, { ...props });
|
|
168
168
|
}
|
|
169
169
|
/** The sheet with an exit of its own (ActionSheet's item tap); not part of the public API. */
|
|
170
|
-
export function BottomSheetBase({ open, onOpenChange, title, children, dismissible = true, "aria-label": ariaLabel, testID, contentStyle, closeLabel = "Close", exit, onExited, }) {
|
|
170
|
+
export function BottomSheetBase({ open, onOpenChange, title, children, dismissible = true, "aria-label": ariaLabel, testID, contentStyle, closeLabel = "Close", detent = "content", exit, onExited, }) {
|
|
171
171
|
const theme = useTheme();
|
|
172
172
|
const insets = useSafeAreaInsets();
|
|
173
173
|
const { width, height: screen } = useWindowDimensions();
|
|
@@ -210,6 +210,8 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
210
210
|
: { accessibilityViewIsModal: true, "aria-label": ariaLabel };
|
|
211
211
|
// Android's sheet stands under the status bar at most; the phone layer's 16 under the top inset
|
|
212
212
|
const maxHeight = screen - insets.top - (android ? 0 : 16);
|
|
213
|
+
// A detent holds the sheet's height whatever its content: half the screen, the most it takes, or a height
|
|
214
|
+
const fixedHeight = detent === "large" ? maxHeight : detent === "medium" ? Math.min(Math.round(screen / 2), maxHeight) : typeof detent === "number" ? Math.min(detent, maxHeight) : undefined;
|
|
213
215
|
// Android's sheet is as wide as the screen in portrait; in landscape 80% of it and 480dp at least
|
|
214
216
|
const maxWidth = android && width > screen ? Math.max(width * 0.8, Math.min(480, width)) : undefined;
|
|
215
217
|
const closeSize = theme.length("--dialog-sheet-close-size", 44);
|
|
@@ -245,6 +247,8 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
245
247
|
styles.sheet,
|
|
246
248
|
{
|
|
247
249
|
maxHeight,
|
|
250
|
+
// A fixed sheet grows by the keyboard it stands over, within the screen, so its content keeps its room
|
|
251
|
+
height: fixedHeight == null ? undefined : Math.min(fixedHeight + keyboard, maxHeight),
|
|
248
252
|
maxWidth,
|
|
249
253
|
borderTopLeftRadius: radius,
|
|
250
254
|
borderTopRightRadius: radius,
|
|
@@ -255,7 +259,11 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
|
|
|
255
259
|
opacity: reduced ? progress : undefined,
|
|
256
260
|
transform: [{ translateY: reduced ? drag : slide(progress) }],
|
|
257
261
|
},
|
|
258
|
-
], children: [android && title != null ? null : header, _jsx(ScrollView
|
|
262
|
+
], children: [android && title != null ? null : header, _jsx(ScrollView
|
|
263
|
+
// A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
|
|
264
|
+
, {
|
|
265
|
+
// A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
|
|
266
|
+
style: [styles.scroll, fixedHeight != null ? styles.grow : null], ...(android
|
|
259
267
|
? {
|
|
260
268
|
...gesture.content,
|
|
261
269
|
onScroll: (event) => {
|
|
@@ -326,6 +334,7 @@ const styles = StyleSheet.create({
|
|
|
326
334
|
bottom: { flex: 1, justifyContent: "flex-end", alignItems: "center" },
|
|
327
335
|
sheet: { alignSelf: "stretch", overflow: "hidden", borderCurve: "continuous", marginHorizontal: "auto", width: "100%" },
|
|
328
336
|
scroll: { flexGrow: 0, flexShrink: 1 },
|
|
337
|
+
grow: { flexGrow: 1 },
|
|
329
338
|
iosBar: { flexDirection: "row", alignItems: "center", gap: 8 },
|
|
330
339
|
iosHeading: { flex: 1, alignItems: "center", justifyContent: "center" },
|
|
331
340
|
scrimTarget: { position: "absolute", top: 0, left: 0, right: 0 },
|
|
@@ -116,7 +116,7 @@ export function List({ children, header, description, footer, error, surface = "
|
|
|
116
116
|
* 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
|
|
117
117
|
* tiled row draws none).
|
|
118
118
|
*/
|
|
119
|
-
export function ListItem({ label, description, leading, leadingColor, value, valuePlacement = "end", trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, disabled = false, destructive = false, accessibilityLabel, testID, }) {
|
|
119
|
+
export function ListItem({ label, description, leading, leadingColor, value, valuePlacement = "end", valueColor, trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, disabled = false, destructive = false, accessibilityLabel, testID, }) {
|
|
120
120
|
const theme = useTheme();
|
|
121
121
|
const { last, top, bottom } = useContext(PlaceContext);
|
|
122
122
|
// A menu opened from the row finds the row (Android lights it over the dim of the screen)
|
|
@@ -151,10 +151,17 @@ export function ListItem({ label, description, leading, leadingColor, value, val
|
|
|
151
151
|
// A control at the end that opens from the row (`RowEnd.press`) gets the row's press, as it gets a toggle's; it stays
|
|
152
152
|
// the one element for a screen reader and the keyboard
|
|
153
153
|
const [endPress, setEndPress] = useState(null);
|
|
154
|
-
|
|
154
|
+
// Once a control has handed the row its press the row stays a pressable frame, so taking the press back (a select
|
|
155
|
+
// disabled) does not swap the frame and remount the row's contents with their state
|
|
156
|
+
const [endHands, setEndHands] = useState(false);
|
|
157
|
+
const handPress = useCallback((open) => {
|
|
158
|
+
setEndPress(() => open);
|
|
159
|
+
if (open != null)
|
|
160
|
+
setEndHands(true);
|
|
161
|
+
}, []);
|
|
155
162
|
const handed = !switchRow && !onPress && !control && !disabled ? endPress : null;
|
|
156
163
|
const press = switchRow ? toggle : (onPress ?? control?.toggle ?? handed ?? undefined);
|
|
157
|
-
const endOwnsFocus = control != null || handed != null;
|
|
164
|
+
const endOwnsFocus = control != null || handed != null || (endHands && press == null);
|
|
158
165
|
// A destructive row is an action, not a page (Settings' Sign Out has no chevron)
|
|
159
166
|
const chevron = disclosure ?? (!!onPress && !switchRow && trailing == null && !destructive);
|
|
160
167
|
const name = accessibilityLabel ?? ([textOf(label), textOf(value)].filter(Boolean).join(", ") || undefined);
|
|
@@ -184,15 +191,15 @@ export function ListItem({ label, description, leading, leadingColor, value, val
|
|
|
184
191
|
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);
|
|
185
192
|
const start = (atStart || checkLeads) && control ? _jsx(RowStartContext.Provider, { value: true, children: control.node }) : leading;
|
|
186
193
|
const startColor = atStart || checkLeads ? undefined : leadingColor;
|
|
187
|
-
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 })) }));
|
|
194
|
+
return (_jsx(RowFrameContext.Provider, { value: frame, children: theme.isAndroid ? (_jsx(AndroidContent, { handPress: handPress, valueColor: valueColor ?? "accent", 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, { handPress: handPress, valueColor: valueColor ?? "secondary", 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 })) }));
|
|
188
195
|
};
|
|
189
|
-
if (press || onLongPress) {
|
|
196
|
+
if (press || onLongPress || endHands) {
|
|
190
197
|
// Android's rows press in the list selector: the native ripple on a device, the drawn one on the web
|
|
191
198
|
const highlight = controlHighlight(theme.scheme);
|
|
192
199
|
const drawn = theme.isAndroid && !nativeRipple;
|
|
193
200
|
return (_jsx(Pressable, { ref: frameNode, collapsable: false, ...described.props, ...(switchRow ? spaceToggles(toggle) : null),
|
|
194
201
|
// A row that toggles its control is not a second element for a screen reader or a Tab stop: the control is
|
|
195
|
-
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, onLongPress: onLongPress, delayLongPress: onLongPress ? 500 : undefined, accessibilityActions: onLongPress ? [{ name: "longpress" }] : undefined, onAccessibilityAction: onLongPress ? (event) => event.nativeEvent.actionName === "longpress" && onLongPress() : undefined, onPressIn: drawn ? ripple.start : undefined, onPressOut: drawn ? ripple.end : undefined, android_ripple: nativeRipple ? { color: highlight, foreground: true } : undefined, testID: testID, style: row, children: ({ pressed }) => (_jsxs(RowHoldContext.Provider, { value: disabled ? null : theme.isAndroid ? hold : setHeld, children: [ripple.layer, theme.isAndroid ? null : _jsx(RowHighlight, { on: (pressed || held) && lit, last: last }), content(pressed || held)] })) }));
|
|
202
|
+
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 || (press == null && onLongPress == null), onPress: press, onLongPress: onLongPress, delayLongPress: onLongPress ? 500 : undefined, accessibilityActions: onLongPress ? [{ name: "longpress" }] : undefined, onAccessibilityAction: onLongPress ? (event) => event.nativeEvent.actionName === "longpress" && onLongPress() : undefined, onPressIn: drawn ? ripple.start : undefined, onPressOut: drawn ? ripple.end : undefined, android_ripple: nativeRipple ? { color: highlight, foreground: true } : undefined, testID: testID, style: row, children: ({ pressed }) => (_jsxs(RowHoldContext.Provider, { value: disabled ? null : theme.isAndroid ? hold : setHeld, children: [ripple.layer, theme.isAndroid ? null : _jsx(RowHighlight, { on: (pressed || held) && lit, last: last }), content(pressed || held)] })) }));
|
|
196
203
|
}
|
|
197
204
|
// A row that only shows (a detail, a value) is one element named by `accessibilityLabel` when it has one; with a
|
|
198
205
|
// control at its end it stays a group, so the control is still reached
|
|
@@ -337,7 +344,7 @@ function useValueBelow(placement, label, value, type, fits) {
|
|
|
337
344
|
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;
|
|
338
345
|
return { below, probe, onRowLayout: auto ? measure("row") : undefined, onTrailingLayout: auto ? measure("trailing") : undefined };
|
|
339
346
|
}
|
|
340
|
-
function IOSContent({ theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, edgeControl = false, error, chevron, disabled, destructive, last }) {
|
|
347
|
+
function IOSContent({ handPress, valueColor, theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, edgeControl = false, error, chevron, disabled, destructive, last }) {
|
|
341
348
|
const inset = theme.length("--list-row-inset", 20);
|
|
342
349
|
const tile = theme.length("--field-row-icon-size", 28);
|
|
343
350
|
const gap = theme.length("--field-row-gap", 16);
|
|
@@ -368,7 +375,7 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
|
|
|
368
375
|
// A switch, a checkbox and a radio stay at the row's edge
|
|
369
376
|
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null;
|
|
370
377
|
const startsColumn = columns && !edgeControl;
|
|
371
|
-
const rowEnd = useMemo(() => ({ fill: setFill, align: startsColumn ? "start" : "end" }), [startsColumn]);
|
|
378
|
+
const rowEnd = useMemo(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end", valueColor }), [handPress, startsColumn, valueColor]);
|
|
372
379
|
const errorOffset = theme.length("--mobile-field-error-offset", 4);
|
|
373
380
|
const errorLine = theme.length("--mobile-field-error-line-height", 20);
|
|
374
381
|
// With an error the label and the control stand on a line of their own over it
|
|
@@ -394,11 +401,11 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
|
|
|
394
401
|
_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 ? (
|
|
395
402
|
// A long value wraps within the 60% the end takes, as the web's, rather than losing its end; set at the
|
|
396
403
|
// row's end (a phone turns "right" over in a right-to-left layout itself, the web does not)
|
|
397
|
-
_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] })] }));
|
|
404
|
+
_jsx(Text, { color: valueColor === "accent" && !disabled ? theme.colors.accent : 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] })] }));
|
|
398
405
|
}
|
|
399
406
|
/** The danger ink of a form's error, as the web's FieldError (`--field-error-color`). */
|
|
400
407
|
const errorColor = (theme) => theme.color("--field-error-color", theme.color("--color-text-danger-outline", theme.color("--color-text-danger")));
|
|
401
|
-
function AndroidContent({ handPress, theme, label, description, descriptionId, leading, leadingColor, leadingMark = false, value, valuePlacement, trailing, edgeControl = false, error, disabled, destructive, last, }) {
|
|
408
|
+
function AndroidContent({ handPress, valueColor, theme, label, description, descriptionId, leading, leadingColor, leadingMark = false, value, valuePlacement, trailing, edgeControl = false, error, disabled, destructive, last, }) {
|
|
402
409
|
// A disabled row fades to half, as Android's rows do
|
|
403
410
|
const dim = (color) => (disabled ? withAlpha(color, 0.5) : color);
|
|
404
411
|
const danger = dangerText(theme);
|
|
@@ -419,7 +426,7 @@ function AndroidContent({ handPress, theme, label, description, descriptionId, l
|
|
|
419
426
|
const [fill, setFill] = useState(false);
|
|
420
427
|
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null;
|
|
421
428
|
const startsColumn = columns && !edgeControl;
|
|
422
|
-
const rowEnd = useMemo(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end" }), [handPress, startsColumn]);
|
|
429
|
+
const rowEnd = useMemo(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end", valueColor }), [handPress, startsColumn, valueColor]);
|
|
423
430
|
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: [
|
|
424
431
|
columns ? [styles.androidTextHug, styles.column] : fill ? styles.androidTextHug : styles.androidText,
|
|
425
432
|
// One line centred in the 50dp row (54 beside a text field: a card's input row); with a second line 12 above
|
|
@@ -427,7 +434,7 @@ function AndroidContent({ handPress, theme, label, description, descriptionId, l
|
|
|
427
434
|
{ paddingVertical: error != null ? 0 : description != null || below ? 12 : fill ? 17 : 15 },
|
|
428
435
|
], children: [_jsx(Text, { color: ink, style: styles.androidLabel, children: label }), below ? (
|
|
429
436
|
// A detail row: the value a 13sp gray line under the label
|
|
430
|
-
_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:
|
|
437
|
+
_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(valueColor === "accent" ? accentText(theme) : theme.material.onSurfaceVariant), numberOfLines: 1, style: [styles.androidLabel, styles.androidValue, { marginEnd: valueEnd - ANDROID_INSET }], children: value })) : null, trailing != null ? (_jsx(View, { style:
|
|
431
438
|
// A switch or a checkbox stays at the row's edge after the label's column (it stretches in a column cell)
|
|
432
439
|
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] }));
|
|
433
440
|
return (_jsxs(_Fragment, { children: [onRowLayout ? _jsx(View, { pointerEvents: "none", onLayout: onRowLayout, style: styles.androidSpan }) : null, probe, error != null ? (
|
|
@@ -77,13 +77,14 @@ export function Select(props) {
|
|
|
77
77
|
const hold = useContext(RowHoldContext);
|
|
78
78
|
const rowEnd = row != null;
|
|
79
79
|
const inRow = rowEnd && !android;
|
|
80
|
-
// At the end of an Android row the select is the row's value, as in an Android value row
|
|
81
|
-
// on the row opens its choice
|
|
80
|
+
// At the end of an Android row the select is the row's value, as in an Android value row. On both platforms a press
|
|
81
|
+
// anywhere on the row opens its choice, as Settings' menu-picker row opens from the whole row on iOS; the row hands
|
|
82
|
+
// its press to the select, which stays the one element for a screen reader
|
|
82
83
|
const androidRow = rowEnd && android;
|
|
83
84
|
// Alone in a row whose label is hidden (a label-hidden `Field row`): the value from the row's text start and the
|
|
84
85
|
// chevrons at its end, on the row's line
|
|
85
86
|
const stacked = row?.stacked === true && block;
|
|
86
|
-
const handRow =
|
|
87
|
+
const handRow = rowEnd && !disabled ? row?.press : undefined;
|
|
87
88
|
useEffect(() => {
|
|
88
89
|
if (!handRow)
|
|
89
90
|
return;
|
|
@@ -107,7 +108,7 @@ export function Select(props) {
|
|
|
107
108
|
// The arrow sits in Compose's trailing icon slot, 12 from the edge
|
|
108
109
|
style: [styles.box, inRow ? styles.row : androidRow ? null : [look.box, { gap: look.gap }], android && !androidRow ? { paddingEnd: 12 } : null, stacked ? styles.stacked : null], children: [android && !androidRow ? _jsx(FieldOutline, { frame: look.frame }) : null, androidRow ? (
|
|
109
110
|
// A value row's value: 16sp in the accent, the placeholder in the hint's gray, faded to half when disabled
|
|
110
|
-
_jsx(Text, { numberOfLines: 1, color: withAlpha(shownLabel != null ? m.primary : withAlpha(m.onSurface, 0.35), disabled ? 0.5 : 1), style: [stacked ? styles.grow : styles.shrink, styles.androidValue, stacked ? styles.startText : null], children: shownLabel ?? placeholder })) : inRow ? (_jsx(Text, { numberOfLines: 1, color: shownLabel != null && !disabled ? theme.colors.labelSecondary : tertiary, style: [stacked ? styles.grow : styles.shrink, { fontSize: theme.length("--field-row-label-font-size", 17), lineHeight: theme.length("--field-row-label-line-height", 22) }], children: shownLabel ?? placeholder })) : (_jsx(Text, { numberOfLines: 1, color: shownLabel != null ? look.text.color : look.placeholder, style: [styles.grow, { fontSize: look.text.fontSize, lineHeight: look.text.lineHeight }], children: shownLabel ?? placeholder })), inRow ? (
|
|
111
|
+
_jsx(Text, { numberOfLines: 1, color: withAlpha(shownLabel != null ? (row?.valueColor === "secondary" ? m.onSurfaceVariant : m.primary) : withAlpha(m.onSurface, 0.35), disabled ? 0.5 : 1), style: [stacked ? styles.grow : styles.shrink, styles.androidValue, stacked ? styles.startText : null], children: shownLabel ?? placeholder })) : inRow ? (_jsx(Text, { numberOfLines: 1, color: shownLabel != null && !disabled ? (row?.valueColor === "accent" ? theme.colors.accent : theme.colors.labelSecondary) : tertiary, style: [stacked ? styles.grow : styles.shrink, { fontSize: theme.length("--field-row-label-font-size", 17), lineHeight: theme.length("--field-row-label-line-height", 22) }], children: shownLabel ?? placeholder })) : (_jsx(Text, { numberOfLines: 1, color: shownLabel != null ? look.text.color : look.placeholder, style: [styles.grow, { fontSize: look.text.fontSize, lineHeight: look.text.lineHeight }], children: shownLabel ?? placeholder })), inRow ? (
|
|
111
112
|
// The menu picker's chevrons, 8.5 by 22 with the 17 symbol overflowing it, 2 inside the row's end
|
|
112
113
|
_jsx(View, { style: styles.rowChevrons, children: _jsx(ChevronUpDown, { size: 17, color: disabled ? tertiary : theme.color("--mobile-accessory-secondary", theme.colors.labelSecondary) }) })) : androidRow ? null : android ? (
|
|
113
114
|
// Turned about the box's center while the picker is open, as Compose rotates its trailing icon 180°
|
|
@@ -70,9 +70,13 @@ export function Glass({ radius = 0, elevation = "regular", tint, interactive, fi
|
|
|
70
70
|
const filterName = filterToken ?? surface?.filter ?? "--mobile-glass-backdrop-filter";
|
|
71
71
|
const dense = web && !theme.isAndroid ? WEB_DENSE[fillName] : undefined;
|
|
72
72
|
const denseFill = dense != null && tint == null && overrides?.[fillName] == null;
|
|
73
|
-
|
|
73
|
+
// Glass with a fill of its own and the plain glass's filter (the large segmented control) blurs as the plain glass
|
|
74
|
+
// does on the web, so a brand's --mobile-glass-web-backdrop-filter reaches it too
|
|
75
|
+
const plainFilter = web && !theme.isAndroid && dense == null && filterToken == null && filterName === "--mobile-glass-backdrop-filter" && overrides?.[filterName] == null;
|
|
76
|
+
const denseFilter = (dense != null && filterToken == null && overrides?.[filterName] == null) || plainFilter;
|
|
77
|
+
const webFilter = dense ?? WEB_DENSE["--mobile-glass-background"];
|
|
74
78
|
const fill = tint ?? (denseFill ? theme.color(dense.fill, theme.scheme === "dark" ? dense.dark : dense.light) : theme.color(fillName));
|
|
75
|
-
const filterValue = denseFilter ? (theme.token(
|
|
79
|
+
const filterValue = denseFilter ? (theme.token(webFilter.filter) ?? webFilter.blur) : theme.token(filterName);
|
|
76
80
|
const filter = blur != null ? `blur(${blur}px)` : typeof filterValue === "string" ? filterValue : "blur(12px)";
|
|
77
81
|
const module = web || Platform.OS !== "ios" ? null : blurModule();
|
|
78
82
|
const opaque = reduceTransparency || (!web && module == null);
|
|
@@ -19,6 +19,12 @@ export type BottomSheetProps = {
|
|
|
19
19
|
* @default "Close"
|
|
20
20
|
*/
|
|
21
21
|
closeLabel?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The sheet's height, as an iOS sheet's detent: `content`, as tall as its content; `medium`, half the screen;
|
|
24
|
+
* `large`, as tall as a sheet goes; or a height in points. A sheet of a fixed height keeps it while its content
|
|
25
|
+
* changes (pages that open inside it), its content scrolling within. @default "content"
|
|
26
|
+
*/
|
|
27
|
+
detent?: "content" | "medium" | "large" | number;
|
|
22
28
|
};
|
|
23
29
|
export type BottomSheetFooterProps = {
|
|
24
30
|
/** The actions, top to bottom: on iOS the main one first, as a setup sheet sets them. */
|
|
@@ -40,7 +46,7 @@ type SheetExit = {
|
|
|
40
46
|
};
|
|
41
47
|
declare function BottomSheetRoot(props: BottomSheetProps): import("react").JSX.Element;
|
|
42
48
|
/** The sheet with an exit of its own (ActionSheet's item tap); not part of the public API. */
|
|
43
|
-
export declare function BottomSheetBase({ open, onOpenChange, title, children, dismissible, "aria-label": ariaLabel, testID, contentStyle, closeLabel, exit, onExited, }: BottomSheetProps & SheetExit): import("react").JSX.Element;
|
|
49
|
+
export declare function BottomSheetBase({ open, onOpenChange, title, children, dismissible, "aria-label": ariaLabel, testID, contentStyle, closeLabel, detent, exit, onExited, }: BottomSheetProps & SheetExit): import("react").JSX.Element;
|
|
44
50
|
/**
|
|
45
51
|
* A sheet from the bottom edge: on iOS 26 the sheet of the phone layer (`--dialog-sheet-radius` 38 on its top corners,
|
|
46
52
|
* a bar 16 under its top edge with Close at the leading edge and the title centered, as the web's phone Sheet; no
|
|
@@ -70,6 +70,11 @@ export type ListItemProps = {
|
|
|
70
70
|
leadingColor?: string;
|
|
71
71
|
/** A value at the end, in the secondary label on iOS (`Wi-Fi … Home`) and the accent on Android. */
|
|
72
72
|
value?: ReactNode;
|
|
73
|
+
/**
|
|
74
|
+
* The value's color, and a select's at the row's end: `secondary`, the secondary label, as iOS draws it; `accent`, as
|
|
75
|
+
* an Android value row draws it. @default "secondary" on iOS, "accent" on Android
|
|
76
|
+
*/
|
|
77
|
+
valueColor?: "secondary" | "accent";
|
|
73
78
|
/**
|
|
74
79
|
* Where the value stands: at the `end` of the row, `below` the label at the full width of the text, or `auto`: at
|
|
75
80
|
* the end while the label and the value fit beside each other on one line, otherwise below (as Calendar sets a long
|
|
@@ -121,7 +126,7 @@ export type ListItemProps = {
|
|
|
121
126
|
* 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
|
|
122
127
|
* tiled row draws none).
|
|
123
128
|
*/
|
|
124
|
-
export declare function ListItem({ label, description, leading, leadingColor, value, valuePlacement, trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, disabled, destructive, accessibilityLabel, testID, }: ListItemProps): import("react").JSX.Element;
|
|
129
|
+
export declare function ListItem({ label, description, leading, leadingColor, value, valuePlacement, valueColor, trailing, error, checked: checkedProp, defaultChecked, onCheckedChange, disclosure, onPress, onLongPress, disabled, destructive, accessibilityLabel, testID, }: ListItemProps): import("react").JSX.Element;
|
|
125
130
|
export type StackedRowProps = {
|
|
126
131
|
/** The label over the value; none for a row whose placeholder names the field (`hideLabel`). */
|
|
127
132
|
label?: ReactNode;
|
|
@@ -22,6 +22,8 @@ export type RowEnd = {
|
|
|
22
22
|
* tall as its lines.
|
|
23
23
|
*/
|
|
24
24
|
stacked?: boolean;
|
|
25
|
+
/** The row's value color, which a select at its end takes for its value. @default the platform's */
|
|
26
|
+
valueColor?: "secondary" | "accent";
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
29
|
* Inside the end of a List row. On iOS a control there takes the row's look, as the web's controls in a `[data-row]` do.
|
package/package.json
CHANGED
|
@@ -30,6 +30,12 @@ export type BottomSheetProps = {
|
|
|
30
30
|
* @default "Close"
|
|
31
31
|
*/
|
|
32
32
|
closeLabel?: string
|
|
33
|
+
/**
|
|
34
|
+
* The sheet's height, as an iOS sheet's detent: `content`, as tall as its content; `medium`, half the screen;
|
|
35
|
+
* `large`, as tall as a sheet goes; or a height in points. A sheet of a fixed height keeps it while its content
|
|
36
|
+
* changes (pages that open inside it), its content scrolling within. @default "content"
|
|
37
|
+
*/
|
|
38
|
+
detent?: "content" | "medium" | "large" | number
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
export type BottomSheetFooterProps = {
|
|
@@ -213,6 +219,7 @@ export function BottomSheetBase({
|
|
|
213
219
|
testID,
|
|
214
220
|
contentStyle,
|
|
215
221
|
closeLabel = "Close",
|
|
222
|
+
detent = "content",
|
|
216
223
|
exit,
|
|
217
224
|
onExited,
|
|
218
225
|
}: BottomSheetProps & SheetExit) {
|
|
@@ -257,6 +264,9 @@ export function BottomSheetBase({
|
|
|
257
264
|
: { accessibilityViewIsModal: true, "aria-label": ariaLabel }
|
|
258
265
|
// Android's sheet stands under the status bar at most; the phone layer's 16 under the top inset
|
|
259
266
|
const maxHeight = screen - insets.top - (android ? 0 : 16)
|
|
267
|
+
// A detent holds the sheet's height whatever its content: half the screen, the most it takes, or a height
|
|
268
|
+
const fixedHeight =
|
|
269
|
+
detent === "large" ? maxHeight : detent === "medium" ? Math.min(Math.round(screen / 2), maxHeight) : typeof detent === "number" ? Math.min(detent, maxHeight) : undefined
|
|
260
270
|
// Android's sheet is as wide as the screen in portrait; in landscape 80% of it and 480dp at least
|
|
261
271
|
const maxWidth = android && width > screen ? Math.max(width * 0.8, Math.min(480, width)) : undefined
|
|
262
272
|
const closeSize = theme.length("--dialog-sheet-close-size", 44)
|
|
@@ -350,6 +360,8 @@ export function BottomSheetBase({
|
|
|
350
360
|
styles.sheet,
|
|
351
361
|
{
|
|
352
362
|
maxHeight,
|
|
363
|
+
// A fixed sheet grows by the keyboard it stands over, within the screen, so its content keeps its room
|
|
364
|
+
height: fixedHeight == null ? undefined : Math.min(fixedHeight + keyboard, maxHeight),
|
|
353
365
|
maxWidth,
|
|
354
366
|
borderTopLeftRadius: radius,
|
|
355
367
|
borderTopRightRadius: radius,
|
|
@@ -366,7 +378,8 @@ export function BottomSheetBase({
|
|
|
366
378
|
{/* Content taller than the screen scrolls; on iOS the drag stays on the bar, on Android it starts at the
|
|
367
379
|
content's top */}
|
|
368
380
|
<ScrollView
|
|
369
|
-
|
|
381
|
+
// A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
|
|
382
|
+
style={[styles.scroll, fixedHeight != null ? styles.grow : null]}
|
|
370
383
|
{...(android
|
|
371
384
|
? {
|
|
372
385
|
...gesture.content,
|
|
@@ -479,6 +492,7 @@ const styles = StyleSheet.create({
|
|
|
479
492
|
bottom: { flex: 1, justifyContent: "flex-end", alignItems: "center" },
|
|
480
493
|
sheet: { alignSelf: "stretch", overflow: "hidden", borderCurve: "continuous", marginHorizontal: "auto", width: "100%" },
|
|
481
494
|
scroll: { flexGrow: 0, flexShrink: 1 },
|
|
495
|
+
grow: { flexGrow: 1 },
|
|
482
496
|
iosBar: { flexDirection: "row", alignItems: "center", gap: 8 },
|
|
483
497
|
iosHeading: { flex: 1, alignItems: "center", justifyContent: "center" },
|
|
484
498
|
scrimTarget: { position: "absolute", top: 0, left: 0, right: 0 },
|
|
@@ -300,6 +300,11 @@ export type ListItemProps = {
|
|
|
300
300
|
leadingColor?: string
|
|
301
301
|
/** A value at the end, in the secondary label on iOS (`Wi-Fi … Home`) and the accent on Android. */
|
|
302
302
|
value?: ReactNode
|
|
303
|
+
/**
|
|
304
|
+
* The value's color, and a select's at the row's end: `secondary`, the secondary label, as iOS draws it; `accent`, as
|
|
305
|
+
* an Android value row draws it. @default "secondary" on iOS, "accent" on Android
|
|
306
|
+
*/
|
|
307
|
+
valueColor?: "secondary" | "accent"
|
|
303
308
|
/**
|
|
304
309
|
* Where the value stands: at the `end` of the row, `below` the label at the full width of the text, or `auto`: at
|
|
305
310
|
* the end while the label and the value fit beside each other on one line, otherwise below (as Calendar sets a long
|
|
@@ -359,6 +364,7 @@ export function ListItem({
|
|
|
359
364
|
leadingColor,
|
|
360
365
|
value,
|
|
361
366
|
valuePlacement = "end",
|
|
367
|
+
valueColor,
|
|
362
368
|
trailing,
|
|
363
369
|
error,
|
|
364
370
|
checked: checkedProp,
|
|
@@ -406,10 +412,16 @@ export function ListItem({
|
|
|
406
412
|
// A control at the end that opens from the row (`RowEnd.press`) gets the row's press, as it gets a toggle's; it stays
|
|
407
413
|
// the one element for a screen reader and the keyboard
|
|
408
414
|
const [endPress, setEndPress] = useState<(() => void) | null>(null)
|
|
409
|
-
|
|
415
|
+
// Once a control has handed the row its press the row stays a pressable frame, so taking the press back (a select
|
|
416
|
+
// disabled) does not swap the frame and remount the row's contents with their state
|
|
417
|
+
const [endHands, setEndHands] = useState(false)
|
|
418
|
+
const handPress = useCallback((open: (() => void) | null) => {
|
|
419
|
+
setEndPress(() => open)
|
|
420
|
+
if (open != null) setEndHands(true)
|
|
421
|
+
}, [])
|
|
410
422
|
const handed = !switchRow && !onPress && !control && !disabled ? endPress : null
|
|
411
423
|
const press = switchRow ? toggle : (onPress ?? control?.toggle ?? handed ?? undefined)
|
|
412
|
-
const endOwnsFocus = control != null || handed != null
|
|
424
|
+
const endOwnsFocus = control != null || handed != null || (endHands && press == null)
|
|
413
425
|
// A destructive row is an action, not a page (Settings' Sign Out has no chevron)
|
|
414
426
|
const chevron = disclosure ?? (!!onPress && !switchRow && trailing == null && !destructive)
|
|
415
427
|
const name = accessibilityLabel ?? ([textOf(label), textOf(value)].filter(Boolean).join(", ") || undefined)
|
|
@@ -449,14 +461,14 @@ export function ListItem({
|
|
|
449
461
|
return (
|
|
450
462
|
<RowFrameContext.Provider value={frame}>
|
|
451
463
|
{theme.isAndroid ? (
|
|
452
|
-
<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} />
|
|
464
|
+
<AndroidContent handPress={handPress} valueColor={valueColor ?? "accent"} 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} />
|
|
453
465
|
) : (
|
|
454
|
-
<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} />
|
|
466
|
+
<IOSContent handPress={handPress} valueColor={valueColor ?? "secondary"} 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} />
|
|
455
467
|
)}
|
|
456
468
|
</RowFrameContext.Provider>
|
|
457
469
|
)
|
|
458
470
|
}
|
|
459
|
-
if (press || onLongPress) {
|
|
471
|
+
if (press || onLongPress || endHands) {
|
|
460
472
|
// Android's rows press in the list selector: the native ripple on a device, the drawn one on the web
|
|
461
473
|
const highlight = controlHighlight(theme.scheme)
|
|
462
474
|
const drawn = theme.isAndroid && !nativeRipple
|
|
@@ -474,7 +486,7 @@ export function ListItem({
|
|
|
474
486
|
accessibilityLabel={endOwnsFocus ? undefined : name}
|
|
475
487
|
accessibilityState={endOwnsFocus ? undefined : switchRow ? { checked, disabled } : { disabled }}
|
|
476
488
|
aria-checked={switchRow ? checked : undefined}
|
|
477
|
-
disabled={disabled}
|
|
489
|
+
disabled={disabled || (press == null && onLongPress == null)}
|
|
478
490
|
onPress={press}
|
|
479
491
|
onLongPress={onLongPress}
|
|
480
492
|
delayLongPress={onLongPress ? 500 : undefined}
|
|
@@ -759,7 +771,7 @@ function useValueBelow(
|
|
|
759
771
|
return { below, probe, onRowLayout: auto ? measure("row") : undefined, onTrailingLayout: auto ? measure("trailing") : undefined }
|
|
760
772
|
}
|
|
761
773
|
|
|
762
|
-
function IOSContent({ theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, edgeControl = false, error, chevron, disabled, destructive, last }: ContentProps & { leadingColor?: string; chevron: boolean; last: boolean }) {
|
|
774
|
+
function IOSContent({ handPress, valueColor, theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, edgeControl = false, error, chevron, disabled, destructive, last }: ContentProps & { leadingColor?: string; chevron: boolean; last: boolean; handPress: RowEnd["press"]; valueColor: "secondary" | "accent" }) {
|
|
763
775
|
const inset = theme.length("--list-row-inset", 20)
|
|
764
776
|
const tile = theme.length("--field-row-icon-size", 28)
|
|
765
777
|
const gap = theme.length("--field-row-gap", 16)
|
|
@@ -793,7 +805,7 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
|
|
|
793
805
|
// A switch, a checkbox and a radio stay at the row's edge
|
|
794
806
|
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null
|
|
795
807
|
const startsColumn = columns && !edgeControl
|
|
796
|
-
const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill, align: startsColumn ? "start" : "end" }), [startsColumn])
|
|
808
|
+
const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end", valueColor }), [handPress, startsColumn, valueColor])
|
|
797
809
|
const errorOffset = theme.length("--mobile-field-error-offset", 4)
|
|
798
810
|
const errorLine = theme.length("--mobile-field-error-line-height", 20)
|
|
799
811
|
// With an error the label and the control stand on a line of their own over it
|
|
@@ -864,7 +876,7 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
|
|
|
864
876
|
{value != null && !below ? (
|
|
865
877
|
// A long value wraps within the 60% the end takes, as the web's, rather than losing its end; set at the
|
|
866
878
|
// row's end (a phone turns "right" over in a right-to-left layout itself, the web does not)
|
|
867
|
-
<Text color={secondary} style={[labelType, styles.shrink, { textAlign: Platform.OS === "web" && rtl ? "left" : "right" }]}>
|
|
879
|
+
<Text color={valueColor === "accent" && !disabled ? theme.colors.accent : secondary} style={[labelType, styles.shrink, { textAlign: Platform.OS === "web" && rtl ? "left" : "right" }]}>
|
|
868
880
|
{value}
|
|
869
881
|
</Text>
|
|
870
882
|
) : null}
|
|
@@ -900,6 +912,7 @@ const errorColor = (theme: Theme) => theme.color("--field-error-color", theme.co
|
|
|
900
912
|
|
|
901
913
|
function AndroidContent({
|
|
902
914
|
handPress,
|
|
915
|
+
valueColor,
|
|
903
916
|
theme,
|
|
904
917
|
label,
|
|
905
918
|
description,
|
|
@@ -915,7 +928,7 @@ function AndroidContent({
|
|
|
915
928
|
disabled,
|
|
916
929
|
destructive,
|
|
917
930
|
last,
|
|
918
|
-
}: ContentProps & { leadingColor?: string; leadingMark?: boolean; last: boolean; handPress: RowEnd["press"] }) {
|
|
931
|
+
}: ContentProps & { leadingColor?: string; leadingMark?: boolean; last: boolean; handPress: RowEnd["press"]; valueColor: "secondary" | "accent" }) {
|
|
919
932
|
// A disabled row fades to half, as Android's rows do
|
|
920
933
|
const dim = (color: string) => (disabled ? withAlpha(color, 0.5) : color)
|
|
921
934
|
const danger = dangerText(theme)
|
|
@@ -936,7 +949,7 @@ function AndroidContent({
|
|
|
936
949
|
const [fill, setFill] = useState(false)
|
|
937
950
|
const columns = useContext(ListOptionsContext)?.columns === true && trailing != null
|
|
938
951
|
const startsColumn = columns && !edgeControl
|
|
939
|
-
const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end" }), [handPress, startsColumn])
|
|
952
|
+
const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end", valueColor }), [handPress, startsColumn, valueColor])
|
|
940
953
|
const parts = (
|
|
941
954
|
<>
|
|
942
955
|
{leading == null ? null : leadingMark ? (
|
|
@@ -972,7 +985,7 @@ function AndroidContent({
|
|
|
972
985
|
) : null}
|
|
973
986
|
</View>
|
|
974
987
|
{value != null && !below ? (
|
|
975
|
-
<Text color={dim(accentText(theme))} numberOfLines={1} style={[styles.androidLabel, styles.androidValue, { marginEnd: valueEnd - ANDROID_INSET }]}>
|
|
988
|
+
<Text color={dim(valueColor === "accent" ? accentText(theme) : theme.material.onSurfaceVariant)} numberOfLines={1} style={[styles.androidLabel, styles.androidValue, { marginEnd: valueEnd - ANDROID_INSET }]}>
|
|
976
989
|
{value}
|
|
977
990
|
</Text>
|
|
978
991
|
) : null}
|
|
@@ -149,13 +149,14 @@ export function Select<T extends SelectOption>(props: SelectProps<T>) {
|
|
|
149
149
|
const hold = useContext(RowHoldContext)
|
|
150
150
|
const rowEnd = row != null
|
|
151
151
|
const inRow = rowEnd && !android
|
|
152
|
-
// At the end of an Android row the select is the row's value, as in an Android value row
|
|
153
|
-
// on the row opens its choice
|
|
152
|
+
// At the end of an Android row the select is the row's value, as in an Android value row. On both platforms a press
|
|
153
|
+
// anywhere on the row opens its choice, as Settings' menu-picker row opens from the whole row on iOS; the row hands
|
|
154
|
+
// its press to the select, which stays the one element for a screen reader
|
|
154
155
|
const androidRow = rowEnd && android
|
|
155
156
|
// Alone in a row whose label is hidden (a label-hidden `Field row`): the value from the row's text start and the
|
|
156
157
|
// chevrons at its end, on the row's line
|
|
157
158
|
const stacked = row?.stacked === true && block
|
|
158
|
-
const handRow =
|
|
159
|
+
const handRow = rowEnd && !disabled ? row?.press : undefined
|
|
159
160
|
useEffect(() => {
|
|
160
161
|
if (!handRow) return
|
|
161
162
|
handRow(dialog ? () => setOpen(true) : () => place(() => setOpen(true)))
|
|
@@ -193,7 +194,7 @@ export function Select<T extends SelectOption>(props: SelectProps<T>) {
|
|
|
193
194
|
// A value row's value: 16sp in the accent, the placeholder in the hint's gray, faded to half when disabled
|
|
194
195
|
<Text
|
|
195
196
|
numberOfLines={1}
|
|
196
|
-
color={withAlpha(shownLabel != null ? m.primary : withAlpha(m.onSurface, 0.35), disabled ? 0.5 : 1)}
|
|
197
|
+
color={withAlpha(shownLabel != null ? (row?.valueColor === "secondary" ? m.onSurfaceVariant : m.primary) : withAlpha(m.onSurface, 0.35), disabled ? 0.5 : 1)}
|
|
197
198
|
style={[stacked ? styles.grow : styles.shrink, styles.androidValue, stacked ? styles.startText : null]}
|
|
198
199
|
>
|
|
199
200
|
{shownLabel ?? placeholder}
|
|
@@ -201,7 +202,7 @@ export function Select<T extends SelectOption>(props: SelectProps<T>) {
|
|
|
201
202
|
) : inRow ? (
|
|
202
203
|
<Text
|
|
203
204
|
numberOfLines={1}
|
|
204
|
-
color={shownLabel != null && !disabled ? theme.colors.labelSecondary : tertiary}
|
|
205
|
+
color={shownLabel != null && !disabled ? (row?.valueColor === "accent" ? theme.colors.accent : theme.colors.labelSecondary) : tertiary}
|
|
205
206
|
style={[stacked ? styles.grow : styles.shrink, { fontSize: theme.length("--field-row-label-font-size", 17), lineHeight: theme.length("--field-row-label-line-height", 22) }]}
|
|
206
207
|
>
|
|
207
208
|
{shownLabel ?? placeholder}
|
package/src/internal/Glass.tsx
CHANGED
|
@@ -122,9 +122,13 @@ export function Glass({
|
|
|
122
122
|
const filterName = filterToken ?? surface?.filter ?? "--mobile-glass-backdrop-filter"
|
|
123
123
|
const dense = web && !theme.isAndroid ? WEB_DENSE[fillName] : undefined
|
|
124
124
|
const denseFill = dense != null && tint == null && overrides?.[fillName] == null
|
|
125
|
-
|
|
125
|
+
// Glass with a fill of its own and the plain glass's filter (the large segmented control) blurs as the plain glass
|
|
126
|
+
// does on the web, so a brand's --mobile-glass-web-backdrop-filter reaches it too
|
|
127
|
+
const plainFilter = web && !theme.isAndroid && dense == null && filterToken == null && filterName === "--mobile-glass-backdrop-filter" && overrides?.[filterName] == null
|
|
128
|
+
const denseFilter = (dense != null && filterToken == null && overrides?.[filterName] == null) || plainFilter
|
|
129
|
+
const webFilter = dense ?? WEB_DENSE["--mobile-glass-background"]
|
|
126
130
|
const fill = tint ?? (denseFill ? theme.color(dense.fill, theme.scheme === "dark" ? dense.dark : dense.light) : theme.color(fillName))
|
|
127
|
-
const filterValue = denseFilter ? (theme.token(
|
|
131
|
+
const filterValue = denseFilter ? (theme.token(webFilter.filter) ?? webFilter.blur) : theme.token(filterName)
|
|
128
132
|
const filter = blur != null ? `blur(${blur}px)` : typeof filterValue === "string" ? filterValue : "blur(12px)"
|
|
129
133
|
const module = web || Platform.OS !== "ios" ? null : blurModule()
|
|
130
134
|
const opaque = reduceTransparency || (!web && module == null)
|
package/src/internal/row.ts
CHANGED