glacia-native 0.4.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 (73) hide show
  1. package/lib/module/Bars.js +269 -0
  2. package/lib/module/Carousel.js +103 -0
  3. package/lib/module/Display.js +317 -0
  4. package/lib/module/Feedback.js +386 -0
  5. package/lib/module/Forms2.js +454 -0
  6. package/lib/module/Message.js +88 -0
  7. package/lib/module/Overlays.js +328 -0
  8. package/lib/module/Pickers.js +243 -0
  9. package/lib/module/SegmentedControl.js +5 -1
  10. package/lib/module/Slider.js +6 -1
  11. package/lib/module/Switch.js +4 -1
  12. package/lib/module/TabBar.js +5 -1
  13. package/lib/module/Text.js +37 -0
  14. package/lib/module/ai.js +8 -3
  15. package/lib/module/index.js +79 -1
  16. package/lib/module/internal/GlassContainer.js +54 -0
  17. package/lib/module/internal/GlassView.js +31 -7
  18. package/lib/module/internal/a11y.js +94 -0
  19. package/lib/module/internal/fallback.js +19 -8
  20. package/lib/module/internal/glass-routing.js +7 -0
  21. package/lib/module/internal/haptics.js +54 -0
  22. package/lib/module/internal/motion.js +10 -1
  23. package/lib/module/internal/primitives.js +73 -3
  24. package/lib/module/internal/tokens.js +101 -1
  25. package/lib/typescript/Bars.d.ts +188 -0
  26. package/lib/typescript/Carousel.d.ts +47 -0
  27. package/lib/typescript/Display.d.ts +178 -0
  28. package/lib/typescript/Feedback.d.ts +196 -0
  29. package/lib/typescript/Forms2.d.ts +209 -0
  30. package/lib/typescript/Glass.d.ts +1 -1
  31. package/lib/typescript/Message.d.ts +71 -0
  32. package/lib/typescript/Overlays.d.ts +146 -0
  33. package/lib/typescript/Pickers.d.ts +105 -0
  34. package/lib/typescript/SegmentedControl.d.ts +2 -0
  35. package/lib/typescript/Slider.d.ts +2 -0
  36. package/lib/typescript/Switch.d.ts +2 -0
  37. package/lib/typescript/TabBar.d.ts +2 -0
  38. package/lib/typescript/Text.d.ts +28 -0
  39. package/lib/typescript/index.d.ts +11 -1
  40. package/lib/typescript/internal/GlassContainer.d.ts +37 -0
  41. package/lib/typescript/internal/GlassView.d.ts +18 -1
  42. package/lib/typescript/internal/a11y.d.ts +19 -0
  43. package/lib/typescript/internal/fallback.d.ts +5 -0
  44. package/lib/typescript/internal/glass-routing.d.ts +10 -0
  45. package/lib/typescript/internal/haptics.d.ts +7 -0
  46. package/lib/typescript/internal/motion.d.ts +4 -0
  47. package/lib/typescript/internal/primitives.d.ts +21 -0
  48. package/lib/typescript/internal/tokens.d.ts +114 -0
  49. package/package.json +2 -2
  50. package/src/Bars.tsx +797 -0
  51. package/src/Carousel.tsx +233 -0
  52. package/src/Display.tsx +778 -0
  53. package/src/Feedback.tsx +969 -0
  54. package/src/Forms2.tsx +1014 -0
  55. package/src/Message.tsx +219 -0
  56. package/src/Overlays.tsx +685 -0
  57. package/src/Pickers.tsx +590 -0
  58. package/src/SegmentedControl.tsx +6 -0
  59. package/src/Slider.tsx +7 -0
  60. package/src/Switch.tsx +5 -0
  61. package/src/TabBar.tsx +6 -0
  62. package/src/Text.tsx +83 -0
  63. package/src/ai.tsx +9 -3
  64. package/src/index.ts +142 -1
  65. package/src/internal/GlassContainer.tsx +82 -0
  66. package/src/internal/GlassView.tsx +37 -7
  67. package/src/internal/a11y.ts +105 -0
  68. package/src/internal/fallback.tsx +19 -2
  69. package/src/internal/glass-routing.ts +17 -0
  70. package/src/internal/haptics.ts +59 -0
  71. package/src/internal/motion.ts +10 -1
  72. package/src/internal/primitives.ts +84 -3
  73. package/src/internal/tokens.ts +110 -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);
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Text = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const tokens_1 = require("./internal/tokens");
7
+ const primitives_1 = require("./internal/primitives");
8
+ const motion_1 = require("./internal/motion");
9
+ /** The accessibility role each variant announces. */
10
+ const roles = {
11
+ title: "heading",
12
+ heading: "heading",
13
+ body: "text",
14
+ caption: "text",
15
+ label: "text",
16
+ };
17
+ /**
18
+ * Themed text.
19
+ *
20
+ * Every Glacia component that renders words uses this, so type, colour and
21
+ * contrast come from one place. It wraps the resolver's `Text`, which is React
22
+ * Native's own on a device.
23
+ */
24
+ exports.Text = (0, react_1.forwardRef)(function Text({ variant = "body", muted = false, destructive = false, numberOfLines, children, style, isDark: isDarkProp, testID, ...props }, ref) {
25
+ const isDark = (0, motion_1.useIsDark)(isDarkProp);
26
+ const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
27
+ const { Text: RNText } = (0, primitives_1.primitives)();
28
+ const scale = tokens_1.typeScale[variant];
29
+ const textStyle = {
30
+ fontSize: scale.fontSize,
31
+ lineHeight: scale.lineHeight,
32
+ fontWeight: scale.fontWeight,
33
+ color: destructive ? theme.destructive : muted ? theme.muted : theme.foreground,
34
+ ...style,
35
+ };
36
+ return ((0, jsx_runtime_1.jsx)(RNText, { ref: ref, testID: testID, accessibilityRole: roles[variant], numberOfLines: numberOfLines, style: textStyle, ...props, children: children }));
37
+ });
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,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.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;
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,86 @@ 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
+ 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; } });
87
+ // Feedback and display.
88
+ var Feedback_1 = require("./Feedback");
89
+ Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Feedback_1.Toast; } });
90
+ Object.defineProperty(exports, "Banner", { enumerable: true, get: function () { return Feedback_1.Banner; } });
91
+ Object.defineProperty(exports, "List", { enumerable: true, get: function () { return Feedback_1.List; } });
92
+ Object.defineProperty(exports, "ListItem", { enumerable: true, get: function () { return Feedback_1.ListItem; } });
93
+ Object.defineProperty(exports, "ListSection", { enumerable: true, get: function () { return Feedback_1.ListSection; } });
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; } });
96
+ // Bars, buttons and navigation.
97
+ var Bars_1 = require("./Bars");
98
+ Object.defineProperty(exports, "SearchBar", { enumerable: true, get: function () { return Bars_1.SearchBar; } });
99
+ Object.defineProperty(exports, "Chip", { enumerable: true, get: function () { return Bars_1.Chip; } });
100
+ Object.defineProperty(exports, "FAB", { enumerable: true, get: function () { return Bars_1.FAB; } });
101
+ Object.defineProperty(exports, "IconButton", { enumerable: true, get: function () { return Bars_1.IconButton; } });
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; } });
104
+ // Overlays.
105
+ var Overlays_1 = require("./Overlays");
106
+ Object.defineProperty(exports, "Menu", { enumerable: true, get: function () { return Overlays_1.Menu; } });
107
+ Object.defineProperty(exports, "Sheet", { enumerable: true, get: function () { return Overlays_1.Sheet; } });
108
+ Object.defineProperty(exports, "Drawer", { enumerable: true, get: function () { return Overlays_1.Drawer; } });
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; } });
112
+ // Carousel.
113
+ var Carousel_1 = require("./Carousel");
114
+ Object.defineProperty(exports, "Carousel", { enumerable: true, get: function () { return Carousel_1.Carousel; } });
115
+ Object.defineProperty(exports, "PageControl", { enumerable: true, get: function () { return Carousel_1.PageControl; } });
116
+ // Forms and pickers.
117
+ var Forms2_1 = require("./Forms2");
118
+ Object.defineProperty(exports, "Stepper", { enumerable: true, get: function () { return Forms2_1.Stepper; } });
119
+ Object.defineProperty(exports, "Toggle", { enumerable: true, get: function () { return Forms2_1.Toggle; } });
120
+ Object.defineProperty(exports, "ToggleGroup", { enumerable: true, get: function () { return Forms2_1.ToggleGroup; } });
121
+ Object.defineProperty(exports, "InputOTP", { enumerable: true, get: function () { return Forms2_1.InputOTP; } });
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; } });
129
+ var Pickers_1 = require("./Pickers");
130
+ Object.defineProperty(exports, "Calendar", { enumerable: true, get: function () { return Pickers_1.Calendar; } });
131
+ Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return Pickers_1.DatePicker; } });
132
+ Object.defineProperty(exports, "TimePicker", { enumerable: true, get: function () { return Pickers_1.TimePicker; } });
133
+ Object.defineProperty(exports, "monthGrid", { enumerable: true, get: function () { return Pickers_1.monthGrid; } });
134
+ Object.defineProperty(exports, "startOfDay", { enumerable: true, get: function () { return Pickers_1.startOfDay; } });
135
+ Object.defineProperty(exports, "sameDay", { enumerable: true, get: function () { return Pickers_1.sameDay; } });
136
+ Object.defineProperty(exports, "parseTime", { enumerable: true, get: function () { return Pickers_1.parseTime; } });
137
+ Object.defineProperty(exports, "formatTime", { enumerable: true, get: function () { return Pickers_1.formatTime; } });
138
+ Object.defineProperty(exports, "WEEKDAYS", { enumerable: true, get: function () { return Pickers_1.WEEKDAYS; } });
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; } });
73
145
  var GlassView_1 = require("./internal/GlassView");
74
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; } });
75
149
  var tokens_1 = require("./internal/tokens");
76
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; } });
77
153
  Object.defineProperty(exports, "radii", { enumerable: true, get: function () { return tokens_1.radii; } });
78
154
  Object.defineProperty(exports, "springs", { enumerable: true, get: function () { return tokens_1.springs; } });
155
+ Object.defineProperty(exports, "typeScale", { enumerable: true, get: function () { return tokens_1.typeScale; } });
156
+ Object.defineProperty(exports, "toneColor", { enumerable: true, get: function () { return tokens_1.toneColor; } });
@@ -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
+ });
@@ -1,27 +1,51 @@
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
8
  const glass_routing_1 = require("./glass-routing");
8
9
  const motion_1 = require("./motion");
9
10
  /**
10
- * The installed `@callstack/liquid-glass` module, resolved once at load.
11
- * `isLiquidGlassSupported` is true only on iOS 26+; false on older iOS,
12
- * Android and Expo Go.
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.
13
18
  */
14
- const router = (0, glass_routing_1.defaultRouter)();
15
- exports.isGlassSupported = router.supported;
19
+ let cachedRouter = null;
20
+ function router() {
21
+ if (cachedRouter === null)
22
+ cachedRouter = (0, glass_routing_1.defaultRouter)();
23
+ return cachedRouter;
24
+ }
25
+ /** Clears the memoised decision. Only tests call this, to drive both branches. */
26
+ function resetGlassRouter() {
27
+ cachedRouter = null;
28
+ }
29
+ /** Whether this build renders Apple's glass. */
30
+ exports.isGlassSupported = (0, glass_routing_1.defaultRouter)().supported;
16
31
  /**
17
32
  * Platform Glass View — the single place a glass surface is chosen:
18
33
  * - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
19
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.
20
43
  */
21
44
  exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
22
45
  const isDark = (0, motion_1.useIsDark)(isDarkProp);
23
- if (router.supported && router.LiquidGlassView) {
24
- const LiquidGlassView = router.LiquidGlassView;
46
+ const decision = router();
47
+ if (decision.supported && decision.LiquidGlassView) {
48
+ const LiquidGlassView = decision.LiquidGlassView;
25
49
  return ((0, jsx_runtime_1.jsx)(LiquidGlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, style: style, ...props, children: children }));
26
50
  }
27
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 }));
@@ -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) {