glacia-native 0.5.0 → 0.5.1

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.
Files changed (63) hide show
  1. package/lib/module/Bars.js +95 -2
  2. package/lib/module/Display.js +78 -1
  3. package/lib/module/Feedback.js +221 -7
  4. package/lib/module/Forms2.js +228 -1
  5. package/lib/module/Message.js +88 -0
  6. package/lib/module/Overlays.js +173 -11
  7. package/lib/module/SegmentedControl.js +5 -1
  8. package/lib/module/Slider.js +6 -1
  9. package/lib/module/Switch.js +4 -1
  10. package/lib/module/TabBar.js +5 -1
  11. package/lib/module/ai.js +8 -3
  12. package/lib/module/index.js +23 -2
  13. package/lib/module/internal/GlassContainer.js +54 -0
  14. package/lib/module/internal/GlassView.js +8 -0
  15. package/lib/module/internal/a11y.js +94 -0
  16. package/lib/module/internal/fallback.js +19 -8
  17. package/lib/module/internal/glass-routing.js +7 -0
  18. package/lib/module/internal/haptics.js +54 -0
  19. package/lib/module/internal/motion.js +10 -1
  20. package/lib/module/internal/primitives.js +69 -4
  21. package/lib/module/internal/tokens.js +47 -1
  22. package/lib/typescript/Bars.d.ts +67 -0
  23. package/lib/typescript/Display.d.ts +59 -0
  24. package/lib/typescript/Feedback.d.ts +58 -0
  25. package/lib/typescript/Forms2.d.ts +81 -0
  26. package/lib/typescript/Message.d.ts +71 -0
  27. package/lib/typescript/Overlays.d.ts +41 -0
  28. package/lib/typescript/SegmentedControl.d.ts +2 -0
  29. package/lib/typescript/Slider.d.ts +2 -0
  30. package/lib/typescript/Switch.d.ts +2 -0
  31. package/lib/typescript/TabBar.d.ts +2 -0
  32. package/lib/typescript/index.d.ts +8 -6
  33. package/lib/typescript/internal/GlassContainer.d.ts +37 -0
  34. package/lib/typescript/internal/GlassView.d.ts +8 -0
  35. package/lib/typescript/internal/a11y.d.ts +19 -0
  36. package/lib/typescript/internal/fallback.d.ts +5 -0
  37. package/lib/typescript/internal/glass-routing.d.ts +10 -0
  38. package/lib/typescript/internal/haptics.d.ts +7 -0
  39. package/lib/typescript/internal/motion.d.ts +4 -0
  40. package/lib/typescript/internal/primitives.d.ts +21 -0
  41. package/lib/typescript/internal/tokens.d.ts +53 -0
  42. package/package.json +2 -2
  43. package/src/Bars.tsx +227 -0
  44. package/src/Display.tsx +229 -1
  45. package/src/Feedback.tsx +412 -22
  46. package/src/Forms2.tsx +407 -1
  47. package/src/Message.tsx +219 -0
  48. package/src/Overlays.tsx +244 -33
  49. package/src/SegmentedControl.tsx +6 -0
  50. package/src/Slider.tsx +7 -0
  51. package/src/Switch.tsx +5 -0
  52. package/src/TabBar.tsx +6 -0
  53. package/src/ai.tsx +9 -3
  54. package/src/index.ts +42 -1
  55. package/src/internal/GlassContainer.tsx +82 -0
  56. package/src/internal/GlassView.tsx +8 -0
  57. package/src/internal/a11y.ts +105 -0
  58. package/src/internal/fallback.tsx +19 -2
  59. package/src/internal/glass-routing.ts +17 -0
  60. package/src/internal/haptics.ts +59 -0
  61. package/src/internal/motion.ts +10 -1
  62. package/src/internal/primitives.ts +80 -4
  63. package/src/internal/tokens.ts +48 -0
package/src/Overlays.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { forwardRef, useCallback, useEffect, useState, type ReactNode } from "react";
1
+ import { forwardRef, useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from "react";
2
2
  import type { StyleProp, ViewStyle } from "react-native";
3
3
 
4
4
  import { Glass } from "./Glass";
@@ -6,6 +6,7 @@ import { Text } from "./Text";
6
6
  import { colors, radii } from "./internal/tokens";
7
7
  import { primitives } from "./internal/primitives";
8
8
  import { useIsDark, useSpring } from "./internal/motion";
9
+ import { hapticSelection } from "./internal/haptics";
9
10
 
10
11
  /**
11
12
  * Registers Android's hardware back while an overlay is open.
@@ -206,6 +207,24 @@ export interface SheetProps {
206
207
  dismissOnBackdropPress?: boolean;
207
208
  /** The drag handle at the top of the panel. */
208
209
  showHandle?: boolean;
210
+ /**
211
+ * Resting heights the sheet can settle at, smallest first. A number is
212
+ * points; a fraction below 1 is a share of the window height. With one
213
+ * point the sheet opens there; with several it can be dragged between them.
214
+ * Omitted, the sheet uses its own natural height.
215
+ */
216
+ snapPoints?: number[];
217
+ /** Which snap point to open at. Defaults to the first. */
218
+ initialSnapIndex?: number;
219
+ /** Controlled snap point. Omit and the sheet tracks its own. */
220
+ snapIndex?: number;
221
+ onSnapIndexChange?: (index: number) => void;
222
+ /** Dragging below the lowest point dismisses instead of springing back. */
223
+ dismissOnSnapToBottom?: boolean;
224
+ /** Turns the drag gesture off, leaving press-and-back dismissal only. */
225
+ draggable?: boolean;
226
+ /** Opt out of the selection tick on snap changes. */
227
+ haptics?: boolean;
209
228
  style?: StyleProp<ViewStyle>;
210
229
  isDark?: boolean;
211
230
  testID?: string;
@@ -219,6 +238,36 @@ export interface SheetProps {
219
238
  * specialisation of this shape; Sheet is for arbitrary content — a form, a
220
239
  * calendar, a detail panel.
221
240
  */
241
+ /**
242
+ * Turns a snap point into a pixel height.
243
+ *
244
+ * A number under 1 is a fraction of the window; anything else is points. The
245
+ * result is clamped so a sheet can never be taller than the space it has.
246
+ */
247
+ export function resolveSnapPoint(point: number, windowHeight: number): number {
248
+ const height = point > 0 && point < 1 ? point * windowHeight : point;
249
+ return Math.max(0, Math.min(height, windowHeight));
250
+ }
251
+
252
+ /**
253
+ * Picks the snap point nearest to where the user let go.
254
+ *
255
+ * `height` is how tall the sheet currently is. Ties go to the smaller sheet,
256
+ * so a small flick does not jump the panel to full height.
257
+ */
258
+ export function nearestSnapPoint(heights: number[], height: number): number {
259
+ let best = 0;
260
+ let bestDistance = Number.POSITIVE_INFINITY;
261
+ heights.forEach((candidate, index) => {
262
+ const distance = Math.abs(candidate - height);
263
+ if (distance < bestDistance) {
264
+ bestDistance = distance;
265
+ best = index;
266
+ }
267
+ });
268
+ return best;
269
+ }
270
+
222
271
  export const Sheet = forwardRef<any, SheetProps>(function Sheet(
223
272
  {
224
273
  open: openProp,
@@ -229,6 +278,13 @@ export const Sheet = forwardRef<any, SheetProps>(function Sheet(
229
278
  footer,
230
279
  dismissOnBackdropPress = true,
231
280
  showHandle = true,
281
+ snapPoints,
282
+ initialSnapIndex = 0,
283
+ snapIndex: snapIndexProp,
284
+ onSnapIndexChange,
285
+ dismissOnSnapToBottom = false,
286
+ draggable = true,
287
+ haptics = true,
232
288
  style,
233
289
  isDark: isDarkProp,
234
290
  testID,
@@ -238,7 +294,7 @@ export const Sheet = forwardRef<any, SheetProps>(function Sheet(
238
294
  ) {
239
295
  const isDark = useIsDark(isDarkProp);
240
296
  const theme = isDark ? colors.dark : colors.light;
241
- const { View, Text: RNText, Pressable, Modal } = primitives();
297
+ const { View, Text: RNText, Pressable, Modal, PanResponder, useWindowDimensions } = primitives();
242
298
 
243
299
  const [internalOpen, setInternalOpen] = useState(defaultOpen);
244
300
  const open = openProp !== undefined ? openProp : internalOpen;
@@ -254,9 +310,125 @@ export const Sheet = forwardRef<any, SheetProps>(function Sheet(
254
310
  const dismiss = useCallback(() => setOpen(false), [setOpen]);
255
311
  useBackDismiss(open, dismiss);
256
312
 
257
- // 0 is fully dismissed, 1 fully presented; the panel rides up this value.
313
+ // Snap points in pixels, smallest first so index 0 is the shortest sheet.
314
+ const windowHeight = useWindowDimensions?.().height ?? 800;
315
+ const heights = useMemo(() => {
316
+ if (!snapPoints || snapPoints.length === 0) return [];
317
+ return snapPoints.map((point) => resolveSnapPoint(point, windowHeight)).sort((a, b) => a - b);
318
+ }, [snapPoints, windowHeight]);
319
+
320
+ const [internalSnap, setInternalSnap] = useState(initialSnapIndex);
321
+ const snapIndex = snapIndexProp !== undefined ? snapIndexProp : internalSnap;
322
+ const activeHeight = heights.length > 0 ? heights[Math.min(snapIndex, heights.length - 1)]! : null;
323
+
324
+ // Drag offset in pixels: 0 is resting at the active snap point, positive is
325
+ // dragged down. It resets to 0 after a release, because the settle either
326
+ // changes the snap index or dismisses.
327
+ const dragRef = useRef(0);
328
+ const [drag, setDrag] = useState(0);
329
+
258
330
  const { value: rise, animated } = useSpring(open ? 1 : 0, "gentle");
259
- const translateY = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: [420, 0] }) : 0;
331
+ const slideIn = animated ? rise.interpolate({ inputRange: [0, 1], outputRange: [420, 0] }) : 0;
332
+
333
+ const heightsRef = useRef(heights);
334
+ heightsRef.current = heights;
335
+ const activeHeightRef = useRef(activeHeight);
336
+ activeHeightRef.current = activeHeight;
337
+ const snapIndexRef = useRef(snapIndex);
338
+ snapIndexRef.current = snapIndex;
339
+
340
+ const goToSnap = useCallback(
341
+ (index: number) => {
342
+ if (snapIndexProp === undefined) setInternalSnap(index);
343
+ onSnapIndexChange?.(index);
344
+ if (haptics) hapticSelection();
345
+ },
346
+ [snapIndexProp, onSnapIndexChange, haptics],
347
+ );
348
+
349
+ /**
350
+ * The release decision.
351
+ *
352
+ * Below the lowest snap point the sheet dismisses when allowed, otherwise it
353
+ * snaps back; anywhere else it settles at the nearest point, with a fast
354
+ * downward flick counting as a step towards the smaller sheet.
355
+ */
356
+ const release = useCallback(
357
+ (dy: number, vy: number) => {
358
+ const list = heightsRef.current;
359
+ const current = list[snapIndexRef.current] ?? activeHeightRef.current ?? 0;
360
+ const restingAfterDrag = current - dy;
361
+
362
+ if (list.length === 0) {
363
+ // No snap points: a decisive downward drag dismisses.
364
+ if (dy > 120 || vy > 0.8) dismiss();
365
+ return;
366
+ }
367
+
368
+ const lowest = list[0]!;
369
+ const belowLowest = restingAfterDrag < lowest - 40;
370
+ if (belowLowest && dismissOnSnapToBottom) {
371
+ dismiss();
372
+ return;
373
+ }
374
+
375
+ // A fast flick moves one step in its direction before distance decides.
376
+ let index = nearestSnapPoint(list, restingAfterDrag);
377
+ if (vy > 0.5) index = Math.max(0, Math.min(index, snapIndexRef.current - 1));
378
+ if (vy < -0.5) index = Math.max(index, Math.min(snapIndexRef.current + 1, list.length - 1));
379
+
380
+ if (index !== snapIndexRef.current) goToSnap(index);
381
+ },
382
+ [dismiss, dismissOnSnapToBottom, goToSnap],
383
+ );
384
+
385
+ const panResponder = useMemo(() => {
386
+ if (!draggable || !PanResponder?.create) return null;
387
+ return PanResponder.create({
388
+ // Vertical drags belong to the sheet; horizontal ones are left alone.
389
+ onStartShouldSetPanResponder: () => false,
390
+ onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
391
+ Math.abs(gesture.dy) > Math.abs(gesture.dx) && Math.abs(gesture.dy) > 6,
392
+ onPanResponderGrant: () => {
393
+ dragRef.current = 0;
394
+ },
395
+ onPanResponderMove: (_event: any, gesture: any) => {
396
+ // Dragging up past the tallest point has nowhere to go; clamp at 0.
397
+ const next = Math.max(-40, gesture.dy);
398
+ dragRef.current = next;
399
+ setDrag(next);
400
+ },
401
+ onPanResponderRelease: (_event: any, gesture: any) => {
402
+ release(gesture.dy, gesture.vy);
403
+ dragRef.current = 0;
404
+ setDrag(0);
405
+ },
406
+ onPanResponderTerminate: () => {
407
+ dragRef.current = 0;
408
+ setDrag(0);
409
+ },
410
+ onPanResponderTerminationRequest: () => false,
411
+ });
412
+ }, [draggable, PanResponder, release]);
413
+
414
+ // Reduce Motion is honoured by useSpring: when it is on, `animated` is false
415
+ // and the panel is already in position, so the sheet opens and snaps without
416
+ // a transition.
417
+ const translateY = drag !== 0 ? drag : animated ? slideIn : 0;
418
+
419
+ const panel = (
420
+ <SheetPanel
421
+ title={title}
422
+ footer={footer}
423
+ showHandle={showHandle}
424
+ isDark={isDark}
425
+ testID={testID}
426
+ style={style}
427
+ height={activeHeight}
428
+ >
429
+ {children}
430
+ </SheetPanel>
431
+ );
260
432
 
261
433
  return (
262
434
  <Modal visible={open} transparent animationType="fade" onRequestClose={dismiss}>
@@ -266,31 +438,16 @@ export const Sheet = forwardRef<any, SheetProps>(function Sheet(
266
438
  onPress={dismissOnBackdropPress ? dismiss : undefined}
267
439
  style={{ flex: 1, justifyContent: "flex-end", backgroundColor: theme.scrim }}
268
440
  >
269
- <Pressable accessibilityRole="none" onPress={() => {}} style={{ width: "100%" }}>
270
- {animated ? (
271
- <SheetRise translateY={translateY}>
272
- <SheetPanel
273
- title={title}
274
- footer={footer}
275
- showHandle={showHandle}
276
- isDark={isDark}
277
- testID={testID}
278
- style={style}
279
- >
280
- {children}
281
- </SheetPanel>
282
- </SheetRise>
441
+ <Pressable
442
+ accessibilityRole="none"
443
+ onPress={() => {}}
444
+ style={{ width: "100%" }}
445
+ {...(panResponder ? panResponder.panHandlers : {})}
446
+ >
447
+ {animated || drag !== 0 ? (
448
+ <SheetRise translateY={translateY}>{panel}</SheetRise>
283
449
  ) : (
284
- <SheetPanel
285
- title={title}
286
- footer={footer}
287
- showHandle={showHandle}
288
- isDark={isDark}
289
- testID={testID}
290
- style={style}
291
- >
292
- {children}
293
- </SheetPanel>
450
+ panel
294
451
  )}
295
452
  </Pressable>
296
453
  </Pressable>
@@ -311,6 +468,7 @@ function SheetPanel({
311
468
  isDark,
312
469
  testID,
313
470
  style,
471
+ height,
314
472
  children,
315
473
  }: {
316
474
  title?: string;
@@ -319,6 +477,8 @@ function SheetPanel({
319
477
  isDark: boolean;
320
478
  testID?: string;
321
479
  style?: StyleProp<ViewStyle>;
480
+ /** The snap point's height, or null for the panel's natural height. */
481
+ height?: number | null;
322
482
  children?: ReactNode;
323
483
  }) {
324
484
  const theme = isDark ? colors.dark : colors.light;
@@ -335,7 +495,8 @@ function SheetPanel({
335
495
  borderBottomLeftRadius: 0,
336
496
  borderBottomRightRadius: 0,
337
497
  paddingBottom: 20,
338
- maxHeight: 560,
498
+ // A snap point fixes the height; without one the panel is natural.
499
+ ...(height != null ? { height } : { maxHeight: 560 }),
339
500
  ...(style as ViewStyle),
340
501
  }}
341
502
  >
@@ -376,6 +537,10 @@ export interface DrawerProps {
376
537
  children?: ReactNode;
377
538
  /** Tapping the scrim dismisses. */
378
539
  dismissOnBackdropPress?: boolean;
540
+ /** Turns the drag-to-close gesture off. */
541
+ draggable?: boolean;
542
+ /** Opt out of the selection tick when the drawer is thrown closed. */
543
+ haptics?: boolean;
379
544
  style?: StyleProp<ViewStyle>;
380
545
  isDark?: boolean;
381
546
  testID?: string;
@@ -387,6 +552,11 @@ export interface DrawerProps {
387
552
  * The same overlay discipline as Sheet — scrim, spring slide, Android back —
388
553
  * but anchored to a side edge, with a square panel that runs the full height.
389
554
  * The caller supplies the content, typically a List.
555
+ *
556
+ * Dragging the panel towards its own edge follows the finger; releasing past
557
+ * the halfway point, or with enough outward velocity, closes it, and a drag
558
+ * that stays inside springs it back open. Reduce Motion is honoured: with it
559
+ * on, the drawer appears and disappears without sliding.
390
560
  */
391
561
  export const Drawer = forwardRef<any, DrawerProps>(function Drawer(
392
562
  {
@@ -397,6 +567,8 @@ export const Drawer = forwardRef<any, DrawerProps>(function Drawer(
397
567
  width = 280,
398
568
  children,
399
569
  dismissOnBackdropPress = true,
570
+ draggable = true,
571
+ haptics = true,
400
572
  style,
401
573
  isDark: isDarkProp,
402
574
  testID,
@@ -406,7 +578,7 @@ export const Drawer = forwardRef<any, DrawerProps>(function Drawer(
406
578
  ) {
407
579
  const isDark = useIsDark(isDarkProp);
408
580
  const theme = isDark ? colors.dark : colors.light;
409
- const { View, Pressable, Modal } = primitives();
581
+ const { View, Pressable, Modal, PanResponder } = primitives();
410
582
 
411
583
  const [internalOpen, setInternalOpen] = useState(defaultOpen);
412
584
  const open = openProp !== undefined ? openProp : internalOpen;
@@ -424,10 +596,44 @@ export const Drawer = forwardRef<any, DrawerProps>(function Drawer(
424
596
 
425
597
  const { value: slide, animated } = useSpring(open ? 1 : 0, "gentle");
426
598
  // Slide in from off-screen: negative from the left, positive from the right.
427
- const translateX = animated
599
+ const slideIn = animated
428
600
  ? slide.interpolate({ inputRange: [0, 1], outputRange: [side === "left" ? -width : width, 0] })
429
601
  : 0;
430
602
 
603
+ // The drag is measured in the drawer's own closing direction, so a drag
604
+ // towards the anchored edge is always positive whichever side it is on.
605
+ const [drag, setDrag] = useState(0);
606
+
607
+ const panResponder = useMemo(() => {
608
+ if (!draggable || !PanResponder?.create) return null;
609
+ const outward = side === "left" ? -1 : 1;
610
+ return PanResponder.create({
611
+ onStartShouldSetPanResponder: () => false,
612
+ onMoveShouldSetPanResponder: (_event: any, gesture: any) =>
613
+ // Only a horizontal drag towards the edge is ours; the other way has
614
+ // nowhere to go and should not fight content inside the panel.
615
+ Math.abs(gesture.dx) > Math.abs(gesture.dy) && gesture.dx * outward > 6,
616
+ onPanResponderMove: (_event: any, gesture: any) => {
617
+ setDrag(Math.max(0, gesture.dx * outward));
618
+ },
619
+ onPanResponderRelease: (_event: any, gesture: any) => {
620
+ const travelled = Math.max(0, gesture.dx * outward);
621
+ const thrown = gesture.vx * outward > 0.4;
622
+ setDrag(0);
623
+ if (travelled > width / 2 || thrown) {
624
+ if (haptics) hapticSelection();
625
+ dismiss();
626
+ }
627
+ },
628
+ onPanResponderTerminate: () => setDrag(0),
629
+ onPanResponderTerminationRequest: () => false,
630
+ });
631
+ // `dismiss` is stable; the gesture only needs rebuilding when its shape
632
+ // (side or width) changes.
633
+ }, [draggable, PanResponder, side, width, haptics, dismiss]);
634
+
635
+ const translateX = drag !== 0 ? (side === "left" ? -drag : drag) : animated ? slideIn : 0;
636
+
431
637
  const panel = (
432
638
  <Glass
433
639
  effect="regular"
@@ -459,8 +665,13 @@ export const Drawer = forwardRef<any, DrawerProps>(function Drawer(
459
665
  alignItems: side === "left" ? "flex-start" : "flex-end",
460
666
  }}
461
667
  >
462
- <Pressable accessibilityRole="none" onPress={() => {}} style={{ height: "100%" }}>
463
- {animated ? <DrawerSlide translateX={translateX}>{panel}</DrawerSlide> : panel}
668
+ <Pressable
669
+ accessibilityRole="none"
670
+ onPress={() => {}}
671
+ style={{ height: "100%" }}
672
+ {...(panResponder ? panResponder.panHandlers : {})}
673
+ >
674
+ {animated || drag !== 0 ? <DrawerSlide translateX={translateX}>{panel}</DrawerSlide> : panel}
464
675
  </Pressable>
465
676
  </View>
466
677
  </Pressable>
@@ -5,12 +5,15 @@ import { Glass } from "./Glass";
5
5
  import { colors, radii } from "./internal/tokens";
6
6
  import { primitives } from "./internal/primitives";
7
7
  import { useIsDark, useSpring } from "./internal/motion";
8
+ import { hapticSelection } from "./internal/haptics";
8
9
 
9
10
  export interface SegmentedControlProps {
10
11
  values: string[];
11
12
  selectedIndex?: number;
12
13
  defaultIndex?: number;
13
14
  onValueChange?: (value: string, index: number) => void;
15
+ /** One selection tick when the segment changes. `false` opts out. */
16
+ haptics?: boolean;
14
17
  style?: StyleProp<ViewStyle>;
15
18
  isDark?: boolean;
16
19
  /** Passed through to the control so it is testable. */
@@ -32,6 +35,7 @@ export const SegmentedControl = forwardRef<any, SegmentedControlProps>(function
32
35
  selectedIndex: selectedProp,
33
36
  defaultIndex = 0,
34
37
  onValueChange,
38
+ haptics = true,
35
39
  style,
36
40
  isDark: isDarkProp,
37
41
  testID,
@@ -52,6 +56,8 @@ export const SegmentedControl = forwardRef<any, SegmentedControlProps>(function
52
56
  const { value: slide, animated } = useSpring(safeIndex, "snappy");
53
57
 
54
58
  const handleSelect = (index: number) => {
59
+ // Only a change ticks: re-pressing the current segment is not a selection.
60
+ if (haptics && index !== safeIndex) hapticSelection();
55
61
  if (selectedProp === undefined) setInternalIndex(index);
56
62
  const val = values[index];
57
63
  if (val !== undefined) onValueChange?.(val, index);
package/src/Slider.tsx CHANGED
@@ -6,6 +6,7 @@ import { Glass } from "./Glass";
6
6
  import { colors } from "./internal/tokens";
7
7
  import { primitives } from "./internal/primitives";
8
8
  import { useIsDark } from "./internal/motion";
9
+ import { hapticSelection } from "./internal/haptics";
9
10
 
10
11
  export interface SliderProps {
11
12
  value?: number;
@@ -15,6 +16,8 @@ export interface SliderProps {
15
16
  step?: number;
16
17
  onValueChange?: (value: number) => void;
17
18
  disabled?: boolean;
19
+ /** One selection tick each time the stepped value changes while dragging. */
20
+ haptics?: boolean;
18
21
  accessibilityLabel: string;
19
22
  style?: StyleProp<ViewStyle>;
20
23
  isDark?: boolean;
@@ -55,6 +58,7 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
55
58
  step = 1,
56
59
  onValueChange,
57
60
  disabled = false,
61
+ haptics = true,
58
62
  accessibilityLabel,
59
63
  style,
60
64
  isDark: isDarkProp,
@@ -93,7 +97,10 @@ export const Slider = forwardRef<any, SliderProps>(function Slider(
93
97
  );
94
98
 
95
99
  const report = (next: number) => {
100
+ // Only a real step change ticks: a drag that stays inside one step is not
101
+ // a selection, and reporting the same value twice must not buzz twice.
96
102
  if (next === valueRef.current) return;
103
+ if (haptics) hapticSelection();
97
104
  valueRef.current = next;
98
105
  if (valueProp === undefined) setInternalValue(next);
99
106
  onValueChange?.(next);
package/src/Switch.tsx CHANGED
@@ -5,11 +5,14 @@ import { Glass } from "./Glass";
5
5
  import { colors } from "./internal/tokens";
6
6
  import { primitives } from "./internal/primitives";
7
7
  import { useIsDark, useSpring } from "./internal/motion";
8
+ import { hapticSelection } from "./internal/haptics";
8
9
 
9
10
  export interface SwitchProps {
10
11
  checked?: boolean;
11
12
  defaultChecked?: boolean;
12
13
  onCheckedChange?: (checked: boolean) => void;
14
+ /** One selection tick when it toggles. `false` opts out. */
15
+ haptics?: boolean;
13
16
  disabled?: boolean;
14
17
  accessibilityLabel: string;
15
18
  style?: StyleProp<ViewStyle>;
@@ -37,6 +40,7 @@ export const Switch = forwardRef<any, SwitchProps>(function Switch(
37
40
  defaultChecked = false,
38
41
  onCheckedChange,
39
42
  disabled = false,
43
+ haptics = true,
40
44
  accessibilityLabel,
41
45
  style,
42
46
  isDark: isDarkProp,
@@ -57,6 +61,7 @@ export const Switch = forwardRef<any, SwitchProps>(function Switch(
57
61
  const toggle = () => {
58
62
  if (disabled) return;
59
63
  const next = !isChecked;
64
+ if (haptics) hapticSelection();
60
65
  if (checkedProp === undefined) setInternalChecked(next);
61
66
  onCheckedChange?.(next);
62
67
  };
package/src/TabBar.tsx CHANGED
@@ -5,6 +5,7 @@ import { Glass } from "./Glass";
5
5
  import { colors, radii } from "./internal/tokens";
6
6
  import { primitives } from "./internal/primitives";
7
7
  import { useIsDark, useSpring } from "./internal/motion";
8
+ import { hapticSelection } from "./internal/haptics";
8
9
 
9
10
  export interface TabBarItem {
10
11
  id: string;
@@ -17,6 +18,8 @@ export interface TabBarProps {
17
18
  activeId?: string;
18
19
  defaultActiveId?: string;
19
20
  onTabChange?: (id: string) => void;
21
+ /** One selection tick when the tab changes. `false` opts out. */
22
+ haptics?: boolean;
20
23
  style?: StyleProp<ViewStyle>;
21
24
  isDark?: boolean;
22
25
  /** Passed through to the bar so it is testable. */
@@ -40,6 +43,7 @@ export const TabBar = forwardRef<any, TabBarProps>(function TabBar(
40
43
  activeId: activeProp,
41
44
  defaultActiveId,
42
45
  onTabChange,
46
+ haptics = true,
43
47
  style,
44
48
  isDark: isDarkProp,
45
49
  testID,
@@ -62,6 +66,8 @@ export const TabBar = forwardRef<any, TabBarProps>(function TabBar(
62
66
  const { value: slide, animated } = useSpring(activeIndex, "snappy");
63
67
 
64
68
  const handleSelect = (id: string) => {
69
+ // Selecting the tab already active is not a change, so it does not tick.
70
+ if (haptics && id !== activeId) hapticSelection();
65
71
  if (activeProp === undefined) setInternalId(id);
66
72
  onTabChange?.(id);
67
73
  };
package/src/ai.tsx CHANGED
@@ -4,6 +4,7 @@ import type { StyleProp, ViewStyle } from "react-native";
4
4
  import { colors, radii } from "./internal/tokens";
5
5
  import { primitives } from "./internal/primitives";
6
6
  import { useIsDark } from "./internal/motion";
7
+ import { useReducedMotion } from "./internal/a11y";
7
8
 
8
9
  export interface NativePlanStep {
9
10
  id: string;
@@ -390,15 +391,20 @@ export function NativeThinkingOrb({
390
391
  const isDark = useIsDark(isDarkProp);
391
392
  const theme = isDark ? colors.dark : colors.light;
392
393
  const { View, Text } = primitives();
394
+ const reducedMotion = useReducedMotion();
393
395
  const [tick, setTick] = useState(0);
394
396
 
397
+ // Reduce Motion: the orb stops pulsing and holds a steady size. The label is
398
+ // what carries the meaning, so nothing is lost by not moving.
399
+ const still = paused || reducedMotion;
400
+
395
401
  useEffect(() => {
396
- if (paused) return;
402
+ if (still) return;
397
403
  const timer = setInterval(() => setTick((value) => value + 1), 700);
398
404
  return () => clearInterval(timer);
399
- }, [paused]);
405
+ }, [still]);
400
406
 
401
- const scale = paused ? 1 : [1, 1.12, 1][tick % 3]!;
407
+ const scale = still ? 1 : [1, 1.12, 1][tick % 3]!;
402
408
 
403
409
  return (
404
410
  <View
package/src/index.ts CHANGED
@@ -105,6 +105,10 @@ export {
105
105
  type SpinnerSize,
106
106
  type ProgressProps,
107
107
  type ProgressVariant,
108
+ Rating,
109
+ type RatingProps,
110
+ NativeImage,
111
+ type NativeImageProps,
108
112
  } from "./Display";
109
113
  // Feedback and display.
110
114
  export {
@@ -114,11 +118,15 @@ export {
114
118
  ListItem,
115
119
  ListSection,
116
120
  Accordion,
121
+ ToastViewport,
117
122
  type ToastProps,
118
123
  type ToastAction,
124
+ type ToastItem,
125
+ type ToastViewportProps,
119
126
  type BannerProps,
120
127
  type ListProps,
121
128
  type ListItemProps,
129
+ type ListSwipeAction,
122
130
  type ListSectionProps,
123
131
  type AccordionProps,
124
132
  type AccordionSection,
@@ -136,6 +144,9 @@ export {
136
144
  type IconButtonProps,
137
145
  type AppBarProps,
138
146
  type AppBarAction,
147
+ FABGroup,
148
+ type FABGroupProps,
149
+ type FABGroupAction,
139
150
  } from "./Bars";
140
151
  // Overlays.
141
152
  export {
@@ -143,6 +154,8 @@ export {
143
154
  Sheet,
144
155
  Drawer,
145
156
  anchorPopover,
157
+ resolveSnapPoint,
158
+ nearestSnapPoint,
146
159
  type MenuProps,
147
160
  type MenuItem,
148
161
  type SheetProps,
@@ -169,6 +182,15 @@ export {
169
182
  type InputOTPProps,
170
183
  type ButtonGroupProps,
171
184
  type ButtonGroupItem,
185
+ ColorPicker,
186
+ DEFAULT_PALETTE,
187
+ hexToRgb,
188
+ rgbToHex,
189
+ hueGradientColors,
190
+ type ColorPickerProps,
191
+ Combobox,
192
+ type ComboboxProps,
193
+ type ComboboxOption,
172
194
  } from "./Forms2";
173
195
  export {
174
196
  Calendar,
@@ -186,5 +208,24 @@ export {
186
208
  type DatePickerProps,
187
209
  type TimePickerProps,
188
210
  } from "./Pickers";
211
+ // Chat. Bubbles are flat tints; the composer (NativeAIInput) is the glass.
212
+ export {
213
+ Message,
214
+ MessageBubble,
215
+ MessageAttachment,
216
+ type MessageProps,
217
+ type MessageBubbleProps,
218
+ type MessageAttachmentProps,
219
+ } from "./Message";
189
220
  export { isGlassSupported } from "./internal/GlassView";
190
- export { colors, radii, springs, typeScale, toneColor, type Tone } from "./internal/tokens";
221
+ export { GlassContainer, type NativeGlassContainerProps } from "./internal/GlassContainer";
222
+ export {
223
+ colors,
224
+ controlSizes,
225
+ palette,
226
+ radii,
227
+ springs,
228
+ typeScale,
229
+ toneColor,
230
+ type Tone,
231
+ } from "./internal/tokens";