glacia-native 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/lib/module/Button.js +15 -2
  2. package/lib/module/Card.js +29 -14
  3. package/lib/module/Dialog.js +43 -32
  4. package/lib/module/Form.js +51 -12
  5. package/lib/module/Glass.js +11 -2
  6. package/lib/module/Input.js +19 -7
  7. package/lib/module/SegmentedControl.js +65 -21
  8. package/lib/module/Slider.js +121 -25
  9. package/lib/module/Switch.js +33 -15
  10. package/lib/module/TabBar.js +63 -25
  11. package/lib/module/Table.js +24 -6
  12. package/lib/module/Tabs.js +55 -33
  13. package/lib/module/ai.js +49 -20
  14. package/lib/module/charts/BarChart.js +4 -2
  15. package/lib/module/charts/FunnelChart.js +4 -2
  16. package/lib/module/charts/HeatmapChart.js +4 -2
  17. package/lib/module/charts/LineChart.js +4 -2
  18. package/lib/module/charts/PlotChart.js +11 -3
  19. package/lib/module/charts/RadarChart.js +4 -2
  20. package/lib/module/charts/RingChart.js +4 -2
  21. package/lib/module/charts/ScatterChart.js +20 -3
  22. package/lib/module/charts/WaterfallChart.js +12 -3
  23. package/lib/module/charts/advanced.js +12 -6
  24. package/lib/module/charts/extra.js +6 -3
  25. package/lib/module/internal/GlassView.js +17 -19
  26. package/lib/module/internal/fallback.js +14 -3
  27. package/lib/module/internal/glass-routing.js +56 -0
  28. package/lib/module/internal/motion.js +55 -0
  29. package/lib/module/internal/primitives.js +408 -0
  30. package/lib/typescript/Button.d.ts +11 -1
  31. package/lib/typescript/Card.d.ts +20 -8
  32. package/lib/typescript/Dialog.d.ts +19 -6
  33. package/lib/typescript/Form.d.ts +27 -11
  34. package/lib/typescript/Glass.d.ts +9 -0
  35. package/lib/typescript/Input.d.ts +11 -1
  36. package/lib/typescript/SegmentedControl.d.ts +11 -1
  37. package/lib/typescript/Slider.d.ts +13 -1
  38. package/lib/typescript/Switch.d.ts +12 -1
  39. package/lib/typescript/TabBar.d.ts +13 -1
  40. package/lib/typescript/Table.d.ts +14 -5
  41. package/lib/typescript/Tabs.d.ts +8 -5
  42. package/lib/typescript/ai.d.ts +12 -9
  43. package/lib/typescript/charts/BarChart.d.ts +1 -1
  44. package/lib/typescript/charts/FunnelChart.d.ts +1 -1
  45. package/lib/typescript/charts/HeatmapChart.d.ts +1 -1
  46. package/lib/typescript/charts/LineChart.d.ts +1 -1
  47. package/lib/typescript/charts/PlotChart.d.ts +1 -1
  48. package/lib/typescript/charts/RadarChart.d.ts +1 -1
  49. package/lib/typescript/charts/RingChart.d.ts +1 -1
  50. package/lib/typescript/charts/ScatterChart.d.ts +1 -1
  51. package/lib/typescript/charts/WaterfallChart.d.ts +1 -1
  52. package/lib/typescript/charts/advanced.d.ts +5 -5
  53. package/lib/typescript/charts/extra.d.ts +2 -2
  54. package/lib/typescript/internal/GlassView.d.ts +11 -3
  55. package/lib/typescript/internal/fallback.d.ts +10 -1
  56. package/lib/typescript/internal/glass-routing.d.ts +30 -0
  57. package/lib/typescript/internal/motion.d.ts +19 -0
  58. package/lib/typescript/internal/primitives.d.ts +41 -0
  59. package/package.json +2 -2
  60. package/src/Button.tsx +47 -22
  61. package/src/Card.tsx +52 -31
  62. package/src/Dialog.tsx +99 -64
  63. package/src/Form.tsx +90 -25
  64. package/src/Glass.tsx +24 -1
  65. package/src/Input.tsx +33 -12
  66. package/src/SegmentedControl.tsx +104 -32
  67. package/src/Slider.tsx +151 -47
  68. package/src/Switch.tsx +56 -32
  69. package/src/TabBar.tsx +100 -30
  70. package/src/Table.tsx +38 -14
  71. package/src/Tabs.tsx +85 -32
  72. package/src/ai.tsx +77 -31
  73. package/src/charts/BarChart.tsx +4 -2
  74. package/src/charts/FunnelChart.tsx +4 -2
  75. package/src/charts/HeatmapChart.tsx +4 -2
  76. package/src/charts/LineChart.tsx +4 -2
  77. package/src/charts/PlotChart.tsx +23 -3
  78. package/src/charts/RadarChart.tsx +4 -2
  79. package/src/charts/RingChart.tsx +4 -2
  80. package/src/charts/ScatterChart.tsx +24 -3
  81. package/src/charts/WaterfallChart.tsx +21 -3
  82. package/src/charts/advanced.tsx +12 -6
  83. package/src/charts/extra.tsx +6 -3
  84. package/src/internal/GlassView.tsx +31 -21
  85. package/src/internal/fallback.tsx +23 -8
  86. package/src/internal/glass-routing.ts +68 -0
  87. package/src/internal/motion.ts +60 -0
  88. package/src/internal/primitives.ts +477 -0
  89. package/lib/module/charts/primitives.js +0 -212
  90. package/lib/typescript/charts/primitives.d.ts +0 -23
  91. package/src/charts/primitives.ts +0 -262
package/lib/module/ai.js CHANGED
@@ -12,14 +12,16 @@ exports.NativeImageGeneration = NativeImageGeneration;
12
12
  const jsx_runtime_1 = require("react/jsx-runtime");
13
13
  const react_1 = require("react");
14
14
  const tokens_1 = require("./internal/tokens");
15
- const primitives_1 = require("./charts/primitives");
15
+ const primitives_1 = require("./internal/primitives");
16
+ const motion_1 = require("./internal/motion");
16
17
  /**
17
18
  * The ordered steps a model intends to take.
18
19
  *
19
20
  * Each step carries its own status, so a half-finished plan is legible instead
20
21
  * of appearing blank until the whole thing completes.
21
22
  */
22
- function NativePlan({ title = "Plan", steps, isDark = false, style }) {
23
+ function NativePlan({ title = "Plan", steps, isDark: isDarkProp, style }) {
24
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
23
25
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
24
26
  const { View, Text } = (0, primitives_1.primitives)();
25
27
  const done = steps.filter((step) => step.status === "done").length;
@@ -56,7 +58,8 @@ function NativePlan({ title = "Plan", steps, isDark = false, style }) {
56
58
  * Native has no anchor element, so a row hands the source to the caller's
57
59
  * `onSourcePress` instead of opening a browser the component cannot control.
58
60
  */
59
- function NativeSources({ sources, title = "Sources", isDark = false, style, onSourcePress, }) {
61
+ function NativeSources({ sources, title = "Sources", isDark: isDarkProp, style, onSourcePress, }) {
62
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
60
63
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
61
64
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
62
65
  if (sources.length === 0)
@@ -78,7 +81,8 @@ function NativeSources({ sources, title = "Sources", isDark = false, style, onSo
78
81
  * The caller owns the streaming clock (usually a network stream); this only
79
82
  * renders the first `revealed` characters and shows a caret while incomplete.
80
83
  */
81
- function NativeResponse({ text, revealed, streaming, isDark = false, style, }) {
84
+ function NativeResponse({ text, revealed, streaming, isDark: isDarkProp, style, }) {
85
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
82
86
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
83
87
  const { View, Text } = (0, primitives_1.primitives)();
84
88
  const shown = revealed == null ? text : text.slice(0, Math.max(0, revealed));
@@ -86,13 +90,17 @@ function NativeResponse({ text, revealed, streaming, isDark = false, style, }) {
86
90
  return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Text, { accessibilityRole: "text", accessibilityLabel: shown, style: { fontSize: 14, lineHeight: 21, color: theme.foreground }, children: [shown, isStreaming ? "▍" : ""] }), (0, jsx_runtime_1.jsx)(Text, { accessibilityRole: "alert", style: { height: 0, opacity: 0, fontSize: 0 }, children: isStreaming ? "Response streaming" : "Response complete" })] }));
87
91
  }
88
92
  /** Progress of a long-running background task. */
89
- function NativeTask({ task, isDark = false, style }) {
93
+ function NativeTask({ task, isDark: isDarkProp, style }) {
94
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
90
95
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
91
96
  const { View, Text } = (0, primitives_1.primitives)();
92
97
  const percent = task.progress == null ? null : Math.round(Math.min(1, Math.max(0, task.progress)) * 100);
93
98
  const status = task.status ?? "running";
94
99
  const fillColor = status === "failed" ? theme.destructive : status === "done" ? "#34c759" : theme.fill;
95
- return ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "progressbar", accessibilityLabel: task.label ?? "Task progress", accessibilityState: {
100
+ return ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "progressbar", accessibilityLabel: task.label ?? "Task progress",
101
+ // Without the value, a screen reader only reads the label and never says
102
+ // how far along the task is.
103
+ accessibilityValue: percent == null ? undefined : { min: 0, max: 100, now: percent }, accessibilityState: {
96
104
  disabled: false,
97
105
  }, style: style, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", justifyContent: "space-between", marginBottom: 6 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "500", color: theme.foreground }, children: task.label ?? "Task" }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: percent == null ? "…" : `${percent}%` })] }), (0, jsx_runtime_1.jsx)(View, { style: {
98
106
  height: 6,
@@ -115,7 +123,8 @@ function NativeTask({ task, isDark = false, style }) {
115
123
  * Without levels it rests at a low, static profile instead of animating:
116
124
  * continuous motion with no audio behind it would be decorative noise.
117
125
  */
118
- function NativeSoundwave({ levels, bars = 28, active = true, height = 40, color, isDark = false, style, label = "Audio level", }) {
126
+ function NativeSoundwave({ levels, bars = 28, active = true, height = 40, color, isDark: isDarkProp, style, label = "Audio level", }) {
127
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
119
128
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
120
129
  const { View } = (0, primitives_1.primitives)();
121
130
  const count = levels?.length || bars;
@@ -140,7 +149,8 @@ function NativeSoundwave({ levels, bars = 28, active = true, height = 40, color,
140
149
  * Purely decorative, so it is hidden from screen readers and the label is
141
150
  * exposed as text instead of relying on the motion being perceived.
142
151
  */
143
- function NativeThinkingOrb({ label = "Thinking", size = 22, paused = false, isDark = false, style, }) {
152
+ function NativeThinkingOrb({ label = "Thinking", size = 22, paused = false, isDark: isDarkProp, style, }) {
153
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
144
154
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
145
155
  const { View, Text } = (0, primitives_1.primitives)();
146
156
  const [tick, setTick] = (0, react_1.useState)(0);
@@ -166,7 +176,8 @@ function NativeThinkingOrb({ label = "Thinking", size = 22, paused = false, isDa
166
176
  * Selection is a press rather than navigation because the panel's content is
167
177
  * client state; the caller decides what a selection means.
168
178
  */
169
- function NativePanelside({ items, value, onValueChange, isDark = false, style, title, }) {
179
+ function NativePanelside({ items, value, onValueChange, isDark: isDarkProp, style, title, }) {
180
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
170
181
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
171
182
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
172
183
  return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [title && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title })), items.map((item) => {
@@ -193,10 +204,23 @@ function NativePanelside({ items, value, onValueChange, isDark = false, style, t
193
204
  * Send stays disabled until there is non-whitespace to send, which is the rule
194
205
  * that prevents empty submissions rather than a validation message afterwards.
195
206
  */
196
- function NativeAIInput({ value = "", onChangeText, onSubmit, placeholder = "Ask anything", disabled = false, busy = false, sendLabel = "Send", isDark = false, style, footer, }) {
207
+ function NativeAIInput({ value: valueProp, defaultValue, onChangeText, onSubmit, placeholder = "Ask anything", disabled = false, busy = false, sendLabel = "Send", isDark: isDarkProp, style, footer, }) {
208
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
197
209
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
198
210
  const { View, Text, TextInput, Pressable } = (0, primitives_1.primitives)();
211
+ // Uncontrolled support: the composer owns its text when no `value` is given,
212
+ // which is what makes typed text appear in plain uncontrolled use.
213
+ const [internalText, setInternalText] = (0, react_1.useState)(defaultValue ?? "");
214
+ const value = valueProp !== undefined ? valueProp : internalText;
215
+ const handleChangeText = (next) => {
216
+ if (valueProp === undefined)
217
+ setInternalText(next);
218
+ onChangeText?.(next);
219
+ };
199
220
  const canSend = !disabled && !busy && value.trim().length > 0;
221
+ // The themed placeholder is drawn as a Text, matching Input: the OS default
222
+ // placeholder colour ignores the theme.
223
+ const showPlaceholder = !value && Boolean(placeholder);
200
224
  return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(View, { style: {
201
225
  flexDirection: "row",
202
226
  alignItems: "flex-end",
@@ -207,15 +231,19 @@ function NativeAIInput({ value = "", onChangeText, onSubmit, placeholder = "Ask
207
231
  borderColor: theme.edge,
208
232
  backgroundColor: theme.glass,
209
233
  opacity: disabled ? 0.5 : 1,
210
- }, children: [(0, jsx_runtime_1.jsx)(TextInput, { value: value, onChangeText: onChangeText, placeholder: placeholder, editable: !disabled, multiline: true, numberOfLines: 3, accessibilityLabel: placeholder, style: {
211
- flex: 1,
212
- minHeight: 34,
213
- maxHeight: 120,
214
- paddingHorizontal: 6,
215
- paddingVertical: 7,
216
- fontSize: 14,
217
- color: theme.foreground,
218
- } }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: sendLabel, accessibilityState: { disabled: !canSend }, disabled: !canSend, onPress: () => canSend && onSubmit?.(), style: {
234
+ }, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, justifyContent: "center" }, children: [showPlaceholder && ((0, jsx_runtime_1.jsx)(Text, { pointerEvents: "none", numberOfLines: 1, style: {
235
+ position: "absolute",
236
+ left: 6,
237
+ fontSize: 14,
238
+ color: theme.muted,
239
+ }, children: placeholder })), (0, jsx_runtime_1.jsx)(TextInput, { value: value, onChangeText: handleChangeText, editable: !disabled, multiline: true, numberOfLines: 3, accessibilityLabel: placeholder, accessibilityState: { disabled }, style: {
240
+ minHeight: 34,
241
+ maxHeight: 120,
242
+ paddingHorizontal: 6,
243
+ paddingVertical: 7,
244
+ fontSize: 14,
245
+ color: theme.foreground,
246
+ } })] }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: sendLabel, accessibilityState: { disabled: !canSend }, disabled: !canSend, onPress: () => canSend && onSubmit?.(), style: {
219
247
  paddingVertical: 8,
220
248
  paddingHorizontal: 14,
221
249
  borderRadius: tokens_1.radii.pill,
@@ -228,7 +256,8 @@ function NativeAIInput({ value = "", onChangeText, onSubmit, placeholder = "Ask
228
256
  * While generating, a placeholder with the same aspect ratio holds the space so
229
257
  * the layout does not jump when the image arrives.
230
258
  */
231
- function NativeImageGeneration({ image, prompt, status = "queued", isDark = false, style, }) {
259
+ function NativeImageGeneration({ image, prompt, status = "queued", isDark: isDarkProp, style, }) {
260
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
232
261
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
233
262
  const { View, Text, Image } = (0, primitives_1.primitives)();
234
263
  const width = image?.width ?? 320;
@@ -4,12 +4,14 @@ exports.NativeBarChart = NativeBarChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  const PADDING = { top: 12, right: 10, bottom: 24, left: 38 };
10
11
  /** Grouped or stacked bars, drawn with react-native-svg. */
11
- function NativeBarChart({ labels, series, width = 320, height = 200, stacked = false, radius = 4, isDark = false, palette, style, onBarPress, }) {
12
+ function NativeBarChart({ labels, series, width = 320, height = 200, stacked = false, radius = 4, isDark: isDarkProp, palette, style, onBarPress, }) {
12
13
  const [active, setActive] = (0, react_1.useState)(null);
14
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
13
15
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
14
16
  const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = (0, primitives_1.primitives)();
15
17
  const plot = {
@@ -4,7 +4,8 @@ exports.NativeFunnelChart = NativeFunnelChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  /**
10
11
  * A sequence of stages where each narrows the one before it.
@@ -14,8 +15,9 @@ const scales_1 = require("./scales");
14
15
  * shows its own value, its share of entry, and the step conversion — the three
15
16
  * numbers a funnel is actually read for.
16
17
  */
17
- function NativeFunnelChart({ stages, width = 320, stageHeight = 38, baseline, isDark = false, palette, style, onStagePress, }) {
18
+ function NativeFunnelChart({ stages, width = 320, stageHeight = 38, baseline, isDark: isDarkProp, palette, style, onStagePress, }) {
18
19
  const [active, setActive] = (0, react_1.useState)(null);
20
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
19
21
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
20
22
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
21
23
  if (stages.length === 0) {
@@ -4,7 +4,8 @@ exports.NativeHeatmapChart = NativeHeatmapChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  /** Parses "#rrggbb" into channels; anything else falls back to grey. */
10
11
  function parseHex(hex) {
@@ -28,8 +29,9 @@ function mix(from, to, t) {
28
29
  * Cells are Views rather than SVG rects: the grid is uniform, so native layout
29
30
  * positions it exactly and text stays crisp without vector text.
30
31
  */
31
- function NativeHeatmapChart({ rows, columns, cellSize = 28, cellGap = 3, isDark = false, minColor = "#e8eef7", maxColor = "#0088ff", style, onCellPress, }) {
32
+ function NativeHeatmapChart({ rows, columns, cellSize = 28, cellGap = 3, isDark: isDarkProp, minColor = "#e8eef7", maxColor = "#0088ff", style, onCellPress, }) {
32
33
  const [active, setActive] = (0, react_1.useState)(null);
34
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
33
35
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
34
36
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
35
37
  if (rows.length === 0 || columns.length === 0) {
@@ -4,7 +4,8 @@ exports.NativeLineChart = NativeLineChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  const PADDING = { top: 12, right: 10, bottom: 24, left: 38 };
10
11
  /**
@@ -14,8 +15,9 @@ const PADDING = { top: 12, right: 10, bottom: 24, left: 38 };
14
15
  * the same axis values on both platforms. Touching a column selects that
15
16
  * point, which is the touch equivalent of hovering on the web.
16
17
  */
17
- function NativeLineChart({ labels, series, width = 320, height = 200, area = false, smooth = true, showDots = false, isDark = false, palette, style, onPointPress, }) {
18
+ function NativeLineChart({ labels, series, width = 320, height = 200, area = false, smooth = true, showDots = false, isDark: isDarkProp, palette, style, onPointPress, }) {
18
19
  const [active, setActive] = (0, react_1.useState)(null);
20
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
19
21
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
20
22
  const { View, Text, Pressable, Svg, G, Line, Path, Circle, SvgText } = (0, primitives_1.primitives)();
21
23
  const plot = {
@@ -4,9 +4,16 @@ exports.NativePlotChart = NativePlotChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  const PADDING = { top: 12, right: 12, bottom: 26, left: 44 };
11
+ /** Reads the chart as one sentence for a screen reader. */
12
+ function plotSummary(points, xDomain, yDomain) {
13
+ return (`Plot chart with ${points.length} points. ` +
14
+ `x from ${(0, scales_1.formatValue)(xDomain[0], { compact: true })} to ${(0, scales_1.formatValue)(xDomain[1], { compact: true })}, ` +
15
+ `y from ${(0, scales_1.formatValue)(yDomain[0], { compact: true })} to ${(0, scales_1.formatValue)(yDomain[1], { compact: true })}.`);
16
+ }
10
17
  /**
11
18
  * A numeric plot you supply the marks for.
12
19
  *
@@ -14,7 +21,8 @@ const PADDING = { top: 12, right: 12, bottom: 26, left: 44 };
14
21
  * pixel scales. That keeps stroke widths and text sizes honest regardless of
15
22
  * the chart's width, instead of a scaled viewBox that would distort them.
16
23
  */
17
- function NativePlotChart({ points, renderMark, width = 320, height = 200, xLabel, yLabel, isDark = false, style, }) {
24
+ function NativePlotChart({ points, renderMark, width = 320, height = 200, xLabel, yLabel, isDark: isDarkProp, style, }) {
25
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
18
26
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
19
27
  const { View, Text, Svg, G, Line, Circle, SvgText } = (0, primitives_1.primitives)();
20
28
  const plot = {
@@ -40,5 +48,5 @@ function NativePlotChart({ points, renderMark, width = 320, height = 200, xLabel
40
48
  }
41
49
  const yTicks = (0, scales_1.ticks)(yDomain, 4);
42
50
  const xTicks = (0, scales_1.ticks)(xDomain, 4);
43
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.22, strokeWidth: 1 }, `grid-${i}`))), renderMark ? (renderMark({ x, y, points, width: plot.width, height: plot.height })) : ((0, jsx_runtime_1.jsx)(G, { children: points.map((point, index) => ((0, jsx_runtime_1.jsx)(Circle, { cx: x(point.x), cy: y(point.y), r: 3.5, fill: theme.fill }, index))) })), yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: plot.x - 6, y: y(tick) + 3, fill: theme.muted, fontSize: 9, textAnchor: "end", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `y-${i}`))), xTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: x(tick), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `x-${i}`)))] }), (xLabel || yLabel) && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 9, color: theme.muted, marginTop: 2 }, children: [xLabel, yLabel].filter(Boolean).join(" · ") }))] }));
51
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style, accessible: true, accessibilityRole: "image", accessibilityLabel: plotSummary(points, xDomain, yDomain), children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.22, strokeWidth: 1 }, `grid-${i}`))), renderMark ? (renderMark({ x, y, points, width: plot.width, height: plot.height })) : ((0, jsx_runtime_1.jsx)(G, { children: points.map((point, index) => ((0, jsx_runtime_1.jsx)(Circle, { cx: x(point.x), cy: y(point.y), r: 3.5, fill: theme.fill }, index))) })), yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: plot.x - 6, y: y(tick) + 3, fill: theme.muted, fontSize: 9, textAnchor: "end", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `y-${i}`))), xTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: x(tick), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `x-${i}`)))] }), (xLabel || yLabel) && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 9, color: theme.muted, marginTop: 2 }, children: [xLabel, yLabel].filter(Boolean).join(" · ") }))] }));
44
52
  }
@@ -4,7 +4,8 @@ exports.NativeRadarChart = NativeRadarChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  const TAU = Math.PI * 2;
10
11
  /** Point on a circle at `index` of `count`, starting at 12 o'clock. */
@@ -19,8 +20,9 @@ function vertex(index, count, radius, cx, cy) {
19
20
  * touch target: tapping one lists that axis's values for all series instead of
20
21
  * relying on a hover tooltip.
21
22
  */
22
- function NativeRadarChart({ axes, series, size = 260, rings = 4, max, isDark = false, palette, style, onAxisPress, }) {
23
+ function NativeRadarChart({ axes, series, size = 260, rings = 4, max, isDark: isDarkProp, palette, style, onAxisPress, }) {
23
24
  const [active, setActive] = (0, react_1.useState)(null);
25
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
24
26
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
25
27
  const { View, Text, Pressable, Svg, G, Line, Polygon, Circle, SvgText } = (0, primitives_1.primitives)();
26
28
  if (axes.length < 3 || series.length === 0) {
@@ -4,7 +4,8 @@ exports.NativeRingChart = NativeRingChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  const TAU = Math.PI * 2;
10
11
  /**
@@ -14,8 +15,9 @@ const TAU = Math.PI * 2;
14
15
  * places on both platforms. A legend is on by default: on a phone there is no
15
16
  * hover, so colour alone cannot identify a slice.
16
17
  */
17
- function NativeRingChart({ data, size = 180, thickness = 22, isDark = false, palette, showLegend = true, style, onSlicePress, }) {
18
+ function NativeRingChart({ data, size = 180, thickness = 22, isDark: isDarkProp, palette, showLegend = true, style, onSlicePress, }) {
18
19
  const [active, setActive] = (0, react_1.useState)(null);
20
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
19
21
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
20
22
  const { View, Text, Pressable, Svg, Path } = (0, primitives_1.primitives)();
21
23
  const total = data.reduce((sum, slice) => sum + Math.max(0, slice.value), 0);
@@ -5,7 +5,8 @@ exports.NativeBubbleChart = NativeBubbleChart;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_1 = require("react");
7
7
  const tokens_1 = require("../internal/tokens");
8
- const primitives_1 = require("./primitives");
8
+ const motion_1 = require("../internal/motion");
9
+ const primitives_1 = require("../internal/primitives");
9
10
  const scales_1 = require("./scales");
10
11
  const PADDING = { top: 12, right: 12, bottom: 24, left: 40 };
11
12
  /**
@@ -14,8 +15,9 @@ const PADDING = { top: 12, right: 12, bottom: 24, left: 40 };
14
15
  * BubbleChart is this component with `bubble` set, so the two share their
15
16
  * axes, padding and touch behaviour instead of drifting apart.
16
17
  */
17
- function NativeScatterChart({ series, width = 320, height = 200, radius = 4, bubble = false, isDark = false, palette, style, onPointPress, }) {
18
+ function NativeScatterChart({ series, width = 320, height = 200, radius = 4, bubble = false, isDark: isDarkProp, palette, style, onPointPress, }) {
18
19
  const [active, setActive] = (0, react_1.useState)(null);
20
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
19
21
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
20
22
  const { View, Text, Svg, G, Line, Circle, SvgText } = (0, primitives_1.primitives)();
21
23
  const plot = {
@@ -53,7 +55,10 @@ function NativeScatterChart({ series, width = 320, height = 200, radius = 4, bub
53
55
  }
54
56
  const yTicks = (0, scales_1.ticks)(yDomain, 4);
55
57
  const xTicks = (0, scales_1.ticks)(xDomain, 4);
56
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.24, strokeWidth: 1 }, `grid-${i}`))), series.map((s, si) => {
58
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style,
59
+ // One summary for the whole chart: the per-point touch targets below are
60
+ // the detailed access, this is what is announced on focus.
61
+ accessible: true, accessibilityRole: "image", accessibilityLabel: scatterSummary(series), children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.24, strokeWidth: 1 }, `grid-${i}`))), series.map((s, si) => {
57
62
  const color = s.color ?? (0, scales_1.seriesColor)(si, palette);
58
63
  return ((0, jsx_runtime_1.jsx)(G, { children: s.points.map((point, pi) => {
59
64
  const isActive = active?.s === si && active?.p === pi;
@@ -72,6 +77,18 @@ function NativeScatterChart({ series, width = 320, height = 200, radius = 4, bub
72
77
  backgroundColor: theme.glass,
73
78
  }, pointerEvents: "none", children: [(0, jsx_runtime_1.jsx)(Text, { style: { color: theme.foreground, fontSize: 10, fontWeight: "600" }, children: series[active.s].points[active.p].label ?? series[active.s].name }), (0, jsx_runtime_1.jsxs)(Text, { style: { color: theme.muted, fontSize: 10 }, children: ["x ", (0, scales_1.formatValue)(series[active.s].points[active.p].x), " \u00B7 y", " ", (0, scales_1.formatValue)(series[active.s].points[active.p].y)] })] }))] }));
74
79
  }
80
+ /** Reads the chart as one sentence for a screen reader. */
81
+ function scatterSummary(series) {
82
+ const sentences = series.map((entry) => {
83
+ const ys = entry.points.map((point) => point.y).filter(Number.isFinite);
84
+ if (ys.length === 0)
85
+ return `${entry.name}: no points`;
86
+ const min = (0, scales_1.formatValue)(Math.min(...ys));
87
+ const max = (0, scales_1.formatValue)(Math.max(...ys));
88
+ return `${entry.name}: ${entry.points.length} points, y from ${min} to ${max}`;
89
+ });
90
+ return `Scatter chart. ${sentences.join(". ")}`;
91
+ }
75
92
  /** Scatter marks sized by a third value. */
76
93
  function NativeBubbleChart(props) {
77
94
  return (0, jsx_runtime_1.jsx)(NativeScatterChart, { ...props, bubble: true });
@@ -4,7 +4,8 @@ exports.NativeWaterfallChart = NativeWaterfallChart;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("../internal/tokens");
7
- const primitives_1 = require("./primitives");
7
+ const motion_1 = require("../internal/motion");
8
+ const primitives_1 = require("../internal/primitives");
8
9
  const scales_1 = require("./scales");
9
10
  const PADDING = { top: 12, right: 8, bottom: 26, left: 42 };
10
11
  /**
@@ -14,8 +15,9 @@ const PADDING = { top: 12, right: 8, bottom: 26, left: 42 };
14
15
  * from opening to closing balance rather than a set of unrelated changes.
15
16
  * Increases and decreases are coloured differently, and totals span the axis.
16
17
  */
17
- function NativeWaterfallChart({ steps, width = 320, height = 200, isDark = false, style, onStepPress, }) {
18
+ function NativeWaterfallChart({ steps, width = 320, height = 200, isDark: isDarkProp, style, onStepPress, }) {
18
19
  const [active, setActive] = (0, react_1.useState)(null);
20
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
19
21
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
20
22
  const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = (0, primitives_1.primitives)();
21
23
  if (steps.length === 0) {
@@ -56,7 +58,7 @@ function NativeWaterfallChart({ steps, width = 320, height = 200, isDark = false
56
58
  const stepWidth = plot.width / steps.length;
57
59
  const barWidth = Math.min(34, stepWidth * 0.6);
58
60
  const zeroY = y(0);
59
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [(0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: zeroY, y2: zeroY, stroke: theme.axis, strokeOpacity: 0.4, strokeWidth: 1 }), geometry.map((g, i) => {
61
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style, accessible: true, accessibilityRole: "image", accessibilityLabel: waterfallSummary(steps, geometry), children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [(0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: zeroY, y2: zeroY, stroke: theme.axis, strokeOpacity: 0.4, strokeWidth: 1 }), geometry.map((g, i) => {
60
62
  const step = steps[i];
61
63
  const top = y(g.high);
62
64
  const barHeight = Math.max(1, y(g.low) - top);
@@ -70,6 +72,13 @@ function NativeWaterfallChart({ steps, width = 320, height = 200, isDark = false
70
72
  ? " (total)"
71
73
  : ` → ${(0, scales_1.formatValue)(geometry[active].end)} running`] }))] }));
72
74
  }
75
+ /** Reads the chart as one sentence for a screen reader. */
76
+ function waterfallSummary(steps, geometry) {
77
+ const last = geometry[geometry.length - 1];
78
+ const changes = steps.filter((step) => !step.isTotal).length;
79
+ const closing = last ? ` Closing value ${(0, scales_1.formatValue)(last.end)}.` : "";
80
+ return `Waterfall chart. ${steps.length} steps, ${changes} of them changes.${closing}`;
81
+ }
73
82
  /** Totals are neutral so they do not read as a gain or loss. */
74
83
  function seriesTotalColor(isDark) {
75
84
  return isDark ? "#8e8e93" : "#3c3c43";
@@ -8,7 +8,8 @@ exports.NativeHexChart = NativeHexChart;
8
8
  const jsx_runtime_1 = require("react/jsx-runtime");
9
9
  const react_1 = require("react");
10
10
  const tokens_1 = require("../internal/tokens");
11
- const primitives_1 = require("./primitives");
11
+ const motion_1 = require("../internal/motion");
12
+ const primitives_1 = require("../internal/primitives");
12
13
  const scales_1 = require("./scales");
13
14
  const PADDING = { top: 12, right: 8, bottom: 24, left: 42 };
14
15
  /**
@@ -18,8 +19,9 @@ const PADDING = { top: 12, right: 8, bottom: 24, left: 42 };
18
19
  * down, which is the convention traders read without a legend. Each candle is
19
20
  * tappable to reveal the four prices, replacing the web hover tooltip.
20
21
  */
21
- function NativeCandlestickChart({ candles, width = 320, height = 200, isDark = false, style, onCandlePress, }) {
22
+ function NativeCandlestickChart({ candles, width = 320, height = 200, isDark: isDarkProp, style, onCandlePress, }) {
22
23
  const [active, setActive] = (0, react_1.useState)(null);
24
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
23
25
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
24
26
  const { View, Text, Svg, G, Line, Rect, SvgText } = (0, primitives_1.primitives)();
25
27
  const up = "#34c759";
@@ -105,8 +107,9 @@ function squarify(values, box, output) {
105
107
  }
106
108
  }
107
109
  /** Proportional rectangles for part-to-whole comparison. */
108
- function NativeTreemapChart({ items, width = 320, height = 200, isDark = false, palette, style, onItemPress, }) {
110
+ function NativeTreemapChart({ items, width = 320, height = 200, isDark: isDarkProp, palette, style, onItemPress, }) {
109
111
  const [active, setActive] = (0, react_1.useState)(null);
112
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
110
113
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
111
114
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
112
115
  if (items.length === 0) {
@@ -150,7 +153,8 @@ function NativeTreemapChart({ items, width = 320, height = 200, isDark = false,
150
153
  * after everything feeding it. Rendering uses Views rather than SVG because the
151
154
  * bands are axis-aligned rectangles.
152
155
  */
153
- function NativeSankeyChart({ nodes, links, width = 320, height = 200, isDark = false, palette, style, }) {
156
+ function NativeSankeyChart({ nodes, links, width = 320, height = 200, isDark: isDarkProp, palette, style, }) {
157
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
154
158
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
155
159
  const { View, Text } = (0, primitives_1.primitives)();
156
160
  if (nodes.length === 0 || links.length === 0) {
@@ -209,7 +213,8 @@ function NativeSankeyChart({ nodes, links, width = 320, height = 200, isDark = f
209
213
  }, children: i === 0 ? "Start" : i === levels.length - 1 ? "End" : `Stage ${i}` }, level)))] }));
210
214
  }
211
215
  /** Rank changes over time, where the vertical position is the rank itself. */
212
- function NativeBumpChart({ labels, series, width = 320, height = 200, isDark = false, palette, style, onPointPress, }) {
216
+ function NativeBumpChart({ labels, series, width = 320, height = 200, isDark: isDarkProp, palette, style, onPointPress, }) {
217
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
213
218
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
214
219
  const { View, Text, Pressable, Svg, G, Line, Circle, SvgText } = (0, primitives_1.primitives)();
215
220
  const periods = labels.length;
@@ -245,8 +250,9 @@ function NativeBumpChart({ labels, series, width = 320, height = 200, isDark = f
245
250
  * Binning keeps thousands of points legible: reading one mark's exact position
246
251
  * matters less than seeing where density is concentrated.
247
252
  */
248
- function NativeHexChart({ points, radius = 9, width = 320, height = 200, isDark = false, style, onBinPress, }) {
253
+ function NativeHexChart({ points, radius = 9, width = 320, height = 200, isDark: isDarkProp, style, onBinPress, }) {
249
254
  const [active, setActive] = (0, react_1.useState)(null);
255
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
250
256
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
251
257
  const { View, Text, Pressable, Svg, G, Path } = (0, primitives_1.primitives)();
252
258
  if (points.length === 0) {
@@ -6,7 +6,8 @@ exports.NativeLiveLineChart = NativeLiveLineChart;
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
8
  const tokens_1 = require("../internal/tokens");
9
- const primitives_1 = require("./primitives");
9
+ const motion_1 = require("../internal/motion");
10
+ const primitives_1 = require("../internal/primitives");
10
11
  const LineChart_1 = require("./LineChart");
11
12
  const scales_1 = require("./scales");
12
13
  const TAU = Math.PI * 2;
@@ -21,8 +22,9 @@ function polar(angle, radius, cx, cy) {
21
22
  * one dimension (radius) rather than area. Each wedge is separately tappable
22
23
  * because a phone has no hover.
23
24
  */
24
- function NativePolarAreaChart({ segments, size = 240, max, isDark = false, palette, style, onSegmentPress, }) {
25
+ function NativePolarAreaChart({ segments, size = 240, max, isDark: isDarkProp, palette, style, onSegmentPress, }) {
25
26
  const [active, setActive] = (0, react_1.useState)(null);
27
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
26
28
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
27
29
  const { View, Text, Pressable, Svg, G, Path, Circle } = (0, primitives_1.primitives)();
28
30
  if (segments.length === 0) {
@@ -68,8 +70,9 @@ function NativePolarAreaChart({ segments, size = 240, max, isDark = false, palet
68
70
  * Bands are Views rather than SVG: each is a centred rectangle whose width is
69
71
  * the band's share of the widest level, which native layout computes exactly.
70
72
  */
71
- function NativePyramidChart({ levels, levelHeight = 34, width = 320, isDark = false, palette, style, onLevelPress, }) {
73
+ function NativePyramidChart({ levels, levelHeight = 34, width = 320, isDark: isDarkProp, palette, style, onLevelPress, }) {
72
74
  const [active, setActive] = (0, react_1.useState)(null);
75
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
73
76
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
74
77
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
75
78
  if (levels.length === 0) {
@@ -4,27 +4,25 @@ exports.GlassView = exports.isGlassSupported = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const fallback_1 = require("./fallback");
7
- let LiquidGlassViewComponent = null;
8
- let supported = false;
9
- try {
10
- const liquidGlass = require("@callstack/liquid-glass");
11
- if (liquidGlass && liquidGlass.LiquidGlassView) {
12
- LiquidGlassViewComponent = liquidGlass.LiquidGlassView;
13
- supported = Boolean(liquidGlass.isLiquidGlassSupported);
14
- }
15
- }
16
- catch {
17
- supported = false;
18
- }
19
- exports.isGlassSupported = supported;
7
+ const glass_routing_1 = require("./glass-routing");
8
+ const motion_1 = require("./motion");
9
+ /**
10
+ * The installed `@callstack/liquid-glass` module, resolved once at load.
11
+ * `isLiquidGlassSupported` is true only on iOS 26+; false on older iOS,
12
+ * Android and Expo Go.
13
+ */
14
+ const router = (0, glass_routing_1.defaultRouter)();
15
+ exports.isGlassSupported = router.supported;
20
16
  /**
21
- * Platform Glass View:
17
+ * Platform Glass View — the single place a glass surface is chosen:
22
18
  * - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
23
- * - iOS < 26 / Android / Expo Go / Fallback: Smooth translucent tint View with identical layout
19
+ * - iOS < 26 / Android / Expo Go: translucent tint View with identical layout
24
20
  */
25
- exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, style, children, ...props }, ref) {
26
- if (exports.isGlassSupported && LiquidGlassViewComponent) {
27
- return ((0, jsx_runtime_1.jsx)(LiquidGlassViewComponent, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, style: style, ...props, children: children }));
21
+ exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
22
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
23
+ if (router.supported && router.LiquidGlassView) {
24
+ const LiquidGlassView = router.LiquidGlassView;
25
+ return ((0, jsx_runtime_1.jsx)(LiquidGlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, style: style, ...props, children: children }));
28
26
  }
29
- return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, style: style, ...props, children: children }));
27
+ return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, testID: testID, isDark: isDark, style: style, ...props, children: children }));
30
28
  });
@@ -4,12 +4,23 @@ exports.FallbackGlassView = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("./tokens");
7
- exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({ effect = "regular", tintColor, style, children, isDark = false, ...props }, ref) {
7
+ const primitives_1 = require("./primitives");
8
+ /**
9
+ * Glacia's own glass surface for every platform where Apple's material is not
10
+ * available: Android, iOS before 26, and Expo Go.
11
+ *
12
+ * It renders the resolver's real React Native `View` with the same shape and
13
+ * layout as the native glass, so switching branches never shifts the layout.
14
+ */
15
+ exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({ effect = "regular", tintColor, testID, style, children, isDark = false, ...props }, ref) {
8
16
  const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
17
+ const { View } = (0, primitives_1.primitives)();
9
18
  const bg = effect === "none"
10
19
  ? "transparent"
11
20
  : effect === "clear"
12
- ? "rgba(255, 255, 255, 0.25)"
21
+ ? isDark
22
+ ? "rgba(28, 28, 30, 0.35)"
23
+ : "rgba(255, 255, 255, 0.35)"
13
24
  : tintColor || themeColors.glass;
14
25
  const containerStyle = {
15
26
  backgroundColor: bg,
@@ -19,5 +30,5 @@ exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({
19
30
  overflow: "hidden",
20
31
  ...style,
21
32
  };
22
- return ((0, jsx_runtime_1.jsx)("div", { ref: ref, style: containerStyle, ...props, children: children }));
33
+ return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: containerStyle, ...props, children: children }));
23
34
  });