glacia-native 0.5.1 → 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 (75) hide show
  1. package/LICENSE +29 -4
  2. package/README.md +27 -0
  3. package/lib/module/Bars.js +10 -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 +8 -7
  8. package/lib/module/Feedback.js +24 -15
  9. package/lib/module/Form.js +29 -33
  10. package/lib/module/Forms2.js +38 -21
  11. package/lib/module/Glass.js +2 -2
  12. package/lib/module/Input.js +12 -10
  13. package/lib/module/Message.js +11 -15
  14. package/lib/module/Overlays.js +22 -6
  15. package/lib/module/Pickers.js +16 -16
  16. package/lib/module/SegmentedControl.js +19 -10
  17. package/lib/module/Slider.js +18 -9
  18. package/lib/module/Switch.js +21 -9
  19. package/lib/module/TabBar.js +18 -12
  20. package/lib/module/Table.js +4 -3
  21. package/lib/module/Tabs.js +3 -2
  22. package/lib/module/ai.js +18 -15
  23. package/lib/module/charts/BarChart.js +11 -3
  24. package/lib/module/internal/GlassView.js +2 -2
  25. package/lib/module/internal/blur.js +78 -0
  26. package/lib/module/internal/fallback.js +110 -20
  27. package/lib/module/internal/glow.js +36 -0
  28. package/lib/module/internal/lens.js +70 -0
  29. package/lib/module/internal/material.js +64 -0
  30. package/lib/module/internal/primitives.js +1 -0
  31. package/lib/module/internal/rim.js +35 -0
  32. package/lib/module/internal/tokens.js +34 -2
  33. package/lib/typescript/Message.d.ts +5 -9
  34. package/lib/typescript/index.d.ts +1 -0
  35. package/lib/typescript/internal/GlassView.d.ts +13 -0
  36. package/lib/typescript/internal/blur.d.ts +24 -0
  37. package/lib/typescript/internal/fallback.d.ts +27 -2
  38. package/lib/typescript/internal/glow.d.ts +11 -0
  39. package/lib/typescript/internal/lens.d.ts +47 -0
  40. package/lib/typescript/internal/material.d.ts +27 -0
  41. package/lib/typescript/internal/primitives.d.ts +2 -0
  42. package/lib/typescript/internal/rim.d.ts +16 -0
  43. package/lib/typescript/internal/tokens.d.ts +36 -0
  44. package/package.json +12 -3
  45. package/src/Bars.tsx +12 -2
  46. package/src/Button.tsx +16 -9
  47. package/src/Card.tsx +2 -2
  48. package/src/Dialog.tsx +37 -26
  49. package/src/Display.tsx +8 -5
  50. package/src/Feedback.tsx +36 -13
  51. package/src/Form.tsx +60 -40
  52. package/src/Forms2.tsx +65 -24
  53. package/src/Glass.tsx +4 -0
  54. package/src/Input.tsx +15 -11
  55. package/src/Message.tsx +15 -16
  56. package/src/Overlays.tsx +25 -6
  57. package/src/Pickers.tsx +11 -6
  58. package/src/SegmentedControl.tsx +33 -9
  59. package/src/Slider.tsx +19 -10
  60. package/src/Switch.tsx +24 -10
  61. package/src/TabBar.tsx +33 -12
  62. package/src/Table.tsx +4 -3
  63. package/src/Tabs.tsx +5 -0
  64. package/src/ai.tsx +28 -20
  65. package/src/charts/BarChart.tsx +41 -3
  66. package/src/index.ts +1 -0
  67. package/src/internal/GlassView.tsx +17 -0
  68. package/src/internal/blur.ts +90 -0
  69. package/src/internal/fallback.tsx +158 -20
  70. package/src/internal/glow.tsx +62 -0
  71. package/src/internal/lens.tsx +105 -0
  72. package/src/internal/material.ts +92 -0
  73. package/src/internal/primitives.ts +3 -0
  74. package/src/internal/rim.tsx +79 -0
  75. package/src/internal/tokens.ts +34 -1
@@ -8,7 +8,10 @@ const tokens_1 = require("./internal/tokens");
8
8
  const primitives_1 = require("./internal/primitives");
9
9
  const motion_1 = require("./internal/motion");
10
10
  const haptics_1 = require("./internal/haptics");
11
- const BAR_HEIGHT = 52;
11
+ const lens_1 = require("./internal/lens");
12
+ // The web bar: a 40pt rail (32pt tabs in a 4pt inset) with a 20pt radius, a
13
+ // glass lens filling the active slot, and 13pt labels at 500/400 weight.
14
+ const BAR_HEIGHT = 40;
12
15
  /**
13
16
  * The bottom bar of an app: a row of tabs on one glass surface.
14
17
  *
@@ -23,6 +26,7 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
23
26
  const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
24
27
  const { View, Text, Pressable, Animated } = (0, primitives_1.primitives)();
25
28
  const [internalId, setInternalId] = (0, react_1.useState)(defaultActiveId || items[0]?.id || "");
29
+ const [held, setHeld] = (0, react_1.useState)(false);
26
30
  const activeId = activeProp !== undefined ? activeProp : internalId;
27
31
  const activeIndex = Math.max(0, items.findIndex((item) => item.id === activeId));
28
32
  // The active wash slides between equally wide items on the springs token.
@@ -40,23 +44,25 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
40
44
  alignItems: "center",
41
45
  justifyContent: "space-around",
42
46
  height: BAR_HEIGHT,
43
- paddingHorizontal: 8,
44
- borderRadius: tokens_1.radii.xl,
47
+ paddingHorizontal: 4,
48
+ borderRadius: tokens_1.radii.lg,
45
49
  ...style,
46
50
  };
47
51
  const count = Math.max(items.length, 1);
48
52
  const itemWidth = `${100 / count}%`;
49
53
  const indicatorStyle = {
50
54
  position: "absolute",
51
- top: 6,
52
- bottom: 6,
53
- left: 8,
55
+ top: 4,
56
+ bottom: 4,
57
+ left: 4,
54
58
  width: itemWidth,
55
- borderRadius: tokens_1.radii.lg,
59
+ borderRadius: tokens_1.radii.pill,
56
60
  backgroundColor: themeColors.glassActive,
57
61
  opacity: 0.75,
62
+ // A lens, not a wash: it lifts off the rail and carries the rim.
63
+ ...(0, lens_1.lensShadow)(isDark),
58
64
  };
59
- return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, style: barStyle, testID: testID, ...props, children: [animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { pointerEvents: "none", style: {
65
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", pressed: held, isDark: isDark, style: barStyle, testID: testID, ...props, children: [animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { pointerEvents: "none", style: {
60
66
  ...indicatorStyle,
61
67
  transform: [
62
68
  {
@@ -69,9 +75,9 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
69
75
  }),
70
76
  },
71
77
  ],
72
- } })) : ((0, jsx_runtime_1.jsx)(View, { pointerEvents: "none", style: { ...indicatorStyle, left: `${(activeIndex * 100) / count}%` } })), items.map((tab) => {
78
+ }, children: (0, jsx_runtime_1.jsx)(lens_1.LensRim, { radius: tokens_1.radii.pill, isDark: isDark }) })) : ((0, jsx_runtime_1.jsx)(View, { pointerEvents: "none", style: { ...indicatorStyle, left: `${(activeIndex * 100) / count}%` }, children: (0, jsx_runtime_1.jsx)(lens_1.LensRim, { radius: tokens_1.radii.pill, isDark: isDark }) })), items.map((tab) => {
73
79
  const isActive = tab.id === activeId;
74
- return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), style: {
80
+ return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: {
75
81
  flex: 1,
76
82
  height: "100%",
77
83
  flexDirection: "column",
@@ -81,8 +87,8 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
81
87
  paddingHorizontal: 8,
82
88
  paddingVertical: 4,
83
89
  }, children: [tab.icon ?? null, (0, jsx_runtime_1.jsx)(Text, { numberOfLines: 1, style: {
84
- fontSize: 11,
85
- fontWeight: isActive ? "600" : "500",
90
+ fontSize: 13,
91
+ fontWeight: isActive ? "500" : "400",
86
92
  color: isActive ? themeColors.fill : themeColors.muted,
87
93
  }, children: tab.label })] }, tab.id));
88
94
  })] }));
@@ -25,7 +25,7 @@ function NativeTable({ columns, rows, onRowPress, caption, isDark: isDarkProp, s
25
25
  const primaryKey = columns.find((column) => column.primary)?.key ?? columns[0]?.key;
26
26
  const primaryColumn = columns.find((column) => column.key === primaryKey);
27
27
  const detailColumns = columns.filter((column) => column.key !== primaryKey);
28
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, testID: testID, children: [caption && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted, marginBottom: 8 }, children: caption })), rows.map((row) => {
28
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style, testID: testID, children: [caption && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginBottom: 8 }, children: caption })), rows.map((row) => {
29
29
  const RowWrapper = onRowPress ? Pressable : View;
30
30
  const wrapperProps = onRowPress
31
31
  ? {
@@ -35,7 +35,8 @@ function NativeTable({ columns, rows, onRowPress, caption, isDark: isDarkProp, s
35
35
  }
36
36
  : { accessibilityRole: "text" };
37
37
  return ((0, jsx_runtime_1.jsxs)(RowWrapper, { ...wrapperProps, style: {
38
- paddingVertical: 10,
38
+ paddingVertical: 12,
39
+ paddingHorizontal: 16,
39
40
  borderBottomWidth: 1,
40
41
  borderBottomColor: theme.edge,
41
42
  }, children: [primaryColumn && ((0, jsx_runtime_1.jsx)(Text, { style: {
@@ -48,7 +49,7 @@ function NativeTable({ columns, rows, onRowPress, caption, isDark: isDarkProp, s
48
49
  justifyContent: "space-between",
49
50
  alignItems: "baseline",
50
51
  gap: 12,
51
- }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: column.header }), (0, jsx_runtime_1.jsx)(Text, { style: {
52
+ }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "600", color: theme.muted }, children: column.header }), (0, jsx_runtime_1.jsx)(Text, { style: {
52
53
  fontSize: 12,
53
54
  color: theme.foreground,
54
55
  textAlign: column.align ?? "left",
@@ -21,6 +21,7 @@ exports.Tabs = (0, react_1.forwardRef)(function Tabs({ items, activeId: activePr
21
21
  const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
22
22
  const { View, Text, Pressable, Animated } = (0, primitives_1.primitives)();
23
23
  const [internalId, setInternalId] = (0, react_1.useState)(defaultActiveId || items[0]?.id || "");
24
+ const [held, setHeld] = (0, react_1.useState)(false);
24
25
  const activeId = activeProp !== undefined ? activeProp : internalId;
25
26
  const activeIndex = Math.max(0, items.findIndex((tab) => tab.id === activeId));
26
27
  const { value: slide, animated } = (0, motion_1.useSpring)(activeIndex, "snappy");
@@ -43,7 +44,7 @@ exports.Tabs = (0, react_1.forwardRef)(function Tabs({ items, activeId: activePr
43
44
  borderWidth: 0.5,
44
45
  borderColor: themeColors.edge,
45
46
  };
46
- return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, style: {
47
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", pressed: held, isDark: isDark, style: {
47
48
  flexDirection: "row",
48
49
  alignItems: "center",
49
50
  alignSelf: "flex-start",
@@ -63,7 +64,7 @@ exports.Tabs = (0, react_1.forwardRef)(function Tabs({ items, activeId: activePr
63
64
  ],
64
65
  } })) : ((0, jsx_runtime_1.jsx)(View, { pointerEvents: "none", style: { ...paneStyle, left: `${(activeIndex * 100) / count}%` } })), items.map((tab) => {
65
66
  const isActive = tab.id === activeId;
66
- return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), style: {
67
+ return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: {
67
68
  flex: 1,
68
69
  height: 36,
69
70
  flexDirection: "row",
package/lib/module/ai.js CHANGED
@@ -11,9 +11,11 @@ exports.NativeAIInput = NativeAIInput;
11
11
  exports.NativeImageGeneration = NativeImageGeneration;
12
12
  const jsx_runtime_1 = require("react/jsx-runtime");
13
13
  const react_1 = require("react");
14
+ const Glass_1 = require("./Glass");
14
15
  const tokens_1 = require("./internal/tokens");
15
16
  const primitives_1 = require("./internal/primitives");
16
17
  const motion_1 = require("./internal/motion");
18
+ const lens_1 = require("./internal/lens");
17
19
  const a11y_1 = require("./internal/a11y");
18
20
  /**
19
21
  * The ordered steps a model intends to take.
@@ -33,7 +35,7 @@ function NativePlan({ title = "Plan", steps, isDark: isDarkProp, style }) {
33
35
  : status === "running"
34
36
  ? theme.fill
35
37
  : theme.muted;
36
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(View, { style: {
38
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsxs)(View, { style: {
37
39
  flexDirection: "row",
38
40
  justifyContent: "space-between",
39
41
  alignItems: "center",
@@ -65,7 +67,7 @@ function NativeSources({ sources, title = "Sources", isDark: isDarkProp, style,
65
67
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
66
68
  if (sources.length === 0)
67
69
  return null;
68
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title }), sources.map((source, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "link", accessibilityLabel: source.title, onPress: () => onSourcePress?.(source), style: {
70
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title }), sources.map((source, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "link", accessibilityLabel: source.title, onPress: () => onSourcePress?.(source), style: {
69
71
  flexDirection: "row",
70
72
  gap: 9,
71
73
  paddingVertical: 7,
@@ -88,7 +90,7 @@ function NativeResponse({ text, revealed, streaming, isDark: isDarkProp, style,
88
90
  const { View, Text } = (0, primitives_1.primitives)();
89
91
  const shown = revealed == null ? text : text.slice(0, Math.max(0, revealed));
90
92
  const isStreaming = streaming ?? (revealed != null && revealed < text.length);
91
- 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" })] }));
93
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, 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" })] }));
92
94
  }
93
95
  /** Progress of a long-running background task. */
94
96
  function NativeTask({ task, isDark: isDarkProp, style }) {
@@ -98,12 +100,12 @@ function NativeTask({ task, isDark: isDarkProp, style }) {
98
100
  const percent = task.progress == null ? null : Math.round(Math.min(1, Math.max(0, task.progress)) * 100);
99
101
  const status = task.status ?? "running";
100
102
  const fillColor = status === "failed" ? theme.destructive : status === "done" ? "#34c759" : theme.fill;
101
- return ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "progressbar", accessibilityLabel: task.label ?? "Task progress",
103
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, accessibilityRole: "progressbar", accessibilityLabel: task.label ?? "Task progress",
102
104
  // Without the value, a screen reader only reads the label and never says
103
105
  // how far along the task is.
104
106
  accessibilityValue: percent == null ? undefined : { min: 0, max: 100, now: percent }, accessibilityState: {
105
107
  disabled: false,
106
- }, 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: {
108
+ }, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, 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: {
107
109
  height: 6,
108
110
  borderRadius: 3,
109
111
  backgroundColor: isDark ? "rgba(235,235,245,0.15)" : "rgba(0,0,0,0.08)",
@@ -185,7 +187,7 @@ function NativePanelside({ items, value, onValueChange, isDark: isDarkProp, styl
185
187
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
186
188
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
187
189
  const { View, Text, Pressable } = (0, primitives_1.primitives)();
188
- 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) => {
190
+ return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [title && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title })), items.map((item) => {
189
191
  const isActive = item.id === value;
190
192
  return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isActive }, accessibilityLabel: item.label, onPress: () => onValueChange?.(item.id), style: {
191
193
  flexDirection: "row",
@@ -194,9 +196,9 @@ function NativePanelside({ items, value, onValueChange, isDark: isDarkProp, styl
194
196
  paddingVertical: 9,
195
197
  paddingHorizontal: 11,
196
198
  borderRadius: tokens_1.radii.md,
197
- backgroundColor: isActive ? theme.glassActive : "transparent",
199
+ backgroundColor: "transparent",
198
200
  marginBottom: 2,
199
- }, children: [(0, jsx_runtime_1.jsx)(Text, { style: {
201
+ }, children: [isActive ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.md, isDark: isDark, style: lens_1.lensFill }) : null, (0, jsx_runtime_1.jsx)(Text, { style: {
200
202
  fontSize: 13,
201
203
  color: isActive ? theme.foreground : theme.muted,
202
204
  fontWeight: isActive ? "600" : "400",
@@ -226,15 +228,14 @@ function NativeAIInput({ value: valueProp, defaultValue, onChangeText, onSubmit,
226
228
  // The themed placeholder is drawn as a Text, matching Input: the OS default
227
229
  // placeholder colour ignores the theme.
228
230
  const showPlaceholder = !value && Boolean(placeholder);
229
- return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(View, { style: {
231
+ return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "field", isDark: isDark, style: {
230
232
  flexDirection: "row",
231
233
  alignItems: "flex-end",
232
234
  gap: 8,
233
- padding: 8,
234
- borderRadius: tokens_1.radii.lg,
235
- borderWidth: 1,
236
- borderColor: theme.edge,
237
- backgroundColor: theme.glass,
235
+ paddingVertical: 6,
236
+ paddingRight: 6,
237
+ paddingLeft: 16,
238
+ borderRadius: tokens_1.radii.pill,
238
239
  opacity: disabled ? 0.5 : 1,
239
240
  }, 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: {
240
241
  position: "absolute",
@@ -249,8 +250,10 @@ function NativeAIInput({ value: valueProp, defaultValue, onChangeText, onSubmit,
249
250
  fontSize: 14,
250
251
  color: theme.foreground,
251
252
  } })] }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: sendLabel, accessibilityState: { disabled: !canSend }, disabled: !canSend, onPress: () => canSend && onSubmit?.(), style: {
252
- paddingVertical: 8,
253
+ height: 34,
253
254
  paddingHorizontal: 14,
255
+ alignItems: "center",
256
+ justifyContent: "center",
254
257
  borderRadius: tokens_1.radii.pill,
255
258
  backgroundColor: canSend ? theme.fill : theme.edge,
256
259
  }, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: canSend ? "#fff" : theme.muted }, children: busy ? "…" : sendLabel }) })] }), footer] }));
@@ -13,7 +13,7 @@ function NativeBarChart({ labels, series, width = 320, height = 200, stacked = f
13
13
  const [active, setActive] = (0, react_1.useState)(null);
14
14
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
15
15
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
16
- const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = (0, primitives_1.primitives)();
16
+ const { View, Text, Pressable, Svg, G, Line, Rect, SvgText, Defs, LinearGradient, Stop, } = (0, primitives_1.primitives)();
17
17
  const plot = {
18
18
  x: PADDING.left,
19
19
  y: PADDING.top,
@@ -31,12 +31,18 @@ function NativeBarChart({ labels, series, width = 320, height = 200, stacked = f
31
31
  }, [totals.join(",")]);
32
32
  const y = (0, scales_1.linearScale)(domain, [bottom, plot.y], { nice: false });
33
33
  const bands = (0, scales_1.bandScale)(labels.length, [plot.x, right], 0.32);
34
+ const seriesColors = series.map((s, si) => s.color ?? (0, scales_1.seriesColor)(si, palette));
35
+ // One gradient per series, so the SVG can reference them by id.
36
+ const gradientKey = (0, react_1.useId)().replace(/[^a-zA-Z0-9_-]/g, "");
34
37
  const barWidth = stacked ? bands.width : bands.width / Math.max(1, series.length);
35
38
  const yTicks = (0, scales_1.ticks)(domain, 4);
36
39
  if (labels.length === 0 || series.length === 0) {
37
40
  return ((0, jsx_runtime_1.jsx)(View, { style: [{ width, height, alignItems: "center", justifyContent: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No bars to display" }) }));
38
41
  }
39
- 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}`))), labels.map((label, i) => {
42
+ 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)(Defs, { children: seriesColors.map((color, si) => (
43
+ // The web's bar fill runs from the series colour at the top to
44
+ // transparent at the base, so a bar reads as lit from above.
45
+ (0, jsx_runtime_1.jsxs)(LinearGradient, { id: `bar-${gradientKey}-${si}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)(Stop, { offset: "0", stopColor: color, stopOpacity: 1 }), (0, jsx_runtime_1.jsx)(Stop, { offset: "0.55", stopColor: color, stopOpacity: 0.62 }), (0, jsx_runtime_1.jsx)(Stop, { offset: "1", stopColor: color, stopOpacity: 0.04 })] }, `grad-${si}`))) }), 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}`))), labels.map((label, i) => {
40
46
  let stackTop = bottom;
41
47
  return ((0, jsx_runtime_1.jsx)(G, { children: series.map((s, si) => {
42
48
  const value = s.values[i] ?? 0;
@@ -49,7 +55,9 @@ function NativeBarChart({ labels, series, width = 320, height = 200, stacked = f
49
55
  const w = stacked ? bands.width : Math.max(1, barWidth - (si > 0 ? 1 : 0));
50
56
  if (stacked)
51
57
  stackTop -= barHeight;
52
- return ((0, jsx_runtime_1.jsx)(Rect, { x: barX, y: barY, width: w, height: barHeight, rx: Math.min(radius, w / 2), fill: color, opacity: active === null || active === i ? 1 : 0.45 }, s.name));
58
+ return ((0, jsx_runtime_1.jsx)(Rect, { x: barX, y: barY, width: w, height: barHeight, rx: Math.min(radius, w / 2), fill: `url(#bar-${gradientKey}-${si})`,
59
+ // The inset edge the web draws inside every bar.
60
+ stroke: color, strokeOpacity: 0.35, strokeWidth: 0.5, opacity: active === null || active === i ? 1 : 0.45 }, s.name));
53
61
  }) }, label + i));
54
62
  }), 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}`))), labels.map((label, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: bands.center(i), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: label }, `x-${i}`)))] }), (0, jsx_runtime_1.jsx)(View, { style: {
55
63
  position: "absolute",
@@ -41,12 +41,12 @@ exports.isGlassSupported = (0, glass_routing_1.defaultRouter)().supported;
41
41
  * overriding Apple's accessibility treatment would be worse than deferring to
42
42
  * it, so the real glass is left exactly as the system renders it.
43
43
  */
44
- exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
44
+ exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, surface = "panel", pressed, testID, style, children, isDark: isDarkProp, ...props }, ref) {
45
45
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
46
46
  const decision = router();
47
47
  if (decision.supported && decision.LiquidGlassView) {
48
48
  const LiquidGlassView = decision.LiquidGlassView;
49
49
  return ((0, jsx_runtime_1.jsx)(LiquidGlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, style: style, ...props, children: children }));
50
50
  }
51
- return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, testID: testID, isDark: isDark, style: style, ...props, children: children }));
51
+ return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, surface: surface, pressed: pressed, testID: testID, isDark: isDark, style: style, ...props, children: children }));
52
52
  });
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ // Backdrop blur for the fallback material.
3
+ //
4
+ // React Native has no backdrop blur of its own. The fallback's biggest missing
5
+ // layer is exactly that: without it a surface is a translucent rectangle, not
6
+ // glass. Two community backends provide a real native blur view, and the
7
+ // package accepts either:
8
+ //
9
+ // - `expo-blur` (Expo apps; also works on web through backdrop-filter)
10
+ // - `@react-native-community/blur` (bare React Native)
11
+ //
12
+ // They are optional peer dependencies, resolved at runtime like every other
13
+ // native module in this package: a project that installs neither still gets a
14
+ // working (unblurred) fallback instead of a crash, and the jsdom test run never
15
+ // touches a native module.
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.resolveBlurView = resolveBlurView;
18
+ exports.resetBlurResolver = resetBlurResolver;
19
+ exports.blurProps = blurProps;
20
+ let resolved;
21
+ /**
22
+ * The installed blur backend, or null when neither is available.
23
+ *
24
+ * Memoised: the answer is a property of the installed modules, not of the
25
+ * render, so resolving once keeps every surface on the same backend.
26
+ */
27
+ function resolveBlurView() {
28
+ if (resolved !== undefined)
29
+ return resolved;
30
+ try {
31
+ const expo = require("expo-blur");
32
+ if (expo?.BlurView) {
33
+ resolved = { kind: "expo", View: expo.BlurView };
34
+ return resolved;
35
+ }
36
+ }
37
+ catch {
38
+ // Not installed: try the bare-React-Native backend below.
39
+ }
40
+ try {
41
+ const community = require("@react-native-community/blur");
42
+ if (community?.BlurView) {
43
+ resolved = { kind: "community", View: community.BlurView };
44
+ return resolved;
45
+ }
46
+ }
47
+ catch {
48
+ // Neither backend is installed; the fallback renders tint, rim and shadow.
49
+ }
50
+ resolved = null;
51
+ return resolved;
52
+ }
53
+ /** Clears the memoised backend. Only tests call this. */
54
+ function resetBlurResolver() {
55
+ resolved = undefined;
56
+ }
57
+ /**
58
+ * The props one backend needs to blur a surface.
59
+ *
60
+ * The two libraries name the same idea differently — expo-blur takes a 0–100
61
+ * intensity and a tint, community-blur a 0–100 amount and a blur type — so the
62
+ * mapping lives here rather than in the fallback's render. Android needs an
63
+ * explicit method on expo-blur; Dimezis is its own real-time backdrop blur.
64
+ */
65
+ function blurProps(kind, intensity, isDark) {
66
+ if (kind === "expo") {
67
+ return {
68
+ intensity,
69
+ tint: isDark ? "dark" : "light",
70
+ experimentalBlurMethod: "dimezisBlurView",
71
+ };
72
+ }
73
+ return {
74
+ // Community blur amounts are coarser; the tint carries most of the read.
75
+ blurAmount: Math.max(1, Math.round(intensity / 1.6)),
76
+ blurType: isDark ? "dark" : "light",
77
+ };
78
+ }
@@ -6,40 +6,130 @@ const react_1 = require("react");
6
6
  const tokens_1 = require("./tokens");
7
7
  const primitives_1 = require("./primitives");
8
8
  const a11y_1 = require("./a11y");
9
+ const blur_1 = require("./blur");
10
+ const glow_1 = require("./glow");
11
+ const material_1 = require("./material");
12
+ const rim_1 = require("./rim");
13
+ const fill = { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 };
14
+ /** Layout and paint properties that belong to the surface itself. */
15
+ const HOISTED = new Set([
16
+ "backgroundColor",
17
+ "shadowColor",
18
+ "shadowOpacity",
19
+ "shadowRadius",
20
+ "shadowOffset",
21
+ "elevation",
22
+ ]);
23
+ /** Merges a style prop into one object; a function style is not resolvable here. */
24
+ function flattenStyle(style) {
25
+ if (!style)
26
+ return {};
27
+ if (Array.isArray(style)) {
28
+ return style.reduce((acc, entry) => ({ ...acc, ...flattenStyle(entry) }), {});
29
+ }
30
+ if (typeof style === "function")
31
+ return {};
32
+ return style;
33
+ }
9
34
  /**
10
35
  * Glacia's own glass surface for every platform where Apple's material is not
11
36
  * available: Android, iOS before 26, and Expo Go.
12
37
  *
13
- * It renders the resolver's real React Native `View` with the same shape and
14
- * layout as the native glass, so switching branches never shifts the layout.
38
+ * The material is the web one, rebuilt in layers, because a single flat View
39
+ * could never read as glass:
40
+ *
41
+ * 1. backdrop blur (`expo-blur` / `@react-native-community/blur` when either
42
+ * is installed — a real `UIVisualEffectView` on iOS 17),
43
+ * 2. the tint token on top of the blurred backdrop,
44
+ * 3. a painted rim light, brightest on the top edge, so corners read as curved,
45
+ * 4. a soft highlight just inside the top edge,
46
+ * 5. the 0.5px edge line, and
47
+ * 6. a drop shadow on the surface itself (outside the clipped layer).
48
+ *
49
+ * All of that lives in an absolutely-positioned, clipped layer behind the
50
+ * children. The caller's style stays on the outer View, so heights, padding and
51
+ * flex behaviour are byte-identical to the old flat implementation and
52
+ * switching branches never shifts the layout.
53
+ *
54
+ * Reduce Transparency still replaces the whole thing with a solid colour: the
55
+ * preference exists precisely to remove see-through surfaces.
15
56
  */
16
- exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({ effect = "regular", tintColor, testID, style, children, isDark = false, reducedTransparency, ...props }, ref) {
57
+ exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({ effect = "regular", surface = "panel", tintColor, pressed, testID, style, children, isDark = false, reducedTransparency, ...props }, ref) {
17
58
  const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
18
59
  const { View } = (0, primitives_1.primitives)();
19
60
  // Reduce Transparency means the translucent material is replaced by a solid
20
61
  // colour — the point of the preference is to remove see-through surfaces.
21
62
  const systemReduced = (0, a11y_1.useReducedTransparency)();
22
63
  const solid = reducedTransparency ?? systemReduced;
23
- const bg = solid
24
- ? effect === "none"
25
- ? "transparent"
26
- : tintColor && effect === "clear"
27
- ? tintColor
28
- : themeColors.glassSolid
29
- : effect === "none"
30
- ? "transparent"
64
+ const flat = flattenStyle(style);
65
+ const radius = typeof flat.borderRadius === "number" ? flat.borderRadius : tokens_1.radii.md;
66
+ const explicitBackground = typeof flat.backgroundColor === "string" ? flat.backgroundColor : undefined;
67
+ // `effect="none"` is a deliberate "no surface here" (a ghost button); it
68
+ // paints nothing at all, exactly as before.
69
+ const bare = effect === "none";
70
+ const layered = !solid && !bare;
71
+ const profile = (0, material_1.materialFor)(surface, bare ? "regular" : effect, isDark);
72
+ const blur = layered ? (0, blur_1.resolveBlurView)() : null;
73
+ const surfaceStyle = { ...flat };
74
+ for (const key of HOISTED)
75
+ delete surfaceStyle[key];
76
+ // The edge is the web's 0.5px inset line. A component that draws only one
77
+ // edge (AppBar's scroll edge) keeps its own widths; a component that asked
78
+ // for a 1px box border is brought back to the hairline.
79
+ const perEdge = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"].some((key) => typeof flat[key] === "number");
80
+ if (typeof flat.borderWidth === "number") {
81
+ surfaceStyle.borderWidth = Math.min(flat.borderWidth, 0.5);
82
+ }
83
+ else if (!perEdge) {
84
+ surfaceStyle.borderWidth = 0.5;
85
+ }
86
+ surfaceStyle.borderColor = flat.borderColor ?? themeColors.edge;
87
+ surfaceStyle.borderRadius = radius;
88
+ if (solid) {
89
+ // The solid path is the old single flat view: opaque, no layers, and the
90
+ // caller's own background (a filled button) still wins over the token.
91
+ surfaceStyle.backgroundColor =
92
+ flat.backgroundColor ??
93
+ (effect === "clear" && tintColor ? tintColor : themeColors.glassSolid);
94
+ surfaceStyle.overflow = "hidden";
95
+ }
96
+ else if (bare) {
97
+ surfaceStyle.backgroundColor = flat.backgroundColor ?? "transparent";
98
+ surfaceStyle.overflow = "hidden";
99
+ }
100
+ else {
101
+ // Layered material. An opaque background is a filled control, not glass:
102
+ // it still gets a rim so it does not read as a sticker, but no blur tint.
103
+ const opaque = Boolean(explicitBackground);
104
+ const tint = opaque
105
+ ? explicitBackground
31
106
  : effect === "clear"
32
107
  ? isDark
33
108
  ? "rgba(28, 28, 30, 0.35)"
34
109
  : "rgba(255, 255, 255, 0.35)"
35
110
  : tintColor || themeColors.glass;
36
- const containerStyle = {
37
- backgroundColor: bg,
38
- borderColor: themeColors.edge,
39
- borderWidth: 0.5,
40
- borderRadius: tokens_1.radii.md,
41
- overflow: "hidden",
42
- ...style,
43
- };
44
- return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: containerStyle, ...props, children: children }));
111
+ const rim = opaque ? profile.rim * 0.5 : profile.rim;
112
+ const highlight = opaque ? profile.highlight * 0.5 : profile.highlight;
113
+ const blurrable = Boolean(blur) && !opaque;
114
+ const shadowOpacity = typeof flat.shadowOpacity === "number" ? flat.shadowOpacity : profile.shadowOpacity;
115
+ const shadowRadius = typeof flat.shadowRadius === "number" ? flat.shadowRadius : profile.shadowRadius;
116
+ const shadowHeight = typeof flat.shadowOffset?.height === "number"
117
+ ? flat.shadowOffset.height
118
+ : profile.shadowOffsetY;
119
+ // The hint family (badges, tooltips) sits flush with the page on the web.
120
+ const lifts = !(0, material_1.isFlatProfile)(surface) && shadowOpacity > 0;
121
+ return ((0, jsx_runtime_1.jsxs)(View, { ref: ref, testID: testID, style: [
122
+ surfaceStyle,
123
+ lifts
124
+ ? {
125
+ shadowColor: tokens_1.material.shadowColor,
126
+ shadowOpacity,
127
+ shadowRadius,
128
+ shadowOffset: { width: 0, height: shadowHeight },
129
+ elevation: typeof flat.elevation === "number" ? flat.elevation : profile.elevation,
130
+ }
131
+ : null,
132
+ ], ...props, children: [(0, jsx_runtime_1.jsxs)(View, { testID: testID ? `${testID}-material` : undefined, style: [fill, { borderRadius: radius, overflow: "hidden" }], pointerEvents: "none", children: [blurrable && blur ? ((0, jsx_runtime_1.jsx)(blur.View, { ...(0, blur_1.blurProps)(blur.kind, profile.blur, isDark), style: [fill, { borderRadius: radius }] })) : null, (0, jsx_runtime_1.jsx)(View, { testID: testID ? `${testID}-tint` : undefined, style: [fill, { backgroundColor: tint }] }), (0, jsx_runtime_1.jsx)(rim_1.GlassRim, { radius: radius, rim: rim, highlight: highlight }), pressed !== undefined ? (0, jsx_runtime_1.jsx)(glow_1.SurfaceGlow, { active: pressed }) : null] }), children] }));
133
+ }
134
+ return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: surfaceStyle, ...props, children: children }));
45
135
  });
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SurfaceGlow = SurfaceGlow;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ // The specular press highlight, painted as a radial glow.
6
+ //
7
+ // The web material fades a 240px radial white highlight in under the finger
8
+ // for 220ms whenever a glass control is held. That is what makes a press feel
9
+ // like touching a lens rather than a flat sticker. The fallback had only an
10
+ // opacity dip, so controls never looked held.
11
+ //
12
+ // The glow lives inside the clipped material layer, so it follows the same
13
+ // radius as the surface and can never spill outside it.
14
+ const react_1 = require("react");
15
+ const motion_1 = require("./motion");
16
+ const primitives_1 = require("./primitives");
17
+ const tokens_1 = require("./tokens");
18
+ const fill = { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 };
19
+ /**
20
+ * A radial highlight that fades in while `active`.
21
+ *
22
+ * Motion uses the package's spring tokens and respects Reduce Motion: with the
23
+ * preference on, the glow appears at its end state rather than fading.
24
+ */
25
+ function SurfaceGlow({ active }) {
26
+ const { Svg, Defs, RadialGradient, Stop, Rect, Animated } = (0, primitives_1.primitives)();
27
+ const { value, animated } = (0, motion_1.useSpring)(active ? 1 : 0, "snappy");
28
+ const gradientId = `glow-${(0, react_1.useId)().replace(/[^a-zA-Z0-9_-]/g, "")}`;
29
+ const painting = ((0, jsx_runtime_1.jsxs)(Svg, { width: "100%", height: "100%", style: fill, pointerEvents: "none", children: [(0, jsx_runtime_1.jsx)(Defs, { children: (0, jsx_runtime_1.jsxs)(RadialGradient, { id: gradientId, cx: "50%", cy: "50%", r: "50%", children: [(0, jsx_runtime_1.jsx)(Stop, { offset: "0", stopColor: tokens_1.material.rimColor, stopOpacity: tokens_1.material.glow }), (0, jsx_runtime_1.jsx)(Stop, { offset: "1", stopColor: tokens_1.material.rimColor, stopOpacity: 0 })] }) }), (0, jsx_runtime_1.jsx)(Rect, { x: "0", y: "0", width: "100%", height: "100%", fill: `url(#${gradientId})` })] }));
30
+ // Off-device there is no Animated API; the settled state is what a preview
31
+ // should show, exactly as `useSpring` documents.
32
+ if (!animated) {
33
+ return ((0, jsx_runtime_1.jsx)(Animated.View, { style: [fill, { opacity: active ? 1 : 0 }], pointerEvents: "none", children: painting }));
34
+ }
35
+ return ((0, jsx_runtime_1.jsx)(Animated.View, { style: [fill, { opacity: value }], pointerEvents: "none", children: painting }));
36
+ }