@plexui/react-native 0.2.16 → 0.2.18
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/SegmentedControl/SegmentedControl.js +9 -5
- package/dist/es/components/Select/Select.js +5 -4
- package/dist/es/components/TabBar/TabBar.js +9 -2
- package/dist/es/internal/CssSlide.js +35 -0
- 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/CssSlide.d.ts +22 -0
- 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/SegmentedControl/SegmentedControl.tsx +28 -5
- package/src/components/Select/Select.tsx +6 -5
- package/src/components/TabBar/TabBar.tsx +17 -2
- package/src/internal/CssSlide.tsx +54 -0
- 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 ? (
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, isValidElement, useContext, useEffect, useRef, useState } from "react";
|
|
3
|
-
import { Animated, Easing, StyleSheet, View } from "react-native";
|
|
3
|
+
import { Animated, Easing, Platform, StyleSheet, View } from "react-native";
|
|
4
4
|
import { Pressable } from "../../internal/Pressable";
|
|
5
|
+
import { CssSlide } from "../../internal/CssSlide";
|
|
5
6
|
import { childrenOfType, isRenderable, textOf } from "../../internal/children";
|
|
6
7
|
import { Glass } from "../../internal/Glass";
|
|
7
8
|
import { curves } from "../../internal/motion";
|
|
@@ -118,7 +119,8 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, show
|
|
|
118
119
|
const [width] = useState(() => new Animated.Value(0));
|
|
119
120
|
const placed = useRef(false);
|
|
120
121
|
useEffect(() => {
|
|
121
|
-
|
|
122
|
+
// The web's thumb slides in CSS
|
|
123
|
+
if (selectedX == null || selectedWidth == null || Platform.OS === "web")
|
|
122
124
|
return;
|
|
123
125
|
if (!placed.current || theme.reducedMotion) {
|
|
124
126
|
x.setValue(selectedX);
|
|
@@ -146,7 +148,9 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, show
|
|
|
146
148
|
};
|
|
147
149
|
// UISegmentedControl keeps its type at a large text size; a label here grows until it fills its segment
|
|
148
150
|
const maxScale = look.height / look.lineHeight;
|
|
149
|
-
const content = (_jsxs(_Fragment, { children: [selected
|
|
151
|
+
const content = (_jsxs(_Fragment, { children: [selected && Platform.OS === "web" ? (
|
|
152
|
+
// The web slides the thumb in CSS, off the JavaScript thread
|
|
153
|
+
_jsx(CssSlide, { x: selected.x, width: selected.width, side: "left", duration: look.duration, easing: "cubic-bezier(0.25, 0.1, 0.25, 1)", still: theme.reducedMotion, style: [styles.thumb, { top: look.gutter, bottom: look.gutter, borderRadius: optionRadius, backgroundColor: look.thumb }] })) : selected ? (_jsx(Animated.View, { pointerEvents: "none", style: [styles.thumb, { top: look.gutter, bottom: look.gutter, left: x, width, borderRadius: optionRadius, backgroundColor: look.thumb }] })) : null, options.map((option) => {
|
|
150
154
|
const isSelected = option.value === value;
|
|
151
155
|
const off = disabled || !!option.disabled;
|
|
152
156
|
const color = off ? theme.color("--alpha-20") : theme.colors.text;
|
|
@@ -204,7 +208,7 @@ function AndroidControl({ options, value, select, keys, disabled, block, equal,
|
|
|
204
208
|
const frameWidth = measured ? widths[options[index].value] : undefined;
|
|
205
209
|
const frame = frameX != null;
|
|
206
210
|
useEffect(() => {
|
|
207
|
-
if (frameX == null || frameWidth == null)
|
|
211
|
+
if (frameX == null || frameWidth == null || Platform.OS === "web")
|
|
208
212
|
return;
|
|
209
213
|
if (!placed.current || theme.reducedMotion) {
|
|
210
214
|
x.setValue(frameX);
|
|
@@ -219,7 +223,7 @@ function AndroidControl({ options, value, select, keys, disabled, block, equal,
|
|
|
219
223
|
styles.androidRow,
|
|
220
224
|
{ height, borderRadius: height / 2, backgroundColor: barSurface(m, theme.scheme), boxShadow: barShadow(theme.scheme) },
|
|
221
225
|
block ? styles.stretch : null,
|
|
222
|
-
], children: [frame ? (_jsx(Animated.View, { pointerEvents: "none", style: [styles.androidPill, { height: inner, borderRadius: inner / 2, backgroundColor: withAlpha(m.primary, 0.12), left: x, width }] })) : null, options.map((option) => (_jsx(AndroidSegment, { option: option, selected: option.value === value, off: disabled || !!option.disabled, framed: frame, showBadges: showBadges, badgeColor: badgeColor, height: inner,
|
|
226
|
+
], children: [frame && Platform.OS === "web" ? (_jsx(CssSlide, { x: frameX, width: frameWidth, side: "left", duration: ANDROID_MOVE.duration, easing: "cubic-bezier(0.23, 1, 0.32, 1)", still: theme.reducedMotion, style: [styles.androidPill, { height: inner, borderRadius: inner / 2, backgroundColor: withAlpha(m.primary, 0.12) }] })) : frame ? (_jsx(Animated.View, { pointerEvents: "none", style: [styles.androidPill, { height: inner, borderRadius: inner / 2, backgroundColor: withAlpha(m.primary, 0.12), left: x, width }] })) : null, options.map((option) => (_jsx(AndroidSegment, { option: option, selected: option.value === value, off: disabled || !!option.disabled, framed: frame, showBadges: showBadges, badgeColor: badgeColor, height: inner,
|
|
223
227
|
// In a filled row equal segments share the width and the others take their label and share what is left; a
|
|
224
228
|
// control that hugs its segments gives equal ones the widest one's width
|
|
225
229
|
size: block ? (equal ? styles.grow : styles.share) : widest ? { minWidth: widest } : null, keys: keys, select: select, onWidth: (w) => setWidths((prev) => (prev[option.value] === w ? prev : { ...prev, [option.value]: w })) }, option.value)))] }));
|
|
@@ -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°
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
-
import { Animated, Easing, StyleSheet, View } from "react-native";
|
|
3
|
+
import { Animated, Easing, Platform, StyleSheet, View } from "react-native";
|
|
4
4
|
import { Pressable } from "../../internal/Pressable";
|
|
5
|
+
import { CssSlide } from "../../internal/CssSlide";
|
|
5
6
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
6
7
|
import Search from "../../icons/plex/Search";
|
|
7
8
|
import { BarBackdrop, SoftBottomEdge, TabBarFade, ANDROID_FADE_ALPHA, ANDROID_FADE_STOPS, glassBarBlur, useAndroidGlass } from "../../internal/BarBackdrop";
|
|
@@ -392,6 +393,9 @@ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, pro
|
|
|
392
393
|
pillShown.current = false;
|
|
393
394
|
return;
|
|
394
395
|
}
|
|
396
|
+
// The web's pill slides in CSS
|
|
397
|
+
if (Platform.OS === "web")
|
|
398
|
+
return;
|
|
395
399
|
// It appears in place (the first frame, back from a minimized bar or the circle's tab), then slides: CSS `ease`
|
|
396
400
|
// over 300ms, as SegmentedControl's thumb
|
|
397
401
|
if (!pillShown.current || theme.reducedMotion) {
|
|
@@ -437,7 +441,10 @@ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, pro
|
|
|
437
441
|
{ paddingTop: padTop + (accessory ? accessoryHeight + accessoryGap : 0), paddingBottom },
|
|
438
442
|
physicalPadding(sideLeft, sideRight),
|
|
439
443
|
style,
|
|
440
|
-
], children: [backdrop, accessory ? (_jsx(Glass, { radius: accessoryHeight / 2, elevation: "raised", style: [styles.accessory, accessoryPlace], children: accessory }, "accessory")) : null, _jsxs(View, { style: [styles.iosRow, { gap: theme.length("--tab-bar-gap", 8), justifyContent: circle || minimized ? "space-between" : "center" }], children: [_jsxs(Glass, { radius: 999, elevation: "raised", style: [styles.capsule, minimized ? { padding: capsulePadding } : { paddingVertical: capsulePadding, paddingHorizontal: theme.length("--tab-bar-capsule-padding-inline", 10) }], children: [pillFrame
|
|
444
|
+
], children: [backdrop, accessory ? (_jsx(Glass, { radius: accessoryHeight / 2, elevation: "raised", style: [styles.accessory, accessoryPlace], children: accessory }, "accessory")) : null, _jsxs(View, { style: [styles.iosRow, { gap: theme.length("--tab-bar-gap", 8), justifyContent: circle || minimized ? "space-between" : "center" }], children: [_jsxs(Glass, { radius: 999, elevation: "raised", style: [styles.capsule, minimized ? { padding: capsulePadding } : { paddingVertical: capsulePadding, paddingHorizontal: theme.length("--tab-bar-capsule-padding-inline", 10) }], children: [pillFrame && Platform.OS === "web" ? (
|
|
445
|
+
// The web slides the pill in CSS, off the JavaScript thread, so a screen mounting under the new tab
|
|
446
|
+
// does not stop it
|
|
447
|
+
_jsx(CssSlide, { x: pillLeft, width: pillSpan, side: "start", duration: 300, easing: "cubic-bezier(0.25, 0.1, 0.25, 1)", still: theme.reducedMotion, style: [styles.pill, { top: pillFrame.y, height: pillFrame.height, backgroundColor: theme.color("--tab-bar-item-background-selected") }] })) : pillFrame ? (_jsx(Animated.View, { pointerEvents: "none", style: [
|
|
441
448
|
styles.pill,
|
|
442
449
|
{ top: pillFrame.y, height: pillFrame.height, start: pillX, width: pillWidth, backgroundColor: theme.color("--tab-bar-item-background-selected") },
|
|
443
450
|
] })) : null, visible.map((tab) => (_jsx(Tab, { ...tab, context: context }, tab.value)))] }), circle ? (_jsx(Glass, { radius: circleSize / 2, elevation: "raised", style: { width: circleSize, height: circleSize }, children: _jsx(Tab, { ...circle, context: { ...context, minimized: false }, kind: "circle", hideLabel: true }) })) : null] })] }) }));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
// A fill at the start of a right-to-left row moves the other way: the CSS direction turns the sign of its offset, so
|
|
4
|
+
// a row whose direction changes moves it over at once, as it moves `start`
|
|
5
|
+
const RULE = "[data-plex-slide=start]:dir(rtl){--plex-slide-sign:-1}";
|
|
6
|
+
let ruled = false;
|
|
7
|
+
function addRule() {
|
|
8
|
+
if (ruled)
|
|
9
|
+
return;
|
|
10
|
+
const dom = globalThis;
|
|
11
|
+
const sheet = dom.document?.createElement("style");
|
|
12
|
+
if (sheet == null || dom.document?.head == null)
|
|
13
|
+
return;
|
|
14
|
+
ruled = true;
|
|
15
|
+
sheet.textContent = RULE;
|
|
16
|
+
dom.document.head.appendChild(sheet);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The web's sliding fill (a segmented control's thumb, a tab bar's pill): its place a `translateX` and its width a CSS
|
|
20
|
+
* transition, so the browser runs the slide itself. A slide driven from JavaScript stops for a frame as long as the
|
|
21
|
+
* page's work in it (a screen mounting under the tab it slides to) and then jumps; the compositor keeps the move going.
|
|
22
|
+
* A fill that mounts stands at its place, since a transition starts from a style the browser has already drawn.
|
|
23
|
+
*/
|
|
24
|
+
export function CssSlide({ x, width, side, duration, easing, still = false, style }) {
|
|
25
|
+
if (side === "start")
|
|
26
|
+
addRule();
|
|
27
|
+
const time = still ? "0ms" : `${duration}ms`;
|
|
28
|
+
const motion = {
|
|
29
|
+
transform: side === "start" ? `translateX(calc(var(--plex-slide-sign, 1) * ${x}px))` : `translateX(${x}px)`,
|
|
30
|
+
transitionProperty: "transform, width",
|
|
31
|
+
transitionDuration: `${time}, ${time}`,
|
|
32
|
+
transitionTimingFunction: `${easing}, ${easing}`,
|
|
33
|
+
};
|
|
34
|
+
return (_jsx(View, { ...{ dataSet: { plexSlide: side } }, pointerEvents: "none", style: [style, side === "left" ? { left: 0 } : { start: 0 }, { width }, motion] }));
|
|
35
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
type CssSlideProps = {
|
|
3
|
+
/** The offset from the side, in points. */
|
|
4
|
+
x: number;
|
|
5
|
+
width: number;
|
|
6
|
+
/** `left` keeps the screen's left; `start` follows the row's direction (the right in a right-to-left row). */
|
|
7
|
+
side: "left" | "start";
|
|
8
|
+
duration: number;
|
|
9
|
+
/** A CSS timing function: `cubic-bezier(…)`. */
|
|
10
|
+
easing: string;
|
|
11
|
+
/** No slide: the fill moves at once (reduced motion). */
|
|
12
|
+
still?: boolean;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The web's sliding fill (a segmented control's thumb, a tab bar's pill): its place a `translateX` and its width a CSS
|
|
17
|
+
* transition, so the browser runs the slide itself. A slide driven from JavaScript stops for a frame as long as the
|
|
18
|
+
* page's work in it (a screen mounting under the tab it slides to) and then jumps; the compositor keeps the move going.
|
|
19
|
+
* A fill that mounts stands at its place, since a transition starts from a style the browser has already drawn.
|
|
20
|
+
*/
|
|
21
|
+
export declare function CssSlide({ x, width, side, duration, easing, still, style }: CssSlideProps): import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -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}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createContext, isValidElement, useContext, useEffect, useRef, useState, type ReactElement, type ReactNode } from "react"
|
|
2
|
-
import { Animated, Easing, StyleSheet, View, type LayoutChangeEvent, type StyleProp, type ViewStyle } from "react-native"
|
|
2
|
+
import { Animated, Easing, Platform, StyleSheet, View, type LayoutChangeEvent, type StyleProp, type ViewStyle } from "react-native"
|
|
3
3
|
import { Pressable } from "../../internal/Pressable"
|
|
4
|
+
import { CssSlide } from "../../internal/CssSlide"
|
|
4
5
|
import { childrenOfType, isRenderable, textOf } from "../../internal/children"
|
|
5
6
|
import { Glass } from "../../internal/Glass"
|
|
6
7
|
import { curves } from "../../internal/motion"
|
|
@@ -250,7 +251,8 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, show
|
|
|
250
251
|
const [width] = useState(() => new Animated.Value(0))
|
|
251
252
|
const placed = useRef(false)
|
|
252
253
|
useEffect(() => {
|
|
253
|
-
|
|
254
|
+
// The web's thumb slides in CSS
|
|
255
|
+
if (selectedX == null || selectedWidth == null || Platform.OS === "web") return
|
|
254
256
|
if (!placed.current || theme.reducedMotion) {
|
|
255
257
|
x.setValue(selectedX)
|
|
256
258
|
width.setValue(selectedWidth)
|
|
@@ -279,7 +281,18 @@ function IOSControl({ options, value, select, keys, disabled, block, equal, show
|
|
|
279
281
|
const maxScale = look.height / look.lineHeight
|
|
280
282
|
const content = (
|
|
281
283
|
<>
|
|
282
|
-
{selected ? (
|
|
284
|
+
{selected && Platform.OS === "web" ? (
|
|
285
|
+
// The web slides the thumb in CSS, off the JavaScript thread
|
|
286
|
+
<CssSlide
|
|
287
|
+
x={selected.x}
|
|
288
|
+
width={selected.width}
|
|
289
|
+
side="left"
|
|
290
|
+
duration={look.duration}
|
|
291
|
+
easing="cubic-bezier(0.25, 0.1, 0.25, 1)"
|
|
292
|
+
still={theme.reducedMotion}
|
|
293
|
+
style={[styles.thumb, { top: look.gutter, bottom: look.gutter, borderRadius: optionRadius, backgroundColor: look.thumb }]}
|
|
294
|
+
/>
|
|
295
|
+
) : selected ? (
|
|
283
296
|
<Animated.View
|
|
284
297
|
pointerEvents="none"
|
|
285
298
|
style={[styles.thumb, { top: look.gutter, bottom: look.gutter, left: x, width, borderRadius: optionRadius, backgroundColor: look.thumb }]}
|
|
@@ -395,7 +408,7 @@ function AndroidControl({ options, value, select, keys, disabled, block, equal,
|
|
|
395
408
|
const frameWidth = measured ? widths[options[index].value] : undefined
|
|
396
409
|
const frame = frameX != null
|
|
397
410
|
useEffect(() => {
|
|
398
|
-
if (frameX == null || frameWidth == null) return
|
|
411
|
+
if (frameX == null || frameWidth == null || Platform.OS === "web") return
|
|
399
412
|
if (!placed.current || theme.reducedMotion) {
|
|
400
413
|
x.setValue(frameX)
|
|
401
414
|
width.setValue(frameWidth)
|
|
@@ -413,7 +426,17 @@ function AndroidControl({ options, value, select, keys, disabled, block, equal,
|
|
|
413
426
|
block ? styles.stretch : null,
|
|
414
427
|
]}
|
|
415
428
|
>
|
|
416
|
-
{frame ? (
|
|
429
|
+
{frame && Platform.OS === "web" ? (
|
|
430
|
+
<CssSlide
|
|
431
|
+
x={frameX}
|
|
432
|
+
width={frameWidth!}
|
|
433
|
+
side="left"
|
|
434
|
+
duration={ANDROID_MOVE.duration}
|
|
435
|
+
easing="cubic-bezier(0.23, 1, 0.32, 1)"
|
|
436
|
+
still={theme.reducedMotion}
|
|
437
|
+
style={[styles.androidPill, { height: inner, borderRadius: inner / 2, backgroundColor: withAlpha(m.primary, 0.12) }]}
|
|
438
|
+
/>
|
|
439
|
+
) : frame ? (
|
|
417
440
|
<Animated.View
|
|
418
441
|
pointerEvents="none"
|
|
419
442
|
style={[styles.androidPill, { height: inner, borderRadius: inner / 2, backgroundColor: withAlpha(m.primary, 0.12), left: x, width }]}
|
|
@@ -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}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, type ReactElement, type ReactNode } from "react"
|
|
2
|
-
import { Animated, Easing, StyleSheet, View, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, type StyleProp, type ViewProps, type ViewStyle } from "react-native"
|
|
2
|
+
import { Animated, Easing, Platform, StyleSheet, View, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, type StyleProp, type ViewProps, type ViewStyle } from "react-native"
|
|
3
3
|
import { Pressable } from "../../internal/Pressable"
|
|
4
|
+
import { CssSlide } from "../../internal/CssSlide"
|
|
4
5
|
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
5
6
|
import Search from "../../icons/plex/Search"
|
|
6
7
|
import { BarBackdrop, SoftBottomEdge, TabBarFade, ANDROID_FADE_ALPHA, ANDROID_FADE_STOPS, glassBarBlur, useAndroidGlass } from "../../internal/BarBackdrop"
|
|
@@ -742,6 +743,8 @@ function TabBarRoot({
|
|
|
742
743
|
pillShown.current = false
|
|
743
744
|
return
|
|
744
745
|
}
|
|
746
|
+
// The web's pill slides in CSS
|
|
747
|
+
if (Platform.OS === "web") return
|
|
745
748
|
// It appears in place (the first frame, back from a minimized bar or the circle's tab), then slides: CSS `ease`
|
|
746
749
|
// over 300ms, as SegmentedControl's thumb
|
|
747
750
|
if (!pillShown.current || theme.reducedMotion) {
|
|
@@ -832,7 +835,19 @@ function TabBarRoot({
|
|
|
832
835
|
elevation="raised"
|
|
833
836
|
style={[styles.capsule, minimized ? { padding: capsulePadding } : { paddingVertical: capsulePadding, paddingHorizontal: theme.length("--tab-bar-capsule-padding-inline", 10) }]}
|
|
834
837
|
>
|
|
835
|
-
{pillFrame ? (
|
|
838
|
+
{pillFrame && Platform.OS === "web" ? (
|
|
839
|
+
// The web slides the pill in CSS, off the JavaScript thread, so a screen mounting under the new tab
|
|
840
|
+
// does not stop it
|
|
841
|
+
<CssSlide
|
|
842
|
+
x={pillLeft!}
|
|
843
|
+
width={pillSpan!}
|
|
844
|
+
side="start"
|
|
845
|
+
duration={300}
|
|
846
|
+
easing="cubic-bezier(0.25, 0.1, 0.25, 1)"
|
|
847
|
+
still={theme.reducedMotion}
|
|
848
|
+
style={[styles.pill, { top: pillFrame.y, height: pillFrame.height, backgroundColor: theme.color("--tab-bar-item-background-selected") }]}
|
|
849
|
+
/>
|
|
850
|
+
) : pillFrame ? (
|
|
836
851
|
<Animated.View
|
|
837
852
|
pointerEvents="none"
|
|
838
853
|
style={[
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from "react-native"
|
|
2
|
+
import { View } from "react-native"
|
|
3
|
+
|
|
4
|
+
type CssSlideProps = {
|
|
5
|
+
/** The offset from the side, in points. */
|
|
6
|
+
x: number
|
|
7
|
+
width: number
|
|
8
|
+
/** `left` keeps the screen's left; `start` follows the row's direction (the right in a right-to-left row). */
|
|
9
|
+
side: "left" | "start"
|
|
10
|
+
duration: number
|
|
11
|
+
/** A CSS timing function: `cubic-bezier(…)`. */
|
|
12
|
+
easing: string
|
|
13
|
+
/** No slide: the fill moves at once (reduced motion). */
|
|
14
|
+
still?: boolean
|
|
15
|
+
style?: StyleProp<ViewStyle>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// A fill at the start of a right-to-left row moves the other way: the CSS direction turns the sign of its offset, so
|
|
19
|
+
// a row whose direction changes moves it over at once, as it moves `start`
|
|
20
|
+
const RULE = "[data-plex-slide=start]:dir(rtl){--plex-slide-sign:-1}"
|
|
21
|
+
let ruled = false
|
|
22
|
+
function addRule() {
|
|
23
|
+
if (ruled) return
|
|
24
|
+
const dom = globalThis as unknown as { document?: { createElement: (tag: string) => { textContent: string }; head?: { appendChild: (node: unknown) => void } } }
|
|
25
|
+
const sheet = dom.document?.createElement("style")
|
|
26
|
+
if (sheet == null || dom.document?.head == null) return
|
|
27
|
+
ruled = true
|
|
28
|
+
sheet.textContent = RULE
|
|
29
|
+
dom.document.head.appendChild(sheet)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The web's sliding fill (a segmented control's thumb, a tab bar's pill): its place a `translateX` and its width a CSS
|
|
34
|
+
* transition, so the browser runs the slide itself. A slide driven from JavaScript stops for a frame as long as the
|
|
35
|
+
* page's work in it (a screen mounting under the tab it slides to) and then jumps; the compositor keeps the move going.
|
|
36
|
+
* A fill that mounts stands at its place, since a transition starts from a style the browser has already drawn.
|
|
37
|
+
*/
|
|
38
|
+
export function CssSlide({ x, width, side, duration, easing, still = false, style }: CssSlideProps) {
|
|
39
|
+
if (side === "start") addRule()
|
|
40
|
+
const time = still ? "0ms" : `${duration}ms`
|
|
41
|
+
const motion = {
|
|
42
|
+
transform: side === "start" ? `translateX(calc(var(--plex-slide-sign, 1) * ${x}px))` : `translateX(${x}px)`,
|
|
43
|
+
transitionProperty: "transform, width",
|
|
44
|
+
transitionDuration: `${time}, ${time}`,
|
|
45
|
+
transitionTimingFunction: `${easing}, ${easing}`,
|
|
46
|
+
} as unknown as ViewStyle
|
|
47
|
+
return (
|
|
48
|
+
<View
|
|
49
|
+
{...({ dataSet: { plexSlide: side } } as object)}
|
|
50
|
+
pointerEvents="none"
|
|
51
|
+
style={[style, side === "left" ? { left: 0 } : { start: 0 }, { width }, motion]}
|
|
52
|
+
/>
|
|
53
|
+
)
|
|
54
|
+
}
|
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