@vvedantb/native-ui 0.24.0 → 0.24.2
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/CaptureButton.jsx +67 -46
- package/dist/Chip.jsx +42 -34
- package/dist/ColorSwatches.jsx +169 -45
- package/dist/Dialog.jsx +16 -3
- package/dist/DropdownMenu.jsx +245 -116
- package/dist/FloatingFAB.jsx +71 -55
- package/dist/IconButton.jsx +62 -48
- package/dist/PinnedBotTile.jsx +87 -72
- package/dist/SearchInput.jsx +313 -50
- package/dist/ai/card-button.jsx +116 -147
- package/dist/ai/file-chip.jsx +46 -22
- package/dist/ai/message-action-sheet.jsx +182 -202
- package/dist/motion.js +31 -0
- package/dist/pressScale.js +131 -0
- package/dist/primitives/overlay.jsx +162 -101
- package/dist/primitives/select.jsx +5 -1
- package/package.json +1 -1
- package/src/CaptureButton.tsx +15 -9
- package/src/Chip.tsx +9 -4
- package/src/ColorSwatches.tsx +74 -29
- package/src/Dialog.tsx +16 -7
- package/src/DropdownMenu.tsx +71 -16
- package/src/FloatingFAB.tsx +20 -13
- package/src/IconButton.tsx +8 -6
- package/src/PinnedBotTile.tsx +9 -5
- package/src/SearchInput.tsx +40 -12
- package/src/ai/card-button.tsx +17 -11
- package/src/ai/file-chip.tsx +13 -4
- package/src/ai/message-action-sheet.tsx +90 -97
- package/src/motion.ts +15 -0
- package/src/pressScale.ts +72 -0
- package/src/primitives/overlay.tsx +48 -8
- package/src/primitives/select.tsx +7 -2
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { cssInterop } from "nativewind";
|
|
3
|
+
import { useCallback, useEffect } from "react";
|
|
4
|
+
import { Pressable } from "react-native";
|
|
5
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
6
|
+
import { EASE_OUT } from "./motion";
|
|
7
|
+
import { useReduceMotion } from "./useReduceMotion";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A `Pressable` whose `style` can take the style from `usePressScale`.
|
|
11
|
+
* NativeWind maps `className` only for components it knows, so it is told
|
|
12
|
+
* about this one, or the classes would be dropped.
|
|
13
|
+
*/
|
|
14
|
+
export const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
15
|
+
cssInterop(AnimatedPressable, {
|
|
16
|
+
className: "style"
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Press feedback for a small control: a scale and a light dim that ease in on
|
|
20
|
+
* press-in and ease back on release. Pass `onPressIn` and `onPressOut` to the
|
|
21
|
+
* `Pressable` and `style` to the animated view that should scale (an
|
|
22
|
+
* `AnimatedPressable`, or an `Animated.View` inside the `Pressable`). One
|
|
23
|
+
* shared value on the UI thread drives transform and opacity only. A new press
|
|
24
|
+
* or release starts from the current value, so a fast tap never sticks. With
|
|
25
|
+
* Reduce Motion nothing animates and nothing scales: the dim switches on and
|
|
26
|
+
* off at once.
|
|
27
|
+
*/
|
|
28
|
+
export function usePressScale(t0) {
|
|
29
|
+
const $ = _c(18);
|
|
30
|
+
let t1;
|
|
31
|
+
if ($[0] !== t0) {
|
|
32
|
+
t1 = t0 === undefined ? {} : t0;
|
|
33
|
+
$[0] = t0;
|
|
34
|
+
$[1] = t1;
|
|
35
|
+
} else {
|
|
36
|
+
t1 = $[1];
|
|
37
|
+
}
|
|
38
|
+
const {
|
|
39
|
+
scale: t2,
|
|
40
|
+
dim: t3,
|
|
41
|
+
reducedDim: t4,
|
|
42
|
+
restOpacity: t5,
|
|
43
|
+
pressInMs: t6,
|
|
44
|
+
pressOutMs: t7,
|
|
45
|
+
disabled: t8
|
|
46
|
+
} = t1;
|
|
47
|
+
const scale = t2 === undefined ? 0.97 : t2;
|
|
48
|
+
const dim = t3 === undefined ? 0.7 : t3;
|
|
49
|
+
const reducedDim = t4 === undefined ? dim : t4;
|
|
50
|
+
const restOpacity = t5 === undefined ? 1 : t5;
|
|
51
|
+
const pressInMs = t6 === undefined ? 120 : t6;
|
|
52
|
+
const pressOutMs = t7 === undefined ? 160 : t7;
|
|
53
|
+
const disabled = t8 === undefined ? false : t8;
|
|
54
|
+
const reduceMotion = useReduceMotion();
|
|
55
|
+
const progress = useSharedValue(0);
|
|
56
|
+
const target = reduceMotion ? reducedDim : dim;
|
|
57
|
+
let t9;
|
|
58
|
+
if ($[2] !== pressInMs || $[3] !== progress || $[4] !== reduceMotion) {
|
|
59
|
+
t9 = () => {
|
|
60
|
+
progress.set(reduceMotion ? 1 : withTiming(1, {
|
|
61
|
+
duration: pressInMs,
|
|
62
|
+
easing: EASE_OUT
|
|
63
|
+
}));
|
|
64
|
+
};
|
|
65
|
+
$[2] = pressInMs;
|
|
66
|
+
$[3] = progress;
|
|
67
|
+
$[4] = reduceMotion;
|
|
68
|
+
$[5] = t9;
|
|
69
|
+
} else {
|
|
70
|
+
t9 = $[5];
|
|
71
|
+
}
|
|
72
|
+
const onPressIn = t9;
|
|
73
|
+
let t10;
|
|
74
|
+
if ($[6] !== pressOutMs || $[7] !== progress || $[8] !== reduceMotion) {
|
|
75
|
+
t10 = () => {
|
|
76
|
+
progress.set(reduceMotion ? 0 : withTiming(0, {
|
|
77
|
+
duration: pressOutMs,
|
|
78
|
+
easing: EASE_OUT
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
$[6] = pressOutMs;
|
|
82
|
+
$[7] = progress;
|
|
83
|
+
$[8] = reduceMotion;
|
|
84
|
+
$[9] = t10;
|
|
85
|
+
} else {
|
|
86
|
+
t10 = $[9];
|
|
87
|
+
}
|
|
88
|
+
const onPressOut = t10;
|
|
89
|
+
let t11;
|
|
90
|
+
let t12;
|
|
91
|
+
if ($[10] !== disabled || $[11] !== progress) {
|
|
92
|
+
t11 = () => {
|
|
93
|
+
if (disabled) {
|
|
94
|
+
progress.set(0);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
t12 = [disabled, progress];
|
|
98
|
+
$[10] = disabled;
|
|
99
|
+
$[11] = progress;
|
|
100
|
+
$[12] = t11;
|
|
101
|
+
$[13] = t12;
|
|
102
|
+
} else {
|
|
103
|
+
t11 = $[12];
|
|
104
|
+
t12 = $[13];
|
|
105
|
+
}
|
|
106
|
+
useEffect(t11, t12);
|
|
107
|
+
const style = useAnimatedStyle(() => {
|
|
108
|
+
const p = progress.get();
|
|
109
|
+
return {
|
|
110
|
+
opacity: restOpacity * (1 - p * (1 - target)),
|
|
111
|
+
transform: [{
|
|
112
|
+
scale: reduceMotion ? 1 : 1 - p * (1 - scale)
|
|
113
|
+
}]
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
let t13;
|
|
117
|
+
if ($[14] !== onPressIn || $[15] !== onPressOut || $[16] !== style) {
|
|
118
|
+
t13 = {
|
|
119
|
+
style,
|
|
120
|
+
onPressIn,
|
|
121
|
+
onPressOut
|
|
122
|
+
};
|
|
123
|
+
$[14] = onPressIn;
|
|
124
|
+
$[15] = onPressOut;
|
|
125
|
+
$[16] = style;
|
|
126
|
+
$[17] = t13;
|
|
127
|
+
} else {
|
|
128
|
+
t13 = $[17];
|
|
129
|
+
}
|
|
130
|
+
return t13;
|
|
131
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import * as Slot from "@rn-primitives/slot";
|
|
3
3
|
import { createContext, Fragment, useContext, useEffect, useState } from "react";
|
|
4
|
-
import { Modal, Pressable, StyleSheet
|
|
5
|
-
import Animated from "react-native-reanimated";
|
|
4
|
+
import { Modal, Pressable, StyleSheet } from "react-native";
|
|
5
|
+
import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
6
6
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
7
7
|
import { palette } from "../palette";
|
|
8
8
|
import { KeyboardAvoidingView, KeyboardLiftContext } from "./keyboard-parts";
|
|
9
|
+
import { DIALOG_ENTER, DIALOG_EXIT, PANEL_SCALE_FROM } from "../motion";
|
|
9
10
|
import { useReduceMotion } from "../useReduceMotion";
|
|
10
11
|
import { useScheme } from "../useScheme";
|
|
11
12
|
import { SheetDragProvider, SheetGestureContext, slideSheetIn, slideSheetOut, useSheetBackdropStyle, useSheetDragState } from "./sheet-drag";
|
|
@@ -152,7 +153,9 @@ export function OverlayClose(props) {
|
|
|
152
153
|
* RN `Modal` with a tinted backdrop, safe-area padding and keyboard avoidance
|
|
153
154
|
* (`KeyboardAvoidingView`: frame by frame with `KeyboardControllerProvider`).
|
|
154
155
|
* `placement="center"` centres the child (dialogs) inside the insets on every
|
|
155
|
-
* side
|
|
156
|
+
* side: the backdrop fades while the panel scales from 0.96 and fades in (200
|
|
157
|
+
* ms on open, 150 ms on close), and the `Modal` stays up until it is out of
|
|
158
|
+
* sight. `"bottom"` pins it to the bottom
|
|
156
159
|
* edge (sheets), which pad their own bottom inset: the sheet slides up on
|
|
157
160
|
* open and back down on close, however it closes, and may be dragged down to
|
|
158
161
|
* close (`SheetDragView`); the backdrop fades with the sheet's position. The
|
|
@@ -179,11 +182,12 @@ export function OverlayModal(t0) {
|
|
|
179
182
|
} = useOverlay(part);
|
|
180
183
|
const reduceMotion = useReduceMotion();
|
|
181
184
|
const slides = placement === "bottom" && !reduceMotion;
|
|
185
|
+
const scales = placement === "center" && !reduceMotion;
|
|
182
186
|
const [shown, setShown] = useState(open);
|
|
183
187
|
if (open && !shown) {
|
|
184
188
|
setShown(true);
|
|
185
189
|
}
|
|
186
|
-
if (!open && shown && !slides) {
|
|
190
|
+
if (!open && shown && !slides && !scales) {
|
|
187
191
|
setShown(false);
|
|
188
192
|
}
|
|
189
193
|
let t1;
|
|
@@ -196,61 +200,61 @@ export function OverlayModal(t0) {
|
|
|
196
200
|
}
|
|
197
201
|
const close = t1;
|
|
198
202
|
const ModalRoot = useContext(SheetGestureContext)?.ModalRoot ?? Fragment;
|
|
199
|
-
|
|
200
|
-
let t3;
|
|
203
|
+
let t2;
|
|
201
204
|
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
202
|
-
|
|
203
|
-
$[2] =
|
|
205
|
+
t2 = () => setShown(false);
|
|
206
|
+
$[2] = t2;
|
|
204
207
|
} else {
|
|
205
|
-
|
|
208
|
+
t2 = $[2];
|
|
206
209
|
}
|
|
207
|
-
let
|
|
208
|
-
if ($[3] !== children || $[4] !== close || $[5] !== dismissible || $[6] !== open || $[7] !== part || $[8] !== placement || $[9] !== slides) {
|
|
209
|
-
|
|
210
|
+
let t3;
|
|
211
|
+
if ($[3] !== children || $[4] !== close || $[5] !== dismissible || $[6] !== open || $[7] !== part || $[8] !== placement || $[9] !== scales || $[10] !== slides) {
|
|
212
|
+
t3 = <OverlayModalBody placement={placement} dismissible={dismissible} open={open} slides={slides} scales={scales} close={close} onHidden={t2} part={part}>{children}</OverlayModalBody>;
|
|
210
213
|
$[3] = children;
|
|
211
214
|
$[4] = close;
|
|
212
215
|
$[5] = dismissible;
|
|
213
216
|
$[6] = open;
|
|
214
217
|
$[7] = part;
|
|
215
218
|
$[8] = placement;
|
|
216
|
-
$[9] =
|
|
217
|
-
$[10] =
|
|
219
|
+
$[9] = scales;
|
|
220
|
+
$[10] = slides;
|
|
221
|
+
$[11] = t3;
|
|
218
222
|
} else {
|
|
219
|
-
|
|
223
|
+
t3 = $[11];
|
|
220
224
|
}
|
|
221
|
-
let
|
|
222
|
-
if ($[
|
|
223
|
-
|
|
224
|
-
$[
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
225
|
+
let t4;
|
|
226
|
+
if ($[12] !== ModalRoot || $[13] !== t3) {
|
|
227
|
+
t4 = <ModalRoot>{t3}</ModalRoot>;
|
|
228
|
+
$[12] = ModalRoot;
|
|
229
|
+
$[13] = t3;
|
|
230
|
+
$[14] = t4;
|
|
227
231
|
} else {
|
|
228
|
-
|
|
232
|
+
t4 = $[14];
|
|
229
233
|
}
|
|
230
|
-
let
|
|
231
|
-
if ($[
|
|
232
|
-
|
|
233
|
-
$[
|
|
234
|
-
$[
|
|
235
|
-
$[
|
|
236
|
-
$[
|
|
237
|
-
$[
|
|
238
|
-
$[19] = t6;
|
|
234
|
+
let t5;
|
|
235
|
+
if ($[15] !== close || $[16] !== onShow || $[17] !== shown || $[18] !== t4) {
|
|
236
|
+
t5 = <Modal visible={shown} transparent={true} animationType="none" statusBarTranslucent={true} onRequestClose={close} onShow={onShow}>{t4}</Modal>;
|
|
237
|
+
$[15] = close;
|
|
238
|
+
$[16] = onShow;
|
|
239
|
+
$[17] = shown;
|
|
240
|
+
$[18] = t4;
|
|
241
|
+
$[19] = t5;
|
|
239
242
|
} else {
|
|
240
|
-
|
|
243
|
+
t5 = $[19];
|
|
241
244
|
}
|
|
242
|
-
return
|
|
245
|
+
return t5;
|
|
243
246
|
}
|
|
244
247
|
|
|
245
248
|
/** The `Modal`'s content: mounted with each opening, so a sheet starts below the screen (or at rest). */
|
|
246
249
|
function OverlayModalBody(t0) {
|
|
247
|
-
const $ = _c(
|
|
250
|
+
const $ = _c(48);
|
|
248
251
|
const {
|
|
249
252
|
part,
|
|
250
253
|
placement,
|
|
251
254
|
dismissible,
|
|
252
255
|
open,
|
|
253
256
|
slides,
|
|
257
|
+
scales,
|
|
254
258
|
close,
|
|
255
259
|
onHidden,
|
|
256
260
|
children
|
|
@@ -258,7 +262,18 @@ function OverlayModalBody(t0) {
|
|
|
258
262
|
const scheme = useScheme();
|
|
259
263
|
const insets = useSafeAreaInsets();
|
|
260
264
|
const drag = useSheetDragState(close, slides);
|
|
261
|
-
const
|
|
265
|
+
const sheetBackdropStyle = useSheetBackdropStyle(drag);
|
|
266
|
+
const progress = useSharedValue(scales ? 0 : 1);
|
|
267
|
+
const centreBackdropStyle = useAnimatedStyle(() => ({
|
|
268
|
+
opacity: progress.get()
|
|
269
|
+
}));
|
|
270
|
+
const centrePanelStyle = useAnimatedStyle(() => ({
|
|
271
|
+
opacity: progress.get(),
|
|
272
|
+
transform: [{
|
|
273
|
+
scale: PANEL_SCALE_FROM + (1 - PANEL_SCALE_FROM) * progress.get()
|
|
274
|
+
}]
|
|
275
|
+
}));
|
|
276
|
+
const backdropStyle = placement === "center" ? centreBackdropStyle : sheetBackdropStyle;
|
|
262
277
|
let t1;
|
|
263
278
|
if ($[0] !== drag || $[1] !== onHidden || $[2] !== open || $[3] !== slides) {
|
|
264
279
|
t1 = () => {
|
|
@@ -289,51 +304,87 @@ function OverlayModalBody(t0) {
|
|
|
289
304
|
t2 = $[7];
|
|
290
305
|
}
|
|
291
306
|
useEffect(t1, t2);
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
307
|
+
let t3;
|
|
308
|
+
if ($[8] !== onHidden || $[9] !== open || $[10] !== progress || $[11] !== scales) {
|
|
309
|
+
t3 = () => {
|
|
310
|
+
if (!scales) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
if (open) {
|
|
314
|
+
progress.set(withTiming(1, DIALOG_ENTER));
|
|
315
|
+
} else {
|
|
316
|
+
progress.set(withTiming(0, DIALOG_EXIT, finished => {
|
|
317
|
+
"worklet";
|
|
318
|
+
|
|
319
|
+
if (finished) {
|
|
320
|
+
runOnJS(onHidden)();
|
|
321
|
+
}
|
|
322
|
+
}));
|
|
323
|
+
}
|
|
297
324
|
};
|
|
298
|
-
$[8] =
|
|
299
|
-
$[9] =
|
|
325
|
+
$[8] = onHidden;
|
|
326
|
+
$[9] = open;
|
|
327
|
+
$[10] = progress;
|
|
328
|
+
$[11] = scales;
|
|
329
|
+
$[12] = t3;
|
|
300
330
|
} else {
|
|
301
|
-
|
|
331
|
+
t3 = $[12];
|
|
302
332
|
}
|
|
303
|
-
let
|
|
304
|
-
if ($[
|
|
305
|
-
|
|
306
|
-
$[
|
|
307
|
-
$[
|
|
308
|
-
$[
|
|
333
|
+
let t4;
|
|
334
|
+
if ($[13] !== open || $[14] !== scales) {
|
|
335
|
+
t4 = [open, scales];
|
|
336
|
+
$[13] = open;
|
|
337
|
+
$[14] = scales;
|
|
338
|
+
$[15] = t4;
|
|
309
339
|
} else {
|
|
310
|
-
|
|
340
|
+
t4 = $[15];
|
|
311
341
|
}
|
|
312
|
-
|
|
313
|
-
const
|
|
314
|
-
let
|
|
315
|
-
if ($[
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
$[
|
|
320
|
-
$[
|
|
321
|
-
$[17] = t8;
|
|
342
|
+
useEffect(t3, t4);
|
|
343
|
+
const t5 = palette.backdrop[scheme];
|
|
344
|
+
let t6;
|
|
345
|
+
if ($[16] !== t5) {
|
|
346
|
+
t6 = {
|
|
347
|
+
backgroundColor: t5
|
|
348
|
+
};
|
|
349
|
+
$[16] = t5;
|
|
350
|
+
$[17] = t6;
|
|
322
351
|
} else {
|
|
323
|
-
|
|
352
|
+
t6 = $[17];
|
|
324
353
|
}
|
|
325
|
-
let
|
|
326
|
-
if ($[18] !==
|
|
327
|
-
|
|
328
|
-
$[18] =
|
|
329
|
-
$[19] =
|
|
330
|
-
$[20] =
|
|
354
|
+
let t7;
|
|
355
|
+
if ($[18] !== backdropStyle || $[19] !== t6) {
|
|
356
|
+
t7 = [StyleSheet.absoluteFill, t6, backdropStyle];
|
|
357
|
+
$[18] = backdropStyle;
|
|
358
|
+
$[19] = t6;
|
|
359
|
+
$[20] = t7;
|
|
331
360
|
} else {
|
|
332
|
-
|
|
361
|
+
t7 = $[20];
|
|
333
362
|
}
|
|
363
|
+
const t8 = `${part}-backdrop`;
|
|
364
|
+
const t9 = !dismissible;
|
|
334
365
|
let t10;
|
|
335
|
-
if ($[21] !==
|
|
336
|
-
t10 =
|
|
366
|
+
if ($[21] !== close || $[22] !== dismissible || $[23] !== t8 || $[24] !== t9) {
|
|
367
|
+
t10 = <Pressable testID={t8} accessible={dismissible} accessibilityRole="button" accessibilityLabel="Close" disabled={t9} onPress={close} style={StyleSheet.absoluteFill} />;
|
|
368
|
+
$[21] = close;
|
|
369
|
+
$[22] = dismissible;
|
|
370
|
+
$[23] = t8;
|
|
371
|
+
$[24] = t9;
|
|
372
|
+
$[25] = t10;
|
|
373
|
+
} else {
|
|
374
|
+
t10 = $[25];
|
|
375
|
+
}
|
|
376
|
+
let t11;
|
|
377
|
+
if ($[26] !== t10 || $[27] !== t7) {
|
|
378
|
+
t11 = <Animated.View pointerEvents="box-none" style={t7}>{t10}</Animated.View>;
|
|
379
|
+
$[26] = t10;
|
|
380
|
+
$[27] = t7;
|
|
381
|
+
$[28] = t11;
|
|
382
|
+
} else {
|
|
383
|
+
t11 = $[28];
|
|
384
|
+
}
|
|
385
|
+
let t12;
|
|
386
|
+
if ($[29] !== insets.bottom || $[30] !== insets.left || $[31] !== insets.right || $[32] !== insets.top || $[33] !== placement) {
|
|
387
|
+
t12 = placement === "bottom" ? {
|
|
337
388
|
justifyContent: "flex-end",
|
|
338
389
|
paddingTop: insets.top + 16,
|
|
339
390
|
paddingLeft: insets.left,
|
|
@@ -344,45 +395,55 @@ function OverlayModalBody(t0) {
|
|
|
344
395
|
paddingBottom: insets.bottom + 16,
|
|
345
396
|
paddingLeft: insets.left + 16,
|
|
346
397
|
paddingRight: insets.right + 16
|
|
347
|
-
}
|
|
348
|
-
$[
|
|
349
|
-
$[
|
|
350
|
-
$[
|
|
351
|
-
$[
|
|
352
|
-
$[
|
|
353
|
-
$[
|
|
398
|
+
};
|
|
399
|
+
$[29] = insets.bottom;
|
|
400
|
+
$[30] = insets.left;
|
|
401
|
+
$[31] = insets.right;
|
|
402
|
+
$[32] = insets.top;
|
|
403
|
+
$[33] = placement;
|
|
404
|
+
$[34] = t12;
|
|
354
405
|
} else {
|
|
355
|
-
|
|
406
|
+
t12 = $[34];
|
|
356
407
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
$[
|
|
362
|
-
$[
|
|
363
|
-
$[
|
|
408
|
+
const t13 = placement === "center" ? centrePanelStyle : null;
|
|
409
|
+
let t14;
|
|
410
|
+
if ($[35] !== t12 || $[36] !== t13) {
|
|
411
|
+
t14 = [styles.fill, t12, t13];
|
|
412
|
+
$[35] = t12;
|
|
413
|
+
$[36] = t13;
|
|
414
|
+
$[37] = t14;
|
|
364
415
|
} else {
|
|
365
|
-
|
|
416
|
+
t14 = $[37];
|
|
366
417
|
}
|
|
367
|
-
let
|
|
368
|
-
if ($[
|
|
369
|
-
|
|
370
|
-
$[
|
|
371
|
-
$[
|
|
372
|
-
$[
|
|
418
|
+
let t15;
|
|
419
|
+
if ($[38] !== children || $[39] !== close || $[40] !== t14) {
|
|
420
|
+
t15 = <Animated.View pointerEvents="box-none" onAccessibilityEscape={close} style={t14}>{children}</Animated.View>;
|
|
421
|
+
$[38] = children;
|
|
422
|
+
$[39] = close;
|
|
423
|
+
$[40] = t14;
|
|
424
|
+
$[41] = t15;
|
|
373
425
|
} else {
|
|
374
|
-
|
|
426
|
+
t15 = $[41];
|
|
375
427
|
}
|
|
376
|
-
let
|
|
377
|
-
if ($[
|
|
378
|
-
|
|
379
|
-
$[
|
|
380
|
-
$[
|
|
381
|
-
$[
|
|
428
|
+
let t16;
|
|
429
|
+
if ($[42] !== t11 || $[43] !== t15) {
|
|
430
|
+
t16 = <KeyboardAvoidingView style={styles.fill}><KeyboardLiftContext.Provider value={false}>{t11}{t15}</KeyboardLiftContext.Provider></KeyboardAvoidingView>;
|
|
431
|
+
$[42] = t11;
|
|
432
|
+
$[43] = t15;
|
|
433
|
+
$[44] = t16;
|
|
434
|
+
} else {
|
|
435
|
+
t16 = $[44];
|
|
436
|
+
}
|
|
437
|
+
let t17;
|
|
438
|
+
if ($[45] !== drag || $[46] !== t16) {
|
|
439
|
+
t17 = <SheetDragProvider value={drag}>{t16}</SheetDragProvider>;
|
|
440
|
+
$[45] = drag;
|
|
441
|
+
$[46] = t16;
|
|
442
|
+
$[47] = t17;
|
|
382
443
|
} else {
|
|
383
|
-
|
|
444
|
+
t17 = $[47];
|
|
384
445
|
}
|
|
385
|
-
return
|
|
446
|
+
return t17;
|
|
386
447
|
}
|
|
387
448
|
const styles = StyleSheet.create({
|
|
388
449
|
fill: {
|
|
@@ -6,6 +6,7 @@ import { IconCheck, IconChevronDown, IconChevronUp } from "@tabler/icons-react-n
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { Platform, ScrollView, StyleSheet, Text, View } from "react-native";
|
|
8
8
|
import { FadeIn, FadeOut } from "react-native-reanimated";
|
|
9
|
+
import { EASE_OUT } from "../motion";
|
|
9
10
|
import { NativeOnlyAnimatedView } from "./native-only-animated-view";
|
|
10
11
|
import { SelectHost } from "./select-host";
|
|
11
12
|
import { TextClassContext } from "./text";
|
|
@@ -155,6 +156,9 @@ const SelectTrigger = React.forwardRef((t0, ref) => {
|
|
|
155
156
|
}
|
|
156
157
|
return t8;
|
|
157
158
|
});
|
|
159
|
+
/** The popover fades in and out on the strong ease-out. */
|
|
160
|
+
const SELECT_ENTER = FadeIn.duration(150).easing(EASE_OUT);
|
|
161
|
+
const SELECT_EXIT = FadeOut.duration(100).easing(EASE_OUT);
|
|
158
162
|
const SelectContent = React.forwardRef((t0, ref) => {
|
|
159
163
|
const $ = _c(31);
|
|
160
164
|
let children;
|
|
@@ -252,7 +256,7 @@ const SelectContent = React.forwardRef((t0, ref) => {
|
|
|
252
256
|
}
|
|
253
257
|
let t11;
|
|
254
258
|
if ($[18] !== position || $[19] !== props || $[20] !== ref || $[21] !== t4 || $[22] !== t9) {
|
|
255
|
-
t11 = <SelectPrimitive.Overlay style={overlayFill}><TextClassContext.Provider value="text-popover-foreground"><NativeOnlyAnimatedView entering={
|
|
259
|
+
t11 = <SelectPrimitive.Overlay style={overlayFill}><TextClassContext.Provider value="text-popover-foreground"><NativeOnlyAnimatedView entering={SELECT_ENTER} exiting={SELECT_EXIT} className="z-50" style={overlayFill} pointerEvents={t3}><SelectPrimitive.Content ref={ref} position={position} className={t4} {...props}>{t5}{t6}{t9}{t10}</SelectPrimitive.Content></NativeOnlyAnimatedView></TextClassContext.Provider></SelectPrimitive.Overlay>;
|
|
256
260
|
$[18] = position;
|
|
257
261
|
$[19] = props;
|
|
258
262
|
$[20] = ref;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
|
|
6
6
|
"type": "module",
|
package/src/CaptureButton.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Pressable
|
|
1
|
+
import { Pressable } from "react-native";
|
|
2
|
+
import Animated from "react-native-reanimated";
|
|
2
3
|
import { cn } from "./cn";
|
|
4
|
+
import { usePressScale } from "./pressScale";
|
|
3
5
|
import { withAlpha } from "./palette";
|
|
4
6
|
import { tokens } from "./tokens";
|
|
5
7
|
|
|
@@ -16,7 +18,8 @@ export const CAPTURE_BUTTON = { size: 76, ring: 4, gap: 4 } as const;
|
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* A camera shutter: a 76 white ring around a white disc, for a live preview in
|
|
19
|
-
* light and dark alike. The disc
|
|
21
|
+
* light and dark alike. The disc eases down to 90% in 100 ms while pressed
|
|
22
|
+
* and back in 160 ms; with Reduce Motion it dims instead. Larger than the
|
|
20
23
|
* 44 target, so it needs no hit slop. A labelled button, dimmed and ignoring
|
|
21
24
|
* presses when `disabled`.
|
|
22
25
|
*/
|
|
@@ -28,6 +31,7 @@ export function CaptureButton({
|
|
|
28
31
|
}: CaptureButtonProps) {
|
|
29
32
|
const { size, ring, gap } = CAPTURE_BUTTON;
|
|
30
33
|
const inner = size - 2 * (ring + gap);
|
|
34
|
+
const press = usePressScale({ scale: 0.9, dim: 1, reducedDim: 0.7, pressInMs: 100, disabled });
|
|
31
35
|
return (
|
|
32
36
|
<Pressable
|
|
33
37
|
testID={testID}
|
|
@@ -36,6 +40,8 @@ export function CaptureButton({
|
|
|
36
40
|
accessibilityState={{ disabled }}
|
|
37
41
|
disabled={disabled}
|
|
38
42
|
onPress={onPress}
|
|
43
|
+
onPressIn={press.onPressIn}
|
|
44
|
+
onPressOut={press.onPressOut}
|
|
39
45
|
className={cn("items-center justify-center", disabled && "opacity-50")}
|
|
40
46
|
style={{
|
|
41
47
|
width: size,
|
|
@@ -46,17 +52,17 @@ export function CaptureButton({
|
|
|
46
52
|
backgroundColor: withAlpha(tokens.color.black, 0.15),
|
|
47
53
|
}}
|
|
48
54
|
>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
<Animated.View
|
|
56
|
+
style={[
|
|
57
|
+
{
|
|
52
58
|
width: inner,
|
|
53
59
|
height: inner,
|
|
54
60
|
borderRadius: inner / 2,
|
|
55
61
|
backgroundColor: tokens.color.white,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
},
|
|
63
|
+
press.style,
|
|
64
|
+
]}
|
|
65
|
+
/>
|
|
60
66
|
</Pressable>
|
|
61
67
|
);
|
|
62
68
|
}
|
package/src/Chip.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Text } from "react-native";
|
|
2
|
+
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
2
3
|
import { textStyle, typeStyle } from "./controlStyles";
|
|
3
4
|
import { useLargerText } from "./theme";
|
|
4
5
|
import { useScheme } from "./useScheme";
|
|
@@ -18,6 +19,7 @@ export function Chip({
|
|
|
18
19
|
}) {
|
|
19
20
|
const largerText = useLargerText();
|
|
20
21
|
const scheme = useScheme();
|
|
22
|
+
const press = usePressScale();
|
|
21
23
|
const size = round
|
|
22
24
|
? largerText
|
|
23
25
|
? "h-14 w-14"
|
|
@@ -26,13 +28,16 @@ export function Chip({
|
|
|
26
28
|
? "min-h-14 px-5 py-3"
|
|
27
29
|
: "min-h-12 px-4 py-2";
|
|
28
30
|
return (
|
|
29
|
-
<
|
|
31
|
+
<AnimatedPressable
|
|
30
32
|
testID={testID}
|
|
31
33
|
accessibilityRole="button"
|
|
32
34
|
accessibilityLabel={label}
|
|
33
35
|
accessibilityState={{ selected }}
|
|
34
36
|
onPress={onPress}
|
|
35
|
-
|
|
37
|
+
onPressIn={press.onPressIn}
|
|
38
|
+
onPressOut={press.onPressOut}
|
|
39
|
+
style={press.style}
|
|
40
|
+
className={`items-center justify-center rounded-full border border-white/40 dark:border-white/10 ${
|
|
36
41
|
size
|
|
37
42
|
} ${selected ? "bg-pink-100 dark:bg-pink-900/40" : "bg-secondary"}`}
|
|
38
43
|
>
|
|
@@ -46,6 +51,6 @@ export function Chip({
|
|
|
46
51
|
>
|
|
47
52
|
{label}
|
|
48
53
|
</Text>
|
|
49
|
-
</
|
|
54
|
+
</AnimatedPressable>
|
|
50
55
|
);
|
|
51
56
|
}
|