glacia-native 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/module/Bars.js +95 -2
  2. package/lib/module/Display.js +78 -1
  3. package/lib/module/Feedback.js +221 -7
  4. package/lib/module/Forms2.js +228 -1
  5. package/lib/module/Message.js +88 -0
  6. package/lib/module/Overlays.js +173 -11
  7. package/lib/module/SegmentedControl.js +5 -1
  8. package/lib/module/Slider.js +6 -1
  9. package/lib/module/Switch.js +4 -1
  10. package/lib/module/TabBar.js +5 -1
  11. package/lib/module/ai.js +8 -3
  12. package/lib/module/index.js +23 -2
  13. package/lib/module/internal/GlassContainer.js +54 -0
  14. package/lib/module/internal/GlassView.js +8 -0
  15. package/lib/module/internal/a11y.js +94 -0
  16. package/lib/module/internal/fallback.js +19 -8
  17. package/lib/module/internal/glass-routing.js +7 -0
  18. package/lib/module/internal/haptics.js +54 -0
  19. package/lib/module/internal/motion.js +10 -1
  20. package/lib/module/internal/primitives.js +69 -4
  21. package/lib/module/internal/tokens.js +47 -1
  22. package/lib/typescript/Bars.d.ts +67 -0
  23. package/lib/typescript/Display.d.ts +59 -0
  24. package/lib/typescript/Feedback.d.ts +58 -0
  25. package/lib/typescript/Forms2.d.ts +81 -0
  26. package/lib/typescript/Message.d.ts +71 -0
  27. package/lib/typescript/Overlays.d.ts +41 -0
  28. package/lib/typescript/SegmentedControl.d.ts +2 -0
  29. package/lib/typescript/Slider.d.ts +2 -0
  30. package/lib/typescript/Switch.d.ts +2 -0
  31. package/lib/typescript/TabBar.d.ts +2 -0
  32. package/lib/typescript/index.d.ts +8 -6
  33. package/lib/typescript/internal/GlassContainer.d.ts +37 -0
  34. package/lib/typescript/internal/GlassView.d.ts +8 -0
  35. package/lib/typescript/internal/a11y.d.ts +19 -0
  36. package/lib/typescript/internal/fallback.d.ts +5 -0
  37. package/lib/typescript/internal/glass-routing.d.ts +10 -0
  38. package/lib/typescript/internal/haptics.d.ts +7 -0
  39. package/lib/typescript/internal/motion.d.ts +4 -0
  40. package/lib/typescript/internal/primitives.d.ts +21 -0
  41. package/lib/typescript/internal/tokens.d.ts +53 -0
  42. package/package.json +2 -2
  43. package/src/Bars.tsx +227 -0
  44. package/src/Display.tsx +229 -1
  45. package/src/Feedback.tsx +412 -22
  46. package/src/Forms2.tsx +407 -1
  47. package/src/Message.tsx +219 -0
  48. package/src/Overlays.tsx +244 -33
  49. package/src/SegmentedControl.tsx +6 -0
  50. package/src/Slider.tsx +7 -0
  51. package/src/Switch.tsx +5 -0
  52. package/src/TabBar.tsx +6 -0
  53. package/src/ai.tsx +9 -3
  54. package/src/index.ts +42 -1
  55. package/src/internal/GlassContainer.tsx +82 -0
  56. package/src/internal/GlassView.tsx +8 -0
  57. package/src/internal/a11y.ts +105 -0
  58. package/src/internal/fallback.tsx +19 -2
  59. package/src/internal/glass-routing.ts +17 -0
  60. package/src/internal/haptics.ts +59 -0
  61. package/src/internal/motion.ts +10 -1
  62. package/src/internal/primitives.ts +80 -4
  63. package/src/internal/tokens.ts +48 -0
@@ -7,6 +7,7 @@ const Glass_1 = require("./Glass");
7
7
  const tokens_1 = require("./internal/tokens");
8
8
  const primitives_1 = require("./internal/primitives");
9
9
  const motion_1 = require("./internal/motion");
10
+ const haptics_1 = require("./internal/haptics");
10
11
  const TRACK_WIDTH = 51;
11
12
  const TRACK_HEIGHT = 31;
12
13
  const THUMB = 27;
@@ -19,7 +20,7 @@ const TRAVEL = TRACK_WIDTH - THUMB - 4;
19
20
  * iOS 26+, Glacia's tint elsewhere) but the control is always ours — React
20
21
  * Native's built-in Switch is never used.
21
22
  */
22
- exports.Switch = (0, react_1.forwardRef)(function Switch({ checked: checkedProp, defaultChecked = false, onCheckedChange, disabled = false, accessibilityLabel, style, isDark: isDarkProp, testID, ...props }, ref) {
23
+ exports.Switch = (0, react_1.forwardRef)(function Switch({ checked: checkedProp, defaultChecked = false, onCheckedChange, disabled = false, haptics = true, accessibilityLabel, style, isDark: isDarkProp, testID, ...props }, ref) {
23
24
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
24
25
  const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
25
26
  const { View, Pressable, Animated } = (0, primitives_1.primitives)();
@@ -31,6 +32,8 @@ exports.Switch = (0, react_1.forwardRef)(function Switch({ checked: checkedProp,
31
32
  if (disabled)
32
33
  return;
33
34
  const next = !isChecked;
35
+ if (haptics)
36
+ (0, haptics_1.hapticSelection)();
34
37
  if (checkedProp === undefined)
35
38
  setInternalChecked(next);
36
39
  onCheckedChange?.(next);
@@ -7,6 +7,7 @@ const Glass_1 = require("./Glass");
7
7
  const tokens_1 = require("./internal/tokens");
8
8
  const primitives_1 = require("./internal/primitives");
9
9
  const motion_1 = require("./internal/motion");
10
+ const haptics_1 = require("./internal/haptics");
10
11
  const BAR_HEIGHT = 52;
11
12
  /**
12
13
  * The bottom bar of an app: a row of tabs on one glass surface.
@@ -17,7 +18,7 @@ const BAR_HEIGHT = 52;
17
18
  * Glacia's bar. The items are always our Pressables and Texts — no native tab
18
19
  * bar is used on any platform.
19
20
  */
20
- exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: activeProp, defaultActiveId, onTabChange, style, isDark: isDarkProp, testID, ...props }, ref) {
21
+ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: activeProp, defaultActiveId, onTabChange, haptics = true, style, isDark: isDarkProp, testID, ...props }, ref) {
21
22
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
22
23
  const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
23
24
  const { View, Text, Pressable, Animated } = (0, primitives_1.primitives)();
@@ -27,6 +28,9 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
27
28
  // The active wash slides between equally wide items on the springs token.
28
29
  const { value: slide, animated } = (0, motion_1.useSpring)(activeIndex, "snappy");
29
30
  const handleSelect = (id) => {
31
+ // Selecting the tab already active is not a change, so it does not tick.
32
+ if (haptics && id !== activeId)
33
+ (0, haptics_1.hapticSelection)();
30
34
  if (activeProp === undefined)
31
35
  setInternalId(id);
32
36
  onTabChange?.(id);
package/lib/module/ai.js CHANGED
@@ -14,6 +14,7 @@ const react_1 = require("react");
14
14
  const tokens_1 = require("./internal/tokens");
15
15
  const primitives_1 = require("./internal/primitives");
16
16
  const motion_1 = require("./internal/motion");
17
+ const a11y_1 = require("./internal/a11y");
17
18
  /**
18
19
  * The ordered steps a model intends to take.
19
20
  *
@@ -153,14 +154,18 @@ function NativeThinkingOrb({ label = "Thinking", size = 22, paused = false, isDa
153
154
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
154
155
  const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
155
156
  const { View, Text } = (0, primitives_1.primitives)();
157
+ const reducedMotion = (0, a11y_1.useReducedMotion)();
156
158
  const [tick, setTick] = (0, react_1.useState)(0);
159
+ // Reduce Motion: the orb stops pulsing and holds a steady size. The label is
160
+ // what carries the meaning, so nothing is lost by not moving.
161
+ const still = paused || reducedMotion;
157
162
  (0, react_1.useEffect)(() => {
158
- if (paused)
163
+ if (still)
159
164
  return;
160
165
  const timer = setInterval(() => setTick((value) => value + 1), 700);
161
166
  return () => clearInterval(timer);
162
- }, [paused]);
163
- const scale = paused ? 1 : [1, 1.12, 1][tick % 3];
167
+ }, [still]);
168
+ const scale = still ? 1 : [1, 1.12, 1][tick % 3];
164
169
  return ((0, jsx_runtime_1.jsxs)(View, { accessibilityRole: "text", accessibilityLabel: label, style: { flexDirection: "row", alignItems: "center", gap: 8, ...style }, children: [(0, jsx_runtime_1.jsx)(View, { style: {
165
170
  width: size,
166
171
  height: size,
@@ -14,8 +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.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;
17
+ exports.ListItem = exports.List = exports.Banner = exports.Toast = exports.NativeImage = exports.Rating = 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.palette = exports.controlSizes = exports.colors = exports.GlassContainer = exports.isGlassSupported = exports.MessageAttachment = exports.MessageBubble = exports.Message = exports.MONTHS = exports.WEEKDAYS = exports.formatTime = exports.parseTime = exports.sameDay = exports.startOfDay = exports.monthGrid = exports.TimePicker = exports.DatePicker = exports.Calendar = exports.Combobox = exports.hueGradientColors = exports.rgbToHex = exports.hexToRgb = exports.DEFAULT_PALETTE = exports.ColorPicker = exports.ButtonGroup = exports.InputOTP = exports.ToggleGroup = exports.Toggle = exports.Stepper = exports.PageControl = exports.Carousel = exports.nearestSnapPoint = exports.resolveSnapPoint = exports.anchorPopover = exports.Drawer = exports.Sheet = exports.Menu = exports.FABGroup = exports.AppBar = exports.IconButton = exports.FAB = exports.Chip = exports.SearchBar = exports.ToastViewport = exports.Accordion = exports.ListSection = void 0;
19
19
  var Glass_1 = require("./Glass");
20
20
  Object.defineProperty(exports, "Glass", { enumerable: true, get: function () { return Glass_1.Glass; } });
21
21
  var Button_1 = require("./Button");
@@ -82,6 +82,8 @@ Object.defineProperty(exports, "Skeleton", { enumerable: true, get: function ()
82
82
  Object.defineProperty(exports, "Spinner", { enumerable: true, get: function () { return Display_1.Spinner; } });
83
83
  Object.defineProperty(exports, "Progress", { enumerable: true, get: function () { return Display_1.Progress; } });
84
84
  Object.defineProperty(exports, "initialsOf", { enumerable: true, get: function () { return Display_1.initialsOf; } });
85
+ Object.defineProperty(exports, "Rating", { enumerable: true, get: function () { return Display_1.Rating; } });
86
+ Object.defineProperty(exports, "NativeImage", { enumerable: true, get: function () { return Display_1.NativeImage; } });
85
87
  // Feedback and display.
86
88
  var Feedback_1 = require("./Feedback");
87
89
  Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Feedback_1.Toast; } });
@@ -90,6 +92,7 @@ Object.defineProperty(exports, "List", { enumerable: true, get: function () { re
90
92
  Object.defineProperty(exports, "ListItem", { enumerable: true, get: function () { return Feedback_1.ListItem; } });
91
93
  Object.defineProperty(exports, "ListSection", { enumerable: true, get: function () { return Feedback_1.ListSection; } });
92
94
  Object.defineProperty(exports, "Accordion", { enumerable: true, get: function () { return Feedback_1.Accordion; } });
95
+ Object.defineProperty(exports, "ToastViewport", { enumerable: true, get: function () { return Feedback_1.ToastViewport; } });
93
96
  // Bars, buttons and navigation.
94
97
  var Bars_1 = require("./Bars");
95
98
  Object.defineProperty(exports, "SearchBar", { enumerable: true, get: function () { return Bars_1.SearchBar; } });
@@ -97,12 +100,15 @@ Object.defineProperty(exports, "Chip", { enumerable: true, get: function () { re
97
100
  Object.defineProperty(exports, "FAB", { enumerable: true, get: function () { return Bars_1.FAB; } });
98
101
  Object.defineProperty(exports, "IconButton", { enumerable: true, get: function () { return Bars_1.IconButton; } });
99
102
  Object.defineProperty(exports, "AppBar", { enumerable: true, get: function () { return Bars_1.AppBar; } });
103
+ Object.defineProperty(exports, "FABGroup", { enumerable: true, get: function () { return Bars_1.FABGroup; } });
100
104
  // Overlays.
101
105
  var Overlays_1 = require("./Overlays");
102
106
  Object.defineProperty(exports, "Menu", { enumerable: true, get: function () { return Overlays_1.Menu; } });
103
107
  Object.defineProperty(exports, "Sheet", { enumerable: true, get: function () { return Overlays_1.Sheet; } });
104
108
  Object.defineProperty(exports, "Drawer", { enumerable: true, get: function () { return Overlays_1.Drawer; } });
105
109
  Object.defineProperty(exports, "anchorPopover", { enumerable: true, get: function () { return Overlays_1.anchorPopover; } });
110
+ Object.defineProperty(exports, "resolveSnapPoint", { enumerable: true, get: function () { return Overlays_1.resolveSnapPoint; } });
111
+ Object.defineProperty(exports, "nearestSnapPoint", { enumerable: true, get: function () { return Overlays_1.nearestSnapPoint; } });
106
112
  // Carousel.
107
113
  var Carousel_1 = require("./Carousel");
108
114
  Object.defineProperty(exports, "Carousel", { enumerable: true, get: function () { return Carousel_1.Carousel; } });
@@ -114,6 +120,12 @@ Object.defineProperty(exports, "Toggle", { enumerable: true, get: function () {
114
120
  Object.defineProperty(exports, "ToggleGroup", { enumerable: true, get: function () { return Forms2_1.ToggleGroup; } });
115
121
  Object.defineProperty(exports, "InputOTP", { enumerable: true, get: function () { return Forms2_1.InputOTP; } });
116
122
  Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return Forms2_1.ButtonGroup; } });
123
+ Object.defineProperty(exports, "ColorPicker", { enumerable: true, get: function () { return Forms2_1.ColorPicker; } });
124
+ Object.defineProperty(exports, "DEFAULT_PALETTE", { enumerable: true, get: function () { return Forms2_1.DEFAULT_PALETTE; } });
125
+ Object.defineProperty(exports, "hexToRgb", { enumerable: true, get: function () { return Forms2_1.hexToRgb; } });
126
+ Object.defineProperty(exports, "rgbToHex", { enumerable: true, get: function () { return Forms2_1.rgbToHex; } });
127
+ Object.defineProperty(exports, "hueGradientColors", { enumerable: true, get: function () { return Forms2_1.hueGradientColors; } });
128
+ Object.defineProperty(exports, "Combobox", { enumerable: true, get: function () { return Forms2_1.Combobox; } });
117
129
  var Pickers_1 = require("./Pickers");
118
130
  Object.defineProperty(exports, "Calendar", { enumerable: true, get: function () { return Pickers_1.Calendar; } });
119
131
  Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return Pickers_1.DatePicker; } });
@@ -125,10 +137,19 @@ Object.defineProperty(exports, "parseTime", { enumerable: true, get: function ()
125
137
  Object.defineProperty(exports, "formatTime", { enumerable: true, get: function () { return Pickers_1.formatTime; } });
126
138
  Object.defineProperty(exports, "WEEKDAYS", { enumerable: true, get: function () { return Pickers_1.WEEKDAYS; } });
127
139
  Object.defineProperty(exports, "MONTHS", { enumerable: true, get: function () { return Pickers_1.MONTHS; } });
140
+ // Chat. Bubbles are flat tints; the composer (NativeAIInput) is the glass.
141
+ var Message_1 = require("./Message");
142
+ Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return Message_1.Message; } });
143
+ Object.defineProperty(exports, "MessageBubble", { enumerable: true, get: function () { return Message_1.MessageBubble; } });
144
+ Object.defineProperty(exports, "MessageAttachment", { enumerable: true, get: function () { return Message_1.MessageAttachment; } });
128
145
  var GlassView_1 = require("./internal/GlassView");
129
146
  Object.defineProperty(exports, "isGlassSupported", { enumerable: true, get: function () { return GlassView_1.isGlassSupported; } });
147
+ var GlassContainer_1 = require("./internal/GlassContainer");
148
+ Object.defineProperty(exports, "GlassContainer", { enumerable: true, get: function () { return GlassContainer_1.GlassContainer; } });
130
149
  var tokens_1 = require("./internal/tokens");
131
150
  Object.defineProperty(exports, "colors", { enumerable: true, get: function () { return tokens_1.colors; } });
151
+ Object.defineProperty(exports, "controlSizes", { enumerable: true, get: function () { return tokens_1.controlSizes; } });
152
+ Object.defineProperty(exports, "palette", { enumerable: true, get: function () { return tokens_1.palette; } });
132
153
  Object.defineProperty(exports, "radii", { enumerable: true, get: function () { return tokens_1.radii; } });
133
154
  Object.defineProperty(exports, "springs", { enumerable: true, get: function () { return tokens_1.springs; } });
134
155
  Object.defineProperty(exports, "typeScale", { enumerable: true, get: function () { return tokens_1.typeScale; } });
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GlassContainer = void 0;
4
+ exports.resetGlassContainerRouter = resetGlassContainerRouter;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = require("react");
7
+ const glass_routing_1 = require("./glass-routing");
8
+ const primitives_1 = require("./primitives");
9
+ const motion_1 = require("./motion");
10
+ /**
11
+ * The installed module's routing decision, memoised so a container and the
12
+ * surfaces inside it always agree about which branch is rendering.
13
+ */
14
+ let cachedRouter = null;
15
+ function router() {
16
+ if (cachedRouter === null)
17
+ cachedRouter = (0, glass_routing_1.defaultRouter)();
18
+ return cachedRouter;
19
+ }
20
+ /** Clears the memoised decision. Only tests call this, to drive both branches. */
21
+ function resetGlassContainerRouter() {
22
+ cachedRouter = null;
23
+ }
24
+ /**
25
+ * Groups glass surfaces so iOS 26 can merge them into one surface.
26
+ *
27
+ * On iOS 26, Apple's Liquid Glass is a connected material: two glass elements
28
+ * placed close enough run together into a single shape with one shared edge,
29
+ * rather than reading as two separate panes. `GlassContainer` is the component
30
+ * that opts into that — a bar and the floating button above it, or a pair of
31
+ * adjacent buttons, become one piece of glass.
32
+ *
33
+ * **Merging is an iOS 26+ visual effect and a no-op everywhere else.** On
34
+ * older iOS, Android, Expo Go and the web preview this renders a plain wrapper
35
+ * with identical layout: the children are the same components, drawn at the
36
+ * same positions, they simply keep their own separate edges. Nothing changes
37
+ * shape or shifts, so a container costs nothing on the platforms that cannot
38
+ * blend.
39
+ *
40
+ * Use it only around surfaces that should read as one; glass inside glass is
41
+ * still forbidden, so a container's children are `Glass` surfaces placed side
42
+ * by side, not a panel wrapping another panel.
43
+ */
44
+ exports.GlassContainer = (0, react_1.forwardRef)(function GlassContainer({ spacing = 0, style, children, isDark: isDarkProp, testID, ...props }, ref) {
45
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
46
+ const decision = router();
47
+ const { View } = (0, primitives_1.primitives)();
48
+ if (decision.supported && decision.LiquidGlassContainerView) {
49
+ const ContentContainer = decision.LiquidGlassContainerView;
50
+ return ((0, jsx_runtime_1.jsx)(ContentContainer, { ref: ref, spacing: spacing, testID: testID, style: style, ...props, children: children }));
51
+ }
52
+ // Unsupported: a wrapper with the same layout, so nothing shifts.
53
+ return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: style, ...props, children: children }));
54
+ });
@@ -32,6 +32,14 @@ exports.isGlassSupported = (0, glass_routing_1.defaultRouter)().supported;
32
32
  * Platform Glass View — the single place a glass surface is chosen:
33
33
  * - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
34
34
  * - iOS < 26 / Android / Expo Go: translucent tint View with identical layout
35
+ *
36
+ * Reduce Transparency is honoured on the fallback branch only: there the
37
+ * translucent tint is replaced by the theme's solid glass colour, with the same
38
+ * radius and the same hairline border, because a translucent surface is what
39
+ * the user asked the system to remove. On iOS 26 the system applies its own
40
+ * treatment to `UIGlassEffect` and this component does not second-guess it —
41
+ * overriding Apple's accessibility treatment would be worse than deferring to
42
+ * it, so the real glass is left exactly as the system renders it.
35
43
  */
36
44
  exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
37
45
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ // Accessibility preferences, as the platform reports them.
3
+ //
4
+ // Apple's HIG makes two of these part of wearing Liquid Glass faithfully:
5
+ // - Reduce Transparency: glass is replaced by a solid colour, because a
6
+ // translucent surface is exactly what the user asked the system to remove.
7
+ // - Reduce Motion: animation jumps to its end state instead of playing.
8
+ //
9
+ // React Native exposes both through AccessibilityInfo, but it is resolved at
10
+ // runtime like every other primitive, so the package stays importable where
11
+ // React Native is absent (jsdom tests, web preview). Where the API is missing
12
+ // the hooks answer `false`: the preference is treated as off, which is the
13
+ // behaviour those environments already had.
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.useReducedTransparency = useReducedTransparency;
16
+ exports.useReducedMotion = useReducedMotion;
17
+ const react_1 = require("react");
18
+ const primitives_1 = require("./primitives");
19
+ /** Reads a boolean preference once, guarding against a missing or throwing API. */
20
+ function readPreference(info, method) {
21
+ try {
22
+ const result = info?.[method]?.();
23
+ // React Native returns a promise; anything unexpected is treated as "off".
24
+ if (result && typeof result.then === "function") {
25
+ return result.then((value) => Boolean(value), () => false);
26
+ }
27
+ return Promise.resolve(Boolean(result));
28
+ }
29
+ catch {
30
+ return Promise.resolve(false);
31
+ }
32
+ }
33
+ /**
34
+ * Subscribes to one AccessibilityInfo preference and keeps it in state.
35
+ *
36
+ * The initial read is async, so the hook starts `false` and corrects itself
37
+ * when the platform answers. The subscription is removed on unmount; a
38
+ * listener that outlives the component would leak on every navigation.
39
+ */
40
+ function useAccessibilityPreference(method, event) {
41
+ const { AccessibilityInfo } = (0, primitives_1.primitives)();
42
+ const [enabled, setEnabled] = (0, react_1.useState)(false);
43
+ (0, react_1.useEffect)(() => {
44
+ if (!AccessibilityInfo)
45
+ return;
46
+ let cancelled = false;
47
+ readPreference(AccessibilityInfo, method).then((value) => {
48
+ if (!cancelled)
49
+ setEnabled(value);
50
+ });
51
+ let subscription = null;
52
+ try {
53
+ subscription = AccessibilityInfo.addEventListener?.(event, (next) => {
54
+ setEnabled(Boolean(next));
55
+ });
56
+ }
57
+ catch {
58
+ // An environment without the event still gets the initial read.
59
+ }
60
+ return () => {
61
+ cancelled = true;
62
+ try {
63
+ subscription?.remove?.();
64
+ }
65
+ catch {
66
+ // Nothing to clean up if subscribing failed.
67
+ }
68
+ };
69
+ }, [AccessibilityInfo, method, event]);
70
+ return enabled;
71
+ }
72
+ /**
73
+ * Whether the user has asked the system to reduce transparency.
74
+ *
75
+ * When true, a glass surface must render a solid colour rather than a
76
+ * translucent one. `GlassView` honours this on the fallback branch; on iOS 26
77
+ * the system applies its own treatment to `UIGlassEffect` and is not
78
+ * second-guessed here.
79
+ *
80
+ * The change event is iOS-only in React Native, so on Android the initial
81
+ * read is the answer.
82
+ */
83
+ function useReducedTransparency() {
84
+ return useAccessibilityPreference("isReduceTransparencyEnabled", "reduceTransparencyChanged");
85
+ }
86
+ /**
87
+ * Whether the user has asked the system to reduce motion.
88
+ *
89
+ * Glacia's own animations settle at their end state instead of playing when
90
+ * this is true.
91
+ */
92
+ function useReducedMotion() {
93
+ return useAccessibilityPreference("isReduceMotionEnabled", "reduceMotionChanged");
94
+ }
@@ -5,6 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const tokens_1 = require("./tokens");
7
7
  const primitives_1 = require("./primitives");
8
+ const a11y_1 = require("./a11y");
8
9
  /**
9
10
  * Glacia's own glass surface for every platform where Apple's material is not
10
11
  * available: Android, iOS before 26, and Expo Go.
@@ -12,16 +13,26 @@ const primitives_1 = require("./primitives");
12
13
  * It renders the resolver's real React Native `View` with the same shape and
13
14
  * layout as the native glass, so switching branches never shifts the layout.
14
15
  */
15
- exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({ effect = "regular", tintColor, testID, style, children, isDark = false, ...props }, ref) {
16
+ exports.FallbackGlassView = (0, react_1.forwardRef)(function FallbackGlassView({ effect = "regular", tintColor, testID, style, children, isDark = false, reducedTransparency, ...props }, ref) {
16
17
  const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
17
18
  const { View } = (0, primitives_1.primitives)();
18
- const bg = effect === "none"
19
- ? "transparent"
20
- : effect === "clear"
21
- ? isDark
22
- ? "rgba(28, 28, 30, 0.35)"
23
- : "rgba(255, 255, 255, 0.35)"
24
- : tintColor || themeColors.glass;
19
+ // Reduce Transparency means the translucent material is replaced by a solid
20
+ // colour — the point of the preference is to remove see-through surfaces.
21
+ const systemReduced = (0, a11y_1.useReducedTransparency)();
22
+ 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"
31
+ : effect === "clear"
32
+ ? isDark
33
+ ? "rgba(28, 28, 30, 0.35)"
34
+ : "rgba(255, 255, 255, 0.35)"
35
+ : tintColor || themeColors.glass;
25
36
  const containerStyle = {
26
37
  backgroundColor: bg,
27
38
  borderColor: themeColors.edge,
@@ -24,9 +24,16 @@ exports.defaultRouter = defaultRouter;
24
24
  */
25
25
  function routerFor(module) {
26
26
  const view = module?.LiquidGlassView ?? null;
27
+ const container = module?.LiquidGlassContainerView ?? null;
27
28
  return {
29
+ // A module that reports support but lacks the container still renders real
30
+ // glass; the container is only needed by GlassContainer, which falls back
31
+ // when it is missing.
28
32
  supported: Boolean(module?.isLiquidGlassSupported) && Boolean(view),
29
33
  LiquidGlassView: view,
34
+ // The container merges only when the material itself is available; a
35
+ // container without the view would have nothing to merge.
36
+ LiquidGlassContainerView: container,
30
37
  };
31
38
  }
32
39
  /**
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ // Haptic feedback for controls.
3
+ //
4
+ // Native iOS controls tick as you move them — a switch toggling, a segment
5
+ // being chosen. Glacia's controls are drawn by the library, so they have to
6
+ // ask for that tick themselves.
7
+ //
8
+ // There is no single React Native API for it, and Glacia does not take a
9
+ // dependency for one. Instead this tries, in order, the APIs that ship with
10
+ // common Expo and React Native projects, and does nothing where none is
11
+ // present. A missing tick must never break a control, so every call is
12
+ // wrapped: these helpers cannot throw.
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.hapticSelection = hapticSelection;
15
+ const primitives_1 = require("./primitives");
16
+ function resolveTick() {
17
+ // Expo's haptics module, when the app has it installed.
18
+ try {
19
+ const expo = require("expo-haptics");
20
+ if (expo?.selectionAsync) {
21
+ return () => {
22
+ expo.selectionAsync().catch?.(() => { });
23
+ };
24
+ }
25
+ }
26
+ catch {
27
+ // Not an Expo project, or expo-haptics is not installed: try the next one.
28
+ }
29
+ // React Native's own Vibration API: a 10 ms buzz is the closest thing to a
30
+ // selection tick that ships with core. It is a coarser feel, but it is real
31
+ // feedback on a device that has no better module.
32
+ const { Vibration } = (0, primitives_1.primitives)();
33
+ if (Vibration?.vibrate) {
34
+ return () => {
35
+ Vibration.vibrate(10);
36
+ };
37
+ }
38
+ return null;
39
+ }
40
+ /**
41
+ * One selection tick, for a control whose value just changed by one step.
42
+ *
43
+ * Silent where no haptics API is available (the DOM preview, a test run, a
44
+ * device without a vibration motor). Never throws.
45
+ */
46
+ function hapticSelection() {
47
+ try {
48
+ const tick = resolveTick();
49
+ tick?.();
50
+ }
51
+ catch {
52
+ // Haptics are a nicety; a failure here must not surface to the user.
53
+ }
54
+ }
@@ -7,10 +7,14 @@
7
7
  // does not pass `isDark`, so a theme-aware app needs no extra prop threading.
8
8
  // - `useSpring` animates a number towards its target with the package's spring
9
9
  // tokens through React Native's Animated API. No CSS, no timers of our own.
10
+ // - Motion respects the system's Reduce Motion preference: when it is on, the
11
+ // value settles at its target instead of animating. Doing it here means every
12
+ // animation built on `useSpring` complies without repeating the check.
10
13
  Object.defineProperty(exports, "__esModule", { value: true });
11
14
  exports.useIsDark = useIsDark;
12
15
  exports.useSpring = useSpring;
13
16
  const react_1 = require("react");
17
+ const a11y_1 = require("./a11y");
14
18
  const primitives_1 = require("./primitives");
15
19
  const tokens_1 = require("./tokens");
16
20
  /**
@@ -29,10 +33,15 @@ function useIsDark(isDark) {
29
33
  * on this platform. A caller that gets `animated === false` renders the target
30
34
  * directly, so the DOM preview and tests show the settled state rather than an
31
35
  * animation the environment cannot advance.
36
+ *
37
+ * Reduce Motion turns this into the same case: `animated` is false and the
38
+ * value is already at its target, so the component jumps to its end state
39
+ * rather than playing a transition the user asked not to see.
32
40
  */
33
41
  function useSpring(target, spring = "snappy") {
34
42
  const { Animated, isNative } = (0, primitives_1.primitives)();
35
- const animated = Boolean(isNative && Animated?.Value && Animated?.spring);
43
+ const reducedMotion = (0, a11y_1.useReducedMotion)();
44
+ const animated = Boolean(isNative && Animated?.Value && Animated?.spring) && !reducedMotion;
36
45
  // Off-device there is no Animated; a plain ref keeps the call sites identical.
37
46
  const value = (0, react_1.useRef)(null);
38
47
  if (value.current === null) {
@@ -181,15 +181,23 @@ function resolve() {
181
181
  };
182
182
  /** An image that reads its remote source in the DOM preview. */
183
183
  function imageFallback(props) {
184
- const { source, accessibilityLabel, style, onError } = props ?? {};
184
+ const { source, accessibilityLabel, accessibilityRole, style, onError, onLoad, testID, ...rest } = props ?? {};
185
185
  const { createElement } = require("react");
186
+ const source_ = typeof source === "number" ? undefined : source?.uri;
186
187
  return createElement("img", {
187
- src: source?.uri,
188
+ src: source_,
189
+ // `alt` covers the visible-description case; `aria-label` is what queries
190
+ // and screen readers in the preview read, so both are set.
188
191
  alt: accessibilityLabel ?? "",
192
+ "aria-label": accessibilityLabel,
193
+ "aria-role": accessibilityRole,
194
+ "data-testid": testID,
189
195
  style: toDomStyle(style),
190
- // A broken source must reach the component the same way it does on a
191
- // device, or a fallback (initials, placeholder) can never render.
196
+ // Load and error must reach the component the way they do on a device,
197
+ // or the placeholder and the fallback can never render in the preview.
192
198
  onError,
199
+ onLoad,
200
+ ...rest,
193
201
  });
194
202
  }
195
203
  const SvgComponent = svg?.default ?? fallback("svg");
@@ -205,6 +213,10 @@ function resolve() {
205
213
  Circle: svg?.Circle ?? fallback("circle"),
206
214
  Rect: svg?.Rect ?? fallback("rect"),
207
215
  Polygon: svg?.Polygon ?? fallback("polygon"),
216
+ Defs: svg?.Defs ?? fallback("defs"),
217
+ LinearGradient: svg?.LinearGradient ?? fallback("linearGradient"),
218
+ Stop: svg?.Stop ?? fallback("stop"),
219
+ ClipPath: svg?.ClipPath ?? fallback("clipPath"),
208
220
  // TextInput is not an SVG primitive, but resolving it here keeps every
209
221
  // component on one runtime-resolution path instead of two.
210
222
  TextInput: rn?.TextInput ?? fallback("input"),
@@ -222,6 +234,18 @@ function resolve() {
222
234
  isNative: Boolean(rn?.View),
223
235
  PanResponder: rn?.PanResponder ?? panResponderShim(),
224
236
  useColorScheme: rn?.useColorScheme ?? null,
237
+ // AccessibilityInfo and Vibration are only meaningful on a device; both
238
+ // are null off it, and their callers already treat absence as "off".
239
+ AccessibilityInfo: rn?.AccessibilityInfo ?? null,
240
+ Vibration: rn?.Vibration ?? null,
241
+ // Off-device there is no window; the DOM preview reports the viewport when
242
+ // it can and a conventional phone size otherwise. Snap points are
243
+ // fractions, so any consistent height yields the same proportions.
244
+ useWindowDimensions: rn?.useWindowDimensions ??
245
+ (() => {
246
+ const view = typeof globalThis !== "undefined" ? globalThis.window : undefined;
247
+ return { width: view?.innerWidth ?? 390, height: view?.innerHeight ?? 800 };
248
+ }),
225
249
  };
226
250
  }
227
251
  /**
@@ -373,6 +397,39 @@ const LENGTH_PROPS = new Set([
373
397
  "gap",
374
398
  ]);
375
399
  /** Converts an RN style object to DOM-compatible CSS. */
400
+ /**
401
+ * Rewrites React Native's `transform` array into a CSS transform string.
402
+ *
403
+ * The preview is a browser, and a browser does not understand
404
+ * `[{ translateX: 12 }, { scale: 2 }]`; React Native's Shape controls and
405
+ * glass offsets would silently not move. Translating the entries here keeps the
406
+ * preview faithful to what a device shows.
407
+ */
408
+ function transformToCss(entries) {
409
+ if (!Array.isArray(entries))
410
+ return typeof entries === "string" ? entries : undefined;
411
+ const parts = [];
412
+ for (const entry of entries) {
413
+ if (!entry || typeof entry !== "object")
414
+ continue;
415
+ for (const [key, raw] of Object.entries(entry)) {
416
+ const value = typeof raw?.__getValue === "function" ? raw.__getValue() : raw;
417
+ if (typeof value !== "number")
418
+ continue;
419
+ if (key === "translateX")
420
+ parts.push(`translateX(${value}px)`);
421
+ else if (key === "translateY")
422
+ parts.push(`translateY(${value}px)`);
423
+ else if (key === "scale")
424
+ parts.push(`scale(${value})`);
425
+ else if (key === "rotate")
426
+ parts.push(`rotate(${value}deg)`);
427
+ else if (key === "rotateZ")
428
+ parts.push(`rotateZ(${value}deg)`);
429
+ }
430
+ }
431
+ return parts.length > 0 ? parts.join(" ") : undefined;
432
+ }
376
433
  function toDomStyle(style) {
377
434
  if (!style)
378
435
  return style;
@@ -386,6 +443,14 @@ function toDomStyle(style) {
386
443
  continue;
387
444
  // Animated values resolve to plain numbers off-device.
388
445
  const resolved = typeof value?.interpolate === "function" ? value.__getValue?.() : value;
446
+ if (key === "transform") {
447
+ const css = transformToCss(resolved);
448
+ // Only set it when there is something to say; an empty transform would
449
+ // override an earlier entry in a style array.
450
+ if (css)
451
+ merged[key] = css;
452
+ continue;
453
+ }
389
454
  merged[key] =
390
455
  typeof resolved === "number" && LENGTH_PROPS.has(key) ? `${resolved}px` : resolved;
391
456
  }