@plexui/react-native 0.2.28 → 0.2.30

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.
@@ -40,10 +40,11 @@ export function BottomActions({ children, floating = false, background = "soft",
40
40
  style: [{ minHeight: height, borderRadius: height / 2 }, props.style],
41
41
  });
42
42
  // A disabled button's fill is see-through (the gray of iOS's disabled button): floating over the content it stands
43
- // on the screen's color, so the rows under it do not show through
44
- if (!floating || !props.disabled || android)
43
+ // on the screen's color, so the rows under it do not show through. The backing stays, clear, while the button is
44
+ // enabled: the button keeps its place in the tree, and with it focus, a screen reader's place and a press
45
+ if (!floating || android)
45
46
  return button;
46
- return (_jsx(View, { style: { borderRadius: height / 2, backgroundColor: canvas, alignSelf: (props.block ?? true) ? "stretch" : "flex-start" }, children: button }, child.key ?? index));
47
+ return (_jsx(View, { style: { borderRadius: height / 2, backgroundColor: props.disabled ? canvas : "transparent", alignSelf: (props.block ?? true) ? "stretch" : "flex-start" }, children: button }, child.key ?? index));
47
48
  });
48
49
  return (_jsxs(View, { testID: testID, pointerEvents: "box-none", style: [styles.bar, { paddingHorizontal: side, paddingTop, paddingBottom: bottom, gap: 8 }, floating ? styles.floating : null, style], children: [floating ? (android ? (_jsx(SoftBottomEdge, { fill: withAlpha(canvas, ANDROID_FADE_ALPHA), top: paddingTop - 13 + 60, tail: 60, blur: 0, stops: ANDROID_FADE_STOPS })) : background === "fade" ? (_jsx(TabBarFade, { fill: canvas, top: paddingTop })) : (_jsx(SoftBottomEdge, { fill: canvas, top: paddingTop, tail: 27, blur: theme.length("--toolbar-edge-blur-small", 3) }))) : null, actions] }));
49
50
  }
@@ -229,7 +229,7 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
229
229
  // (69 in all). Content scrolled under it shows through the sheet's color at
230
230
  // 63% over a light blur, let go over its last 32dp (12 past the bar), with no line
231
231
  const barItem = useMemoBarItem(background);
232
- const header = android ? (title != null ? (_jsxs(View, { onStartShouldSetResponderCapture: gesture.chrome, onLayout: (event) => setAndroidBarHeight(Math.max(ANDROID_BAR_HEIGHT, event.nativeEvent.layout.height)), style: styles.androidBar, children: [_jsx(SheetBarFade, { fill: background, shown: scrolled }), _jsx(View, { style: styles.androidCircle, children: dismissible ? (_jsx(BarItemContext.Provider, { value: barItem, children: _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) })) : null }), _jsx(View, { style: styles.androidHeading, children: _jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "medium", align: "center", numberOfLines: 2, color: m.onSurface, style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title }) }), _jsx(View, { style: styles.androidCircle })] })) : (_jsx(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidGrip }))) : dismissible || title != null ? (
232
+ const header = android ? (title != null ? (_jsxs(View, { onStartShouldSetResponderCapture: gesture.chrome, onLayout: (event) => setAndroidBarHeight(Math.max(ANDROID_BAR_HEIGHT, event.nativeEvent.layout.height)), style: [styles.androidBar, { paddingHorizontal: androidInline }], children: [_jsx(SheetBarFade, { fill: background, shown: scrolled }), _jsx(View, { style: styles.androidCircle, children: dismissible ? (_jsx(BarItemContext.Provider, { value: barItem, children: _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) })) : null }), _jsx(View, { style: styles.androidHeading, children: _jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "medium", align: "center", numberOfLines: 2, color: m.onSurface, style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title }) }), _jsx(View, { style: styles.androidCircle })] })) : (_jsx(View, { onStartShouldSetResponderCapture: gesture.chrome, style: styles.androidGrip }))) : dismissible || title != null ? (
233
233
  // The web's phone Sheet bar: one 44 row 16 under the top edge, Close at the leading edge and the title alone centered
234
234
  // The bar is the web's Toolbar: 16 above the row and --toolbar-padding-bottom under it
235
235
  _jsxs(View, { ...responder.panHandlers, style: [styles.iosBar, { paddingTop: theme.length("--dialog-sheet-action-inset-block", 16), paddingBottom: theme.length("--toolbar-padding-bottom", 10), paddingHorizontal: margin }], children: [_jsx(View, { style: { width: closeSize, height: closeSize }, children: dismissible ? _jsx(NavigationButton, { action: "close", accessibilityLabel: closeLabel, onPress: close }) : null }), _jsx(View, { style: [styles.iosHeading, { minHeight: closeSize }], children: title != null ? (_jsx(Text, { nativeID: titleId, accessibilityRole: "header", weight: "semibold", align: "center", style: { fontSize: titleType.fontSize, lineHeight: titleType.lineHeight }, children: title })) : null }), _jsx(View, { style: { width: closeSize } })] })) : null;
@@ -6,7 +6,20 @@ import { createIcon } from "./createIcon";
6
6
  */
7
7
  /** `arrow_drop_down`: a sharp 10x5 triangle in a 24dp box (Compose `ExposedDropdownMenuDefaults.TrailingIcon`). */
8
8
  export const MaterialArrowDropDown = createIcon("MaterialArrowDropDown", "0 0 24 24", [["path", { d: "M7 10l5 5 5-5z", fill: 0 }]]);
9
- /** `cancel`: a ring with an X, the clear button of a text field's trailing slot. */
9
+ /**
10
+ * Material Components' `mtrl_ic_cancel`: a solid circle with the X cut out, 24dp, the clear-text end icon of a text
11
+ * field (TextInputLayout END_ICON_CLEAR_TEXT), tinted onSurfaceVariant.
12
+ */
13
+ export const MaterialCancelFilled = createIcon("MaterialCancelFilled", "0 0 24 24", [
14
+ [
15
+ "path",
16
+ {
17
+ d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z",
18
+ fill: 0,
19
+ },
20
+ ],
21
+ ]);
22
+ /** `cancel`: a ring with an X (Material Symbols Outlined). */
10
23
  export const MaterialCancel = createIcon("MaterialCancel", "0 -960 960 960", [
11
24
  [
12
25
  "path",
@@ -14,7 +14,7 @@ import { androidGray, barShadow, barSurface, withAlpha, dangerText, stateLayer }
14
14
  import { useTheme } from "../../theme/ThemeProvider";
15
15
  import { BarFieldContext } from "../Button/Button";
16
16
  import { IconDefaultsProvider } from "../Icon/createIcon";
17
- import { MaterialCancel, MaterialClose } from "../Icon/material";
17
+ import { MaterialCancelFilled, MaterialClose } from "../Icon/material";
18
18
  /**
19
19
  * The phone layer's field at each size: Input.module.css's size table under touch.css's phone rules, which give every
20
20
  * size 17pt text and a 14pt gutter (11 beside a start adornment, `html [data-slot="input"]`, scoped rules with no root
@@ -116,7 +116,7 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
116
116
  gutter: 18,
117
117
  };
118
118
  }
119
- // Android's fields: `outline` is the outlined field (radius 8, a hairline in a light gray that thickens to 1.5dp in
119
+ // Android's fields: `outline` is the outlined field (radius 8, a hairline in Material's outline that thickens to 1.5dp in
120
120
  // the accent on focus, the label floating on the top line, the text 16), `soft` a field filled with the text color
121
121
  // at 5% (the chips' and sheets' search fields), `ghost` the bare field of a card (the text 17, 22 in). The hint is
122
122
  // a light gray (#A8A8A8, #7D7D7D at night); a field is 50dp (a row's height), 56 with a label; disabled dims it to
@@ -126,8 +126,9 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
126
126
  const accent = state.invalid ? dangerText(theme) : state.focused ? focusAccent(theme) : null;
127
127
  const height = label ? 56 : 50;
128
128
  const radius = pill ? height / 2 : 8;
129
- // The idle line: a hairline in a light gray (#DBDBDB), the text at 24% in dark mode
130
- const idle = androidGray(theme, "fieldLine");
129
+ // The idle line: Material 3's `outline` role (tone 50, 60 at night), at least 3:1 on the surface as a field's
130
+ // boundary needs; the lighter `--android-field-line` gray read as no field at all on a light screen
131
+ const idle = m.outline;
131
132
  const frame = outlined
132
133
  ? { outlined: true, color: accent ?? idle, width: state.focused && !state.disabled ? FOCUS_LINE : hairline(), radius }
133
134
  : state.invalid
@@ -441,16 +442,18 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
441
442
  useEffect(() => springTo(line, thick ? 1 : 0, FIELD_SPRING, theme.reducedMotion), [thick, line, theme.reducedMotion]);
442
443
  const lineColor = useSpringColor(look.frame?.color ?? "transparent", FIELD_SPRING.stiffness, !lined || theme.reducedMotion);
443
444
  const lineMotion = lined ? { color: lineColor, width: line.interpolate({ inputRange: [0, 1], outputRange: [hairline(), FOCUS_LINE] }) } : null;
444
- // Android's label is in the hint color at rest and in the accent while the field has focus, springing between them
445
- const labelColor = invalid ? dangerText(theme) : focused ? focusAccent(theme) : look.placeholder;
445
+ // Android's label is Material 3's `onSurfaceVariant` at rest or floating (tone 30, 80 at night: text contrast, which
446
+ // the hint gray is not) and the accent while the field has focus, springing between them; the hint stays lighter
447
+ const labelColor = invalid ? dangerText(theme) : focused ? focusAccent(theme) : theme.isAndroid ? theme.material.onSurfaceVariant : look.placeholder;
446
448
  const labelTint = useSpringColor(labelColor, FIELD_SPRING.stiffness, !floating || theme.reducedMotion);
447
449
  // iOS shows a form field's clear button while it is edited (UITextField's whileEditing), a search field's while it
448
- // has text; Android while the field has text
450
+ // has text; Android's text field while it has focus and text (Material Components' ClearTextEndIconDelegate), its
451
+ // search fields with the text (androidClear, below)
449
452
  const searchField = rest.inputMode === "search" || barField != null;
450
453
  // A value at a row's end has no clear button on iOS, as Settings' and Contacts' rows: only a value that starts its
451
454
  // column or stands on its own line under the label takes one
452
455
  const valueRight = !startAligned && (inRow || (fillsRow && valueAtEnd));
453
- const showClear = !!onClear && filled && !disabled && !readOnly && (theme.isAndroid || ((focused || clearing || searchField) && !valueRight));
456
+ const showClear = !!onClear && filled && !disabled && !readOnly && (theme.isAndroid ? focused || clearing : (focused || clearing || searchField) && !valueRight);
454
457
  // Android's search fields keep their clear button in place and show it with the text
455
458
  const androidClear = (search || barSearch) && !!onClear && !disabled && !readOnly;
456
459
  // A 24dp icon stands 12 in, the text 12 past it (48 in); otherwise the text is 14 in (the outlined field), 21 in a
@@ -552,14 +555,16 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
552
555
  if (!locked)
553
556
  input.current?.focus();
554
557
  } })) : showClear ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Clear", onFocus: () => setClearing(true), onBlur: () => setClearing(false), ...(Platform.OS === "web" ? { onMouseDown: (event) => event.preventDefault() } : null), onPress: () => {
555
- // As UIKit's clear button, the field keeps editing; first, so a caller's onClear may still move the focus
556
- if (!theme.isAndroid && !searchField)
558
+ // As UIKit's clear button and Material's clear-text icon, the field keeps editing (the button goes with
559
+ // the text, so it lets its own focus go); first, so a caller's onClear may still move the focus
560
+ setClearing(false);
561
+ if (!searchField)
557
562
  input.current?.focus();
558
563
  if (value === undefined)
559
564
  setOwn("");
560
565
  onChangeText?.("");
561
566
  onClear();
562
- }, style: [styles.clear, { width: look.clearTarget, minHeight: look.clearTarget }, theme.isAndroid ? styles.clearStretch : null, clearMargin], children: theme.isAndroid ? _jsx(MaterialCancel, { size: look.clearSize, color: look.trailingIcon }) : _jsx(XCircleFilled, { size: look.clearSize, color: theme.color("--mobile-label-tertiary") }) })) : null, endAdornment ? (_jsx(IconDefaultsProvider, { size: look.iconSize, color: look.trailingIcon, children: adornment(endAdornment, "end") })) : null] }));
567
+ }, style: [styles.clear, { width: look.clearTarget, minHeight: look.clearTarget }, theme.isAndroid ? styles.clearStretch : null, clearMargin], children: theme.isAndroid ? _jsx(MaterialCancelFilled, { size: look.clearSize, color: look.trailingIcon }) : _jsx(XCircleFilled, { size: look.clearSize, color: theme.color("--mobile-label-tertiary") }) })) : null, endAdornment ? (_jsx(IconDefaultsProvider, { size: look.iconSize, color: look.trailingIcon, children: adornment(endAdornment, "end") })) : null] }));
563
568
  }
564
569
  /**
565
570
  * The field's box: a View, or for a bar's search field the glass of the bar's buttons. With `shift` it moves sideways
@@ -579,11 +584,12 @@ export function TextField({ label, description, errorMessage, required, invalid,
579
584
  const theme = useTheme();
580
585
  const [typed, setTyped] = useState((input.defaultValue ?? "").length);
581
586
  const count = input.value != null ? input.value.length : typed;
582
- const counterText = counter && input.maxLength != null ? (_jsxs(Text, { color: "secondary", accessibilityLabel: `${count} of ${input.maxLength}`, style: [
587
+ const own = typeof counter === "string" ? counter : null;
588
+ const counterText = own != null || (counter === true && input.maxLength != null) ? (_jsx(Text, { color: "secondary", accessibilityLabel: own ?? `${count} of ${input.maxLength}`, style: [
583
589
  theme.isAndroid ? styles.androidCounter : styles.iosCounter,
584
590
  { opacity: input.disabled ? 0.5 : 1 },
585
591
  theme.isAndroid ? { color: theme.colors.textSecondary } : null,
586
- ], children: [count, "/", input.maxLength] })) : null;
592
+ ], children: own ?? `${count}/${input.maxLength}` })) : null;
587
593
  const end = labelAction != null && counterText != null ? (_jsxs(View, { style: styles.endRow, children: [labelAction, counterText] })) : (labelAction ?? counterText);
588
594
  // The count follows every edit, so a counter shown later reads the text as it is
589
595
  const field = { ...input, onChangeText: (next) => (setTyped(next.length), input.onChangeText?.(next)) };
@@ -489,8 +489,11 @@ function AndroidContent({ handPress, valueColor, theme, label, description, desc
489
489
  // Android's row symbols are the text's ink over a light card and a gray over a dark one
490
490
  const symbol = dim(destructive ? danger : theme.scheme === "dark" ? theme.colors.labelSecondary : theme.colors.text);
491
491
  const tile = leading != null && !!leadingColor;
492
+ // A picture wider than the symbol's 24 (a photo, an avatar) keeps its own size from the rows' inset (21, where the
493
+ // header and the footer stand), the text 16 past it, as Material's list item with a leading avatar; 0 for a symbol
494
+ const [wide, setWide] = useState(0);
492
495
  // The text (and the divider) 21 in, or 64 after a symbol, a tile or a choice's mark (its 20dp circle 22 in)
493
- const textStart = leading == null ? ANDROID_INSET : 64;
496
+ const textStart = leading == null ? ANDROID_INSET : wide > 0 && !tile && !leadingMark ? ANDROID_INSET + wide + 16 : 64;
494
497
  // A value that ends the row stands 17 from the end (a value row), 20 in a row with a tile (a tiled row)
495
498
  const valueEnd = trailing == null && !tile ? 17 : 20;
496
499
  // At the end the value takes half the row at most, 16 from the label and from a control
@@ -503,7 +506,14 @@ function AndroidContent({ handPress, valueColor, theme, label, description, desc
503
506
  const columns = useContext(ListOptionsContext)?.columns === true && trailing != null;
504
507
  const startsColumn = columns && !edgeControl;
505
508
  const rowEnd = useMemo(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end", valueColor }), [handPress, startsColumn, valueColor]);
506
- 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: [
509
+ 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, wide > 0 ? styles.androidWide : null], onLayout: tile
510
+ ? undefined
511
+ : (event) => {
512
+ const width = event.nativeEvent.layout.width;
513
+ const next = width > 24.5 ? width : 0;
514
+ if (Math.abs(next - wide) > 0.5)
515
+ setWide(next);
516
+ }, children: _jsx(IconDefaultsProvider, { size: 24, color: tile ? "#ffffff" : symbol, children: leading }) })), _jsxs(View, { style: [
507
517
  columns ? [styles.androidTextHug, styles.column] : fill ? styles.androidTextHug : styles.androidText,
508
518
  // One line centred in the 50dp row (54 beside a text field: a card's input row); with a second line 12 above
509
519
  // and below (a 64dp row)
@@ -547,7 +557,8 @@ const styles = StyleSheet.create({
547
557
  androidFooterPlain: { paddingHorizontal: ANDROID_INSET },
548
558
  androidRow: { flexDirection: "row", alignItems: "center", minHeight: 50, paddingStart: ANDROID_INSET, paddingEnd: ANDROID_INSET },
549
559
  // A 24dp symbol at 20, a 28dp tile at 18 with a 24dp symbol, or a choice's 20dp mark at 22: the text at 64
550
- androidIcon: { width: 24, height: 24, alignItems: "center", justifyContent: "center", marginStart: -1, marginEnd: 20 },
560
+ androidIcon: { minWidth: 24, minHeight: 24, alignItems: "center", justifyContent: "center", marginStart: -1, marginEnd: 20 },
561
+ androidWide: { marginStart: 0, marginEnd: 16 },
551
562
  androidMark: { width: 20, alignItems: "center", justifyContent: "center", marginStart: 1, marginEnd: 22 },
552
563
  androidTile: { width: 28, height: 28, borderRadius: 10, alignItems: "center", justifyContent: "center", marginStart: -3, marginEnd: 18 },
553
564
  androidText: { flex: 1, minWidth: 0, gap: 4 },
@@ -5,7 +5,12 @@
5
5
  */
6
6
  /** `arrow_drop_down`: a sharp 10x5 triangle in a 24dp box (Compose `ExposedDropdownMenuDefaults.TrailingIcon`). */
7
7
  export declare const MaterialArrowDropDown: import("./createIcon").IconComponent;
8
- /** `cancel`: a ring with an X, the clear button of a text field's trailing slot. */
8
+ /**
9
+ * Material Components' `mtrl_ic_cancel`: a solid circle with the X cut out, 24dp, the clear-text end icon of a text
10
+ * field (TextInputLayout END_ICON_CLEAR_TEXT), tinted onSurfaceVariant.
11
+ */
12
+ export declare const MaterialCancelFilled: import("./createIcon").IconComponent;
13
+ /** `cancel`: a ring with an X (Material Symbols Outlined). */
9
14
  export declare const MaterialCancel: import("./createIcon").IconComponent;
10
15
  /** `close`: a 14dp X of 2dp strokes in a 24dp box (`Icons.Filled.Close`, the snackbar's dismiss action, an app bar's close). */
11
16
  export declare const MaterialClose: import("./createIcon").IconComponent;
@@ -153,9 +153,10 @@ export type TextFieldProps = InputProps & {
153
153
  labelAction?: ReactNode;
154
154
  /**
155
155
  * Shows the count of characters against `maxLength` (`3/15`): Material's counter at the end of the help's line on
156
- * Android, at the end of the label's line on iOS.
156
+ * Android, at the end of the label's line on iOS. A string is a count of its own in that place (chosen tags,
157
+ * `"3/10"`).
157
158
  */
158
- counter?: boolean;
159
+ counter?: boolean | string;
159
160
  };
160
161
  /**
161
162
  * A labelled text field: Plex UI's Field around an Input. iOS sets the label over the field (15/20 medium) and the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/react-native",
3
- "version": "0.2.28",
3
+ "version": "0.2.30",
4
4
  "description": "Plex UI components for React Native and Expo: iOS 26 and Material 3, on the shared @plexui/styles tokens",
5
5
  "license": "MIT",
6
6
  "homepage": "https://plexui.com",
@@ -74,10 +74,14 @@ export function BottomActions({ children, floating = false, background = "soft",
74
74
  style: [{ minHeight: height, borderRadius: height / 2 }, props.style],
75
75
  })
76
76
  // A disabled button's fill is see-through (the gray of iOS's disabled button): floating over the content it stands
77
- // on the screen's color, so the rows under it do not show through
78
- if (!floating || !props.disabled || android) return button
77
+ // on the screen's color, so the rows under it do not show through. The backing stays, clear, while the button is
78
+ // enabled: the button keeps its place in the tree, and with it focus, a screen reader's place and a press
79
+ if (!floating || android) return button
79
80
  return (
80
- <View key={child.key ?? index} style={{ borderRadius: height / 2, backgroundColor: canvas, alignSelf: (props.block ?? true) ? "stretch" : "flex-start" }}>
81
+ <View
82
+ key={child.key ?? index}
83
+ style={{ borderRadius: height / 2, backgroundColor: props.disabled ? canvas : "transparent", alignSelf: (props.block ?? true) ? "stretch" : "flex-start" }}
84
+ >
81
85
  {button}
82
86
  </View>
83
87
  )
@@ -286,7 +286,7 @@ export function BottomSheetBase({
286
286
  const barItem = useMemoBarItem(background)
287
287
  const header = android ? (
288
288
  title != null ? (
289
- <View onStartShouldSetResponderCapture={gesture.chrome} onLayout={(event) => setAndroidBarHeight(Math.max(ANDROID_BAR_HEIGHT, event.nativeEvent.layout.height))} style={styles.androidBar}>
289
+ <View onStartShouldSetResponderCapture={gesture.chrome} onLayout={(event) => setAndroidBarHeight(Math.max(ANDROID_BAR_HEIGHT, event.nativeEvent.layout.height))} style={[styles.androidBar, { paddingHorizontal: androidInline }]}>
290
290
  <SheetBarFade fill={background} shown={scrolled} />
291
291
  <View style={styles.androidCircle}>
292
292
  {dismissible ? (
@@ -9,7 +9,21 @@ import { createIcon } from "./createIcon"
9
9
  /** `arrow_drop_down`: a sharp 10x5 triangle in a 24dp box (Compose `ExposedDropdownMenuDefaults.TrailingIcon`). */
10
10
  export const MaterialArrowDropDown = createIcon("MaterialArrowDropDown", "0 0 24 24", [["path", { d: "M7 10l5 5 5-5z", fill: 0 }]])
11
11
 
12
- /** `cancel`: a ring with an X, the clear button of a text field's trailing slot. */
12
+ /**
13
+ * Material Components' `mtrl_ic_cancel`: a solid circle with the X cut out, 24dp, the clear-text end icon of a text
14
+ * field (TextInputLayout END_ICON_CLEAR_TEXT), tinted onSurfaceVariant.
15
+ */
16
+ export const MaterialCancelFilled = createIcon("MaterialCancelFilled", "0 0 24 24", [
17
+ [
18
+ "path",
19
+ {
20
+ d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z",
21
+ fill: 0,
22
+ },
23
+ ],
24
+ ])
25
+
26
+ /** `cancel`: a ring with an X (Material Symbols Outlined). */
13
27
  export const MaterialCancel = createIcon("MaterialCancel", "0 -960 960 960", [
14
28
  [
15
29
  "path",
@@ -14,7 +14,7 @@ import { useTheme } from "../../theme/ThemeProvider"
14
14
  import type { Theme } from "../../theme/types"
15
15
  import { BarFieldContext, type ControlSize } from "../Button/Button"
16
16
  import { IconDefaultsProvider } from "../Icon/createIcon"
17
- import { MaterialCancel, MaterialClose } from "../Icon/material"
17
+ import { MaterialCancelFilled, MaterialClose } from "../Icon/material"
18
18
 
19
19
  export type InputVariant = "outline" | "soft" | "ghost"
20
20
 
@@ -174,7 +174,7 @@ export function fieldLook(
174
174
  gutter: 18,
175
175
  }
176
176
  }
177
- // Android's fields: `outline` is the outlined field (radius 8, a hairline in a light gray that thickens to 1.5dp in
177
+ // Android's fields: `outline` is the outlined field (radius 8, a hairline in Material's outline that thickens to 1.5dp in
178
178
  // the accent on focus, the label floating on the top line, the text 16), `soft` a field filled with the text color
179
179
  // at 5% (the chips' and sheets' search fields), `ghost` the bare field of a card (the text 17, 22 in). The hint is
180
180
  // a light gray (#A8A8A8, #7D7D7D at night); a field is 50dp (a row's height), 56 with a label; disabled dims it to
@@ -184,8 +184,9 @@ export function fieldLook(
184
184
  const accent = state.invalid ? dangerText(theme) : state.focused ? focusAccent(theme) : null
185
185
  const height = label ? 56 : 50
186
186
  const radius = pill ? height / 2 : 8
187
- // The idle line: a hairline in a light gray (#DBDBDB), the text at 24% in dark mode
188
- const idle = androidGray(theme, "fieldLine")
187
+ // The idle line: Material 3's `outline` role (tone 50, 60 at night), at least 3:1 on the surface as a field's
188
+ // boundary needs; the lighter `--android-field-line` gray read as no field at all on a light screen
189
+ const idle = m.outline
189
190
  const frame: FieldFrame | null = outlined
190
191
  ? { outlined: true, color: accent ?? idle, width: state.focused && !state.disabled ? FOCUS_LINE : hairline(), radius }
191
192
  : state.invalid
@@ -648,17 +649,19 @@ export function InputField({
648
649
  useEffect(() => springTo(line, thick ? 1 : 0, FIELD_SPRING, theme.reducedMotion), [thick, line, theme.reducedMotion])
649
650
  const lineColor = useSpringColor(look.frame?.color ?? "transparent", FIELD_SPRING.stiffness, !lined || theme.reducedMotion)
650
651
  const lineMotion: FrameMotion | null = lined ? { color: lineColor, width: line.interpolate({ inputRange: [0, 1], outputRange: [hairline(), FOCUS_LINE] }) } : null
651
- // Android's label is in the hint color at rest and in the accent while the field has focus, springing between them
652
- const labelColor = invalid ? dangerText(theme) : focused ? focusAccent(theme) : look.placeholder
652
+ // Android's label is Material 3's `onSurfaceVariant` at rest or floating (tone 30, 80 at night: text contrast, which
653
+ // the hint gray is not) and the accent while the field has focus, springing between them; the hint stays lighter
654
+ const labelColor = invalid ? dangerText(theme) : focused ? focusAccent(theme) : theme.isAndroid ? theme.material.onSurfaceVariant : look.placeholder
653
655
  const labelTint = useSpringColor(labelColor, FIELD_SPRING.stiffness, !floating || theme.reducedMotion)
654
656
  // iOS shows a form field's clear button while it is edited (UITextField's whileEditing), a search field's while it
655
- // has text; Android while the field has text
657
+ // has text; Android's text field while it has focus and text (Material Components' ClearTextEndIconDelegate), its
658
+ // search fields with the text (androidClear, below)
656
659
  const searchField = rest.inputMode === "search" || barField != null
657
660
  // A value at a row's end has no clear button on iOS, as Settings' and Contacts' rows: only a value that starts its
658
661
  // column or stands on its own line under the label takes one
659
662
  const valueRight = !startAligned && (inRow || (fillsRow && valueAtEnd))
660
663
  const showClear =
661
- !!onClear && filled && !disabled && !readOnly && (theme.isAndroid || ((focused || clearing || searchField) && !valueRight))
664
+ !!onClear && filled && !disabled && !readOnly && (theme.isAndroid ? focused || clearing : (focused || clearing || searchField) && !valueRight)
662
665
  // Android's search fields keep their clear button in place and show it with the text
663
666
  const androidClear = (search || barSearch) && !!onClear && !disabled && !readOnly
664
667
  // A 24dp icon stands 12 in, the text 12 past it (48 in); otherwise the text is 14 in (the outlined field), 21 in a
@@ -857,15 +860,17 @@ export function InputField({
857
860
  // On the web a press would blur the field before it lands and take the button away: the field keeps focus
858
861
  {...(Platform.OS === "web" ? ({ onMouseDown: (event: { preventDefault: () => void }) => event.preventDefault() } as object) : null)}
859
862
  onPress={() => {
860
- // As UIKit's clear button, the field keeps editing; first, so a caller's onClear may still move the focus
861
- if (!theme.isAndroid && !searchField) input.current?.focus()
863
+ // As UIKit's clear button and Material's clear-text icon, the field keeps editing (the button goes with
864
+ // the text, so it lets its own focus go); first, so a caller's onClear may still move the focus
865
+ setClearing(false)
866
+ if (!searchField) input.current?.focus()
862
867
  if (value === undefined) setOwn("")
863
868
  onChangeText?.("")
864
869
  onClear()
865
870
  }}
866
871
  style={[styles.clear, { width: look.clearTarget, minHeight: look.clearTarget }, theme.isAndroid ? styles.clearStretch : null, clearMargin]}
867
872
  >
868
- {theme.isAndroid ? <MaterialCancel size={look.clearSize} color={look.trailingIcon} /> : <XCircleFilled size={look.clearSize} color={theme.color("--mobile-label-tertiary")} />}
873
+ {theme.isAndroid ? <MaterialCancelFilled size={look.clearSize} color={look.trailingIcon} /> : <XCircleFilled size={look.clearSize} color={theme.color("--mobile-label-tertiary")} />}
869
874
  </Pressable>
870
875
  ) : null}
871
876
  {endAdornment ? (
@@ -901,9 +906,10 @@ export type TextFieldProps = InputProps & {
901
906
  labelAction?: ReactNode
902
907
  /**
903
908
  * Shows the count of characters against `maxLength` (`3/15`): Material's counter at the end of the help's line on
904
- * Android, at the end of the label's line on iOS.
909
+ * Android, at the end of the label's line on iOS. A string is a count of its own in that place (chosen tags,
910
+ * `"3/10"`).
905
911
  */
906
- counter?: boolean
912
+ counter?: boolean | string
907
913
  }
908
914
 
909
915
  /**
@@ -915,18 +921,19 @@ export function TextField({ label, description, errorMessage, required, invalid,
915
921
  const theme = useTheme()
916
922
  const [typed, setTyped] = useState((input.defaultValue ?? "").length)
917
923
  const count = input.value != null ? input.value.length : typed
924
+ const own = typeof counter === "string" ? counter : null
918
925
  const counterText =
919
- counter && input.maxLength != null ? (
926
+ own != null || (counter === true && input.maxLength != null) ? (
920
927
  <Text
921
928
  color="secondary"
922
- accessibilityLabel={`${count} of ${input.maxLength}`}
929
+ accessibilityLabel={own ?? `${count} of ${input.maxLength}`}
923
930
  style={[
924
931
  theme.isAndroid ? styles.androidCounter : styles.iosCounter,
925
932
  { opacity: input.disabled ? 0.5 : 1 },
926
933
  theme.isAndroid ? { color: theme.colors.textSecondary } : null,
927
934
  ]}
928
935
  >
929
- {count}/{input.maxLength}
936
+ {own ?? `${count}/${input.maxLength}`}
930
937
  </Text>
931
938
  ) : null
932
939
  const end =
@@ -1067,8 +1067,11 @@ function AndroidContent({
1067
1067
  // Android's row symbols are the text's ink over a light card and a gray over a dark one
1068
1068
  const symbol = dim(destructive ? danger : theme.scheme === "dark" ? theme.colors.labelSecondary : theme.colors.text)
1069
1069
  const tile = leading != null && !!leadingColor
1070
+ // A picture wider than the symbol's 24 (a photo, an avatar) keeps its own size from the rows' inset (21, where the
1071
+ // header and the footer stand), the text 16 past it, as Material's list item with a leading avatar; 0 for a symbol
1072
+ const [wide, setWide] = useState(0)
1070
1073
  // The text (and the divider) 21 in, or 64 after a symbol, a tile or a choice's mark (its 20dp circle 22 in)
1071
- const textStart = leading == null ? ANDROID_INSET : 64
1074
+ const textStart = leading == null ? ANDROID_INSET : wide > 0 && !tile && !leadingMark ? ANDROID_INSET + wide + 16 : 64
1072
1075
  // A value that ends the row stands 17 from the end (a value row), 20 in a row with a tile (a tiled row)
1073
1076
  const valueEnd = trailing == null && !tile ? 17 : 20
1074
1077
  // At the end the value takes half the row at most, 16 from the label and from a control
@@ -1086,7 +1089,18 @@ function AndroidContent({
1086
1089
  {leading == null ? null : leadingMark ? (
1087
1090
  <View style={styles.androidMark}>{leading}</View>
1088
1091
  ) : (
1089
- <View style={tile ? [styles.androidTile, { backgroundColor: leadingColor, opacity: disabled ? 0.5 : 1 }] : styles.androidIcon}>
1092
+ <View
1093
+ style={tile ? [styles.androidTile, { backgroundColor: leadingColor, opacity: disabled ? 0.5 : 1 }] : [styles.androidIcon, wide > 0 ? styles.androidWide : null]}
1094
+ onLayout={
1095
+ tile
1096
+ ? undefined
1097
+ : (event) => {
1098
+ const width = event.nativeEvent.layout.width
1099
+ const next = width > 24.5 ? width : 0
1100
+ if (Math.abs(next - wide) > 0.5) setWide(next)
1101
+ }
1102
+ }
1103
+ >
1090
1104
  <IconDefaultsProvider size={24} color={tile ? "#ffffff" : symbol}>
1091
1105
  {leading}
1092
1106
  </IconDefaultsProvider>
@@ -1184,7 +1198,8 @@ const styles = StyleSheet.create({
1184
1198
  androidFooterPlain: { paddingHorizontal: ANDROID_INSET },
1185
1199
  androidRow: { flexDirection: "row", alignItems: "center", minHeight: 50, paddingStart: ANDROID_INSET, paddingEnd: ANDROID_INSET },
1186
1200
  // A 24dp symbol at 20, a 28dp tile at 18 with a 24dp symbol, or a choice's 20dp mark at 22: the text at 64
1187
- androidIcon: { width: 24, height: 24, alignItems: "center", justifyContent: "center", marginStart: -1, marginEnd: 20 },
1201
+ androidIcon: { minWidth: 24, minHeight: 24, alignItems: "center", justifyContent: "center", marginStart: -1, marginEnd: 20 },
1202
+ androidWide: { marginStart: 0, marginEnd: 16 },
1188
1203
  androidMark: { width: 20, alignItems: "center", justifyContent: "center", marginStart: 1, marginEnd: 22 },
1189
1204
  androidTile: { width: 28, height: 28, borderRadius: 10, alignItems: "center", justifyContent: "center", marginStart: -3, marginEnd: 18 },
1190
1205
  androidText: { flex: 1, minWidth: 0, gap: 4 },