@plexui/react-native 0.2.31 → 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.
- package/dist/es/components/BottomSheet/BottomSheet.js +58 -57
- package/dist/es/components/BottomSheet/context.js +6 -0
- package/dist/es/components/Input/Input.js +12 -6
- package/dist/types/components/BottomSheet/context.d.ts +5 -0
- package/dist/types/components/Input/Input.d.ts +3 -1
- package/package.json +2 -2
- package/src/components/BottomSheet/BottomSheet.tsx +3 -0
- package/src/components/BottomSheet/context.ts +7 -0
- package/src/components/Input/Input.tsx +14 -5
|
@@ -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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
gesture.content
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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,8 +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
|
|
171
|
-
//
|
|
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)
|
|
172
173
|
const gutter = theme.length("--toolbar-search-gutter", 10.54);
|
|
173
174
|
return {
|
|
174
175
|
box: {
|
|
@@ -185,8 +186,12 @@ export function fieldLook(theme, { variant, size, pill, startAdornment = false,
|
|
|
185
186
|
lineHeight: theme.length("--toolbar-label-line-height", 22),
|
|
186
187
|
color: theme.color("--input-text-color", theme.colors.text),
|
|
187
188
|
},
|
|
188
|
-
placeholder:
|
|
189
|
-
|
|
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),
|
|
190
195
|
frame: null,
|
|
191
196
|
trailingIcon: theme.color("--mobile-label-secondary"),
|
|
192
197
|
caret: theme.color("--color-background-accent-solid"),
|
|
@@ -377,6 +382,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
|
|
|
377
382
|
// `readOnly={false}` cannot unlock a disabled field
|
|
378
383
|
const locked = disabled || readOnly;
|
|
379
384
|
const barField = useContext(BarFieldContext);
|
|
385
|
+
const inSheet = useContext(InSheetContext);
|
|
380
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
|
|
381
387
|
// label, with no frame (the row's error marks it invalid), its text at the end and the placeholder in the tertiary label
|
|
382
388
|
// (on Android it fills the room too, keeping its own field look)
|
|
@@ -410,7 +416,7 @@ export function InputField({ variant = "outline", size = "md", disabled = false,
|
|
|
410
416
|
const search = theme.isAndroid && !barField && variant === "soft" && !!startAdornment && label == null;
|
|
411
417
|
const barSearch = theme.isAndroid && !!barField;
|
|
412
418
|
const androidGlass = useAndroidGlass("bar", barField?.canvas);
|
|
413
|
-
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 });
|
|
414
420
|
const look = barSearch
|
|
415
421
|
? { ...fieldLookOf, box: { ...fieldLookOf.box, ...androidGlass } }
|
|
416
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.
|
|
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.
|
|
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,8 +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
|
|
229
|
-
//
|
|
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)
|
|
230
234
|
const gutter = theme.length("--toolbar-search-gutter", 10.54)
|
|
231
235
|
return {
|
|
232
236
|
box: {
|
|
@@ -243,8 +247,12 @@ export function fieldLook(
|
|
|
243
247
|
lineHeight: theme.length("--toolbar-label-line-height", 22),
|
|
244
248
|
color: theme.color("--input-text-color", theme.colors.text),
|
|
245
249
|
},
|
|
246
|
-
placeholder:
|
|
247
|
-
|
|
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),
|
|
248
256
|
frame: null as FieldFrame | null,
|
|
249
257
|
trailingIcon: theme.color("--mobile-label-secondary"),
|
|
250
258
|
caret: theme.color("--color-background-accent-solid"),
|
|
@@ -578,6 +586,7 @@ export function InputField({
|
|
|
578
586
|
// `readOnly={false}` cannot unlock a disabled field
|
|
579
587
|
const locked = disabled || readOnly
|
|
580
588
|
const barField = useContext(BarFieldContext)
|
|
589
|
+
const inSheet = useContext(InSheetContext)
|
|
581
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
|
|
582
591
|
// label, with no frame (the row's error marks it invalid), its text at the end and the placeholder in the tertiary label
|
|
583
592
|
// (on Android it fills the room too, keeping its own field look)
|
|
@@ -615,7 +624,7 @@ export function InputField({
|
|
|
615
624
|
const androidGlass = useAndroidGlass("bar", barField?.canvas)
|
|
616
625
|
const fieldLookOf = fieldLook(
|
|
617
626
|
theme,
|
|
618
|
-
{ variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search },
|
|
627
|
+
{ variant, size, pill, startAdornment: !!startAdornment, bar: barField, label: label != null, search, inSheet },
|
|
619
628
|
{ focused, filled, disabled, invalid },
|
|
620
629
|
)
|
|
621
630
|
const look = barSearch
|