@vvedantb/native-ui 0.35.0 → 0.36.0
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/README.md +16 -1
- package/dist/Button.jsx +9 -3
- package/dist/ExpoWebRoot.jsx +42 -21
- package/dist/Field.jsx +309 -0
- package/dist/FloatingTabBar.jsx +98 -94
- package/dist/ai/conversation.jsx +1 -1
- package/dist/blur.js +6 -0
- package/dist/controlStyles.js +24 -2
- package/dist/entries/primitives.js +1 -0
- package/dist/examples/ParityGallery.jsx +488 -475
- package/dist/glassBlur.jsx +1 -1
- package/dist/index.js +1 -0
- package/dist/primitives/window-layer.jsx +35 -28
- package/package.json +27 -3
- package/src/Button.tsx +10 -4
- package/src/DropdownMenu.tsx +11 -2
- package/src/ExpoWebRoot.tsx +18 -3
- package/src/Field.tsx +105 -0
- package/src/FloatingTabBar.tsx +17 -12
- package/src/Spinner.tsx +2 -2
- package/src/ai/conversation.tsx +1 -1
- package/src/ai/message.tsx +2 -2
- package/src/auth/AccountScreens.tsx +4 -4
- package/src/auth/SignInScreen.tsx +4 -4
- package/src/blur.ts +8 -0
- package/src/controlStyles.ts +29 -2
- package/src/entries/primitives.ts +2 -0
- package/src/examples/ParityGallery.tsx +22 -1
- package/src/glassBlur.tsx +5 -7
- package/src/index.ts +2 -0
- package/src/primitives/sheet-gesture.tsx +1 -2
- package/src/primitives/web-click-guard.ts +3 -3
- package/src/primitives/window-layer.tsx +8 -6
- package/src/tabBarRoutes.ts +4 -3
- package/src/webview/HtmlView.tsx +5 -2
|
@@ -68,6 +68,11 @@ import {
|
|
|
68
68
|
GoogleMark,
|
|
69
69
|
IconButton,
|
|
70
70
|
Input,
|
|
71
|
+
Field,
|
|
72
|
+
FieldControl,
|
|
73
|
+
FieldDescription,
|
|
74
|
+
FieldError,
|
|
75
|
+
FieldLabel,
|
|
71
76
|
Label,
|
|
72
77
|
LabeledSwitchRow,
|
|
73
78
|
ListRow,
|
|
@@ -131,12 +136,19 @@ import {
|
|
|
131
136
|
} from "../ai";
|
|
132
137
|
import { AiChatSamples } from "./AiChatGallery";
|
|
133
138
|
|
|
139
|
+
// Every shared variant; the aliases (`primary`, `tertiary`, `danger`) draw as the name they alias.
|
|
134
140
|
const BUTTON_VARIANTS: ButtonVariant[] = [
|
|
135
141
|
"default",
|
|
142
|
+
"primary",
|
|
136
143
|
"secondary",
|
|
137
144
|
"outline",
|
|
138
145
|
"destructive",
|
|
146
|
+
"danger",
|
|
139
147
|
"ghost",
|
|
148
|
+
"tertiary",
|
|
149
|
+
"flat",
|
|
150
|
+
"success",
|
|
151
|
+
"warning",
|
|
140
152
|
"link",
|
|
141
153
|
];
|
|
142
154
|
|
|
@@ -289,7 +301,7 @@ function GalleryScreen() {
|
|
|
289
301
|
{/* The web gallery: a full-width column of variants, then the sm row. */}
|
|
290
302
|
<View className="gap-2">
|
|
291
303
|
{BUTTON_VARIANTS.map((variant) => (
|
|
292
|
-
<Button key={variant} variant={variant} onPress={() => toast(variant)}>
|
|
304
|
+
<Button key={variant} testID={`button-variant-${variant}`} variant={variant} onPress={() => toast(variant)}>
|
|
293
305
|
{variant}
|
|
294
306
|
</Button>
|
|
295
307
|
))}
|
|
@@ -307,6 +319,9 @@ function GalleryScreen() {
|
|
|
307
319
|
Small
|
|
308
320
|
</Button>
|
|
309
321
|
<Button fullWidth={false}>Default</Button>
|
|
322
|
+
<Button size="md" fullWidth={false}>
|
|
323
|
+
Medium
|
|
324
|
+
</Button>
|
|
310
325
|
<Button size="lg" fullWidth={false}>
|
|
311
326
|
Large
|
|
312
327
|
</Button>
|
|
@@ -357,6 +372,12 @@ function GalleryScreen() {
|
|
|
357
372
|
<Label nativeID="gallery-name">Name</Label>
|
|
358
373
|
<Input placeholder="Your name" accessibilityLabel="Name" />
|
|
359
374
|
</View>
|
|
375
|
+
<Field testID="field-parity">
|
|
376
|
+
<FieldLabel testID="field-parity-label">Email</FieldLabel>
|
|
377
|
+
<FieldControl testID="field-parity-input" placeholder="you@example.com" />
|
|
378
|
+
<FieldDescription testID="field-parity-description">We never share it.</FieldDescription>
|
|
379
|
+
<FieldError testID="field-parity-error">Enter a valid email.</FieldError>
|
|
380
|
+
</Field>
|
|
360
381
|
{/* Empty (`sm`: icon and placeholder) and filled (`md`: the clear button). */}
|
|
361
382
|
<SearchInput value={emptySearch} onChange={setEmptySearch} />
|
|
362
383
|
<SearchInput value={search} onChange={setSearch} size="md" label="Search colours" />
|
package/src/glassBlur.tsx
CHANGED
|
@@ -5,14 +5,10 @@ import {
|
|
|
5
5
|
useRef,
|
|
6
6
|
useState,
|
|
7
7
|
useSyncExternalStore,
|
|
8
|
-
type ComponentRef,
|
|
9
8
|
type ReactNode,
|
|
10
|
-
type RefObject,
|
|
11
9
|
} from "react";
|
|
12
10
|
import { StyleSheet, View, type ViewProps } from "react-native";
|
|
13
|
-
import { loadBlur } from "./blur";
|
|
14
|
-
|
|
15
|
-
type BlurTargetRef = RefObject<ComponentRef<typeof View> | null>;
|
|
11
|
+
import { loadBlur, type BlurTargetElement, type BlurTargetRef } from "./blur";
|
|
16
12
|
|
|
17
13
|
/**
|
|
18
14
|
* The current blur target, outside React state. A target change (each tab
|
|
@@ -84,7 +80,7 @@ export function GlassBlurTarget({
|
|
|
84
80
|
...props
|
|
85
81
|
}: GlassBlurTargetProps) {
|
|
86
82
|
const store = useContext(BlurTargetStoreContext);
|
|
87
|
-
const ref = useRef<
|
|
83
|
+
const ref = useRef<BlurTargetElement>(null);
|
|
88
84
|
const BlurTargetView = loadBlur()?.BlurTargetView;
|
|
89
85
|
|
|
90
86
|
// Publish the ref only once it is attached: expo-blur compares
|
|
@@ -102,12 +98,14 @@ export function GlassBlurTarget({
|
|
|
102
98
|
// Surfaces in here get no target: a blur view must not sit inside its own.
|
|
103
99
|
const content = <BlurTargetStoreContext.Provider value={null}>{children}</BlurTargetStoreContext.Provider>;
|
|
104
100
|
|
|
101
|
+
// The plain `View` is the fallback when expo-blur is absent: no `BlurView`
|
|
102
|
+
// then reads the store, so this branch needs no target ref.
|
|
105
103
|
return BlurTargetView ? (
|
|
106
104
|
<BlurTargetView ref={ref} style={[styles.fill, style]} {...props}>
|
|
107
105
|
{content}
|
|
108
106
|
</BlurTargetView>
|
|
109
107
|
) : (
|
|
110
|
-
<View
|
|
108
|
+
<View style={[styles.fill, style]} {...props}>
|
|
111
109
|
{content}
|
|
112
110
|
</View>
|
|
113
111
|
);
|
package/src/index.ts
CHANGED
|
@@ -52,6 +52,8 @@ export { Textarea } from "./Textarea";
|
|
|
52
52
|
export type { TextareaProps } from "./Textarea";
|
|
53
53
|
export { Label } from "./Label";
|
|
54
54
|
export type { LabelProps } from "./Label";
|
|
55
|
+
export { Field, FieldControl, FieldDescription, FieldError, FieldLabel } from "./Field";
|
|
56
|
+
export type { FieldProps } from "./Field";
|
|
55
57
|
export { Select } from "./Select";
|
|
56
58
|
export type { SelectOption, SelectProps } from "./Select";
|
|
57
59
|
export { Switch } from "./Switch";
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
Gesture,
|
|
5
5
|
GestureDetector,
|
|
6
6
|
GestureHandlerRootView,
|
|
7
|
-
type NativeGesture,
|
|
8
7
|
} from "react-native-gesture-handler";
|
|
9
8
|
import Animated, {
|
|
10
9
|
cancelAnimation,
|
|
@@ -46,7 +45,7 @@ import { GestureToastDrag } from "./toast-drag-gesture";
|
|
|
46
45
|
/** What a body inside the sheet needs from the drag around it. */
|
|
47
46
|
type SheetScrollLink = {
|
|
48
47
|
/** The body's native scroll, run together with the sheet's pan. */
|
|
49
|
-
native:
|
|
48
|
+
native: ReturnType<typeof Gesture.Native>;
|
|
50
49
|
/** While the sheet follows the finger: the scroll offset the body holds; else `null`. */
|
|
51
50
|
heldTop: SharedValue<number | null>;
|
|
52
51
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useRef } from "react";
|
|
2
|
-
import { Platform,
|
|
1
|
+
import { useRef, type ComponentRef } from "react";
|
|
2
|
+
import { Platform, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
/** The part of a DOM element the web click guard uses: on the web a `View` is a DOM element. */
|
|
5
5
|
type DomNode = {
|
|
@@ -27,7 +27,7 @@ export function useWebClickGuard(swallowOnDown: () => boolean = () => false) {
|
|
|
27
27
|
swallowNext: () => {
|
|
28
28
|
swallow.current = true;
|
|
29
29
|
},
|
|
30
|
-
ref: (node: View | null) => {
|
|
30
|
+
ref: (node: ComponentRef<typeof View> | null) => {
|
|
31
31
|
if (Platform.OS !== "web" || !node || !isDomNode(node)) return;
|
|
32
32
|
const onClick = (event: DomEvent) => {
|
|
33
33
|
if (!swallow.current) return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { useId, useLayoutEffect, useSyncExternalStore, type ReactNode } from "react";
|
|
1
|
+
import { useId, useLayoutEffect, useSyncExternalStore, type ComponentRef, type ReactNode } from "react";
|
|
2
2
|
import { BackHandler, Modal, StyleSheet, View } from "react-native";
|
|
3
|
-
import Animated, { FadeIn, FadeOut
|
|
3
|
+
import Animated, { FadeIn, FadeOut } from "react-native-reanimated";
|
|
4
4
|
import { useReduceMotion } from "../useReduceMotion";
|
|
5
5
|
|
|
6
6
|
// Overlays drawn in the app's own window. A React Native `Modal` is a window
|
|
@@ -59,7 +59,7 @@ const onBack = () => {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
/** Mounted: the host is there, and it answers Android back for its layers. */
|
|
62
|
-
const hostRef = (view: View | null) => {
|
|
62
|
+
const hostRef = (view: ComponentRef<typeof View> | null) => {
|
|
63
63
|
if (view === null) return undefined;
|
|
64
64
|
hosts += 1;
|
|
65
65
|
const back = BackHandler.addEventListener("hardwareBackPress", onBack);
|
|
@@ -79,9 +79,11 @@ const hostRef = (view: View | null) => {
|
|
|
79
79
|
export function WindowLayerHost({ children }: { children: ReactNode }) {
|
|
80
80
|
const shown = useSyncExternalStore(subscribe, () => layers, () => EMPTY);
|
|
81
81
|
// The layers fade in and out as a Modal's `fade`, unless they move on their
|
|
82
|
-
// own (`fade={false}`)
|
|
83
|
-
|
|
84
|
-
const
|
|
82
|
+
// own (`fade={false}`). With Reduce Motion they get no layout animation at
|
|
83
|
+
// all, as the fallback Modal gets `animationType="none"`.
|
|
84
|
+
const reduceMotion = useReduceMotion();
|
|
85
|
+
const enter = reduceMotion ? undefined : FadeIn.duration(200);
|
|
86
|
+
const exit = reduceMotion ? undefined : FadeOut.duration(150);
|
|
85
87
|
return (
|
|
86
88
|
<View ref={hostRef} style={styles.fill}>
|
|
87
89
|
<View
|
package/src/tabBarRoutes.ts
CHANGED
|
@@ -27,10 +27,11 @@ export type FloatingTabOptions = {
|
|
|
27
27
|
* Only `display: "none"` is read: on the focused route it hides the whole
|
|
28
28
|
* bar, as in React Navigation's own bar (for example while a screen is in
|
|
29
29
|
* select mode and shows its `BulkActionBar` in the bar's place). Typed
|
|
30
|
-
* loosely:
|
|
31
|
-
* which is an object or a
|
|
30
|
+
* loosely: Expo Router's own type is an animated style, each member of
|
|
31
|
+
* which is an object, a falsy value or `void` (a mapped animated field).
|
|
32
|
+
* `displayOf` reads only `display`.
|
|
32
33
|
*/
|
|
33
|
-
tabBarStyle?: object | false | "" | null;
|
|
34
|
+
tabBarStyle?: object | false | "" | null | void;
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
/** The `display` a style resolves to: in an array the last one set wins, as in `StyleSheet.flatten`. */
|
package/src/webview/HtmlView.tsx
CHANGED
|
@@ -60,7 +60,10 @@ export function HtmlView({
|
|
|
60
60
|
ref: handle,
|
|
61
61
|
testID,
|
|
62
62
|
}: HtmlViewProps) {
|
|
63
|
-
|
|
63
|
+
// `WebView<object>`: react-native-webview 14 types the class as
|
|
64
|
+
// `WebView<P = undefined>`, and its props as `WebViewProps & P`, which is
|
|
65
|
+
// `never` without a type argument.
|
|
66
|
+
const ref = useRef<WebView<object>>(null);
|
|
64
67
|
useImperativeHandle(handle, () => ({
|
|
65
68
|
postMessage: (message: string) => ref.current?.injectJavaScript(htmlViewPostScript(message)),
|
|
66
69
|
}));
|
|
@@ -77,7 +80,7 @@ export function HtmlView({
|
|
|
77
80
|
|
|
78
81
|
return (
|
|
79
82
|
<View testID={testID} style={{ height }}>
|
|
80
|
-
<WebView
|
|
83
|
+
<WebView<object>
|
|
81
84
|
ref={ref}
|
|
82
85
|
source={{ html }}
|
|
83
86
|
accessibilityLabel={title}
|