@plexui/react-native 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +34 -0
  2. package/dist/es/components/ActionSheet/ActionSheet.js +67 -19
  3. package/dist/es/components/Alert/Alert.js +163 -0
  4. package/dist/es/components/Avatar/Avatar.js +20 -8
  5. package/dist/es/components/BottomActions/BottomActions.js +34 -0
  6. package/dist/es/components/BottomSheet/BottomSheet.js +85 -17
  7. package/dist/es/components/Button/Button.js +108 -28
  8. package/dist/es/components/Card/Card.js +16 -8
  9. package/dist/es/components/Checkbox/Checkbox.js +67 -99
  10. package/dist/es/components/Chip/Chip.js +39 -19
  11. package/dist/es/components/Dialog/Dialog.js +38 -24
  12. package/dist/es/components/Field/Field.js +91 -0
  13. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +59 -0
  14. package/dist/es/components/Icon/createIcon.js +13 -2
  15. package/dist/es/components/Indicator/CircularProgress.js +80 -0
  16. package/dist/es/components/Indicator/LoadingDots.js +46 -0
  17. package/dist/es/components/Indicator/LoadingIndicator.js +101 -0
  18. package/dist/es/components/Indicator/index.js +3 -0
  19. package/dist/es/components/Input/Input.js +69 -60
  20. package/dist/es/components/InputGroup/InputGroup.js +130 -0
  21. package/dist/es/components/List/List.js +175 -59
  22. package/dist/es/components/Menu/Menu.js +69 -40
  23. package/dist/es/components/NavigationButton/NavigationButton.js +20 -4
  24. package/dist/es/components/OTPInput/OTPInput.js +9 -3
  25. package/dist/es/components/PageControl/PageControl.js +13 -7
  26. package/dist/es/components/Popover/Popover.js +128 -0
  27. package/dist/es/components/Progress/Progress.js +142 -0
  28. package/dist/es/components/ProgressSteps/ProgressSteps.js +207 -0
  29. package/dist/es/components/RollingNumber/RollingNumber.js +125 -0
  30. package/dist/es/components/Select/Select.js +97 -34
  31. package/dist/es/components/Separator/Separator.js +31 -0
  32. package/dist/es/components/ShimmerText/ShimmerText.js +98 -0
  33. package/dist/es/components/Stepper/Stepper.js +219 -0
  34. package/dist/es/components/Switch/Switch.js +26 -12
  35. package/dist/es/components/TagInput/TagInput.js +121 -0
  36. package/dist/es/components/Text/Text.js +7 -4
  37. package/dist/es/components/TextLink/TextLink.js +42 -0
  38. package/dist/es/components/Textarea/Textarea.js +12 -0
  39. package/dist/es/components/Tip/Tip.js +193 -0
  40. package/dist/es/components/Toolbar/Toolbar.js +6 -2
  41. package/dist/es/components/Tooltip/Tooltip.js +272 -0
  42. package/dist/es/index.js +20 -2
  43. package/dist/es/internal/FloatingPanel.js +111 -0
  44. package/dist/es/internal/fieldStack.js +73 -0
  45. package/dist/es/internal/floating.js +97 -0
  46. package/dist/es/internal/ripple.js +119 -0
  47. package/dist/es/internal/row.js +2 -1
  48. package/dist/es/internal/transition.js +113 -0
  49. package/dist/es/theme/ThemeProvider.js +41 -9
  50. package/dist/es/theme/material.js +37 -7
  51. package/dist/types/components/ActionSheet/ActionSheet.d.ts +15 -7
  52. package/dist/types/components/Alert/Alert.d.ts +51 -0
  53. package/dist/types/components/Avatar/Avatar.d.ts +4 -2
  54. package/dist/types/components/BottomActions/BottomActions.d.ts +18 -0
  55. package/dist/types/components/BottomSheet/BottomSheet.d.ts +4 -2
  56. package/dist/types/components/Button/Button.d.ts +20 -5
  57. package/dist/types/components/Card/Card.d.ts +14 -1
  58. package/dist/types/components/Checkbox/Checkbox.d.ts +4 -3
  59. package/dist/types/components/Chip/Chip.d.ts +23 -4
  60. package/dist/types/components/Dialog/Dialog.d.ts +9 -5
  61. package/dist/types/components/Field/Field.d.ts +64 -0
  62. package/dist/types/components/FloatingLabelInput/FloatingLabelInput.d.ts +42 -0
  63. package/dist/types/components/Indicator/CircularProgress.d.ts +34 -0
  64. package/dist/types/components/Indicator/LoadingDots.d.ts +17 -0
  65. package/dist/types/components/Indicator/LoadingIndicator.d.ts +46 -0
  66. package/dist/types/components/Indicator/index.d.ts +3 -0
  67. package/dist/types/components/Input/Input.d.ts +13 -3
  68. package/dist/types/components/InputGroup/InputGroup.d.ts +71 -0
  69. package/dist/types/components/List/List.d.ts +57 -14
  70. package/dist/types/components/Menu/Menu.d.ts +4 -0
  71. package/dist/types/components/NavigationButton/NavigationButton.d.ts +11 -3
  72. package/dist/types/components/OTPInput/OTPInput.d.ts +10 -1
  73. package/dist/types/components/PageControl/PageControl.d.ts +11 -1
  74. package/dist/types/components/Popover/Popover.d.ts +86 -0
  75. package/dist/types/components/Progress/Progress.d.ts +56 -0
  76. package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +61 -0
  77. package/dist/types/components/RollingNumber/RollingNumber.d.ts +36 -0
  78. package/dist/types/components/Select/Select.d.ts +36 -8
  79. package/dist/types/components/Separator/Separator.d.ts +19 -0
  80. package/dist/types/components/ShimmerText/ShimmerText.d.ts +28 -0
  81. package/dist/types/components/Stepper/Stepper.d.ts +61 -0
  82. package/dist/types/components/Switch/Switch.d.ts +5 -5
  83. package/dist/types/components/TagInput/TagInput.d.ts +44 -0
  84. package/dist/types/components/TextLink/TextLink.d.ts +30 -0
  85. package/dist/types/components/Textarea/Textarea.d.ts +19 -0
  86. package/dist/types/components/Tip/Tip.d.ts +71 -0
  87. package/dist/types/components/Toolbar/Toolbar.d.ts +9 -1
  88. package/dist/types/components/Tooltip/Tooltip.d.ts +84 -0
  89. package/dist/types/index.d.ts +20 -2
  90. package/dist/types/internal/FloatingPanel.d.ts +70 -0
  91. package/dist/types/internal/fieldStack.d.ts +48 -0
  92. package/dist/types/internal/floating.d.ts +71 -0
  93. package/dist/types/internal/ripple.d.ts +17 -0
  94. package/dist/types/internal/row.d.ts +15 -3
  95. package/dist/types/internal/transition.d.ts +37 -0
  96. package/dist/types/theme/ThemeProvider.d.ts +28 -4
  97. package/dist/types/theme/material.d.ts +20 -6
  98. package/dist/types/theme/types.d.ts +8 -0
  99. package/package.json +2 -2
  100. package/src/components/ActionSheet/ActionSheet.tsx +123 -38
  101. package/src/components/Alert/Alert.tsx +279 -0
  102. package/src/components/Avatar/Avatar.tsx +21 -9
  103. package/src/components/BottomActions/BottomActions.tsx +54 -0
  104. package/src/components/BottomSheet/BottomSheet.tsx +111 -25
  105. package/src/components/Button/Button.tsx +170 -35
  106. package/src/components/Card/Card.tsx +33 -9
  107. package/src/components/Checkbox/Checkbox.tsx +89 -124
  108. package/src/components/Chip/Chip.tsx +83 -20
  109. package/src/components/Dialog/Dialog.tsx +68 -37
  110. package/src/components/Field/Field.tsx +227 -0
  111. package/src/components/FloatingLabelInput/FloatingLabelInput.tsx +144 -0
  112. package/src/components/Icon/createIcon.tsx +16 -6
  113. package/src/components/Indicator/CircularProgress.tsx +141 -0
  114. package/src/components/Indicator/LoadingDots.tsx +79 -0
  115. package/src/components/Indicator/LoadingIndicator.tsx +166 -0
  116. package/src/components/Indicator/index.ts +3 -0
  117. package/src/components/Input/Input.tsx +126 -97
  118. package/src/components/InputGroup/InputGroup.tsx +261 -0
  119. package/src/components/List/List.tsx +345 -88
  120. package/src/components/Menu/Menu.tsx +83 -41
  121. package/src/components/NavigationButton/NavigationButton.tsx +35 -5
  122. package/src/components/OTPInput/OTPInput.tsx +21 -2
  123. package/src/components/PageControl/PageControl.tsx +36 -8
  124. package/src/components/Popover/Popover.tsx +261 -0
  125. package/src/components/Progress/Progress.tsx +255 -0
  126. package/src/components/ProgressSteps/ProgressSteps.tsx +415 -0
  127. package/src/components/RollingNumber/RollingNumber.tsx +189 -0
  128. package/src/components/Select/Select.tsx +175 -71
  129. package/src/components/Separator/Separator.tsx +51 -0
  130. package/src/components/ShimmerText/ShimmerText.tsx +144 -0
  131. package/src/components/Stepper/Stepper.tsx +386 -0
  132. package/src/components/Switch/Switch.tsx +26 -12
  133. package/src/components/TagInput/TagInput.tsx +227 -0
  134. package/src/components/Text/Text.tsx +8 -4
  135. package/src/components/TextLink/TextLink.tsx +77 -0
  136. package/src/components/Textarea/Textarea.tsx +23 -0
  137. package/src/components/Tip/Tip.tsx +410 -0
  138. package/src/components/Toolbar/Toolbar.tsx +27 -2
  139. package/src/components/Tooltip/Tooltip.tsx +478 -0
  140. package/src/index.ts +36 -2
  141. package/src/internal/FloatingPanel.tsx +199 -0
  142. package/src/internal/fieldStack.tsx +179 -0
  143. package/src/internal/floating.ts +131 -0
  144. package/src/internal/ripple.tsx +132 -0
  145. package/src/internal/row.ts +16 -3
  146. package/src/internal/transition.ts +124 -0
  147. package/src/theme/ThemeProvider.tsx +65 -15
  148. package/src/theme/material.ts +39 -7
  149. package/src/theme/types.ts +8 -0
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { Animated, Easing, StyleSheet, View } from "react-native";
4
+ import Svg, { Circle } from "react-native-svg";
5
+ import { nativeDriver } from "../../internal/transition";
6
+ import { useTheme } from "../../theme/ThemeProvider";
7
+ import { textColor } from "../Text/Text";
8
+ /** The opacities of the eight spokes, from the top clockwise: the leading spoke, then the faintest, brightening. */
9
+ const SPOKES = [1, 0.15, 0.27, 0.39, 0.51, 0.63, 0.75, 0.87];
10
+ /** The kit's spoke for a size: Small (14) up to 16, Regular (30) to 27, Large (35) from 28, as width and height. */
11
+ function spoke(size) {
12
+ if (size <= 16)
13
+ return { width: (2 / 14) * size, height: (4 / 14) * size };
14
+ if (size >= 28)
15
+ return { width: (5 / 35) * size, height: (13 / 35) * size };
16
+ return { width: (4 / 30) * size, height: (10 / 30) * size };
17
+ }
18
+ /** CSS `steps(8, end)`: the spinner turns a spoke at a time. */
19
+ const eightSteps = (t) => Math.min(1, Math.floor(t * 8) / 8);
20
+ const defaultColor = (theme, color) => color ? textColor(theme, color) : theme.isAndroid ? theme.material.primary : textColor(theme, "primary");
21
+ /**
22
+ * A spinner for a loading state, as @plexui/ui's LoadingIndicator. iOS: the iOS 27 spinner (UIActivityIndicatorView)
23
+ * of eight rounded spokes, as the touch stylesheet draws it: 20pt, the spokes brightening to the leading one, a turn in
24
+ * 800ms in eight steps. Android: Material's circular progress, the arc of CircularProgressDrawable (a 5.4s cycle of four
25
+ * 250° surges) in the accent. With reduced motion it stands still.
26
+ */
27
+ export function LoadingIndicator({ size = 20, strokeWidth, color, duration = 800, "aria-label": ariaLabel, accessibilityLabel, testID, style }) {
28
+ const theme = useTheme();
29
+ const ink = defaultColor(theme, color);
30
+ const name = accessibilityLabel ?? ariaLabel;
31
+ return (_jsx(View, { accessible: name != null, accessibilityRole: name != null ? "progressbar" : undefined, accessibilityLabel: name, accessibilityState: name != null ? { busy: true } : undefined, importantForAccessibility: name != null ? undefined : "no-hide-descendants", accessibilityElementsHidden: name == null, testID: testID, style: [{ width: size, height: size }, style], children: theme.isAndroid ? (_jsx(Arc, { size: size, stroke: strokeWidth ?? size / 8, color: ink, cycle: (SPIN.cycle * duration) / 800, still: theme.reducedMotion })) : (_jsx(Spokes, { size: size, strokeWidth: strokeWidth, color: ink, duration: duration, still: theme.reducedMotion })) }));
32
+ }
33
+ function Spokes({ size, strokeWidth, color, duration, still }) {
34
+ const [turn] = useState(() => new Animated.Value(0));
35
+ useEffect(() => {
36
+ turn.setValue(0);
37
+ if (still || duration <= 0)
38
+ return;
39
+ const loop = Animated.loop(Animated.timing(turn, { toValue: 1, duration, easing: eightSteps, useNativeDriver: nativeDriver, isInteraction: false }));
40
+ loop.start();
41
+ return () => loop.stop();
42
+ }, [turn, duration, still]);
43
+ const { width: kitWidth, height } = spoke(size);
44
+ const width = strokeWidth ?? kitWidth;
45
+ return (_jsx(Animated.View, { style: [StyleSheet.absoluteFill, { transform: [{ rotate: turn.interpolate({ inputRange: [0, 1], outputRange: ["0deg", "360deg"] }) }] }], children: SPOKES.map((opacity, index) => (_jsx(View, { style: [StyleSheet.absoluteFill, { opacity, transform: [{ rotate: `${index * 45}deg` }] }], children: _jsx(View, { style: { position: "absolute", top: 0, left: (size - width) / 2, width, height, borderRadius: width / 2, backgroundColor: color } }) }, index))) }));
46
+ }
47
+ /** Material's standard curve, on which the arc surges. */
48
+ const standard = Easing.bezier(0.4, 0, 0.2, 1);
49
+ /**
50
+ * Android's spinner over one 5400ms cycle (CircularProgressDrawable): the arc's head turns 1520° and makes four surges
51
+ * of 250°, 667ms each, 1350ms apart; its tail turns 20° behind the head's steady turn and makes the same surges 667ms
52
+ * later.
53
+ */
54
+ export const SPIN = { cycle: 5400, turn: 1520, lag: 20, surge: 250, surgeTime: 667, surgeEvery: 1350, surges: 4 };
55
+ /** The spinner at a share of its cycle: how far its tail has turned and how long its arc is, in degrees. */
56
+ export function spinnerAt(share) {
57
+ const t = share * SPIN.cycle;
58
+ const surges = (delay) => {
59
+ let total = 0;
60
+ for (let index = 0; index < SPIN.surges; index++) {
61
+ const from = delay + index * SPIN.surgeEvery;
62
+ total += standard(Math.min(1, Math.max(0, (t - from) / SPIN.surgeTime))) * SPIN.surge;
63
+ }
64
+ return total;
65
+ };
66
+ const head = (t / SPIN.cycle) * SPIN.turn + surges(0);
67
+ // The tail stands still until the head is 20° on
68
+ const lagTime = (SPIN.lag * SPIN.cycle) / SPIN.turn;
69
+ const tail = Math.max(0, (t - lagTime) / (SPIN.cycle - lagTime)) * (SPIN.turn - SPIN.lag) + surges(SPIN.surgeTime);
70
+ return { tail, arc: head - tail };
71
+ }
72
+ /** The still frame: the end of the first surge, a 270° arc. */
73
+ const STILL = SPIN.surgeTime / SPIN.cycle;
74
+ /**
75
+ * The arc is redrawn from a clock on each frame: an animated SVG prop does not reach the element on the web. The
76
+ * stroke runs on a circle that fills the box, as Android lays its drawable out (8.75 of 20 with a 2.5 stroke).
77
+ */
78
+ function Arc({ size, stroke, color, cycle, still }) {
79
+ const [time, setShare] = useState(STILL);
80
+ const share = still || cycle <= 0 ? STILL : time;
81
+ useEffect(() => {
82
+ if (still || cycle <= 0)
83
+ return;
84
+ const time = new Animated.Value(0);
85
+ const id = time.addListener(({ value }) => setShare(value));
86
+ const loop = Animated.loop(Animated.timing(time, { toValue: 1, duration: cycle, easing: Easing.linear, useNativeDriver: false, isInteraction: false }));
87
+ loop.start();
88
+ return () => {
89
+ loop.stop();
90
+ time.removeListener(id);
91
+ };
92
+ }, [cycle, still]);
93
+ const { tail, arc } = spinnerAt(share);
94
+ const radius = Math.max(0, (size - stroke) / 2);
95
+ const length = 2 * Math.PI * radius;
96
+ return (
97
+ // The circle's stroke starts at 3 o'clock and runs clockwise, as Android's arcs
98
+ _jsx(View, { style: [StyleSheet.absoluteFill, { transform: [{ rotate: `${tail}deg` }] }], children: _jsx(Svg, { width: size, height: size, children: _jsx(Circle, { cx: size / 2, cy: size / 2, r: radius, fill: "none", stroke: color, strokeWidth: stroke, strokeLinecap: "round",
99
+ // One dash as long as the arc, the rest of the circle a gap
100
+ strokeDasharray: [length, length], strokeDashoffset: length * (1 - arc / 360) }) }) }));
101
+ }
@@ -0,0 +1,3 @@
1
+ export { CircularProgress, getSimulatedProgress } from "./CircularProgress";
2
+ export { LoadingDots } from "./LoadingDots";
3
+ export { LoadingIndicator } from "./LoadingIndicator";
@@ -2,18 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react";
3
3
  import { Animated, Easing, PixelRatio, Platform, Pressable, StyleSheet, Text as NativeText, TextInput, View, processColor, } from "react-native";
4
4
  import XCircleFilled from "../../icons/plex/XCircleFilled";
5
- import { useDescription } from "../../internal/a11y";
6
5
  import { useAndroidGlass } from "../../internal/BarBackdrop";
6
+ import { FieldStack, FloatLabelContext } from "../../internal/fieldStack";
7
7
  import { Glass } from "../../internal/Glass";
8
8
  import { useRTL } from "../../internal/direction";
9
9
  import { springTo, stiffSpring } from "../../internal/motion";
10
10
  import { RowEndContext } from "../../internal/row";
11
- import { barShadow, barSurface, withAlpha, dangerText, stateLayer } from "../../theme/material";
11
+ import { androidGray, barShadow, barSurface, withAlpha, dangerText, stateLayer } from "../../theme/material";
12
12
  import { useTheme } from "../../theme/ThemeProvider";
13
13
  import { BarFieldContext } from "../Button/Button";
14
14
  import { IconDefaultsProvider } from "../Icon/createIcon";
15
15
  import { MaterialCancel, MaterialClose } from "../Icon/material";
16
- import { Text } from "../Text/Text";
17
16
  /**
18
17
  * The phone layer's field at each size: Input.module.css's size table under touch.css's phone rules, which give every
19
18
  * size 17pt text and a 14pt gutter (11 beside a start adornment, `html [data-slot="input"]`, scoped rules with no root
@@ -33,8 +32,8 @@ const IOS_FIELD = {
33
32
  /** The kit's own values of the tokens the table reads, for a theme without them. */
34
33
  const IOS_RADIUS = { sm: 6, md: 8, lg: 10, xl: 12 };
35
34
  const IOS_GAP = { md: 8, lg: 10 };
36
- /** Android's outlined line with focus. */
37
- const FOCUS_LINE = 1.667;
35
+ /** Android's outlined line with focus: 1.5dp (the reference's focused field). */
36
+ const FOCUS_LINE = 1.5;
38
37
  /** Android's idle outlined line: 0.5dp, at least 2 device pixels (1 on a 1x screen). */
39
38
  function hairline() {
40
39
  const ratio = PixelRatio.get();
@@ -115,25 +114,25 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
115
114
  gutter: 18,
116
115
  };
117
116
  }
118
- // Android's fields: `outline` is the outlined field (radius 8, a hairline that thickens to 1.667dp in the accent
119
- // on focus, the label floating on the top line), `soft` a field filled with the text color at 5% (the chips' and
120
- // sheets' search fields), `ghost` the bare field of a card. The text is 17 with a 38% hint; a field is 50dp (a
121
- // row's height), 56 with a label; disabled dims it to 50%. Focused, the line and the label take the accent, its
122
- // lighter text in dark mode (#6EB2EF)
117
+ // Android's fields: `outline` is the outlined field (radius 8, a hairline in a light gray that thickens to 1.5dp in
118
+ // the accent on focus, the label floating on the top line, the text 16), `soft` a field filled with the text color
119
+ // at 5% (the chips' and sheets' search fields), `ghost` the bare field of a card (the text 17, 22 in). The hint is
120
+ // a light gray (#A8A8A8, #7D7D7D at night); a field is 50dp (a row's height), 56 with a label; disabled dims it to
121
+ // 50%. Focused, the line and the label take the accent, its lighter text in dark mode (#6EB2EF)
123
122
  const outlined = variant === "outline";
124
123
  const ghost = variant === "ghost";
125
124
  const accent = state.invalid ? dangerText(theme) : state.focused ? focusAccent(theme) : null;
126
125
  const height = label ? 56 : 50;
127
126
  const radius = pill ? height / 2 : 8;
128
- // The idle line: a hairline in the text at 16%, 24% in dark mode
129
- const idle = withAlpha(m.onSurface, theme.scheme === "dark" ? 0.24 : 0.16);
127
+ // The idle line: a hairline in a light gray (#DBDBDB), the text at 24% in dark mode
128
+ const idle = androidGray(theme, "fieldLine");
130
129
  const frame = outlined
131
130
  ? { outlined: true, color: accent ?? idle, width: state.focused && !state.disabled ? FOCUS_LINE : hairline(), radius }
132
131
  : state.invalid
133
132
  ? // A field with no line of its own shows an error as Android's underline does: 2dp in the error color
134
133
  ghost
135
134
  ? { outlined: false, color: dangerText(theme), width: 2, radius: 0 }
136
- : { outlined: true, color: dangerText(theme), width: 1.667, radius }
135
+ : { outlined: true, color: dangerText(theme), width: FOCUS_LINE, radius }
137
136
  : null;
138
137
  const box = {
139
138
  minHeight: height,
@@ -141,13 +140,13 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
141
140
  backgroundColor: variant === "soft" ? withAlpha(m.onSurface, 0.05) : "transparent",
142
141
  opacity: state.disabled ? 0.5 : 1,
143
142
  };
144
- const hint = withAlpha(m.onSurface, 0.38);
143
+ const hint = androidGray(theme, "hint");
145
144
  return {
146
145
  box,
147
146
  glass: false,
148
147
  frame,
149
148
  gap: 12,
150
- text: { fontSize: 17, lineHeight: 20, color: m.onSurface },
149
+ text: { fontSize: outlined ? 16 : 17, lineHeight: 20, color: m.onSurface },
151
150
  placeholder: hint,
152
151
  icon: m.onSurfaceVariant,
153
152
  trailingIcon: state.invalid ? dangerText(theme) : m.onSurfaceVariant,
@@ -159,8 +158,8 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
159
158
  clearTarget: 48,
160
159
  adornmentOffset: 0,
161
160
  height,
162
- // A card's bare field stands 21dp in, as a card's edit row; the others 14
163
- gutter: ghost ? 21 : 14,
161
+ // A card's bare field stands 22dp in, as a card's input row; the others 14
162
+ gutter: ghost ? 22 : 14,
164
163
  };
165
164
  }
166
165
  if (bar) {
@@ -223,7 +222,8 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
223
222
  },
224
223
  gap: theme.length(`--input-gap-${row.gap}`, IOS_GAP[row.gap]),
225
224
  text: { fontSize: 17, lineHeight: 22, color: theme.color("--input-text-color", theme.colors.text) },
226
- placeholder: theme.color("--input-placeholder-text-color", theme.colors.textTertiary),
225
+ // iOS's placeholder is the tertiary label (UIColor.placeholderText, the ink at 25%), as in a form row
226
+ placeholder: theme.colors.labelTertiary,
227
227
  icon: theme.color("--mobile-label-secondary"),
228
228
  frame: null,
229
229
  trailingIcon: theme.color("--mobile-label-secondary"),
@@ -353,8 +353,13 @@ export function InputAdornmentButton({ children, accessibilityLabel, selected, d
353
353
  }
354
354
  Input.AdornmentButton = InputAdornmentButton;
355
355
  /** The field itself; TextField passes it a floating label on Android. */
356
- export function InputField({ variant = "outline", size = "md", disabled = false, invalid = false, onClear, startAdornment, endAdornment, pill = false, style, testID, label, required, shift, value, defaultValue, onChangeText, onFocus, onBlur, readOnly: readOnlyProp, placeholderTextColor, selectionColor, cursorColor, ...rest }) {
356
+ export function InputField({ variant = "outline", size = "md", disabled = false, invalid = false, onClear, startAdornment, endAdornment, pill = false, style, testID, label: ownLabel, required: ownRequired, shift: ownShift, rows, maxRows, autoResize = false, valueAtEnd = false, value, defaultValue, onChangeText, onFocus, onBlur, readOnly: readOnlyProp, placeholderTextColor, selectionColor, cursorColor, ...rest }) {
357
357
  const theme = useTheme();
358
+ // A Field's label, floated in the field on Android (FloatLabelContext); the field's own wins
359
+ const floatLabel = useContext(FloatLabelContext);
360
+ const label = ownLabel ?? floatLabel?.label;
361
+ const required = ownRequired ?? floatLabel?.required;
362
+ const shift = ownShift ?? floatLabel?.shift;
358
363
  const [focused, setFocused] = useState(false);
359
364
  const [own, setOwn] = useState(defaultValue ?? "");
360
365
  const text = value ?? own;
@@ -371,6 +376,12 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
371
376
  const rowEnd = useContext(RowEndContext);
372
377
  const fillsRow = rowEnd != null && !barField;
373
378
  const inRow = fillsRow && !theme.isAndroid;
379
+ // A line of its own under a row's label, or alone in the row (the web's vertical or label-hidden `Field row`): the
380
+ // bare value on both platforms, from the row's text start; in a List with `columns` the value starts its column
381
+ const stacked = fillsRow && rowEnd?.stacked === true;
382
+ const bare = inRow || stacked;
383
+ const startAligned = stacked || rowEnd?.align === "start";
384
+ const multiline = rest.multiline === true;
374
385
  // The row's value stands at its end: the right, or the left in a right-to-left row (a phone turns "right" over
375
386
  // itself, the web does not)
376
387
  const { ref: textBox, rtl } = useRTL();
@@ -395,13 +406,15 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
395
406
  const fieldLookOf = fieldLook(theme, { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search }, { focused, filled, disabled, invalid });
396
407
  const look = barSearch
397
408
  ? { ...fieldLookOf, box: { ...fieldLookOf.box, ...androidGlass } }
398
- : inRow
409
+ : bare
399
410
  ? {
400
411
  ...fieldLookOf,
401
- box: { minHeight: theme.length("--field-row-label-line-height", 22), opacity: disabled ? 0.5 : 1 },
402
- placeholder: theme.colors.labelTertiary,
412
+ box: { minHeight: theme.isAndroid ? fieldLookOf.text.lineHeight : theme.length("--field-row-label-line-height", 22), opacity: disabled ? 0.5 : 1 },
413
+ frame: null,
414
+ placeholder: theme.isAndroid ? fieldLookOf.placeholder : theme.colors.labelTertiary,
403
415
  text: { ...fieldLookOf.text, color: theme.colors.text },
404
416
  adornmentOffset: 0,
417
+ gutter: 0,
405
418
  }
406
419
  : fieldLookOf;
407
420
  const floating = theme.isAndroid && label != null && !barField;
@@ -432,12 +445,31 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
432
445
  // 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
433
446
  // card's bare field, or 20 in a bar's search field. Android's search field keeps its text 48 from the end
434
447
  // (at a row's end the row sets the edge: a bare field keeps 14)
435
- const edge = barField && !search ? 20 : fillsRow && variant === "ghost" ? 14 : look.gutter;
448
+ // A ghost value that starts a row's column, or (Android) stands at the row's end, has the row's insets for its own
449
+ const flush = fillsRow && variant === "ghost" && (rowEnd?.align === "start" || (theme.isAndroid && valueAtEnd));
450
+ const edge = barField && !search ? 20 : stacked || flush ? 0 : fillsRow && variant === "ghost" ? 14 : look.gutter;
436
451
  const endEdge = search ? 48 : edge;
437
452
  const sides = theme.isAndroid
438
- ? { paddingStart: startAdornment ? 12 : edge, paddingEnd: endAdornment || showClear || androidClear ? 12 : endEdge }
453
+ ? stacked
454
+ ? { paddingStart: 0, paddingEnd: 0 }
455
+ : { paddingStart: startAdornment ? 12 : edge, paddingEnd: endAdornment || showClear || androidClear ? 12 : endEdge }
439
456
  : null;
440
457
  const textStart = theme.isAndroid ? (startAdornment ? 48 : edge) : 0;
458
+ // Above and below the text: a label floated inside a filled field (8 to 24) sets the text under it; Android centres
459
+ // a line in the field's height; iOS keeps 10 in its border (11 from the edge); a bare value none
460
+ const padding = bare
461
+ ? { top: 0, bottom: 0 }
462
+ : floating && !outlined
463
+ ? { top: 26, bottom: 10 }
464
+ : theme.isAndroid
465
+ ? { top: (look.height - look.text.lineHeight) / 2, bottom: (look.height - look.text.lineHeight) / 2 }
466
+ : { top: 10, bottom: 10 };
467
+ // A Textarea's lines: `rows` at least; with `autoResize` as many as its text takes (a hidden copy of the text, as
468
+ // wide as the field's, measures them), up to `maxRows` (the larger of `rows` and 10, as the web's)
469
+ const minLines = Math.max(1, Math.round(rows ?? 1));
470
+ const maxLines = Math.max(minLines, Math.round(maxRows ?? Math.max(minLines, 10)));
471
+ const [measured, setMeasured] = useState(0);
472
+ const lines = multiline && autoResize && measured > 0 ? Math.min(maxLines, Math.max(minLines, Math.round(measured / look.text.lineHeight))) : minLines;
441
473
  // An outlined label floats to the text's start over the line (past a pill's round end), the cut 5 around it
442
474
  const floatedStart = pill ? look.height / 2 : 14;
443
475
  const [labelWidth, setLabelWidth] = useState(0);
@@ -455,7 +487,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
455
487
  // than itself (an IconButton's 40dp in a 50dp field)
456
488
  const adornment = (node, side) => (_jsx(View, { style: look.adornmentOffset ? (side === "start" ? { marginStart: look.adornmentOffset } : { marginEnd: look.adornmentOffset }) : null, children: _jsx(AdornmentContext.Provider, { value: side === "start" ? (inRow ? ROW_START : FIELD_START) : inRow ? ROW_END : FIELD_END, children: node }) }));
457
489
  const labelText = (_jsxs(_Fragment, { children: [label, required ? " *" : ""] }));
458
- return (_jsxs(FieldBox, { glass: look.glass, raised: !!barField?.raised, radius: look.height / 2, shift: shift, style: [styles.box, look.box, { gap: look.gap }, sides, style], testID: testID, children: [theme.isAndroid ? _jsx(FieldOutline, { frame: look.frame, cut: cut, motion: lineMotion }) : null, startAdornment ? (_jsx(IconDefaultsProvider, { size: look.iconSize, color: look.icon, children: adornment(startAdornment, "start") })) : null, _jsxs(View, { ref: textBox, style: styles.grow, children: [floating ? (_jsxs(_Fragment, { children: [outlined ? (
490
+ return (_jsxs(FieldBox, { glass: look.glass, raised: !!barField?.raised, radius: look.height / 2, shift: shift, style: [styles.box, look.box, { gap: look.gap }, multiline ? styles.boxTop : null, sides, style], testID: testID, children: [theme.isAndroid ? _jsx(FieldOutline, { frame: look.frame, cut: cut, motion: lineMotion }) : null, startAdornment ? (_jsx(IconDefaultsProvider, { size: look.iconSize, color: look.icon, children: adornment(startAdornment, "start") })) : null, _jsxs(View, { ref: textBox, style: styles.grow, children: [floating ? (_jsxs(_Fragment, { children: [outlined ? (
459
491
  // The floated label's width, in the visible label's own type (React Native's Text: no Plex tracking)
460
492
  _jsx(NativeText, { "aria-hidden": true, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", numberOfLines: 1, onLayout: (event) => setLabelWidth(event.nativeEvent.layout.width), style: [styles.measure, { fontSize: LABEL.floated.fontSize, lineHeight: LABEL.floated.lineHeight, ...theme.font("regular") }], children: labelText })) : null, _jsx(Animated.View, { pointerEvents: "none", style: [
461
493
  styles.floating,
@@ -470,7 +502,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
470
502
  fontSize: float.interpolate({ inputRange: [0, 1], outputRange: [LABEL.rest.fontSize, LABEL.floated.fontSize] }),
471
503
  lineHeight: float.interpolate({ inputRange: [0, 1], outputRange: [LABEL.rest.lineHeight, LABEL.floated.lineHeight] }),
472
504
  ...theme.font("regular"),
473
- }, numberOfLines: 1, children: labelText }) })] })) : null, _jsx(TextInput, { ...rest, ref: setInput, accessibilityLabel: rest.accessibilityLabel ?? (typeof label === "string" ? label : undefined), accessibilityState: disabled ? { ...rest.accessibilityState, disabled: true } : rest.accessibilityState, "aria-disabled": disabled || rest["aria-disabled"] || undefined, "aria-invalid": invalid || undefined, "aria-required": required || undefined, value: text, onChangeText: (next) => {
505
+ }, numberOfLines: 1, children: labelText }) })] })) : null, multiline && autoResize ? (_jsx(NativeText, { "aria-hidden": true, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", onLayout: (event) => setMeasured(event.nativeEvent.layout.height), style: [styles.mirror, look.text, theme.font("regular")], children: `${text || rest.placeholder || " "}\u200b` })) : null, _jsx(TextInput, { ...rest, ref: setInput, accessibilityLabel: rest.accessibilityLabel ?? (typeof label === "string" ? label : undefined), accessibilityState: disabled ? { ...rest.accessibilityState, disabled: true } : rest.accessibilityState, "aria-disabled": disabled || rest["aria-disabled"] || undefined, "aria-invalid": invalid || undefined, "aria-required": required || undefined, value: text, onChangeText: (next) => {
474
506
  // A disabled field takes no text, whatever reaches it (a paste, an autofill)
475
507
  if (locked)
476
508
  return;
@@ -490,8 +522,12 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
490
522
  look.text,
491
523
  theme.font("regular"),
492
524
  // A label floated inside the field (8 to 24) sets the text under it
493
- floating && !outlined ? { paddingTop: 26, paddingBottom: 10 } : { paddingVertical: theme.isAndroid ? (look.height - look.text.lineHeight) / 2 : inRow ? 0 : 10 },
494
- inRow ? { textAlign: Platform.OS === "web" && rtl ? "left" : "right" } : null,
525
+ { paddingTop: padding.top, paddingBottom: padding.bottom },
526
+ (inRow && !startAligned) || (fillsRow && valueAtEnd && !startAligned) ? { textAlign: Platform.OS === "web" && rtl ? "left" : "right" } : null,
527
+ // A value in a row that the person cannot edit is the secondary label, as the web's phone rows (iOS's
528
+ // values of a row that only informs)
529
+ fillsRow && readOnly && !disabled ? { color: theme.colors.labelSecondary } : null,
530
+ multiline ? { height: lines * look.text.lineHeight + padding.top + padding.bottom, textAlignVertical: "top" } : null,
495
531
  ] })] }), androidClear ? (_jsx(AndroidClear, { visible: filled, kind: barSearch ? "bar" : "field", color: look.trailingIcon, target: look.clearTarget, style: clearMargin, onPress: () => {
496
532
  if (value === undefined)
497
533
  setOwn("");
@@ -523,37 +559,7 @@ function FieldBox({ glass, raised, radius, shift, style, ...rest }) {
523
559
  */
524
560
  export function TextField({ label, description, errorMessage, required, invalid, ...input }) {
525
561
  const theme = useTheme();
526
- const error = errorMessage != null && errorMessage !== false && errorMessage !== "";
527
- const bad = invalid || error;
528
- const help = error ? errorMessage : description;
529
- // The help or the error describes the field: read after its label (a hint on a phone, `aria-describedby` on the
530
- // web). A caller's own hint wins; its described-by ids are kept with this one.
531
- const described = useDescription(help);
532
- const describedBy = [input["aria-describedby"], described.props["aria-describedby"]].filter(Boolean).join(" ") || undefined;
533
- const describedProps = {
534
- ...described.props,
535
- ...(describedBy ? { "aria-describedby": describedBy } : null),
536
- ...(input.accessibilityHint != null ? { accessibilityHint: input.accessibilityHint } : null),
537
- };
538
- // Android shakes the field when an error message appears: flung left at 350dp/s on a spring of stiffness 600 at half
539
- // its critical damping, it swings back and settles where it stood
540
- const [shake] = useState(() => new Animated.Value(0));
541
- const hadError = useRef(error);
542
- useEffect(() => {
543
- const appeared = error && !hadError.current;
544
- hadError.current = error;
545
- if (!appeared || !theme.isAndroid || theme.reducedMotion)
546
- return;
547
- shake.setValue(0);
548
- Animated.spring(shake, { toValue: 0, velocity: -350, ...stiffSpring(600, 0.5), useNativeDriver: false }).start();
549
- }, [error, shake, theme.isAndroid, theme.reducedMotion]);
550
- if (theme.isAndroid) {
551
- return (_jsxs(View, { style: styles.field, children: [_jsx(InputField, { ...input, ...describedProps, label: label, required: required, invalid: bad, shift: shake }), help != null ? (
552
- // Android's help under a field: 14 in the gray of secondary text, or in the error color, at the text's 14
553
- // (dimmed with a disabled field)
554
- _jsx(Text, { nativeID: described.id, color: bad ? dangerText(theme) : theme.colors.textSecondary, accessibilityLiveRegion: error ? "polite" : undefined, style: { fontSize: 14, lineHeight: 18, paddingHorizontal: 14, paddingTop: 6, opacity: input.disabled ? 0.5 : 1 }, children: help })) : null] }));
555
- }
556
- return (_jsxs(View, { style: [styles.field, { gap: 8 }], children: [_jsxs(Text, { weight: "medium", style: { fontSize: 15, lineHeight: 20 }, color: input.disabled ? "disabled" : "primary", children: [label, required ? _jsx(Text, { color: theme.color("--color-text-danger"), children: " *" }) : null] }), _jsx(InputField, { ...input, ...describedProps, accessibilityLabel: input.accessibilityLabel ?? (typeof label === "string" ? label : undefined), required: required, invalid: bad }), help != null ? (_jsx(Text, { nativeID: described.id, color: bad ? theme.color("--color-text-danger") : "secondary", accessibilityLiveRegion: error ? "polite" : undefined, style: { fontSize: theme.length("--mobile-field-error-font-size", 15), lineHeight: theme.length("--mobile-field-error-line-height", 20), marginTop: theme.length("--mobile-field-error-offset", 4) - 8 }, children: help })) : null] }));
562
+ return (_jsx(FieldStack, { label: label, required: required, description: description, errorMessage: errorMessage, invalid: invalid, disabled: input.disabled, floating: theme.isAndroid, describedBy: input["aria-describedby"], hint: input.accessibilityHint, children: ({ described, invalid: bad, shake }) => theme.isAndroid ? (_jsx(InputField, { ...input, ...described, label: label, required: required, invalid: bad, shift: shake })) : (_jsx(InputField, { ...input, ...described, accessibilityLabel: input.accessibilityLabel ?? (typeof label === "string" ? label : undefined), required: required, invalid: bad })) }));
557
563
  }
558
564
  const FIELD_START = { side: "start", row: false };
559
565
  const FIELD_END = { side: "end", row: false };
@@ -564,15 +570,18 @@ const styles = StyleSheet.create({
564
570
  // Centered in the 48dp target
565
571
  adornmentPressed: { position: "absolute", top: 4, start: 4, width: 40, height: 40, borderRadius: 20 },
566
572
  box: { flexDirection: "row", alignItems: "center", alignSelf: "stretch" },
573
+ // A field of several lines keeps its adornments on its first line
574
+ boxTop: { alignItems: "flex-start" },
567
575
  grow: { flex: 1, minWidth: 0, justifyContent: "center" },
568
576
  // On the web a zero width leaves Chrome's `auto` focus ring drawn round the text: the field shows its focus itself
569
577
  input: { margin: 0, padding: 0, outlineWidth: 0, outlineStyle: "none", minWidth: 0 },
570
578
  floating: { position: "absolute", start: 0, maxWidth: "100%", flexDirection: "row" },
571
579
  measure: { position: "absolute", start: 0, top: 0, opacity: 0 },
580
+ // As wide as the text, out of the flow and unseen
581
+ mirror: { position: "absolute", start: 0, end: 0, top: 0, opacity: 0 },
572
582
  underline: { position: "absolute", left: 0, right: 0, bottom: 0 },
573
583
  window: { position: "absolute", overflow: "hidden" },
574
584
  copy: { position: "absolute" },
575
585
  clear: { alignItems: "center", justifyContent: "center" },
576
586
  clearStretch: { alignSelf: "stretch" },
577
- field: { alignSelf: "stretch" },
578
587
  });
@@ -0,0 +1,130 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, isValidElement, useContext } from "react";
3
+ import { Pressable, StyleSheet, View } from "react-native";
4
+ import { flattenChildren } from "../../internal/children";
5
+ import { RowEndContext } from "../../internal/row";
6
+ import { useTheme } from "../../theme/ThemeProvider";
7
+ import { Button, buttonColors } from "../Button/Button";
8
+ import { IconDefaultsProvider } from "../Icon/createIcon";
9
+ import { InputAdornmentButton, InputField } from "../Input/Input";
10
+ import { Text } from "../Text/Text";
11
+ const GroupContext = createContext(null);
12
+ /** The size of a button in a group, a step under the field's (InputGroup.tsx). */
13
+ const BUTTON_SIZE = { "3xs": "3xs", "2xs": "3xs", xs: "3xs", sm: "3xs", md: "2xs", lg: "sm", xl: "md", "2xl": "lg", "3xl": "xl" };
14
+ /** The control of a group: its props, read by the group (it is drawn by the group's field). */
15
+ function InputGroupInput(_props) {
16
+ return null;
17
+ }
18
+ function InputGroupTextarea(_props) {
19
+ return null;
20
+ }
21
+ /** Content beside, above or below the control: icons, text, buttons. */
22
+ function InputGroupAddon({ children, style }) {
23
+ return _jsx(View, { style: [styles.addon, style], children: children });
24
+ }
25
+ /**
26
+ * A ghost Button sized from the group, a step under the field. An icon alone (`uniform`) is the field's adornment
27
+ * button: its 44pt (48dp) target around a 20pt (24dp) glyph in the field's icon gray.
28
+ */
29
+ function InputGroupButton({ color = "secondary", variant = "ghost", uniform = false, disabled, children, accessibilityLabel, onPress, style, ...rest }) {
30
+ const group = useContext(GroupContext);
31
+ const theme = useTheme();
32
+ if (uniform && variant === "ghost" && group?.row && !theme.isAndroid) {
33
+ // In a row on iOS, as the web's on a phone: a 36pt square (the 44pt row control less 4 above and below) that ends
34
+ // at the row's inset, an 18pt symbol in the ghost button's color
35
+ const size = theme.length("--control-size-lg", 44) - 8;
36
+ const off = disabled ?? group.disabled;
37
+ return (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityState: { disabled: off }, disabled: off, onPress: onPress ?? undefined, style: ({ pressed }) => [
38
+ styles.rowButton,
39
+ // It overhangs the row's line, as the web's, so the row keeps its 52
40
+ { width: size, height: size, marginVertical: (theme.length("--field-row-label-line-height", 22) - size) / 2, opacity: off || pressed ? 0.5 : 1 },
41
+ style,
42
+ ], children: _jsx(IconDefaultsProvider, { size: theme.length("--control-icon-size-md", 18), color: buttonColors(theme, color, "ghost", false, false).text, children: children }) }));
43
+ }
44
+ if (uniform && variant === "ghost") {
45
+ return (_jsx(InputAdornmentButton, { accessibilityLabel: accessibilityLabel ?? "", disabled: disabled ?? group?.disabled, onPress: onPress ?? undefined, style: style, children: children }));
46
+ }
47
+ return (_jsx(Button, { ...rest, color: color, variant: variant, uniform: uniform, size: BUTTON_SIZE[group?.size ?? "md"], disabled: disabled ?? group?.disabled, accessibilityLabel: accessibilityLabel, onPress: onPress, style: style, children: children }));
48
+ }
49
+ /** Plain text in an addon (a prefix, a unit, a counter): the field's type in the secondary label. */
50
+ function InputGroupText({ style, children, ...rest }) {
51
+ const theme = useTheme();
52
+ const group = useContext(GroupContext);
53
+ const type = theme.isAndroid
54
+ ? group?.row
55
+ ? styles.androidRowText
56
+ : styles.androidText
57
+ : { fontSize: theme.length("--field-row-label-font-size", 17), lineHeight: theme.length("--field-row-label-line-height", 22) };
58
+ return (_jsx(Text, { ...rest, color: theme.colors.labelSecondary, numberOfLines: 1, style: [type, { opacity: group?.disabled ? 0.5 : 1 }, style], children: children }));
59
+ }
60
+ /**
61
+ * A field with addons around its control: Plex UI's InputGroup. The addons on its line are the field's adornments
62
+ * (an icon, a prefix, a unit, a button), in the frame of an Input of the same `variant`, `size` and `pill`; block
63
+ * addons stand as rows above and below the control inside one frame. In a List row (a `Field row`) the row is the
64
+ * frame, as the web's on a phone: a prefix sits right before the value in the secondary label, a unit right after it
65
+ * ("72 kg"), a button at the row's end.
66
+ */
67
+ export function InputGroup({ variant = "outline", size = "md", pill = false, disabled = false, invalid = false, children, style, testID }) {
68
+ const theme = useTheme();
69
+ const rowEnd = useContext(RowEndContext);
70
+ const row = rowEnd != null;
71
+ const parts = flattenChildren(children).filter(isValidElement);
72
+ const control = parts.find((part) => part.type === InputGroupInput || part.type === InputGroupTextarea);
73
+ const addons = parts.filter((part) => part.type === InputGroupAddon);
74
+ const at = (align) => addons.filter((addon) => (addon.props.align ?? "inline-start") === align);
75
+ const inline = (align) => {
76
+ const found = at(align);
77
+ return found.length === 0 ? undefined : _jsx(View, { style: styles.addons, children: found });
78
+ };
79
+ const multiline = control?.type === InputGroupTextarea;
80
+ const own = control?.props ?? {};
81
+ const state = { size, pill, disabled, invalid, row };
82
+ const field = (props) => (_jsx(InputField, { ...own, disabled: own.disabled ?? disabled, invalid: own.invalid ?? invalid, size: size, pill: pill, multiline: multiline, rows: multiline ? (own.rows ?? 3) : undefined, ...props }));
83
+ if (row) {
84
+ // The row is the frame: the prefix right before the value, the unit 8 after it (as the web's "5 km"), a button at
85
+ // the end
86
+ const start = inline("inline-start");
87
+ const end = inline("inline-end");
88
+ // A text prefix is part of the value ("$0.00", as iOS writes it); an icon keeps a gap before the value
89
+ const textPrefix = at("inline-start").every((addon) => flattenChildren(addon.props.children).every((child) => typeof child === "string" || (isValidElement(child) && child.type === InputGroupText)));
90
+ return (_jsx(GroupContext.Provider, { value: state, children: _jsxs(View, { testID: testID, style: [styles.inRow, style], children: [start != null ? _jsx(View, { style: { marginEnd: textPrefix ? 0 : theme.isAndroid ? 4 : 8 }, children: start }) : null, _jsx(View, { style: styles.grow, children: field({ variant: "ghost", style: theme.isAndroid ? styles.flush : undefined, valueAtEnd: theme.isAndroid && rowEnd.align !== "start" }) }), end != null ? _jsx(View, { style: { marginStart: theme.isAndroid ? 4 : 8 }, children: end }) : null] }) }));
91
+ }
92
+ const above = at("block-start");
93
+ const below = at("block-end");
94
+ if (above.length === 0 && below.length === 0) {
95
+ return (_jsx(GroupContext.Provider, { value: state, children: field({ variant, startAdornment: inline("inline-start"), endAdornment: inline("inline-end"), style, testID }) }));
96
+ }
97
+ // Block addons: rows above and below the control in one frame, the control bare between them
98
+ const radius = theme.isAndroid ? 8 : theme.length("--control-radius-lg", 10);
99
+ return (_jsx(GroupContext.Provider, { value: state, children: _jsxs(View, { testID: testID, style: [
100
+ styles.block,
101
+ {
102
+ borderRadius: pill ? 9999 : radius,
103
+ borderWidth: variant === "outline" ? StyleSheet.hairlineWidth * 2 : 0,
104
+ borderColor: invalid ? theme.color("--color-border-danger-outline", theme.colors.border) : theme.colors.border,
105
+ backgroundColor: variant === "soft" ? theme.color("--input-soft-background-color", theme.colors.surfaceSecondary) : undefined,
106
+ opacity: disabled ? 0.5 : 1,
107
+ },
108
+ style,
109
+ ], children: [above.length > 0 ? _jsx(View, { style: [styles.blockRow, styles.blockTop], children: above }) : null, field({ variant: "ghost", startAdornment: inline("inline-start"), endAdornment: inline("inline-end") }), below.length > 0 ? _jsx(View, { style: [styles.blockRow, styles.blockBottom], children: below }) : null] }) }));
110
+ }
111
+ InputGroup.Input = InputGroupInput;
112
+ InputGroup.Textarea = InputGroupTextarea;
113
+ InputGroup.Addon = InputGroupAddon;
114
+ InputGroup.Button = InputGroupButton;
115
+ InputGroup.Text = InputGroupText;
116
+ export { InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea };
117
+ const styles = StyleSheet.create({
118
+ addon: { flexDirection: "row", alignItems: "center", gap: 8 },
119
+ addons: { flexDirection: "row", alignItems: "center", gap: 8 },
120
+ inRow: { flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center" },
121
+ grow: { flex: 1, minWidth: 0 },
122
+ rowButton: { alignItems: "center", justifyContent: "center" },
123
+ flush: { paddingStart: 0, paddingEnd: 0 },
124
+ androidText: { fontSize: 16, lineHeight: 20 },
125
+ androidRowText: { fontSize: 16, lineHeight: 20 },
126
+ block: { alignSelf: "stretch", overflow: "hidden" },
127
+ blockRow: { paddingHorizontal: 12, flexDirection: "row", alignItems: "center", gap: 8 },
128
+ blockTop: { paddingTop: 10 },
129
+ blockBottom: { paddingBottom: 10 },
130
+ });