glacia-native 0.3.5 → 0.5.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 (121) hide show
  1. package/lib/module/Bars.js +176 -0
  2. package/lib/module/Button.js +15 -2
  3. package/lib/module/Card.js +29 -14
  4. package/lib/module/Carousel.js +103 -0
  5. package/lib/module/Dialog.js +43 -32
  6. package/lib/module/Display.js +240 -0
  7. package/lib/module/Feedback.js +172 -0
  8. package/lib/module/Form.js +51 -12
  9. package/lib/module/Forms2.js +227 -0
  10. package/lib/module/Glass.js +11 -2
  11. package/lib/module/Input.js +19 -7
  12. package/lib/module/Overlays.js +166 -0
  13. package/lib/module/Pickers.js +243 -0
  14. package/lib/module/SegmentedControl.js +65 -21
  15. package/lib/module/Slider.js +121 -25
  16. package/lib/module/Switch.js +33 -15
  17. package/lib/module/TabBar.js +63 -25
  18. package/lib/module/Table.js +24 -6
  19. package/lib/module/Tabs.js +55 -33
  20. package/lib/module/Text.js +37 -0
  21. package/lib/module/ai.js +49 -20
  22. package/lib/module/charts/BarChart.js +4 -2
  23. package/lib/module/charts/FunnelChart.js +4 -2
  24. package/lib/module/charts/HeatmapChart.js +4 -2
  25. package/lib/module/charts/LineChart.js +4 -2
  26. package/lib/module/charts/PlotChart.js +11 -3
  27. package/lib/module/charts/RadarChart.js +4 -2
  28. package/lib/module/charts/RingChart.js +4 -2
  29. package/lib/module/charts/ScatterChart.js +20 -3
  30. package/lib/module/charts/WaterfallChart.js +12 -3
  31. package/lib/module/charts/advanced.js +12 -6
  32. package/lib/module/charts/extra.js +6 -3
  33. package/lib/module/index.js +58 -1
  34. package/lib/module/internal/GlassView.js +31 -17
  35. package/lib/module/internal/fallback.js +14 -3
  36. package/lib/module/internal/glass-routing.js +56 -0
  37. package/lib/module/internal/motion.js +55 -0
  38. package/lib/module/internal/primitives.js +413 -0
  39. package/lib/module/internal/tokens.js +55 -1
  40. package/lib/typescript/Bars.d.ts +121 -0
  41. package/lib/typescript/Button.d.ts +11 -1
  42. package/lib/typescript/Card.d.ts +20 -8
  43. package/lib/typescript/Carousel.d.ts +47 -0
  44. package/lib/typescript/Dialog.d.ts +19 -6
  45. package/lib/typescript/Display.d.ts +119 -0
  46. package/lib/typescript/Feedback.d.ts +138 -0
  47. package/lib/typescript/Form.d.ts +27 -11
  48. package/lib/typescript/Forms2.d.ts +128 -0
  49. package/lib/typescript/Glass.d.ts +10 -1
  50. package/lib/typescript/Input.d.ts +11 -1
  51. package/lib/typescript/Overlays.d.ts +105 -0
  52. package/lib/typescript/Pickers.d.ts +105 -0
  53. package/lib/typescript/SegmentedControl.d.ts +11 -1
  54. package/lib/typescript/Slider.d.ts +13 -1
  55. package/lib/typescript/Switch.d.ts +12 -1
  56. package/lib/typescript/TabBar.d.ts +13 -1
  57. package/lib/typescript/Table.d.ts +14 -5
  58. package/lib/typescript/Tabs.d.ts +8 -5
  59. package/lib/typescript/Text.d.ts +28 -0
  60. package/lib/typescript/ai.d.ts +12 -9
  61. package/lib/typescript/charts/BarChart.d.ts +1 -1
  62. package/lib/typescript/charts/FunnelChart.d.ts +1 -1
  63. package/lib/typescript/charts/HeatmapChart.d.ts +1 -1
  64. package/lib/typescript/charts/LineChart.d.ts +1 -1
  65. package/lib/typescript/charts/PlotChart.d.ts +1 -1
  66. package/lib/typescript/charts/RadarChart.d.ts +1 -1
  67. package/lib/typescript/charts/RingChart.d.ts +1 -1
  68. package/lib/typescript/charts/ScatterChart.d.ts +1 -1
  69. package/lib/typescript/charts/WaterfallChart.d.ts +1 -1
  70. package/lib/typescript/charts/advanced.d.ts +5 -5
  71. package/lib/typescript/charts/extra.d.ts +2 -2
  72. package/lib/typescript/index.d.ts +9 -1
  73. package/lib/typescript/internal/GlassView.d.ts +21 -4
  74. package/lib/typescript/internal/fallback.d.ts +10 -1
  75. package/lib/typescript/internal/glass-routing.d.ts +30 -0
  76. package/lib/typescript/internal/motion.d.ts +19 -0
  77. package/lib/typescript/internal/primitives.d.ts +41 -0
  78. package/lib/typescript/internal/tokens.d.ts +61 -0
  79. package/package.json +2 -2
  80. package/src/Bars.tsx +570 -0
  81. package/src/Button.tsx +47 -22
  82. package/src/Card.tsx +52 -31
  83. package/src/Carousel.tsx +233 -0
  84. package/src/Dialog.tsx +99 -64
  85. package/src/Display.tsx +550 -0
  86. package/src/Feedback.tsx +579 -0
  87. package/src/Form.tsx +90 -25
  88. package/src/Forms2.tsx +608 -0
  89. package/src/Glass.tsx +24 -1
  90. package/src/Input.tsx +33 -12
  91. package/src/Overlays.tsx +474 -0
  92. package/src/Pickers.tsx +590 -0
  93. package/src/SegmentedControl.tsx +104 -32
  94. package/src/Slider.tsx +151 -47
  95. package/src/Switch.tsx +56 -32
  96. package/src/TabBar.tsx +100 -30
  97. package/src/Table.tsx +38 -14
  98. package/src/Tabs.tsx +85 -32
  99. package/src/Text.tsx +83 -0
  100. package/src/ai.tsx +77 -31
  101. package/src/charts/BarChart.tsx +4 -2
  102. package/src/charts/FunnelChart.tsx +4 -2
  103. package/src/charts/HeatmapChart.tsx +4 -2
  104. package/src/charts/LineChart.tsx +4 -2
  105. package/src/charts/PlotChart.tsx +23 -3
  106. package/src/charts/RadarChart.tsx +4 -2
  107. package/src/charts/RingChart.tsx +4 -2
  108. package/src/charts/ScatterChart.tsx +24 -3
  109. package/src/charts/WaterfallChart.tsx +21 -3
  110. package/src/charts/advanced.tsx +12 -6
  111. package/src/charts/extra.tsx +6 -3
  112. package/src/index.ts +101 -1
  113. package/src/internal/GlassView.tsx +51 -19
  114. package/src/internal/fallback.tsx +23 -8
  115. package/src/internal/glass-routing.ts +68 -0
  116. package/src/internal/motion.ts +60 -0
  117. package/src/internal/primitives.ts +482 -0
  118. package/src/internal/tokens.ts +62 -0
  119. package/lib/module/charts/primitives.js +0 -212
  120. package/lib/typescript/charts/primitives.d.ts +0 -23
  121. package/src/charts/primitives.ts +0 -262
@@ -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) {
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.springs = exports.radii = exports.colors = exports.isGlassSupported = exports.NativeScrollArea = exports.NativeTable = exports.NativeImageGeneration = exports.NativeAIInput = exports.NativePanelside = exports.NativeThinkingOrb = exports.NativeSoundwave = exports.NativeTask = exports.NativeResponse = exports.NativeSources = exports.NativePlan = exports.ActionSheet = exports.AlertDialog = exports.DialogTrigger = exports.Dialog = exports.Select = exports.RadioGroup = exports.Checkbox = exports.Field = exports.Label = exports.Textarea = exports.Input = exports.CardFooter = exports.CardBody = exports.CardContent = exports.CardDescription = exports.CardTitle = exports.CardHeader = exports.Card = exports.Tabs = exports.TabBar = exports.SegmentedControl = exports.Slider = exports.Switch = exports.Button = exports.Glass = void 0;
17
+ exports.Accordion = exports.ListSection = exports.ListItem = exports.List = exports.Banner = exports.Toast = exports.initialsOf = exports.Progress = exports.Spinner = exports.Skeleton = exports.Separator = exports.Badge = exports.Avatar = exports.Text = exports.NativeScrollArea = exports.NativeTable = exports.NativeImageGeneration = exports.NativeAIInput = exports.NativePanelside = exports.NativeThinkingOrb = exports.NativeSoundwave = exports.NativeTask = exports.NativeResponse = exports.NativeSources = exports.NativePlan = exports.ActionSheet = exports.AlertDialog = exports.DialogTrigger = exports.Dialog = exports.Select = exports.RadioGroup = exports.Checkbox = exports.Field = exports.Label = exports.Textarea = exports.Input = exports.CardFooter = exports.CardBody = exports.CardContent = exports.CardDescription = exports.CardTitle = exports.CardHeader = exports.Card = exports.Tabs = exports.TabBar = exports.SegmentedControl = exports.Slider = exports.Switch = exports.Button = exports.Glass = void 0;
18
+ exports.toneColor = exports.typeScale = exports.springs = exports.radii = exports.colors = exports.isGlassSupported = exports.MONTHS = exports.WEEKDAYS = exports.formatTime = exports.parseTime = exports.sameDay = exports.startOfDay = exports.monthGrid = exports.TimePicker = exports.DatePicker = exports.Calendar = exports.ButtonGroup = exports.InputOTP = exports.ToggleGroup = exports.Toggle = exports.Stepper = exports.PageControl = exports.Carousel = exports.anchorPopover = exports.Drawer = exports.Sheet = exports.Menu = exports.AppBar = exports.IconButton = exports.FAB = exports.Chip = exports.SearchBar = void 0;
18
19
  var Glass_1 = require("./Glass");
19
20
  Object.defineProperty(exports, "Glass", { enumerable: true, get: function () { return Glass_1.Glass; } });
20
21
  var Button_1 = require("./Button");
@@ -70,9 +71,65 @@ Object.defineProperty(exports, "NativeTable", { enumerable: true, get: function
70
71
  Object.defineProperty(exports, "NativeScrollArea", { enumerable: true, get: function () { return Table_1.NativeScrollArea; } });
71
72
  // Charts, drawn with react-native-svg using the same maths as the web package.
72
73
  __exportStar(require("./charts"), exports);
74
+ // Basics.
75
+ var Text_1 = require("./Text");
76
+ Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return Text_1.Text; } });
77
+ var Display_1 = require("./Display");
78
+ Object.defineProperty(exports, "Avatar", { enumerable: true, get: function () { return Display_1.Avatar; } });
79
+ Object.defineProperty(exports, "Badge", { enumerable: true, get: function () { return Display_1.Badge; } });
80
+ Object.defineProperty(exports, "Separator", { enumerable: true, get: function () { return Display_1.Separator; } });
81
+ Object.defineProperty(exports, "Skeleton", { enumerable: true, get: function () { return Display_1.Skeleton; } });
82
+ Object.defineProperty(exports, "Spinner", { enumerable: true, get: function () { return Display_1.Spinner; } });
83
+ Object.defineProperty(exports, "Progress", { enumerable: true, get: function () { return Display_1.Progress; } });
84
+ Object.defineProperty(exports, "initialsOf", { enumerable: true, get: function () { return Display_1.initialsOf; } });
85
+ // Feedback and display.
86
+ var Feedback_1 = require("./Feedback");
87
+ Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Feedback_1.Toast; } });
88
+ Object.defineProperty(exports, "Banner", { enumerable: true, get: function () { return Feedback_1.Banner; } });
89
+ Object.defineProperty(exports, "List", { enumerable: true, get: function () { return Feedback_1.List; } });
90
+ Object.defineProperty(exports, "ListItem", { enumerable: true, get: function () { return Feedback_1.ListItem; } });
91
+ Object.defineProperty(exports, "ListSection", { enumerable: true, get: function () { return Feedback_1.ListSection; } });
92
+ Object.defineProperty(exports, "Accordion", { enumerable: true, get: function () { return Feedback_1.Accordion; } });
93
+ // Bars, buttons and navigation.
94
+ var Bars_1 = require("./Bars");
95
+ Object.defineProperty(exports, "SearchBar", { enumerable: true, get: function () { return Bars_1.SearchBar; } });
96
+ Object.defineProperty(exports, "Chip", { enumerable: true, get: function () { return Bars_1.Chip; } });
97
+ Object.defineProperty(exports, "FAB", { enumerable: true, get: function () { return Bars_1.FAB; } });
98
+ Object.defineProperty(exports, "IconButton", { enumerable: true, get: function () { return Bars_1.IconButton; } });
99
+ Object.defineProperty(exports, "AppBar", { enumerable: true, get: function () { return Bars_1.AppBar; } });
100
+ // Overlays.
101
+ var Overlays_1 = require("./Overlays");
102
+ Object.defineProperty(exports, "Menu", { enumerable: true, get: function () { return Overlays_1.Menu; } });
103
+ Object.defineProperty(exports, "Sheet", { enumerable: true, get: function () { return Overlays_1.Sheet; } });
104
+ Object.defineProperty(exports, "Drawer", { enumerable: true, get: function () { return Overlays_1.Drawer; } });
105
+ Object.defineProperty(exports, "anchorPopover", { enumerable: true, get: function () { return Overlays_1.anchorPopover; } });
106
+ // Carousel.
107
+ var Carousel_1 = require("./Carousel");
108
+ Object.defineProperty(exports, "Carousel", { enumerable: true, get: function () { return Carousel_1.Carousel; } });
109
+ Object.defineProperty(exports, "PageControl", { enumerable: true, get: function () { return Carousel_1.PageControl; } });
110
+ // Forms and pickers.
111
+ var Forms2_1 = require("./Forms2");
112
+ Object.defineProperty(exports, "Stepper", { enumerable: true, get: function () { return Forms2_1.Stepper; } });
113
+ Object.defineProperty(exports, "Toggle", { enumerable: true, get: function () { return Forms2_1.Toggle; } });
114
+ Object.defineProperty(exports, "ToggleGroup", { enumerable: true, get: function () { return Forms2_1.ToggleGroup; } });
115
+ Object.defineProperty(exports, "InputOTP", { enumerable: true, get: function () { return Forms2_1.InputOTP; } });
116
+ Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return Forms2_1.ButtonGroup; } });
117
+ var Pickers_1 = require("./Pickers");
118
+ Object.defineProperty(exports, "Calendar", { enumerable: true, get: function () { return Pickers_1.Calendar; } });
119
+ Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return Pickers_1.DatePicker; } });
120
+ Object.defineProperty(exports, "TimePicker", { enumerable: true, get: function () { return Pickers_1.TimePicker; } });
121
+ Object.defineProperty(exports, "monthGrid", { enumerable: true, get: function () { return Pickers_1.monthGrid; } });
122
+ Object.defineProperty(exports, "startOfDay", { enumerable: true, get: function () { return Pickers_1.startOfDay; } });
123
+ Object.defineProperty(exports, "sameDay", { enumerable: true, get: function () { return Pickers_1.sameDay; } });
124
+ Object.defineProperty(exports, "parseTime", { enumerable: true, get: function () { return Pickers_1.parseTime; } });
125
+ Object.defineProperty(exports, "formatTime", { enumerable: true, get: function () { return Pickers_1.formatTime; } });
126
+ Object.defineProperty(exports, "WEEKDAYS", { enumerable: true, get: function () { return Pickers_1.WEEKDAYS; } });
127
+ Object.defineProperty(exports, "MONTHS", { enumerable: true, get: function () { return Pickers_1.MONTHS; } });
73
128
  var GlassView_1 = require("./internal/GlassView");
74
129
  Object.defineProperty(exports, "isGlassSupported", { enumerable: true, get: function () { return GlassView_1.isGlassSupported; } });
75
130
  var tokens_1 = require("./internal/tokens");
76
131
  Object.defineProperty(exports, "colors", { enumerable: true, get: function () { return tokens_1.colors; } });
77
132
  Object.defineProperty(exports, "radii", { enumerable: true, get: function () { return tokens_1.radii; } });
78
133
  Object.defineProperty(exports, "springs", { enumerable: true, get: function () { return tokens_1.springs; } });
134
+ Object.defineProperty(exports, "typeScale", { enumerable: true, get: function () { return tokens_1.typeScale; } });
135
+ Object.defineProperty(exports, "toneColor", { enumerable: true, get: function () { return tokens_1.toneColor; } });
@@ -1,30 +1,44 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GlassView = exports.isGlassSupported = void 0;
4
+ exports.resetGlassRouter = resetGlassRouter;
4
5
  const jsx_runtime_1 = require("react/jsx-runtime");
5
6
  const react_1 = require("react");
6
7
  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
- }
8
+ const glass_routing_1 = require("./glass-routing");
9
+ const motion_1 = require("./motion");
10
+ /**
11
+ * The installed `@callstack/liquid-glass` module's routing decision.
12
+ *
13
+ * Resolved lazily and memoised on first use, rather than at module load, so the
14
+ * decision is taken when a surface first renders. On a device that is the same
15
+ * answer either way — `isLiquidGlassSupported` is a constant of the installed
16
+ * build — but it keeps the choice a property of the module rather than of
17
+ * import order, which is what makes both branches reachable in tests.
18
+ */
19
+ let cachedRouter = null;
20
+ function router() {
21
+ if (cachedRouter === null)
22
+ cachedRouter = (0, glass_routing_1.defaultRouter)();
23
+ return cachedRouter;
15
24
  }
16
- catch {
17
- supported = false;
25
+ /** Clears the memoised decision. Only tests call this, to drive both branches. */
26
+ function resetGlassRouter() {
27
+ cachedRouter = null;
18
28
  }
19
- exports.isGlassSupported = supported;
29
+ /** Whether this build renders Apple's glass. */
30
+ exports.isGlassSupported = (0, glass_routing_1.defaultRouter)().supported;
20
31
  /**
21
- * Platform Glass View:
32
+ * Platform Glass View — the single place a glass surface is chosen:
22
33
  * - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
23
- * - iOS < 26 / Android / Expo Go / Fallback: Smooth translucent tint View with identical layout
34
+ * - iOS < 26 / Android / Expo Go: translucent tint View with identical layout
24
35
  */
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 }));
36
+ exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
37
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
38
+ const decision = router();
39
+ if (decision.supported && decision.LiquidGlassView) {
40
+ const LiquidGlassView = decision.LiquidGlassView;
41
+ return ((0, jsx_runtime_1.jsx)(LiquidGlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, style: style, ...props, children: children }));
28
42
  }
29
- return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, style: style, ...props, children: children }));
43
+ 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
44
  });
@@ -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
  });
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ // The glass switch — the law of this library.
3
+ //
4
+ // Every glass surface in every Glacia Native component goes through
5
+ // `GlassView`, which routes here. On iOS 26+ `@callstack/liquid-glass` reports
6
+ // `isLiquidGlassSupported === true` and the surface is rendered by Apple's
7
+ // real `UIGlassEffect` (`LiquidGlassView`). Everywhere else — older iOS,
8
+ // Android, Expo Go, or a build without the module — it is Glacia's own
9
+ // translucent fallback of identical shape.
10
+ //
11
+ // The decision is split out from the React component so both branches can be
12
+ // exercised in tests: `routerFor` takes the module as an argument, and the
13
+ // default export routes on whatever is installed. On a device the argument is
14
+ // always the installed module, so the routing logic is unchanged.
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.routerFor = routerFor;
17
+ exports.loadLiquidGlass = loadLiquidGlass;
18
+ exports.defaultRouter = defaultRouter;
19
+ /**
20
+ * Reads a liquid-glass module and decides which branch renders.
21
+ *
22
+ * A module only counts as supported when it exports the view *and* reports
23
+ * support; a missing export falls back rather than crashing.
24
+ */
25
+ function routerFor(module) {
26
+ const view = module?.LiquidGlassView ?? null;
27
+ return {
28
+ supported: Boolean(module?.isLiquidGlassSupported) && Boolean(view),
29
+ LiquidGlassView: view,
30
+ };
31
+ }
32
+ /**
33
+ * Loads `@callstack/liquid-glass` at runtime.
34
+ *
35
+ * Resolved through `require` rather than a static import so the package stays
36
+ * importable where the native module is absent (jsdom tests, web preview).
37
+ * `isLiquidGlassSupported` is a constant baked by the package's own platform
38
+ * resolution: its iOS build reads the native module and answers true only on
39
+ * iOS 26+; the default build answers false.
40
+ */
41
+ function loadLiquidGlass() {
42
+ try {
43
+ const module = require("@callstack/liquid-glass");
44
+ if (module && (module.LiquidGlassView || module.isLiquidGlassSupported !== undefined)) {
45
+ return module;
46
+ }
47
+ return null;
48
+ }
49
+ catch {
50
+ return null;
51
+ }
52
+ }
53
+ /** The installed module's routing decision, computed once per process. */
54
+ function defaultRouter() {
55
+ return routerFor(loadLiquidGlass());
56
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ // Shared component plumbing: dark-mode defaulting and spring motion.
3
+ //
4
+ // Two rules apply to every Glacia component, so they live here instead of
5
+ // being repeated (and forgotten) in each file:
6
+ // - `useIsDark` falls back to the phone's own colour scheme when the caller
7
+ // does not pass `isDark`, so a theme-aware app needs no extra prop threading.
8
+ // - `useSpring` animates a number towards its target with the package's spring
9
+ // tokens through React Native's Animated API. No CSS, no timers of our own.
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.useIsDark = useIsDark;
12
+ exports.useSpring = useSpring;
13
+ const react_1 = require("react");
14
+ const primitives_1 = require("./primitives");
15
+ const tokens_1 = require("./tokens");
16
+ /**
17
+ * Resolves the theme. An explicit `isDark` always wins; otherwise the phone's
18
+ * colour scheme decides, defaulting to light when it is unknown.
19
+ */
20
+ function useIsDark(isDark) {
21
+ const { useColorScheme } = (0, primitives_1.primitives)();
22
+ const scheme = typeof useColorScheme === "function" ? useColorScheme() : null;
23
+ return isDark ?? scheme === "dark";
24
+ }
25
+ /**
26
+ * A value that springs towards `target` whenever it changes.
27
+ *
28
+ * Returns the `Animated.Value` to put in a style, plus whether motion is real
29
+ * on this platform. A caller that gets `animated === false` renders the target
30
+ * directly, so the DOM preview and tests show the settled state rather than an
31
+ * animation the environment cannot advance.
32
+ */
33
+ function useSpring(target, spring = "snappy") {
34
+ const { Animated, isNative } = (0, primitives_1.primitives)();
35
+ const animated = Boolean(isNative && Animated?.Value && Animated?.spring);
36
+ // Off-device there is no Animated; a plain ref keeps the call sites identical.
37
+ const value = (0, react_1.useRef)(null);
38
+ if (value.current === null) {
39
+ value.current = animated ? new Animated.Value(target) : { value: target };
40
+ }
41
+ (0, react_1.useEffect)(() => {
42
+ if (!animated) {
43
+ value.current.value = target;
44
+ return;
45
+ }
46
+ const animation = Animated.spring(value.current, {
47
+ toValue: target,
48
+ ...tokens_1.springs[spring],
49
+ useNativeDriver: false,
50
+ });
51
+ animation.start();
52
+ return () => animation.stop?.();
53
+ }, [animated, spring, target]);
54
+ return { value: value.current, animated };
55
+ }