@plexui/react-native 0.2.30 → 0.2.32

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.
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { isValidElement, useId, useLayoutEffect, useMemo, useState } from "react";
3
+ import { InSheetContext } from "./context";
3
4
  import { Animated, Easing, PanResponder, Platform, ScrollView, StyleSheet, View, useWindowDimensions } from "react-native";
4
5
  import { Pressable } from "../../internal/Pressable";
5
6
  import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -244,64 +245,64 @@ export function BottomSheetBase({ open, onOpenChange, title, children, dismissib
244
245
  const slide = (progress) => android
245
246
  ? Animated.add(progress.interpolate({ inputRange: [0, 1], outputRange: [(height || screen) + ANDROID_OFFSCREEN, 0] }), Animated.multiply(drag, progress))
246
247
  : Animated.add(progress.interpolate({ inputRange: [0, 1], outputRange: [height || screen, 0] }), drag);
247
- return (_jsx(Overlay, { open: open, onDismiss: close, scrim: android ? ANDROID_DIM.sheet : iosDim(theme), dismissible: dismissible, motion: "sheet", exit: exit, onExited: onExited, testID: testID, children: (progress, _opening, focus) => (_jsxs(View, { pointerEvents: "box-none", style: styles.bottom, children: [_jsxs(Animated.View, { ...a11y, ...(android ? responder.panHandlers : null), onTouchEnd: android ? gesture.end : undefined, onTouchCancel: android ? gesture.end : undefined,
248
- // On the web the sheet itself takes the first focus, not its Close or a field
249
- tabIndex: focus.tabIndex, onBlur: focus.onBlur, onLayout: (event) => setHeight(event.nativeEvent.layout.height), style: [
250
- focus.style,
251
- styles.sheet,
252
- {
253
- maxHeight,
254
- // A fixed sheet grows by the keyboard it stands over, within the screen, so its content keeps its room
255
- height: fixedHeight == null ? undefined : Math.min(fixedHeight + keyboard, maxHeight),
256
- maxWidth,
257
- borderTopLeftRadius: radius,
258
- borderTopRightRadius: radius,
259
- backgroundColor: background,
260
- // Over the keyboard: Android's height is over its navigation bar, iOS's from the screen's edge
261
- paddingBottom: android ? insets.bottom + keyboard : keyboard,
262
- // With reduced motion it fades in place, and follows only the finger
263
- opacity: reduced ? progress : undefined,
264
- transform: [{ translateY: reduced ? drag : slide(progress) }],
265
- },
266
- ], children: [android && title != null ? null : header, _jsx(ScrollView
267
- // A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
268
- , {
248
+ return (_jsx(Overlay, { open: open, onDismiss: close, scrim: android ? ANDROID_DIM.sheet : iosDim(theme), dismissible: dismissible, motion: "sheet", exit: exit, onExited: onExited, testID: testID, children: (progress, _opening, focus) => (_jsx(InSheetContext.Provider, { value: true, children: _jsxs(View, { pointerEvents: "box-none", style: styles.bottom, children: [_jsxs(Animated.View, { ...a11y, ...(android ? responder.panHandlers : null), onTouchEnd: android ? gesture.end : undefined, onTouchCancel: android ? gesture.end : undefined,
249
+ // On the web the sheet itself takes the first focus, not its Close or a field
250
+ tabIndex: focus.tabIndex, onBlur: focus.onBlur, onLayout: (event) => setHeight(event.nativeEvent.layout.height), style: [
251
+ focus.style,
252
+ styles.sheet,
253
+ {
254
+ maxHeight,
255
+ // A fixed sheet grows by the keyboard it stands over, within the screen, so its content keeps its room
256
+ height: fixedHeight == null ? undefined : Math.min(fixedHeight + keyboard, maxHeight),
257
+ maxWidth,
258
+ borderTopLeftRadius: radius,
259
+ borderTopRightRadius: radius,
260
+ backgroundColor: background,
261
+ // Over the keyboard: Android's height is over its navigation bar, iOS's from the screen's edge
262
+ paddingBottom: android ? insets.bottom + keyboard : keyboard,
263
+ // With reduced motion it fades in place, and follows only the finger
264
+ opacity: reduced ? progress : undefined,
265
+ transform: [{ translateY: reduced ? drag : slide(progress) }],
266
+ },
267
+ ], children: [android && title != null ? null : header, _jsx(ScrollView
269
268
  // A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
270
- style: [styles.scroll, fixedHeight != null ? styles.grow : null], ...(android
271
- ? {
272
- ...gesture.content,
273
- onScroll: (event) => {
274
- gesture.content.onScroll(event);
275
- const under = event.nativeEvent.contentOffset.y > 0;
276
- if (under !== scrolled)
277
- setScrolled(under);
278
- },
279
- scrollEventThrottle: 16,
280
- }
281
- : null), contentContainerStyle: [
282
- android
283
- ? [
284
- styles.androidContent,
285
- // A screen whose gutter is Material's compact 16 sets it with --bottom-sheet-android-padding-inline
286
- { paddingHorizontal: androidInline },
287
- // 2 under the bar: 71 under a one-line title
288
- title != null ? { paddingTop: androidBarHeight + 2 } : null,
289
- // Over a footer: 8 above its height, which reaches over the sheet's bottom padding
290
- footer ? { paddingBottom: 8 + Math.max(0, footerHeight - insets.bottom - keyboard) } : null,
291
- ]
292
- : iosContent,
293
- contentStyle,
294
- ], keyboardShouldPersistTaps: "handled", bounces: false, children: content }), android && title != null ? header : null, footer ? (_jsxs(View, { onStartShouldSetResponderCapture: android ? gesture.chrome : undefined, onLayout: android ? (event) => setFooterHeight(event.nativeEvent.layout.height) : undefined, style: [
295
- android
296
- ? [
297
- styles.androidFooter,
298
- { paddingHorizontal: androidInline },
299
- // Over the sheet's color at 80%, faded in over its top 24dp, down over the gesture bar
300
- { paddingBottom: 12 + insets.bottom + keyboard, backgroundImage: `linear-gradient(to bottom, ${withAlpha(background, 0)}, ${withAlpha(background, 0.8)} 24px)` },
301
- ]
302
- : [styles.iosFooter, { paddingHorizontal: margin, paddingBottom: keyboard ? 16 : Math.max(16, insets.bottom) }],
303
- footer.props.style,
304
- ], children: [android ? null : (_jsx(View, { pointerEvents: "none", style: [styles.iosFooterEdge, { backgroundImage: `linear-gradient(${withAlpha(background, 0)}, ${background} 27px)` }] })), footer.props.children] })) : null] }), android && Platform.OS === "android" && dismissible ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel, onPress: close, style: [styles.scrimTarget, { bottom: height }] })) : null] })) }));
269
+ , {
270
+ // A sheet of a fixed height gives its content the room left, so a footer stays at its bottom
271
+ style: [styles.scroll, fixedHeight != null ? styles.grow : null], ...(android
272
+ ? {
273
+ ...gesture.content,
274
+ onScroll: (event) => {
275
+ gesture.content.onScroll(event);
276
+ const under = event.nativeEvent.contentOffset.y > 0;
277
+ if (under !== scrolled)
278
+ setScrolled(under);
279
+ },
280
+ scrollEventThrottle: 16,
281
+ }
282
+ : null), contentContainerStyle: [
283
+ android
284
+ ? [
285
+ styles.androidContent,
286
+ // A screen whose gutter is Material's compact 16 sets it with --bottom-sheet-android-padding-inline
287
+ { paddingHorizontal: androidInline },
288
+ // 2 under the bar: 71 under a one-line title
289
+ title != null ? { paddingTop: androidBarHeight + 2 } : null,
290
+ // Over a footer: 8 above its height, which reaches over the sheet's bottom padding
291
+ footer ? { paddingBottom: 8 + Math.max(0, footerHeight - insets.bottom - keyboard) } : null,
292
+ ]
293
+ : iosContent,
294
+ contentStyle,
295
+ ], keyboardShouldPersistTaps: "handled", bounces: false, children: content }), android && title != null ? header : null, footer ? (_jsxs(View, { onStartShouldSetResponderCapture: android ? gesture.chrome : undefined, onLayout: android ? (event) => setFooterHeight(event.nativeEvent.layout.height) : undefined, style: [
296
+ android
297
+ ? [
298
+ styles.androidFooter,
299
+ { paddingHorizontal: androidInline },
300
+ // Over the sheet's color at 80%, faded in over its top 24dp, down over the gesture bar
301
+ { paddingBottom: 12 + insets.bottom + keyboard, backgroundImage: `linear-gradient(to bottom, ${withAlpha(background, 0)}, ${withAlpha(background, 0.8)} 24px)` },
302
+ ]
303
+ : [styles.iosFooter, { paddingHorizontal: margin, paddingBottom: keyboard ? 16 : Math.max(16, insets.bottom) }],
304
+ footer.props.style,
305
+ ], children: [android ? null : (_jsx(View, { pointerEvents: "none", style: [styles.iosFooterEdge, { backgroundImage: `linear-gradient(${withAlpha(background, 0)}, ${background} 27px)` }] })), footer.props.children] })) : null] }), android && Platform.OS === "android" && dismissible ? (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: closeLabel, onPress: close, style: [styles.scrimTarget, { bottom: height }] })) : null] }) })) }));
305
306
  }
306
307
  const isFooter = (child) => isValidElement(child) && child.type === BottomSheetFooter;
307
308
  /** The item of an Android sheet's bar: a 46dp glass circle solved against the sheet's color. */
@@ -0,0 +1,6 @@
1
+ import { createContext } from "react";
2
+ /**
3
+ * True inside a BottomSheet: an iOS sheet's own search field draws its magnifier and its hint in one gray, darker than
4
+ * a bar's hint (IMG_5491), where a bar's magnifier is the text color (IMG_5737).
5
+ */
6
+ export const InSheetContext = createContext(false);
@@ -15,6 +15,7 @@ import { useTheme } from "../../theme/ThemeProvider";
15
15
  import { BarFieldContext } from "../Button/Button";
16
16
  import { IconDefaultsProvider } from "../Icon/createIcon";
17
17
  import { MaterialCancelFilled, MaterialClose } from "../Icon/material";
18
+ import { InSheetContext } from "../BottomSheet/context";
18
19
  /**
19
20
  * The phone layer's field at each size: Input.module.css's size table under touch.css's phone rules, which give every
20
21
  * size 17pt text and a 14pt gutter (11 beside a start adornment, `html [data-slot="input"]`, scoped rules with no root
@@ -67,7 +68,7 @@ export function useSpringColor(color, stiffness, instant) {
67
68
  return value;
68
69
  }
69
70
  /** The look of a field on this platform: its box, text and colors. Shared by Input, TextField and Select. */
70
- export function fieldLook(theme, { variant, size, pill, startAdornment = false, bar = null, label = false, search = false, }, state) {
71
+ export function fieldLook(theme, { variant, size, pill, startAdornment = false, bar = null, label = false, search = false, inSheet = false, }, state) {
71
72
  if (theme.isAndroid) {
72
73
  const m = theme.material;
73
74
  if (search) {
@@ -167,7 +168,8 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
167
168
  }
168
169
  if (bar) {
169
170
  // A Toolbar's search field (Toolbar.module.css, iOS 26 kit Search Top and Bottom): the bar's item height, the
170
- // glass of its buttons, the bar's magnifier in the label color, its text Regular at the bar's label size
171
+ // glass of its buttons, the bar's magnifier in the text color (Contacts, IMG_5737), its text Regular at the bar's
172
+ // label size; in a sheet the magnifier and the hint are one darker gray, typed in or not (IMG_5491)
171
173
  const gutter = theme.length("--toolbar-search-gutter", 10.54);
172
174
  return {
173
175
  box: {
@@ -184,8 +186,12 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
184
186
  lineHeight: theme.length("--toolbar-label-line-height", 22),
185
187
  color: theme.color("--input-text-color", theme.colors.text),
186
188
  },
187
- placeholder: theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
188
- icon: theme.color("--color-text", theme.colors.text),
189
+ placeholder: inSheet
190
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
191
+ : theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
192
+ icon: inSheet
193
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
194
+ : theme.color("--toolbar-search-icon-color", theme.colors.text),
189
195
  frame: null,
190
196
  trailingIcon: theme.color("--mobile-label-secondary"),
191
197
  caret: theme.color("--color-background-accent-solid"),
@@ -376,6 +382,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
376
382
  // `readOnly={false}` cannot unlock a disabled field
377
383
  const locked = disabled || readOnly;
378
384
  const barField = useContext(BarFieldContext);
385
+ const inSheet = useContext(InSheetContext);
379
386
  // At an iOS row's end the field is the row's value, as the web's field in a `[data-row]`: it fills the room after the
380
387
  // label, with no frame (the row's error marks it invalid), its text at the end and the placeholder in the tertiary label
381
388
  // (on Android it fills the room too, keeping its own field look)
@@ -409,7 +416,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
409
416
  const search = theme.isAndroid && !barField && variant === "soft" && !!startAdornment && label == null;
410
417
  const barSearch = theme.isAndroid && !!barField;
411
418
  const androidGlass = useAndroidGlass("bar", barField?.canvas);
412
- const fieldLookOf = fieldLook(theme, { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search }, { focused, filled, disabled, invalid });
419
+ const fieldLookOf = fieldLook(theme, { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search, inSheet }, { focused, filled, disabled, invalid });
413
420
  const look = barSearch
414
421
  ? { ...fieldLookOf, box: { ...fieldLookOf.box, ...androidGlass } }
415
422
  : bare
@@ -0,0 +1,5 @@
1
+ /**
2
+ * True inside a BottomSheet: an iOS sheet's own search field draws its magnifier and its hint in one gray, darker than
3
+ * a bar's hint (IMG_5491), where a bar's magnifier is the text color (IMG_5737).
4
+ */
5
+ export declare const InSheetContext: import("react").Context<boolean>;
@@ -46,7 +46,7 @@ export type FieldFrame = {
46
46
  */
47
47
  export declare function useSpringColor(color: string, stiffness: number, instant: boolean): Animated.Color;
48
48
  /** The look of a field on this platform: its box, text and colors. Shared by Input, TextField and Select. */
49
- export declare function fieldLook(theme: Theme, { variant, size, pill, startAdornment, bar, label, search, }: {
49
+ export declare function fieldLook(theme: Theme, { variant, size, pill, startAdornment, bar, label, search, inSheet, }: {
50
50
  variant: InputVariant;
51
51
  size: ControlSize;
52
52
  pill: boolean;
@@ -60,6 +60,8 @@ export declare function fieldLook(theme: Theme, { variant, size, pill, startAdor
60
60
  label?: boolean;
61
61
  /** Android: the pill search field (40dp) of a screen or a sheet; a bar's own field, in or under it, is `bar`. */
62
62
  search?: boolean;
63
+ /** iOS: a bar's field inside a BottomSheet (its magnifier and hint in one gray) */
64
+ inSheet?: boolean;
63
65
  }, state: FrameState): {
64
66
  box: ViewStyle;
65
67
  glass: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexui/react-native",
3
- "version": "0.2.30",
3
+ "version": "0.2.32",
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",
@@ -84,7 +84,7 @@
84
84
  "test": "npm run typecheck && npm run lint && npm run test:web --prefix example"
85
85
  },
86
86
  "dependencies": {
87
- "@plexui/styles": "^0.17.6",
87
+ "@plexui/styles": "^0.17.11",
88
88
  "libphonenumber-js": "^1.13.17"
89
89
  },
90
90
  "peerDependencies": {
@@ -1,4 +1,5 @@
1
1
  import { isValidElement, useId, useLayoutEffect, useMemo, useState, type ReactNode } from "react"
2
+ import { InSheetContext } from "./context"
2
3
  import { Animated, Easing, PanResponder, Platform, ScrollView, StyleSheet, View, useWindowDimensions, type LayoutChangeEvent, type NativeScrollEvent, type NativeSyntheticEvent, type StyleProp, type ViewStyle } from "react-native"
3
4
  import { Pressable } from "../../internal/Pressable"
4
5
  import { useSafeAreaInsets } from "react-native-safe-area-context"
@@ -349,6 +350,7 @@ export function BottomSheetBase({
349
350
  testID={testID}
350
351
  >
351
352
  {(progress, _opening, focus) => (
353
+ <InSheetContext.Provider value>
352
354
  <View pointerEvents="box-none" style={styles.bottom}>
353
355
  <Animated.View
354
356
  {...a11y}
@@ -451,6 +453,7 @@ export function BottomSheetBase({
451
453
  />
452
454
  ) : null}
453
455
  </View>
456
+ </InSheetContext.Provider>
454
457
  )}
455
458
  </Overlay>
456
459
  )
@@ -0,0 +1,7 @@
1
+ import { createContext } from "react"
2
+
3
+ /**
4
+ * True inside a BottomSheet: an iOS sheet's own search field draws its magnifier and its hint in one gray, darker than
5
+ * a bar's hint (IMG_5491), where a bar's magnifier is the text color (IMG_5737).
6
+ */
7
+ export const InSheetContext = createContext(false)
@@ -15,6 +15,7 @@ import type { Theme } from "../../theme/types"
15
15
  import { BarFieldContext, type ControlSize } from "../Button/Button"
16
16
  import { IconDefaultsProvider } from "../Icon/createIcon"
17
17
  import { MaterialCancelFilled, MaterialClose } from "../Icon/material"
18
+ import { InSheetContext } from "../BottomSheet/context"
18
19
 
19
20
  export type InputVariant = "outline" | "soft" | "ghost"
20
21
 
@@ -113,6 +114,7 @@ export function fieldLook(
113
114
  bar = null,
114
115
  label = false,
115
116
  search = false,
117
+ inSheet = false,
116
118
  }: {
117
119
  variant: InputVariant
118
120
  size: ControlSize
@@ -123,6 +125,8 @@ export function fieldLook(
123
125
  label?: boolean
124
126
  /** Android: the pill search field (40dp) of a screen or a sheet; a bar's own field, in or under it, is `bar`. */
125
127
  search?: boolean
128
+ /** iOS: a bar's field inside a BottomSheet (its magnifier and hint in one gray) */
129
+ inSheet?: boolean
126
130
  },
127
131
  state: FrameState,
128
132
  ) {
@@ -225,7 +229,8 @@ export function fieldLook(
225
229
  }
226
230
  if (bar) {
227
231
  // A Toolbar's search field (Toolbar.module.css, iOS 26 kit Search Top and Bottom): the bar's item height, the
228
- // glass of its buttons, the bar's magnifier in the label color, its text Regular at the bar's label size
232
+ // glass of its buttons, the bar's magnifier in the text color (Contacts, IMG_5737), its text Regular at the bar's
233
+ // label size; in a sheet the magnifier and the hint are one darker gray, typed in or not (IMG_5491)
229
234
  const gutter = theme.length("--toolbar-search-gutter", 10.54)
230
235
  return {
231
236
  box: {
@@ -242,8 +247,12 @@ export function fieldLook(
242
247
  lineHeight: theme.length("--toolbar-label-line-height", 22),
243
248
  color: theme.color("--input-text-color", theme.colors.text),
244
249
  },
245
- placeholder: theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
246
- icon: theme.color("--color-text", theme.colors.text),
250
+ placeholder: inSheet
251
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
252
+ : theme.color("--toolbar-search-placeholder-color", theme.colors.textTertiary),
253
+ icon: inSheet
254
+ ? theme.color("--toolbar-search-sheet-color", theme.colors.textTertiary)
255
+ : theme.color("--toolbar-search-icon-color", theme.colors.text),
247
256
  frame: null as FieldFrame | null,
248
257
  trailingIcon: theme.color("--mobile-label-secondary"),
249
258
  caret: theme.color("--color-background-accent-solid"),
@@ -577,6 +586,7 @@ export function InputField({
577
586
  // `readOnly={false}` cannot unlock a disabled field
578
587
  const locked = disabled || readOnly
579
588
  const barField = useContext(BarFieldContext)
589
+ const inSheet = useContext(InSheetContext)
580
590
  // At an iOS row's end the field is the row's value, as the web's field in a `[data-row]`: it fills the room after the
581
591
  // label, with no frame (the row's error marks it invalid), its text at the end and the placeholder in the tertiary label
582
592
  // (on Android it fills the room too, keeping its own field look)
@@ -614,7 +624,7 @@ export function InputField({
614
624
  const androidGlass = useAndroidGlass("bar", barField?.canvas)
615
625
  const fieldLookOf = fieldLook(
616
626
  theme,
617
- { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search },
627
+ { variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search, inSheet },
618
628
  { focused, filled, disabled, invalid },
619
629
  )
620
630
  const look = barSearch