glacia-native 0.5.0 → 0.5.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.
Files changed (100) hide show
  1. package/LICENSE +29 -4
  2. package/README.md +27 -0
  3. package/lib/module/Bars.js +103 -9
  4. package/lib/module/Button.js +11 -8
  5. package/lib/module/Card.js +2 -2
  6. package/lib/module/Dialog.js +16 -17
  7. package/lib/module/Display.js +86 -8
  8. package/lib/module/Feedback.js +244 -21
  9. package/lib/module/Form.js +29 -33
  10. package/lib/module/Forms2.js +257 -13
  11. package/lib/module/Glass.js +2 -2
  12. package/lib/module/Input.js +12 -10
  13. package/lib/module/Message.js +84 -0
  14. package/lib/module/Overlays.js +195 -17
  15. package/lib/module/Pickers.js +16 -16
  16. package/lib/module/SegmentedControl.js +24 -11
  17. package/lib/module/Slider.js +24 -10
  18. package/lib/module/Switch.js +25 -10
  19. package/lib/module/TabBar.js +23 -13
  20. package/lib/module/Table.js +4 -3
  21. package/lib/module/Tabs.js +3 -2
  22. package/lib/module/ai.js +26 -18
  23. package/lib/module/charts/BarChart.js +11 -3
  24. package/lib/module/index.js +23 -2
  25. package/lib/module/internal/GlassContainer.js +54 -0
  26. package/lib/module/internal/GlassView.js +10 -2
  27. package/lib/module/internal/a11y.js +94 -0
  28. package/lib/module/internal/blur.js +78 -0
  29. package/lib/module/internal/fallback.js +120 -19
  30. package/lib/module/internal/glass-routing.js +7 -0
  31. package/lib/module/internal/glow.js +36 -0
  32. package/lib/module/internal/haptics.js +54 -0
  33. package/lib/module/internal/lens.js +70 -0
  34. package/lib/module/internal/material.js +64 -0
  35. package/lib/module/internal/motion.js +10 -1
  36. package/lib/module/internal/primitives.js +70 -4
  37. package/lib/module/internal/rim.js +35 -0
  38. package/lib/module/internal/tokens.js +80 -2
  39. package/lib/typescript/Bars.d.ts +67 -0
  40. package/lib/typescript/Display.d.ts +59 -0
  41. package/lib/typescript/Feedback.d.ts +58 -0
  42. package/lib/typescript/Forms2.d.ts +81 -0
  43. package/lib/typescript/Message.d.ts +67 -0
  44. package/lib/typescript/Overlays.d.ts +41 -0
  45. package/lib/typescript/SegmentedControl.d.ts +2 -0
  46. package/lib/typescript/Slider.d.ts +2 -0
  47. package/lib/typescript/Switch.d.ts +2 -0
  48. package/lib/typescript/TabBar.d.ts +2 -0
  49. package/lib/typescript/index.d.ts +9 -6
  50. package/lib/typescript/internal/GlassContainer.d.ts +37 -0
  51. package/lib/typescript/internal/GlassView.d.ts +21 -0
  52. package/lib/typescript/internal/a11y.d.ts +19 -0
  53. package/lib/typescript/internal/blur.d.ts +24 -0
  54. package/lib/typescript/internal/fallback.d.ts +32 -2
  55. package/lib/typescript/internal/glass-routing.d.ts +10 -0
  56. package/lib/typescript/internal/glow.d.ts +11 -0
  57. package/lib/typescript/internal/haptics.d.ts +7 -0
  58. package/lib/typescript/internal/lens.d.ts +47 -0
  59. package/lib/typescript/internal/material.d.ts +27 -0
  60. package/lib/typescript/internal/motion.d.ts +4 -0
  61. package/lib/typescript/internal/primitives.d.ts +23 -0
  62. package/lib/typescript/internal/rim.d.ts +16 -0
  63. package/lib/typescript/internal/tokens.d.ts +89 -0
  64. package/package.json +12 -3
  65. package/src/Bars.tsx +239 -2
  66. package/src/Button.tsx +16 -9
  67. package/src/Card.tsx +2 -2
  68. package/src/Dialog.tsx +37 -26
  69. package/src/Display.tsx +237 -6
  70. package/src/Feedback.tsx +448 -35
  71. package/src/Form.tsx +60 -40
  72. package/src/Forms2.tsx +455 -8
  73. package/src/Glass.tsx +4 -0
  74. package/src/Input.tsx +15 -11
  75. package/src/Message.tsx +218 -0
  76. package/src/Overlays.tsx +269 -39
  77. package/src/Pickers.tsx +11 -6
  78. package/src/SegmentedControl.tsx +39 -9
  79. package/src/Slider.tsx +26 -10
  80. package/src/Switch.tsx +29 -10
  81. package/src/TabBar.tsx +39 -12
  82. package/src/Table.tsx +4 -3
  83. package/src/Tabs.tsx +5 -0
  84. package/src/ai.tsx +37 -23
  85. package/src/charts/BarChart.tsx +41 -3
  86. package/src/index.ts +43 -1
  87. package/src/internal/GlassContainer.tsx +82 -0
  88. package/src/internal/GlassView.tsx +25 -0
  89. package/src/internal/a11y.ts +105 -0
  90. package/src/internal/blur.ts +90 -0
  91. package/src/internal/fallback.tsx +170 -15
  92. package/src/internal/glass-routing.ts +17 -0
  93. package/src/internal/glow.tsx +62 -0
  94. package/src/internal/haptics.ts +59 -0
  95. package/src/internal/lens.tsx +105 -0
  96. package/src/internal/material.ts +92 -0
  97. package/src/internal/motion.ts +10 -1
  98. package/src/internal/primitives.ts +83 -4
  99. package/src/internal/rim.tsx +79 -0
  100. package/src/internal/tokens.ts +82 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Accordion = exports.ListSection = exports.List = exports.ListItem = exports.Banner = exports.Toast = void 0;
3
+ exports.Accordion = exports.ListSection = exports.List = exports.ListItem = exports.Banner = exports.ToastViewport = exports.Toast = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const Glass_1 = require("./Glass");
@@ -8,6 +8,8 @@ const Display_1 = require("./Display");
8
8
  const tokens_1 = require("./internal/tokens");
9
9
  const primitives_1 = require("./internal/primitives");
10
10
  const motion_1 = require("./internal/motion");
11
+ const lens_1 = require("./internal/lens");
12
+ const haptics_1 = require("./internal/haptics");
11
13
  /**
12
14
  * A transient message on a glass pill.
13
15
  *
@@ -43,16 +45,21 @@ exports.Toast = (0, react_1.forwardRef)(function Toast({ visible: visibleProp, d
43
45
  if (!visible)
44
46
  return null;
45
47
  const accent = tone === "neutral" ? theme.foreground : (0, tokens_1.toneColor)(theme, tone);
46
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, pointerEvents: "box-none", style: { alignItems: "center", ...style }, ...props, children: (0, jsx_runtime_1.jsx)(Entrance, { animated: animated, rise: rise, fade: fade, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: {
48
+ return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, pointerEvents: "box-none", style: { alignItems: "center", ...style }, ...props, children: (0, jsx_runtime_1.jsx)(Entrance, { animated: animated, rise: rise, fade: fade, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", surface: "overlay", isDark: isDark, style: {
47
49
  flexDirection: "row",
48
50
  alignItems: "center",
49
51
  gap: 10,
50
- paddingVertical: 10,
51
- paddingHorizontal: 14,
52
- borderRadius: tokens_1.radii.pill,
53
- maxWidth: 420,
52
+ paddingVertical: 12,
53
+ paddingHorizontal: 16,
54
+ borderRadius: tokens_1.radii.lg,
55
+ maxWidth: 400,
56
+ minWidth: 280,
57
+ // A toast floats above everything; without a shadow it is a label.
58
+ shadowOpacity: 0.12,
59
+ shadowRadius: 30,
60
+ shadowOffset: { width: 0, height: 10 },
54
61
  borderColor: tone === "neutral" ? theme.edge : accent,
55
- }, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", accessibilityLiveRegion: "polite", style: { fontSize: 14, color: theme.foreground, flexShrink: 1 }, children: message }), action && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: action.onPress, style: { paddingHorizontal: 4 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, fontWeight: "600", color: theme.fill }, children: action.label }) }))] }) }) }));
62
+ }, children: [icon ? (0, jsx_runtime_1.jsx)(View, { children: icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", accessibilityLiveRegion: "polite", style: { fontSize: 13, color: theme.foreground, flexShrink: 1 }, children: message }), action && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: action.onPress, style: { paddingHorizontal: 4 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, fontWeight: "600", color: theme.fill }, children: action.label }) }))] }) }) }));
56
63
  });
57
64
  /**
58
65
  * Applies the toast's entrance motion around the pill.
@@ -66,6 +73,97 @@ function Entrance({ animated, rise, fade, children, }) {
66
73
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
67
74
  return ((0, jsx_runtime_1.jsx)(Animated.View, { style: { transform: [{ translateY: rise }], opacity: fade }, children: children }));
68
75
  }
76
+ /**
77
+ * A queue of toasts, stacked the way Sonner stacks them.
78
+ *
79
+ * Three at a time is the practical limit: beyond that the messages stop being
80
+ * read and start covering the screen. Extras wait in the order they arrived, so
81
+ * no message is lost and the newest is never hidden behind a backlog.
82
+ *
83
+ * Each toast is independently dismissible — its own timer, its own action, and
84
+ * a swipe up. Swiping one up removes only that one.
85
+ *
86
+ * The single `Toast` keeps working unchanged: this is the host for when an app
87
+ * has several messages at once, not a replacement. A caller that shows one
88
+ * message continues to use `Toast` directly.
89
+ */
90
+ exports.ToastViewport = (0, react_1.forwardRef)(function ToastViewport({ toasts, onDismiss, max = 3, position = "bottom", style, isDark: isDarkProp, testID, ...props }, ref) {
91
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
92
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
93
+ const { View, PanResponder } = (0, primitives_1.primitives)();
94
+ // The visible window is the newest `max`, so a burst shows the latest
95
+ // messages rather than a stale backlog. Earlier ones remain queued in the
96
+ // caller's array and appear as the visible ones leave.
97
+ //
98
+ // A host is often rendered for the whole life of a screen and simply has no
99
+ // messages yet, so an absent queue means empty rather than a crash.
100
+ const visible = (toasts ?? []).slice(0, Math.max(0, max));
101
+ return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, pointerEvents: "box-none", style: {
102
+ position: "absolute",
103
+ left: 0,
104
+ right: 0,
105
+ alignItems: "center",
106
+ gap: 8,
107
+ ...(position === "top" ? { top: 16 } : { bottom: 16 }),
108
+ ...style,
109
+ }, ...props, children: visible.map((toast) => ((0, jsx_runtime_1.jsx)(SwipeableToast, { toast: toast, isDark: isDark, onDismiss: () => onDismiss(toast.id), theme: theme }, toast.id))) }));
110
+ });
111
+ /**
112
+ * One toast inside the viewport, with the swipe-up dismissal.
113
+ *
114
+ * Wrapping the existing Toast would have meant threading the gesture through
115
+ * its props, so the viewport renders the same pill with the gesture attached —
116
+ * the styling lives in one place (`Toast`), and this adds only the drag.
117
+ */
118
+ function SwipeableToast({ toast, isDark, onDismiss, theme, }) {
119
+ const { View, Text: RNText, Pressable, PanResponder, Animated } = (0, primitives_1.primitives)();
120
+ const [lift, setLift] = (0, react_1.useState)(0);
121
+ const dismissRef = (0, react_1.useRef)(onDismiss);
122
+ dismissRef.current = onDismiss;
123
+ const duration = toast.duration ?? 4000;
124
+ (0, react_1.useEffect)(() => {
125
+ if (duration <= 0)
126
+ return;
127
+ const timer = setTimeout(() => dismissRef.current(), duration);
128
+ return () => clearTimeout(timer);
129
+ }, [duration]);
130
+ const panResponder = (0, react_1.useMemo)(() => {
131
+ if (!PanResponder?.create)
132
+ return null;
133
+ return PanResponder.create({
134
+ onMoveShouldSetPanResponder: (_event, gesture) =>
135
+ // Only an upward swipe removes a toast; downward drags are ignored.
136
+ gesture.dy < -8 && Math.abs(gesture.dy) > Math.abs(gesture.dx),
137
+ onPanResponderMove: (_event, gesture) => setLift(Math.min(0, gesture.dy)),
138
+ onPanResponderRelease: (_event, gesture) => {
139
+ // A quick flick or a long drag removes it; anything less springs back.
140
+ if (gesture.dy < -40 || gesture.vy < -0.5) {
141
+ dismissRef.current();
142
+ }
143
+ else {
144
+ setLift(0);
145
+ }
146
+ },
147
+ onPanResponderTerminate: () => setLift(0),
148
+ });
149
+ }, [PanResponder]);
150
+ const tone = toast.tone ?? "neutral";
151
+ const accent = tone === "neutral" ? theme.foreground : (0, tokens_1.toneColor)(theme, tone);
152
+ const pill = ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { effect: "regular", isDark: isDark, style: {
153
+ flexDirection: "row",
154
+ alignItems: "center",
155
+ gap: 10,
156
+ paddingVertical: 10,
157
+ paddingHorizontal: 14,
158
+ borderRadius: tokens_1.radii.pill,
159
+ maxWidth: 420,
160
+ borderColor: tone === "neutral" ? theme.edge : accent,
161
+ }, children: [toast.icon ? (0, jsx_runtime_1.jsx)(View, { children: toast.icon }) : null, (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", accessibilityLiveRegion: "polite", style: { fontSize: 14, color: theme.foreground, flexShrink: 1 }, children: toast.message }), toast.action ? ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: toast.action.label, onPress: () => {
162
+ toast.action?.onPress();
163
+ onDismiss();
164
+ }, style: { paddingHorizontal: 4 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 14, fontWeight: "600", color: theme.fill }, children: toast.action.label }) })) : null] }));
165
+ return ((0, jsx_runtime_1.jsx)(View, { style: { transform: [{ translateY: lift }], opacity: lift === 0 ? 1 : Math.max(0.4, 1 + lift / 120) }, ...(panResponder ? panResponder.panHandlers : {}), children: pill }));
166
+ }
69
167
  /**
70
168
  * An inline alert.
71
169
  *
@@ -79,8 +177,16 @@ exports.Banner = (0, react_1.forwardRef)(function Banner({ title, message, tone
79
177
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
80
178
  const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
81
179
  const accent = (0, tokens_1.toneColor)(theme, tone);
82
- return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.md, borderColor: accent, ...style }, ...props, children: (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "flex-start", gap: 10, padding: 12 }, children: [icon ? (0, jsx_runtime_1.jsx)(View, { style: { paddingTop: 1 }, children: icon }) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [title && ((0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 14, fontWeight: "600", color: theme.foreground }, children: title })), (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", style: { fontSize: 13, color: theme.muted, lineHeight: 18 }, children: message }), action && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: action.onPress, style: { alignSelf: "flex-start", paddingTop: 6 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, fontWeight: "600", color: accent }, children: action.label }) }))] }), onDismiss && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss", onPress: onDismiss, hitSlop: 8, style: { padding: 2 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, color: theme.muted }, children: "\u00D7" }) }))] }) }));
180
+ return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "overlay", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.md, borderColor: accent, ...style }, ...props, children: (0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", alignItems: "flex-start", gap: 10, padding: 12 }, children: [icon ? (0, jsx_runtime_1.jsx)(View, { style: { paddingTop: 1 }, children: icon }) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [title && ((0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "heading", style: { fontSize: 14, fontWeight: "600", color: theme.foreground }, children: title })), (0, jsx_runtime_1.jsx)(RNText, { accessibilityRole: "alert", style: { fontSize: 13, color: theme.muted, lineHeight: 18 }, children: message }), action && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: action.onPress, style: { alignSelf: "flex-start", paddingTop: 6 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, fontWeight: "600", color: accent }, children: action.label }) }))] }), onDismiss && ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss", onPress: onDismiss, hitSlop: 8, style: { padding: 2 }, children: (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, color: theme.muted }, children: "\u00D7" }) }))] }) }));
83
181
  });
182
+ /**
183
+ * Tracks which row of a List is open, so opening one closes the rest.
184
+ *
185
+ * A list with two open rows looks broken; iOS Mail and every kit that copied
186
+ * it keep at most one. The List provides the registry and each swipeable row
187
+ * registers its own close function.
188
+ */
189
+ const OpenRowContext = (0, react_1.createContext)(null);
84
190
  /**
85
191
  * One row of a List.
86
192
  *
@@ -89,27 +195,139 @@ exports.Banner = (0, react_1.forwardRef)(function Banner({ title, message, tone
89
195
  * itself as a button. The chevron is decoration and is hidden from screen
90
196
  * readers, since the row's own role already says it is tappable.
91
197
  */
92
- exports.ListItem = (0, react_1.forwardRef)(function ListItem({ leading, title, description, trailing, chevron, onPress, disabled = false, selected = false, style, isDark: isDarkProp, testID, ...props }, ref) {
198
+ exports.ListItem = (0, react_1.forwardRef)(function ListItem({ leading, title, description, trailing, chevron, onPress, disabled = false, selected = false, swipeActions, leadingSwipeActions, swipeActionWidth = 78, swipeable = true, haptics = true, style, isDark: isDarkProp, testID, ...props }, ref) {
93
199
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
94
200
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
95
- const { View, Text: RNText, Pressable } = (0, primitives_1.primitives)();
201
+ const { View, Text: RNText, Pressable, PanResponder } = (0, primitives_1.primitives)();
202
+ const rowGroup = (0, react_1.useContext)(OpenRowContext);
96
203
  const interactive = Boolean(onPress) && !disabled;
97
204
  const showChevron = interactive && chevron !== false && trailing === undefined;
205
+ const trailActions = swipeActions?.filter(Boolean) ?? [];
206
+ const leadActions = leadingSwipeActions?.filter(Boolean) ?? [];
207
+ const canSwipe = swipeable && !disabled && (trailActions.length > 0 || leadActions.length > 0);
208
+ // The row's own identity, so a List can close its siblings.
209
+ const rowId = (0, react_1.useRef)(`row-${Math.random().toString(36).slice(2)}`);
210
+ // 0 is closed; a positive offset reveals trailing actions, negative leading.
211
+ const [offset, setOffset] = (0, react_1.useState)(0);
212
+ const offsetRef = (0, react_1.useRef)(0);
213
+ offsetRef.current = offset;
214
+ // A gesture that moved is a swipe, not a tap: the press that follows the
215
+ // release must not fire the row's onPress.
216
+ const swipedRef = (0, react_1.useRef)(false);
217
+ const trailingWidth = trailActions.length * swipeActionWidth;
218
+ const leadingWidth = leadActions.length * swipeActionWidth;
219
+ const close = () => setOffset(0);
220
+ // When another row opens, this one closes.
221
+ (0, react_1.useEffect)(() => {
222
+ if (rowGroup && rowGroup.openId !== rowId.current && offsetRef.current !== 0) {
223
+ setOffset(0);
224
+ }
225
+ }, [rowGroup?.openId]);
226
+ const settle = (next) => {
227
+ setOffset(next);
228
+ if (rowGroup) {
229
+ rowGroup.setOpenId(next !== 0 ? rowId.current : null);
230
+ }
231
+ if (next !== 0 && haptics && offsetRef.current === 0)
232
+ (0, haptics_1.hapticSelection)();
233
+ };
234
+ const panResponder = (0, react_1.useMemo)(() => {
235
+ if (!canSwipe || !PanResponder?.create)
236
+ return null;
237
+ return PanResponder.create({
238
+ // A horizontal drag claims the gesture; a vertical one stays with the
239
+ // surrounding scroll view.
240
+ onMoveShouldSetPanResponder: (_event, gesture) => Math.abs(gesture.dx) > Math.abs(gesture.dy) && Math.abs(gesture.dx) > 8,
241
+ onPanResponderGrant: () => {
242
+ swipedRef.current = false;
243
+ },
244
+ onPanResponderMove: (_event, gesture) => {
245
+ if (Math.abs(gesture.dx) > 4)
246
+ swipedRef.current = true;
247
+ const from = offsetRef.current;
248
+ let next = from + gesture.dx;
249
+ // Do not drag past what the actions actually occupy; a small
250
+ // overshoot makes the edge feel elastic rather than hard.
251
+ next = Math.min(next, trailingWidth + 24);
252
+ next = Math.max(next, -(leadingWidth + 24));
253
+ setOffset(next);
254
+ },
255
+ onPanResponderRelease: (_event, gesture) => {
256
+ const released = offsetRef.current;
257
+ // Beyond half an action, or with a decisive flick, it stays open;
258
+ // otherwise it falls back closed.
259
+ if (gesture.dx > 0 && trailActions.length > 0) {
260
+ settle(released > trailingWidth / 2 || gesture.vx > 0.5 ? trailingWidth : 0);
261
+ }
262
+ else if (gesture.dx < 0 && leadActions.length > 0) {
263
+ settle(released < -leadingWidth / 2 || gesture.vx < -0.5 ? -leadingWidth : 0);
264
+ }
265
+ else {
266
+ settle(offsetRef.current > 0 ? Math.min(offsetRef.current, trailingWidth) : Math.max(offsetRef.current, -leadingWidth));
267
+ }
268
+ },
269
+ onPanResponderTerminate: () => settle(0),
270
+ onPanResponderTerminationRequest: () => false,
271
+ });
272
+ // The responder reads from refs, so it never acts on a stale offset.
273
+ }, [canSwipe, PanResponder, trailingWidth, leadingWidth, trailActions.length, leadActions.length]);
274
+ /**
275
+ * Runs an action and closes the row.
276
+ *
277
+ * The action is dispatched first so its own feedback is not delayed by the
278
+ * close, then the row resets — the reveal should not outlive the press.
279
+ */
280
+ const runAction = (action) => {
281
+ action.onPress();
282
+ settle(0);
283
+ if (rowGroup)
284
+ rowGroup.setOpenId(null);
285
+ };
286
+ const guardPress = (handler) => () => {
287
+ // Swallow the press that ends a swipe.
288
+ if (swipedRef.current) {
289
+ swipedRef.current = false;
290
+ return;
291
+ }
292
+ handler?.();
293
+ };
98
294
  const content = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [leading ? (0, jsx_runtime_1.jsx)(View, { style: { marginRight: 12 }, children: leading }) : null, (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [(0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 1, style: { fontSize: 16, color: theme.foreground, fontWeight: "400" }, children: title }), description ? ((0, jsx_runtime_1.jsx)(RNText, { numberOfLines: 2, style: { fontSize: 13, color: theme.muted, lineHeight: 17 }, children: description })) : null] }), trailing ? (0, jsx_runtime_1.jsx)(View, { style: { marginLeft: 8 }, children: trailing }) : null, showChevron ? ((0, jsx_runtime_1.jsx)(RNText, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { marginLeft: 6, fontSize: 17, color: theme.muted }, children: "\u203A" })) : null] }));
99
295
  const rowStyle = {
100
296
  flexDirection: "row",
101
297
  alignItems: "center",
102
- minHeight: 48,
298
+ minHeight: 44,
103
299
  paddingVertical: 10,
104
- paddingHorizontal: 14,
105
- backgroundColor: selected ? theme.glassActive : "transparent",
300
+ paddingHorizontal: 16,
301
+ // The selected row is a lens painted behind the content, not a flat wash.
302
+ backgroundColor: "transparent",
106
303
  opacity: disabled ? 0.38 : 1,
107
304
  ...style,
108
305
  };
109
- if (!interactive) {
110
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, accessibilityRole: "text", accessibilityState: { disabled }, style: rowStyle, ...props, children: content }));
306
+ const lens = selected ? ((0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: 8, isDark: isDark, style: (0, lens_1.rowLensStyle)(8), testID: testID ? `${testID}-lens` : undefined })) : null;
307
+ const rowInner = !interactive ? ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "text", accessibilityState: { disabled }, style: rowStyle, children: [lens, content] })) : ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: description ? `${title}, ${description}` : title, accessibilityState: { selected, disabled }, disabled: disabled, onPress: guardPress(onPress), style: ({ pressed }) => ({ ...rowStyle, opacity: pressed ? 0.7 : rowStyle.opacity }), children: [lens, content] }));
308
+ if (!canSwipe) {
309
+ return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: { overflow: "hidden" }, ...props, children: rowInner }));
111
310
  }
112
- return ((0, jsx_runtime_1.jsx)(Pressable, { ref: ref, testID: testID, accessibilityRole: "button", accessibilityLabel: description ? `${title}, ${description}` : title, accessibilityState: { selected, disabled }, disabled: disabled, onPress: onPress, style: ({ pressed }) => ({ ...rowStyle, opacity: pressed ? 0.7 : rowStyle.opacity }), ...props, children: content }));
311
+ /** The tinted tray behind the row: glass-tinted actions, flat not glass. */
312
+ const tray = (actions, edge) => ((0, jsx_runtime_1.jsx)(View, { style: {
313
+ position: "absolute",
314
+ top: 0,
315
+ bottom: 0,
316
+ [edge]: 0,
317
+ flexDirection: "row",
318
+ }, children: actions.map((action, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: action.label, onPress: () => runAction(action), style: {
319
+ width: swipeActionWidth,
320
+ alignItems: "center",
321
+ justifyContent: "center",
322
+ gap: 3,
323
+ backgroundColor: action.color ?? theme.glassActive,
324
+ }, children: [action.icon, (0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 12, color: theme.foreground }, numberOfLines: 1, children: action.label })] }, `${action.label}-${index}`))) }));
325
+ return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, accessibilityRole: "none", style: { overflow: "hidden" }, ...props, children: [leadActions.length > 0 ? tray(leadActions, "right") : null, trailActions.length > 0 ? tray(trailActions, "left") : null, (0, jsx_runtime_1.jsx)(View, { style: {
326
+ transform: [{ translateX: offset }],
327
+ // The row rides over its tray while it is open, so the actions are
328
+ // uncovered rather than shown alongside.
329
+ backgroundColor: "transparent",
330
+ }, ...(panResponder ? panResponder.panHandlers : {}), children: rowInner })] }));
113
331
  });
114
332
  /**
115
333
  * A grouped list of rows — the backbone of settings and profile screens.
@@ -122,11 +340,15 @@ exports.List = (0, react_1.forwardRef)(function List({ children, inset = false,
122
340
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
123
341
  const { View } = (0, primitives_1.primitives)();
124
342
  const rows = Array.isArray(children) ? children.filter(Boolean) : children == null ? [] : [children];
125
- const body = ((0, jsx_runtime_1.jsx)(View, { style: { gap: 2 }, children: rows.map((row, index) => ((0, jsx_runtime_1.jsxs)(View, { children: [index > 0 ? (0, jsx_runtime_1.jsx)(Display_1.Separator, { isDark: isDark, inset: inset ? 14 : 0 }) : null, row] }, index))) }));
343
+ // At most one swipeable row is open at a time, so a list never shows two
344
+ // trays at once.
345
+ const [openId, setOpenId] = (0, react_1.useState)(null);
346
+ const group = (0, react_1.useMemo)(() => ({ openId, setOpenId }), [openId]);
347
+ const body = ((0, jsx_runtime_1.jsx)(OpenRowContext.Provider, { value: group, children: (0, jsx_runtime_1.jsx)(View, { style: { gap: 2 }, children: rows.map((row, index) => ((0, jsx_runtime_1.jsxs)(View, { children: [index > 0 ? (0, jsx_runtime_1.jsx)(Display_1.Separator, { isDark: isDark, inset: inset ? 14 : 0 }) : null, row] }, index))) }) }));
126
348
  if (!inset) {
127
349
  return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: style, ...props, children: body }));
128
350
  }
129
- return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.md, overflow: "hidden", ...style }, ...props, children: body }));
351
+ return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "panel", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.lg, ...style }, ...props, children: body }));
130
352
  });
131
353
  exports.ListSection = (0, react_1.forwardRef)(function ListSection({ header, children, style, isDark: isDarkProp, testID, ...props }, ref) {
132
354
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
@@ -138,7 +360,8 @@ exports.ListSection = (0, react_1.forwardRef)(function ListSection({ header, chi
138
360
  letterSpacing: 0.4,
139
361
  textTransform: "uppercase",
140
362
  color: theme.muted,
141
- paddingHorizontal: 14,
363
+ paddingHorizontal: 16,
364
+ paddingVertical: 5,
142
365
  }, children: header })) : null, (0, jsx_runtime_1.jsx)(exports.List, { inset: true, isDark: isDark, children: children })] }));
143
366
  });
144
367
  /**
@@ -165,8 +388,8 @@ exports.Accordion = (0, react_1.forwardRef)(function Accordion({ sections, multi
165
388
  setInternalOpen(next);
166
389
  onOpenSectionsChange?.(next);
167
390
  };
168
- return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.md, overflow: "hidden", ...style }, ...props, children: sections.map((section, index) => {
391
+ return ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "panel", isDark: isDark, testID: testID, style: { borderRadius: tokens_1.radii.stack, ...style }, ...props, children: sections.map((section, index) => {
169
392
  const expanded = open.includes(section.value);
170
- return ((0, jsx_runtime_1.jsxs)(View, { children: [index > 0 ? (0, jsx_runtime_1.jsx)(Display_1.Separator, { isDark: isDark }) : null, (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: section.title, accessibilityState: { expanded }, onPress: () => toggle(section.value), style: { paddingVertical: 12, paddingHorizontal: 14, flexDirection: "row", alignItems: "center" }, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [(0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, fontWeight: "500", color: theme.foreground }, children: section.title }), section.description ? ((0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, color: theme.muted }, children: section.description })) : null] }), (0, jsx_runtime_1.jsx)(RNText, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { fontSize: 13, color: theme.muted, marginLeft: 8 }, children: expanded ? "\u2303" : "\u2304" })] }), expanded ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 14, paddingBottom: 12 }, children: section.content })) : null] }, section.value));
393
+ return ((0, jsx_runtime_1.jsxs)(View, { children: [index > 0 ? (0, jsx_runtime_1.jsx)(Display_1.Separator, { isDark: isDark }) : null, (0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityLabel: section.title, accessibilityState: { expanded }, onPress: () => toggle(section.value), style: { paddingVertical: 16, paddingHorizontal: 20, flexDirection: "row", alignItems: "center" }, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, gap: 2 }, children: [(0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 15, fontWeight: "500", color: theme.foreground }, children: section.title }), section.description ? ((0, jsx_runtime_1.jsx)(RNText, { style: { fontSize: 13, color: theme.muted }, children: section.description })) : null] }), (0, jsx_runtime_1.jsx)(RNText, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { fontSize: 13, color: theme.muted, marginLeft: 8 }, children: expanded ? "\u2303" : "\u2304" })] }), expanded ? ((0, jsx_runtime_1.jsx)(View, { style: { paddingHorizontal: 20, paddingBottom: 16 }, children: section.content })) : null] }, section.value));
171
394
  }) }));
172
395
  });
@@ -7,9 +7,11 @@ exports.RadioGroup = RadioGroup;
7
7
  exports.Select = Select;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const react_1 = require("react");
10
+ const Glass_1 = require("./Glass");
10
11
  const tokens_1 = require("./internal/tokens");
11
12
  const primitives_1 = require("./internal/primitives");
12
13
  const motion_1 = require("./internal/motion");
14
+ const lens_1 = require("./internal/lens");
13
15
  /** The text above a control. */
14
16
  exports.Label = (0, react_1.forwardRef)(function Label({ children, required = false, disabled = false, nativeID, isDark: isDarkProp, style }, ref) {
15
17
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
@@ -17,7 +19,7 @@ exports.Label = (0, react_1.forwardRef)(function Label({ children, required = fa
17
19
  const { Text } = (0, primitives_1.primitives)();
18
20
  return ((0, jsx_runtime_1.jsxs)(Text, { ref: ref, nativeID: nativeID, accessibilityRole: "text", style: {
19
21
  fontSize: 13,
20
- fontWeight: "600",
22
+ fontWeight: "500",
21
23
  color: disabled ? theme.muted : theme.foreground,
22
24
  opacity: disabled ? 0.6 : 1,
23
25
  ...style,
@@ -32,8 +34,8 @@ function Field({ label, description, error, required = false, disabled = false,
32
34
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
33
35
  const { View, Text } = (0, primitives_1.primitives)();
34
36
  const message = error ?? description;
35
- return ((0, jsx_runtime_1.jsxs)(View, { style: { gap: 6, ...style }, children: [label && ((0, jsx_runtime_1.jsx)(exports.Label, { required: required, disabled: disabled, isDark: isDark, children: label })), children, message && ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: error ? "alert" : "text", style: {
36
- fontSize: 11,
37
+ return ((0, jsx_runtime_1.jsxs)(View, { style: { gap: 7, ...style }, children: [label && ((0, jsx_runtime_1.jsx)(exports.Label, { required: required, disabled: disabled, isDark: isDark, children: label })), children, message && ((0, jsx_runtime_1.jsx)(Text, { accessibilityRole: error ? "alert" : "text", style: {
38
+ fontSize: 12,
37
39
  color: error ? theme.destructive : theme.muted,
38
40
  }, children: message }))] }));
39
41
  }
@@ -60,19 +62,17 @@ function Checkbox({ checked: checkedProp, defaultChecked = false, onCheckedChang
60
62
  gap: 10,
61
63
  opacity: disabled ? 0.45 : 1,
62
64
  ...style,
63
- }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
65
+ }, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "control", isDark: isDark, style: {
64
66
  width: 20,
65
67
  height: 20,
66
68
  borderRadius: 6,
67
- borderWidth: filled ? 0 : 1.5,
68
- borderColor: theme.edge,
69
- backgroundColor: filled ? theme.fill : "transparent",
69
+ backgroundColor: filled ? theme.fill : undefined,
70
70
  alignItems: "center",
71
71
  justifyContent: "center",
72
72
  marginTop: 1,
73
- }, children: indeterminate ? ((0, jsx_runtime_1.jsx)(View, { style: { width: 10, height: 2, borderRadius: 1, backgroundColor: "#fff" } })) : checked ? (
73
+ }, children: indeterminate ? ((0, jsx_runtime_1.jsx)(View, { style: { width: 10, height: 2, borderRadius: 1, backgroundColor: theme.onTint } })) : checked ? (
74
74
  // A glyph rather than an icon dependency: one text node, no package.
75
- (0, jsx_runtime_1.jsx)(Text, { style: { color: "#fff", fontSize: 12, fontWeight: "700", lineHeight: 14 }, children: "\u2713" })) : null }), (label || description) && ((0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [label && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground, fontWeight: "500" }, children: label })), description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 2 }, children: description }))] }))] }));
75
+ (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.onTint, fontSize: 12, fontWeight: "700", lineHeight: 14 }, children: "\u2713" })) : null }), (label || description) && ((0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [label && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground, fontWeight: "500" }, children: label })), description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginTop: 2 }, children: description }))] }))] }));
76
76
  }
77
77
  /** One choice from a small, always-visible set. */
78
78
  function RadioGroup({ value: valueProp, defaultValue, onValueChange, options, horizontal = false, disabled = false, isDark: isDarkProp, style, testID, }) {
@@ -101,14 +101,15 @@ function RadioGroup({ value: valueProp, defaultValue, onValueChange, options, ho
101
101
  alignItems: "flex-start",
102
102
  gap: 9,
103
103
  opacity: isDisabled ? 0.45 : 1,
104
- }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
104
+ }, children: [(0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "control", isDark: isDark, style: {
105
105
  width: 20,
106
106
  height: 20,
107
107
  borderRadius: 10,
108
- borderWidth: isSelected ? 6 : 1.5,
109
- borderColor: isSelected ? theme.fill : theme.edge,
108
+ backgroundColor: isSelected ? theme.fill : undefined,
109
+ alignItems: "center",
110
+ justifyContent: "center",
110
111
  marginTop: 1,
111
- } }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label }), option.description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginTop: 2 }, children: option.description }))] })] }, option.value));
112
+ }, children: isSelected ? ((0, jsx_runtime_1.jsx)(View, { style: { width: 8, height: 8, borderRadius: 4, backgroundColor: theme.onTint } })) : null }), (0, jsx_runtime_1.jsxs)(View, { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label }), option.description && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginTop: 2 }, children: option.description }))] })] }, option.value));
112
113
  }) }));
113
114
  }
114
115
  /**
@@ -132,33 +133,28 @@ function Select({ value: valueProp, defaultValue, onValueChange, options, placeh
132
133
  onValueChange?.(next);
133
134
  };
134
135
  const selected = options.find((option) => option.value === value);
135
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Pressable, { testID: testID, accessibilityRole: "button", accessibilityState: { expanded: open, disabled }, accessibilityLabel: selected?.label ?? placeholder, disabled: disabled, onPress: () => setOpen(!open), style: {
136
- minHeight: 42,
137
- flexDirection: "row",
138
- alignItems: "center",
139
- justifyContent: "space-between",
140
- paddingHorizontal: 12,
141
- borderRadius: tokens_1.radii.md,
142
- borderWidth: 1,
143
- borderColor: theme.edge,
144
- backgroundColor: theme.glass,
145
- opacity: disabled ? 0.5 : 1,
146
- }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 15, color: selected ? theme.foreground : theme.muted }, children: selected?.label ?? placeholder }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted }, children: open ? "▲" : "▼" })] }), open && ((0, jsx_runtime_1.jsx)(View, { style: {
136
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsx)(Pressable, { testID: testID, accessibilityRole: "button", accessibilityState: { expanded: open, disabled }, accessibilityLabel: selected?.label ?? placeholder, disabled: disabled, onPress: () => setOpen(!open), style: { opacity: disabled ? 0.5 : 1 }, children: (0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "field", isDark: isDark, style: {
137
+ minHeight: 34,
138
+ flexDirection: "row",
139
+ alignItems: "center",
140
+ justifyContent: "space-between",
141
+ paddingHorizontal: 14,
142
+ }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 15, color: selected ? theme.foreground : theme.muted }, children: selected?.label ?? placeholder }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 10, color: theme.muted }, children: open ? "▲" : "▼" })] }) }), open && ((0, jsx_runtime_1.jsx)(Glass_1.Glass, { surface: "overlay", isDark: isDark, style: {
147
143
  marginTop: 6,
148
144
  borderRadius: tokens_1.radii.md,
149
- borderWidth: 1,
150
- borderColor: theme.edge,
151
- backgroundColor: theme.glass,
152
- overflow: "hidden",
145
+ shadowOpacity: 0.12,
146
+ shadowRadius: 30,
147
+ shadowOffset: { width: 0, height: 10 },
153
148
  }, children: options.map((option) => {
154
149
  const isSelected = option.value === value;
155
- return ((0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isSelected }, accessibilityLabel: option.label, onPress: () => {
150
+ return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isSelected }, accessibilityLabel: option.label, onPress: () => {
156
151
  choose(option.value);
157
152
  setOpen(false);
158
153
  }, style: {
159
- paddingVertical: 10,
154
+ minHeight: 32,
160
155
  paddingHorizontal: 12,
161
- backgroundColor: isSelected ? theme.glassActive : "transparent",
162
- }, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label }) }, option.value));
156
+ borderRadius: 10,
157
+ backgroundColor: "transparent",
158
+ }, children: [isSelected ? ((0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: 10, isDark: isDark, style: lens_1.lensFill })) : null, (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 14, color: theme.foreground }, children: option.label })] }, option.value));
163
159
  }) }))] }));
164
160
  }