@vvedantb/native-ui 0.24.1 → 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.
@@ -1,6 +1,6 @@
1
1
  import { c as _c } from "react/compiler-runtime";
2
2
  import { useEffect } from "react";
3
- import { Modal, Pressable, StyleSheet, Text, View } from "react-native";
3
+ import { Pressable, StyleSheet, Text, View } from "react-native";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
  import { cn } from "../cn";
6
6
  import { MIN_TOUCH_TARGET, sizeStyle, textStyle, touchSlop, typeStyle } from "../controlStyles";
@@ -8,8 +8,9 @@ import { selectionHaptic } from "../haptics";
8
8
  import { palette } from "../palette";
9
9
  import { useLargerText } from "../theme";
10
10
  import { tokens } from "../tokens";
11
- import { useReduceMotion } from "../useReduceMotion";
12
11
  import { useScheme } from "../useScheme";
12
+ import { OverlayModal, OverlayRoot } from "../primitives/overlay";
13
+ import { SheetDragView } from "../primitives/sheet-drag";
13
14
  import { chatTextSize } from "./chat-text";
14
15
 
15
16
  /** One row of `MessageActionSheet`. */
@@ -18,13 +19,14 @@ import { chatTextSize } from "./chat-text";
18
19
  export const MESSAGE_ACTIONS_TITLE = "Message actions";
19
20
  /**
20
21
  * The sheet that opens on a long press of a chat message: a bottom sheet in
21
- * an RN `Modal` (no bottom-sheet library) with one pressable row per action
22
- * and a Cancel row. It closes on the backdrop, Cancel, Android back and after
22
+ * the kit's `OverlayModal` (an RN `Modal`, no bottom-sheet library) with one row per action
23
+ * and a Cancel row. It slides up and down as `Sheet` does (a drag down closes it too; with
24
+ * Reduce Motion on it appears and leaves in place). It closes on the backdrop, Cancel, Android back and after
23
25
  * an action. A `selectionHaptic()` fires when it opens (`expo-haptics` is an
24
26
  * optional peer). Row testIDs are `{testID}-action-{key}`.
25
27
  */
26
28
  export function MessageActionSheet(t0) {
27
- const $ = _c(112);
29
+ const $ = _c(106);
28
30
  const {
29
31
  open,
30
32
  onClose,
@@ -39,7 +41,6 @@ export function MessageActionSheet(t0) {
39
41
  const scheme = useScheme();
40
42
  const largerText = useLargerText();
41
43
  const insets = useSafeAreaInsets();
42
- const reduceMotion = useReduceMotion();
43
44
  let t4;
44
45
  let t5;
45
46
  if ($[0] !== open) {
@@ -62,6 +63,7 @@ export function MessageActionSheet(t0) {
62
63
  let T2;
63
64
  let T3;
64
65
  let T4;
66
+ let T5;
65
67
  let t10;
66
68
  let t11;
67
69
  let t12;
@@ -80,119 +82,99 @@ export function MessageActionSheet(t0) {
80
82
  let t25;
81
83
  let t26;
82
84
  let t27;
83
- let t28;
84
- let t29;
85
85
  let t6;
86
86
  let t7;
87
87
  let t8;
88
88
  let t9;
89
- if ($[3] !== actions || $[4] !== cancelLabel || $[5] !== insets.bottom || $[6] !== largerText || $[7] !== onClose || $[8] !== open || $[9] !== reduceMotion || $[10] !== scheme || $[11] !== testID || $[12] !== title) {
89
+ if ($[3] !== actions || $[4] !== cancelLabel || $[5] !== insets.bottom || $[6] !== largerText || $[7] !== onClose || $[8] !== open || $[9] !== scheme || $[10] !== testID || $[11] !== title) {
90
90
  const caption = chatTextSize("caption", largerText);
91
91
  const body = chatTextSize("body", largerText);
92
92
  const minHeight = largerText ? 56 : MIN_TOUCH_TARGET + 4;
93
- T4 = Modal;
94
- t24 = open;
95
- t25 = true;
96
- t26 = reduceMotion ? "none" : "fade";
97
- t27 = true;
98
- t28 = onClose;
99
- const t30 = `${testID}-backdrop`;
100
- let t31;
101
- if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
102
- t31 = touchSlop(MIN_TOUCH_TARGET);
103
- $[42] = t31;
104
- } else {
105
- t31 = $[42];
106
- }
107
- const t32 = palette.backdrop[scheme];
108
- let t33;
109
- if ($[43] !== t32) {
110
- t33 = [StyleSheet.absoluteFill, {
111
- backgroundColor: t32
112
- }];
113
- $[43] = t32;
114
- $[44] = t33;
115
- } else {
116
- t33 = $[44];
117
- }
118
- if ($[45] !== onClose || $[46] !== t30 || $[47] !== t33) {
119
- t29 = <Pressable testID={t30} accessibilityRole="button" accessibilityLabel="Close" onPress={onClose} hitSlop={t31} style={t33} />;
120
- $[45] = onClose;
121
- $[46] = t30;
122
- $[47] = t33;
123
- $[48] = t29;
93
+ T5 = OverlayRoot;
94
+ t26 = open;
95
+ if ($[40] !== onClose) {
96
+ t27 = next => {
97
+ if (!next) {
98
+ onClose();
99
+ }
100
+ };
101
+ $[40] = onClose;
102
+ $[41] = t27;
124
103
  } else {
125
- t29 = $[48];
104
+ t27 = $[41];
126
105
  }
127
- T3 = View;
128
- t22 = "box-none";
129
- t23 = styles.anchor;
106
+ T4 = OverlayModal;
107
+ t23 = testID;
108
+ t24 = "bottom";
109
+ t25 = true;
110
+ T3 = SheetDragView;
111
+ t22 = true;
130
112
  T2 = View;
131
113
  t15 = testID;
132
114
  t16 = true;
133
115
  t17 = title;
134
116
  t18 = onClose;
135
117
  t19 = "w-full self-center px-2";
136
- const t34 = insets.bottom + 8;
137
- if ($[49] !== t34) {
118
+ const t28 = insets.bottom + 8;
119
+ if ($[42] !== t28) {
138
120
  t20 = {
139
121
  maxWidth: 480,
140
- paddingBottom: t34
122
+ paddingBottom: t28
141
123
  };
142
- $[49] = t34;
143
- $[50] = t20;
124
+ $[42] = t28;
125
+ $[43] = t20;
144
126
  } else {
145
- t20 = $[50];
127
+ t20 = $[43];
146
128
  }
147
- const t35 = tokens.color.surface[scheme];
148
- let t36;
149
- if ($[51] !== t35) {
150
- t36 = {
151
- backgroundColor: t35,
129
+ const t29 = tokens.color.surface[scheme];
130
+ let t30;
131
+ if ($[44] !== t29) {
132
+ t30 = {
133
+ backgroundColor: t29,
152
134
  borderRadius: tokens.radius.card
153
135
  };
154
- $[51] = t35;
155
- $[52] = t36;
136
+ $[44] = t29;
137
+ $[45] = t30;
156
138
  } else {
157
- t36 = $[52];
139
+ t30 = $[45];
158
140
  }
159
- const t37 = cn(caption, "px-4 pb-1 pt-3 font-instrument-sans-medium");
160
- const t38 = sizeStyle(caption);
161
- let t39;
162
- if ($[53] === Symbol.for("react.memo_cache_sentinel")) {
163
- t39 = typeStyle("medium");
164
- $[53] = t39;
141
+ const t31 = cn(caption, "px-4 pb-1 pt-3 font-instrument-sans-medium");
142
+ const t32 = sizeStyle(caption);
143
+ let t33;
144
+ if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
145
+ t33 = typeStyle("medium");
146
+ $[46] = t33;
165
147
  } else {
166
- t39 = $[53];
148
+ t33 = $[46];
167
149
  }
168
- let t40;
169
- if ($[54] !== scheme) {
170
- t40 = textStyle("muted", scheme);
171
- $[54] = scheme;
172
- $[55] = t40;
150
+ let t34;
151
+ if ($[47] !== scheme) {
152
+ t34 = textStyle("muted", scheme);
153
+ $[47] = scheme;
154
+ $[48] = t34;
173
155
  } else {
174
- t40 = $[55];
156
+ t34 = $[48];
175
157
  }
176
- let t41;
177
- if ($[56] !== t38 || $[57] !== t40) {
178
- t41 = [t38, t39, t40];
179
- $[56] = t38;
180
- $[57] = t40;
181
- $[58] = t41;
158
+ let t35;
159
+ if ($[49] !== t32 || $[50] !== t34) {
160
+ t35 = [t32, t33, t34];
161
+ $[49] = t32;
162
+ $[50] = t34;
163
+ $[51] = t35;
182
164
  } else {
183
- t41 = $[58];
165
+ t35 = $[51];
184
166
  }
185
- let t42;
186
- if ($[59] !== t37 || $[60] !== t41 || $[61] !== title) {
187
- t42 = <Text accessibilityRole="header" numberOfLines={1} className={t37} style={t41}>{title}</Text>;
188
- $[59] = t37;
189
- $[60] = t41;
190
- $[61] = title;
191
- $[62] = t42;
167
+ let t36;
168
+ if ($[52] !== t31 || $[53] !== t35 || $[54] !== title) {
169
+ t36 = <Text accessibilityRole="header" numberOfLines={1} className={t31} style={t35}>{title}</Text>;
170
+ $[52] = t31;
171
+ $[53] = t35;
172
+ $[54] = title;
173
+ $[55] = t36;
192
174
  } else {
193
- t42 = $[62];
175
+ t36 = $[55];
194
176
  }
195
- t21 = <View className="overflow-hidden" style={t36}>{t42}{actions.map((action, index) => {
177
+ t21 = <View className="overflow-hidden" style={t30}>{t36}{actions.map((action, index) => {
196
178
  const Icon = action.icon;
197
179
  const color = action.destructive ? palette.danger[scheme] : tokens.color.foreground[scheme];
198
180
  return <Pressable key={action.key} testID={`${testID}-action-${action.key}`} accessibilityRole="button" accessibilityLabel={action.label} hitSlop={touchSlop(MIN_TOUCH_TARGET)} onPress={() => {
@@ -212,25 +194,25 @@ export function MessageActionSheet(t0) {
212
194
  t9 = "button";
213
195
  t10 = cancelLabel;
214
196
  t11 = onClose;
215
- if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
197
+ if ($[56] === Symbol.for("react.memo_cache_sentinel")) {
216
198
  t12 = touchSlop(MIN_TOUCH_TARGET);
217
- $[63] = t12;
199
+ $[56] = t12;
218
200
  } else {
219
- t12 = $[63];
201
+ t12 = $[56];
220
202
  }
221
203
  t13 = "mt-2 items-center justify-center";
222
- const t43 = tokens.color.surface[scheme];
223
- if ($[64] !== minHeight || $[65] !== t43) {
204
+ const t37 = tokens.color.surface[scheme];
205
+ if ($[57] !== minHeight || $[58] !== t37) {
224
206
  t14 = {
225
207
  minHeight,
226
- backgroundColor: t43,
208
+ backgroundColor: t37,
227
209
  borderRadius: tokens.radius.card
228
210
  };
229
- $[64] = minHeight;
230
- $[65] = t43;
231
- $[66] = t14;
211
+ $[57] = minHeight;
212
+ $[58] = t37;
213
+ $[59] = t14;
232
214
  } else {
233
- t14 = $[66];
215
+ t14 = $[59];
234
216
  }
235
217
  T0 = Text;
236
218
  t7 = cn(body, "font-instrument-sans-semibold");
@@ -241,15 +223,15 @@ export function MessageActionSheet(t0) {
241
223
  $[6] = largerText;
242
224
  $[7] = onClose;
243
225
  $[8] = open;
244
- $[9] = reduceMotion;
245
- $[10] = scheme;
246
- $[11] = testID;
247
- $[12] = title;
248
- $[13] = T0;
249
- $[14] = T1;
250
- $[15] = T2;
251
- $[16] = T3;
252
- $[17] = T4;
226
+ $[9] = scheme;
227
+ $[10] = testID;
228
+ $[11] = title;
229
+ $[12] = T0;
230
+ $[13] = T1;
231
+ $[14] = T2;
232
+ $[15] = T3;
233
+ $[16] = T4;
234
+ $[17] = T5;
253
235
  $[18] = t10;
254
236
  $[19] = t11;
255
237
  $[20] = t12;
@@ -268,18 +250,17 @@ export function MessageActionSheet(t0) {
268
250
  $[33] = t25;
269
251
  $[34] = t26;
270
252
  $[35] = t27;
271
- $[36] = t28;
272
- $[37] = t29;
273
- $[38] = t6;
274
- $[39] = t7;
275
- $[40] = t8;
276
- $[41] = t9;
253
+ $[36] = t6;
254
+ $[37] = t7;
255
+ $[38] = t8;
256
+ $[39] = t9;
277
257
  } else {
278
- T0 = $[13];
279
- T1 = $[14];
280
- T2 = $[15];
281
- T3 = $[16];
282
- T4 = $[17];
258
+ T0 = $[12];
259
+ T1 = $[13];
260
+ T2 = $[14];
261
+ T3 = $[15];
262
+ T4 = $[16];
263
+ T5 = $[17];
283
264
  t10 = $[18];
284
265
  t11 = $[19];
285
266
  t12 = $[20];
@@ -298,111 +279,110 @@ export function MessageActionSheet(t0) {
298
279
  t25 = $[33];
299
280
  t26 = $[34];
300
281
  t27 = $[35];
301
- t28 = $[36];
302
- t29 = $[37];
303
- t6 = $[38];
304
- t7 = $[39];
305
- t8 = $[40];
306
- t9 = $[41];
282
+ t6 = $[36];
283
+ t7 = $[37];
284
+ t8 = $[38];
285
+ t9 = $[39];
286
+ }
287
+ let t28;
288
+ if ($[60] === Symbol.for("react.memo_cache_sentinel")) {
289
+ t28 = typeStyle("semibold");
290
+ $[60] = t28;
291
+ } else {
292
+ t28 = $[60];
293
+ }
294
+ let t29;
295
+ if ($[61] !== scheme) {
296
+ t29 = textStyle("foreground", scheme);
297
+ $[61] = scheme;
298
+ $[62] = t29;
299
+ } else {
300
+ t29 = $[62];
307
301
  }
308
302
  let t30;
309
- if ($[67] === Symbol.for("react.memo_cache_sentinel")) {
310
- t30 = typeStyle("semibold");
311
- $[67] = t30;
303
+ if ($[63] !== t29 || $[64] !== t6) {
304
+ t30 = [t6, t28, t29];
305
+ $[63] = t29;
306
+ $[64] = t6;
307
+ $[65] = t30;
312
308
  } else {
313
- t30 = $[67];
309
+ t30 = $[65];
314
310
  }
315
311
  let t31;
316
- if ($[68] !== scheme) {
317
- t31 = textStyle("foreground", scheme);
318
- $[68] = scheme;
319
- $[69] = t31;
312
+ if ($[66] !== T0 || $[67] !== cancelLabel || $[68] !== t30 || $[69] !== t7) {
313
+ t31 = <T0 className={t7} style={t30}>{cancelLabel}</T0>;
314
+ $[66] = T0;
315
+ $[67] = cancelLabel;
316
+ $[68] = t30;
317
+ $[69] = t7;
318
+ $[70] = t31;
320
319
  } else {
321
- t31 = $[69];
320
+ t31 = $[70];
322
321
  }
323
322
  let t32;
324
- if ($[70] !== t31 || $[71] !== t6) {
325
- t32 = [t6, t30, t31];
326
- $[70] = t31;
327
- $[71] = t6;
328
- $[72] = t32;
323
+ if ($[71] !== T1 || $[72] !== t10 || $[73] !== t11 || $[74] !== t12 || $[75] !== t13 || $[76] !== t14 || $[77] !== t31 || $[78] !== t8 || $[79] !== t9) {
324
+ t32 = <T1 testID={t8} accessibilityRole={t9} accessibilityLabel={t10} onPress={t11} hitSlop={t12} className={t13} style={t14}>{t31}</T1>;
325
+ $[71] = T1;
326
+ $[72] = t10;
327
+ $[73] = t11;
328
+ $[74] = t12;
329
+ $[75] = t13;
330
+ $[76] = t14;
331
+ $[77] = t31;
332
+ $[78] = t8;
333
+ $[79] = t9;
334
+ $[80] = t32;
329
335
  } else {
330
- t32 = $[72];
336
+ t32 = $[80];
331
337
  }
332
338
  let t33;
333
- if ($[73] !== T0 || $[74] !== cancelLabel || $[75] !== t32 || $[76] !== t7) {
334
- t33 = <T0 className={t7} style={t32}>{cancelLabel}</T0>;
335
- $[73] = T0;
336
- $[74] = cancelLabel;
337
- $[75] = t32;
338
- $[76] = t7;
339
- $[77] = t33;
339
+ if ($[81] !== T2 || $[82] !== t15 || $[83] !== t16 || $[84] !== t17 || $[85] !== t18 || $[86] !== t19 || $[87] !== t20 || $[88] !== t21 || $[89] !== t32) {
340
+ t33 = <T2 testID={t15} accessibilityViewIsModal={t16} accessibilityLabel={t17} onAccessibilityEscape={t18} className={t19} style={t20}>{t21}{t32}</T2>;
341
+ $[81] = T2;
342
+ $[82] = t15;
343
+ $[83] = t16;
344
+ $[84] = t17;
345
+ $[85] = t18;
346
+ $[86] = t19;
347
+ $[87] = t20;
348
+ $[88] = t21;
349
+ $[89] = t32;
350
+ $[90] = t33;
340
351
  } else {
341
- t33 = $[77];
352
+ t33 = $[90];
342
353
  }
343
354
  let t34;
344
- if ($[78] !== T1 || $[79] !== t10 || $[80] !== t11 || $[81] !== t12 || $[82] !== t13 || $[83] !== t14 || $[84] !== t33 || $[85] !== t8 || $[86] !== t9) {
345
- t34 = <T1 testID={t8} accessibilityRole={t9} accessibilityLabel={t10} onPress={t11} hitSlop={t12} className={t13} style={t14}>{t33}</T1>;
346
- $[78] = T1;
347
- $[79] = t10;
348
- $[80] = t11;
349
- $[81] = t12;
350
- $[82] = t13;
351
- $[83] = t14;
352
- $[84] = t33;
353
- $[85] = t8;
354
- $[86] = t9;
355
- $[87] = t34;
355
+ if ($[91] !== T3 || $[92] !== t22 || $[93] !== t33) {
356
+ t34 = <T3 enabled={t22}>{t33}</T3>;
357
+ $[91] = T3;
358
+ $[92] = t22;
359
+ $[93] = t33;
360
+ $[94] = t34;
356
361
  } else {
357
- t34 = $[87];
362
+ t34 = $[94];
358
363
  }
359
364
  let t35;
360
- if ($[88] !== T2 || $[89] !== t15 || $[90] !== t16 || $[91] !== t17 || $[92] !== t18 || $[93] !== t19 || $[94] !== t20 || $[95] !== t21 || $[96] !== t34) {
361
- t35 = <T2 testID={t15} accessibilityViewIsModal={t16} accessibilityLabel={t17} onAccessibilityEscape={t18} className={t19} style={t20}>{t21}{t34}</T2>;
362
- $[88] = T2;
363
- $[89] = t15;
364
- $[90] = t16;
365
- $[91] = t17;
366
- $[92] = t18;
367
- $[93] = t19;
368
- $[94] = t20;
369
- $[95] = t21;
370
- $[96] = t34;
371
- $[97] = t35;
365
+ if ($[95] !== T4 || $[96] !== t23 || $[97] !== t24 || $[98] !== t25 || $[99] !== t34) {
366
+ t35 = <T4 part={t23} placement={t24} dismissible={t25}>{t34}</T4>;
367
+ $[95] = T4;
368
+ $[96] = t23;
369
+ $[97] = t24;
370
+ $[98] = t25;
371
+ $[99] = t34;
372
+ $[100] = t35;
372
373
  } else {
373
- t35 = $[97];
374
+ t35 = $[100];
374
375
  }
375
376
  let t36;
376
- if ($[98] !== T3 || $[99] !== t22 || $[100] !== t23 || $[101] !== t35) {
377
- t36 = <T3 pointerEvents={t22} style={t23}>{t35}</T3>;
378
- $[98] = T3;
379
- $[99] = t22;
380
- $[100] = t23;
381
- $[101] = t35;
382
- $[102] = t36;
377
+ if ($[101] !== T5 || $[102] !== t26 || $[103] !== t27 || $[104] !== t35) {
378
+ t36 = <T5 open={t26} onOpenChange={t27}>{t35}</T5>;
379
+ $[101] = T5;
380
+ $[102] = t26;
381
+ $[103] = t27;
382
+ $[104] = t35;
383
+ $[105] = t36;
383
384
  } else {
384
- t36 = $[102];
385
+ t36 = $[105];
385
386
  }
386
- let t37;
387
- if ($[103] !== T4 || $[104] !== t24 || $[105] !== t25 || $[106] !== t26 || $[107] !== t27 || $[108] !== t28 || $[109] !== t29 || $[110] !== t36) {
388
- t37 = <T4 visible={t24} transparent={t25} animationType={t26} statusBarTranslucent={t27} onRequestClose={t28}>{t29}{t36}</T4>;
389
- $[103] = T4;
390
- $[104] = t24;
391
- $[105] = t25;
392
- $[106] = t26;
393
- $[107] = t27;
394
- $[108] = t28;
395
- $[109] = t29;
396
- $[110] = t36;
397
- $[111] = t37;
398
- } else {
399
- t37 = $[111];
400
- }
401
- return t37;
387
+ return t36;
402
388
  }
403
- const styles = StyleSheet.create({
404
- anchor: {
405
- flex: 1,
406
- justifyContent: "flex-end"
407
- }
408
- });
package/dist/motion.js CHANGED
@@ -31,3 +31,34 @@ export const SHEET_SNAP_SPRING = {
31
31
  export function usePressFeedback() {
32
32
  return useReduceMotion() ? "active:opacity-80" : "active:scale-[0.97]";
33
33
  }
34
+
35
+ /** Start scale of a popover or dialog panel as it opens: never from 0, as the `animate-expo` rules say. */
36
+ export const PANEL_SCALE_FROM = 0.96;
37
+
38
+ /** A menu panel opening from its trigger: opacity and scale together. */
39
+ export const POPOVER_ENTER = {
40
+ duration: 150,
41
+ easing: EASE_OUT,
42
+ reduceMotion: ReduceMotion.System
43
+ };
44
+
45
+ /** A menu panel leaving: a quick fade only. */
46
+ export const POPOVER_EXIT = {
47
+ duration: 100,
48
+ easing: EASE_OUT,
49
+ reduceMotion: ReduceMotion.System
50
+ };
51
+
52
+ /** A centred dialog opening: the backdrop fades while the panel scales and fades in. */
53
+ export const DIALOG_ENTER = {
54
+ duration: 200,
55
+ easing: EASE_OUT,
56
+ reduceMotion: ReduceMotion.System
57
+ };
58
+
59
+ /** A centred dialog closing. */
60
+ export const DIALOG_EXIT = {
61
+ duration: 150,
62
+ easing: EASE_OUT,
63
+ reduceMotion: ReduceMotion.System
64
+ };