glacia-native 0.3.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/lib/module/Bars.js +176 -0
  2. package/lib/module/Button.js +15 -2
  3. package/lib/module/Card.js +29 -14
  4. package/lib/module/Carousel.js +103 -0
  5. package/lib/module/Dialog.js +43 -32
  6. package/lib/module/Display.js +240 -0
  7. package/lib/module/Feedback.js +172 -0
  8. package/lib/module/Form.js +51 -12
  9. package/lib/module/Forms2.js +227 -0
  10. package/lib/module/Glass.js +11 -2
  11. package/lib/module/Input.js +19 -7
  12. package/lib/module/Overlays.js +166 -0
  13. package/lib/module/Pickers.js +243 -0
  14. package/lib/module/SegmentedControl.js +65 -21
  15. package/lib/module/Slider.js +121 -25
  16. package/lib/module/Switch.js +33 -15
  17. package/lib/module/TabBar.js +63 -25
  18. package/lib/module/Table.js +24 -6
  19. package/lib/module/Tabs.js +55 -33
  20. package/lib/module/Text.js +37 -0
  21. package/lib/module/ai.js +49 -20
  22. package/lib/module/charts/BarChart.js +4 -2
  23. package/lib/module/charts/FunnelChart.js +4 -2
  24. package/lib/module/charts/HeatmapChart.js +4 -2
  25. package/lib/module/charts/LineChart.js +4 -2
  26. package/lib/module/charts/PlotChart.js +11 -3
  27. package/lib/module/charts/RadarChart.js +4 -2
  28. package/lib/module/charts/RingChart.js +4 -2
  29. package/lib/module/charts/ScatterChart.js +20 -3
  30. package/lib/module/charts/WaterfallChart.js +12 -3
  31. package/lib/module/charts/advanced.js +12 -6
  32. package/lib/module/charts/extra.js +6 -3
  33. package/lib/module/index.js +58 -1
  34. package/lib/module/internal/GlassView.js +31 -17
  35. package/lib/module/internal/fallback.js +14 -3
  36. package/lib/module/internal/glass-routing.js +56 -0
  37. package/lib/module/internal/motion.js +55 -0
  38. package/lib/module/internal/primitives.js +413 -0
  39. package/lib/module/internal/tokens.js +55 -1
  40. package/lib/typescript/Bars.d.ts +121 -0
  41. package/lib/typescript/Button.d.ts +11 -1
  42. package/lib/typescript/Card.d.ts +20 -8
  43. package/lib/typescript/Carousel.d.ts +47 -0
  44. package/lib/typescript/Dialog.d.ts +19 -6
  45. package/lib/typescript/Display.d.ts +119 -0
  46. package/lib/typescript/Feedback.d.ts +138 -0
  47. package/lib/typescript/Form.d.ts +27 -11
  48. package/lib/typescript/Forms2.d.ts +128 -0
  49. package/lib/typescript/Glass.d.ts +10 -1
  50. package/lib/typescript/Input.d.ts +11 -1
  51. package/lib/typescript/Overlays.d.ts +105 -0
  52. package/lib/typescript/Pickers.d.ts +105 -0
  53. package/lib/typescript/SegmentedControl.d.ts +11 -1
  54. package/lib/typescript/Slider.d.ts +13 -1
  55. package/lib/typescript/Switch.d.ts +12 -1
  56. package/lib/typescript/TabBar.d.ts +13 -1
  57. package/lib/typescript/Table.d.ts +14 -5
  58. package/lib/typescript/Tabs.d.ts +8 -5
  59. package/lib/typescript/Text.d.ts +28 -0
  60. package/lib/typescript/ai.d.ts +12 -9
  61. package/lib/typescript/charts/BarChart.d.ts +1 -1
  62. package/lib/typescript/charts/FunnelChart.d.ts +1 -1
  63. package/lib/typescript/charts/HeatmapChart.d.ts +1 -1
  64. package/lib/typescript/charts/LineChart.d.ts +1 -1
  65. package/lib/typescript/charts/PlotChart.d.ts +1 -1
  66. package/lib/typescript/charts/RadarChart.d.ts +1 -1
  67. package/lib/typescript/charts/RingChart.d.ts +1 -1
  68. package/lib/typescript/charts/ScatterChart.d.ts +1 -1
  69. package/lib/typescript/charts/WaterfallChart.d.ts +1 -1
  70. package/lib/typescript/charts/advanced.d.ts +5 -5
  71. package/lib/typescript/charts/extra.d.ts +2 -2
  72. package/lib/typescript/index.d.ts +9 -1
  73. package/lib/typescript/internal/GlassView.d.ts +21 -4
  74. package/lib/typescript/internal/fallback.d.ts +10 -1
  75. package/lib/typescript/internal/glass-routing.d.ts +30 -0
  76. package/lib/typescript/internal/motion.d.ts +19 -0
  77. package/lib/typescript/internal/primitives.d.ts +41 -0
  78. package/lib/typescript/internal/tokens.d.ts +61 -0
  79. package/package.json +2 -2
  80. package/src/Bars.tsx +570 -0
  81. package/src/Button.tsx +47 -22
  82. package/src/Card.tsx +52 -31
  83. package/src/Carousel.tsx +233 -0
  84. package/src/Dialog.tsx +99 -64
  85. package/src/Display.tsx +550 -0
  86. package/src/Feedback.tsx +579 -0
  87. package/src/Form.tsx +90 -25
  88. package/src/Forms2.tsx +608 -0
  89. package/src/Glass.tsx +24 -1
  90. package/src/Input.tsx +33 -12
  91. package/src/Overlays.tsx +474 -0
  92. package/src/Pickers.tsx +590 -0
  93. package/src/SegmentedControl.tsx +104 -32
  94. package/src/Slider.tsx +151 -47
  95. package/src/Switch.tsx +56 -32
  96. package/src/TabBar.tsx +100 -30
  97. package/src/Table.tsx +38 -14
  98. package/src/Tabs.tsx +85 -32
  99. package/src/Text.tsx +83 -0
  100. package/src/ai.tsx +77 -31
  101. package/src/charts/BarChart.tsx +4 -2
  102. package/src/charts/FunnelChart.tsx +4 -2
  103. package/src/charts/HeatmapChart.tsx +4 -2
  104. package/src/charts/LineChart.tsx +4 -2
  105. package/src/charts/PlotChart.tsx +23 -3
  106. package/src/charts/RadarChart.tsx +4 -2
  107. package/src/charts/RingChart.tsx +4 -2
  108. package/src/charts/ScatterChart.tsx +24 -3
  109. package/src/charts/WaterfallChart.tsx +21 -3
  110. package/src/charts/advanced.tsx +12 -6
  111. package/src/charts/extra.tsx +6 -3
  112. package/src/index.ts +101 -1
  113. package/src/internal/GlassView.tsx +51 -19
  114. package/src/internal/fallback.tsx +23 -8
  115. package/src/internal/glass-routing.ts +68 -0
  116. package/src/internal/motion.ts +60 -0
  117. package/src/internal/primitives.ts +482 -0
  118. package/src/internal/tokens.ts +62 -0
  119. package/lib/module/charts/primitives.js +0 -212
  120. package/lib/typescript/charts/primitives.d.ts +0 -23
  121. package/src/charts/primitives.ts +0 -262
@@ -0,0 +1,413 @@
1
+ "use strict";
2
+ // React Native component resolution.
3
+ //
4
+ // The package never imports `react-native` or `react-native-svg` statically:
5
+ // both ship Flow-typed sources that a plain JS bundler (and the jsdom test
6
+ // environment) cannot parse. Resolving them at runtime keeps the package
7
+ // importable everywhere, matching how GlassView locates the native liquid
8
+ // glass module.
9
+ //
10
+ // Every component in the package builds its structure from these primitives.
11
+ // On a device the resolver returns React Native's own View/Text/Pressable/…
12
+ // and react-native-svg's elements. The DOM stand-ins further down exist only
13
+ // for the case where React Native is genuinely absent: a jsdom test run or a
14
+ // web preview. They are the single place in the package allowed to emit DOM
15
+ // host elements, and their whole job is translating React Native props into
16
+ // DOM ones.
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.measurePreviewWidth = measurePreviewWidth;
19
+ exports.primitives = primitives;
20
+ /**
21
+ * Resolves the primitives, falling back to pass-through DOM elements so the
22
+ * package can be rendered in a non-native environment (tests, web preview)
23
+ * without throwing.
24
+ */
25
+ function resolve() {
26
+ let rn = null;
27
+ let svg = null;
28
+ try {
29
+ rn = require("react-native");
30
+ }
31
+ catch {
32
+ // Non-native environment: the DOM stand-ins below take over.
33
+ }
34
+ try {
35
+ svg = require("react-native-svg");
36
+ }
37
+ catch {
38
+ svg = null;
39
+ }
40
+ // On a device the SVG elements are required: the DOM <svg> stand-ins would
41
+ // crash in a real app ("View config not found"), so say so loudly instead of
42
+ // silently degrading to something that cannot run.
43
+ if (rn && !svg) {
44
+ console.error("[glacia-native] react-native-svg is required by the Glacia charts but could not be " +
45
+ "resolved. Install it as a dependency of your app (npx expo install react-native-svg). " +
46
+ "Charts will not render until it is available.");
47
+ }
48
+ /**
49
+ * Adapts React Native props to the DOM preview used when RN is absent.
50
+ * Without this, `accessibilityRole` and `onPress` reach the DOM untranslated
51
+ * and the element is neither reachable nor clickable in tests.
52
+ */
53
+ const fallback = (tag) => function Primitive(props) {
54
+ const { children, style, accessibilityRole, accessibilityLabel, accessible, accessibilityState, accessibilityValue, onPress, numberOfLines, onChangeText, value, editable: editableProp, nativeID, disabled, keyboardType: _keyboardType, returnKeyType: _returnKeyType, onSubmitEditing: _onSubmitEditing, secureTextEntry: _secureTextEntry, autoCapitalize: _autoCapitalize, autoCorrect: _autoCorrect, multiline, onFocus: _onFocus, onBlur: _onBlur, testID,
55
+ // Gesture handlers from PanResponder.panHandlers are plain DOM events
56
+ // off-device; let them reach the element so a drag is exercisable.
57
+ onMouseDown, onMouseMove, onMouseUp, onMouseLeave, onLayout: _onLayout, onAccessibilityAction, accessibilityActions: _accessibilityActions, ...rest } = props ?? {};
58
+ const { createElement } = require("react");
59
+ const editable = editableProp;
60
+ // RN accepts unitless numbers where the DOM requires "px"; convert the
61
+ // length properties so the preview lays out instead of throwing.
62
+ const domProps = { style: toDomStyle(style), ...rest };
63
+ // RN roles that already exist in ARIA pass straight through.
64
+ const ROLE_MAP = {
65
+ button: "button",
66
+ checkbox: "checkbox",
67
+ radio: "radio",
68
+ radiogroup: "radiogroup",
69
+ alert: "alert",
70
+ text: "text",
71
+ link: "link",
72
+ image: "img",
73
+ tab: "tab",
74
+ tablist: "tablist",
75
+ progressbar: "progressbar",
76
+ switch: "switch",
77
+ slider: "slider",
78
+ adjustable: "slider",
79
+ heading: "heading",
80
+ };
81
+ // "none" means presentational: emit no role rather than a misleading one.
82
+ if (accessibilityRole && accessibilityRole !== "none") {
83
+ domProps.role = ROLE_MAP[accessibilityRole] ?? "text";
84
+ }
85
+ if (accessibilityLabel != null)
86
+ domProps["aria-label"] = accessibilityLabel;
87
+ // RN's `accessible` groups children into one element; a role carries the
88
+ // same meaning in the DOM, so it is dropped rather than emitted raw.
89
+ if (accessible !== undefined && !domProps.role)
90
+ domProps.role = "group";
91
+ if (numberOfLines != null)
92
+ domProps["data-lines"] = numberOfLines;
93
+ if (nativeID != null)
94
+ domProps.id = nativeID;
95
+ if (testID != null)
96
+ domProps["data-testid"] = testID;
97
+ if (accessibilityState) {
98
+ const state = accessibilityState;
99
+ if (state.checked !== undefined)
100
+ domProps["aria-checked"] = state.checked;
101
+ if (state.selected !== undefined)
102
+ domProps["aria-selected"] = state.selected;
103
+ if (state.expanded !== undefined)
104
+ domProps["aria-expanded"] = state.expanded;
105
+ if (state.disabled !== undefined)
106
+ domProps["aria-disabled"] = state.disabled;
107
+ }
108
+ if (accessibilityValue) {
109
+ const value = accessibilityValue;
110
+ if (value.min !== undefined)
111
+ domProps["aria-valuemin"] = value.min;
112
+ if (value.max !== undefined)
113
+ domProps["aria-valuemax"] = value.max;
114
+ if (value.now !== undefined)
115
+ domProps["aria-valuenow"] = value.now;
116
+ if (value.text !== undefined)
117
+ domProps["aria-valuetext"] = value.text;
118
+ }
119
+ // Inputs: bridge the RN controlled-value contract to the DOM one.
120
+ if (tag === "input") {
121
+ // A multiline field must be a real textarea: an <input> cannot wrap.
122
+ if (multiline) {
123
+ tag = "textarea";
124
+ if (typeof numberOfLines === "number")
125
+ domProps.rows = numberOfLines;
126
+ }
127
+ }
128
+ if (tag === "input" || tag === "textarea") {
129
+ if (value != null)
130
+ domProps.value = value;
131
+ if (onChangeText) {
132
+ domProps.onChange = (event) => onChangeText(event.target.value);
133
+ }
134
+ if (editable === false || disabled)
135
+ domProps.disabled = true;
136
+ }
137
+ // Accessibility actions are React Native's; off-device they are exposed
138
+ // as a handler so a test can drive them, matching the role translation.
139
+ if (onAccessibilityAction)
140
+ domProps.onAccessibilityAction = onAccessibilityAction;
141
+ if (onMouseDown)
142
+ domProps.onMouseDown = onMouseDown;
143
+ if (onMouseMove)
144
+ domProps.onMouseMove = onMouseMove;
145
+ if (onMouseUp)
146
+ domProps.onMouseUp = onMouseUp;
147
+ if (onMouseLeave)
148
+ domProps.onMouseLeave = onMouseLeave;
149
+ if (onPress && !disabled) {
150
+ // Any element hosting a press handler needs a DOM click to fire it.
151
+ // A disabled control gets no handler at all, mirroring React Native's
152
+ // Pressable, which swallows the press rather than calling it through.
153
+ domProps.onClick = onPress;
154
+ if (domProps.role === "button" ||
155
+ domProps.role === "checkbox" ||
156
+ domProps.role === "radio" ||
157
+ domProps.role === "switch" ||
158
+ domProps.role === "tab" ||
159
+ domProps.role === "slider") {
160
+ domProps.tabIndex = 0;
161
+ }
162
+ }
163
+ if (disabled)
164
+ domProps["aria-disabled"] = true;
165
+ return createElement(tag, domProps, children);
166
+ };
167
+ /** Resolves React Native's BackHandler, or null off-device. */
168
+ const getBackHandler = () => rn?.BackHandler ?? null;
169
+ /**
170
+ * A Modal that only mounts its children while visible.
171
+ *
172
+ * The generic fallback would render the content regardless of `visible`,
173
+ * which would surface every closed dialog in the DOM preview.
174
+ */
175
+ const modalFallback = (tag) => function Primitive(props) {
176
+ const { children, visible, onRequestClose: _onRequestClose, ...rest } = props ?? {};
177
+ if (!visible)
178
+ return null;
179
+ const { createElement } = require("react");
180
+ return createElement(tag, { style: toDomStyle(rest.style) }, children);
181
+ };
182
+ /** An image that reads its remote source in the DOM preview. */
183
+ function imageFallback(props) {
184
+ const { source, accessibilityLabel, style, onError } = props ?? {};
185
+ const { createElement } = require("react");
186
+ return createElement("img", {
187
+ src: source?.uri,
188
+ alt: accessibilityLabel ?? "",
189
+ 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.
192
+ onError,
193
+ });
194
+ }
195
+ const SvgComponent = svg?.default ?? fallback("svg");
196
+ const SvgText = svg?.Text ?? fallback("text");
197
+ return {
198
+ View: rn?.View ?? fallback("div"),
199
+ Text: rn?.Text ?? fallback("span"),
200
+ Pressable: rn?.Pressable ?? fallback("button"),
201
+ Svg: SvgComponent,
202
+ G: svg?.G ?? fallback("g"),
203
+ Line: svg?.Line ?? fallback("line"),
204
+ Path: svg?.Path ?? fallback("path"),
205
+ Circle: svg?.Circle ?? fallback("circle"),
206
+ Rect: svg?.Rect ?? fallback("rect"),
207
+ Polygon: svg?.Polygon ?? fallback("polygon"),
208
+ // TextInput is not an SVG primitive, but resolving it here keeps every
209
+ // component on one runtime-resolution path instead of two.
210
+ TextInput: rn?.TextInput ?? fallback("input"),
211
+ // Modal is resolved the same way so dialogs degrade to a plain overlay
212
+ // outside a native runtime instead of failing to mount.
213
+ Modal: rn?.Modal ?? modalFallback("div"),
214
+ Image: rn?.Image ?? imageFallback,
215
+ // Animated comes from the same module; off-device the shim below keeps
216
+ // Animated.View/Value/spring from throwing in the DOM preview.
217
+ Animated: rn?.Animated ?? animationShim(require("react")),
218
+ Easing: rn?.Easing ?? easingShim(),
219
+ getScrollView: () => rn?.ScrollView ?? null,
220
+ getBackHandler,
221
+ SvgText,
222
+ isNative: Boolean(rn?.View),
223
+ PanResponder: rn?.PanResponder ?? panResponderShim(),
224
+ useColorScheme: rn?.useColorScheme ?? null,
225
+ };
226
+ }
227
+ /**
228
+ * A stand-in for React Native's Animated API off-device.
229
+ *
230
+ * `Animated.Value` keeps the value it was given and `spring` snaps to the
231
+ * target immediately, so the preview renders the settled state instead of
232
+ * animating against a requestAnimationFrame loop that jsdom does not drive.
233
+ */
234
+ function animationShim(reactModule) {
235
+ class Value {
236
+ current;
237
+ constructor(initial) {
238
+ this.current = initial;
239
+ }
240
+ setValue(next) {
241
+ this.current = next;
242
+ }
243
+ interpolate(config) {
244
+ const input = config?.inputRange;
245
+ const output = config?.outputRange;
246
+ if (!input || !output || input.length !== output.length)
247
+ return this.current;
248
+ for (let i = 0; i < input.length - 1; i += 1) {
249
+ if (this.current <= input[i + 1]) {
250
+ const span = input[i + 1] - input[i] || 1;
251
+ const ratio = (this.current - input[i]) / span;
252
+ return output[i] + (output[i + 1] - output[i]) * ratio;
253
+ }
254
+ }
255
+ return output[output.length - 1];
256
+ }
257
+ }
258
+ function AnimatedView(props) {
259
+ const { style, children, ...rest } = props ?? {};
260
+ return reactModule.createElement("div", { style: toDomStyle(resolveAnimatedStyle(style)), ...rest }, children);
261
+ }
262
+ return {
263
+ Value,
264
+ View: AnimatedView,
265
+ Text: AnimatedView,
266
+ spring: (value, config) => {
267
+ value?.setValue?.(config?.toValue ?? 0);
268
+ return { start: (callback) => callback?.({ finished: true }), stop: () => { } };
269
+ },
270
+ timing: (value, config) => {
271
+ value?.setValue?.(config?.toValue ?? 0);
272
+ return { start: (callback) => callback?.({ finished: true }), stop: () => { } };
273
+ },
274
+ };
275
+ }
276
+ /**
277
+ * A stand-in for React Native's PanResponder off-device.
278
+ *
279
+ * It runs the handler hooks on DOM pointer events so a drag written against
280
+ * PanResponder is still exercisable in the preview and in tests. On a device
281
+ * the resolver returns React Native's own implementation.
282
+ */
283
+ function panResponderShim() {
284
+ return {
285
+ create: (config) => {
286
+ let granted = false;
287
+ const start = (event) => {
288
+ if (!config?.onStartShouldSetPanResponder?.(event, gesture(event)))
289
+ return;
290
+ granted = true;
291
+ config?.onPanResponderGrant?.(event, gesture(event));
292
+ };
293
+ const move = (event) => {
294
+ if (!granted) {
295
+ if (!config?.onMoveShouldSetPanResponder?.(event, gesture(event)))
296
+ return;
297
+ granted = true;
298
+ config?.onPanResponderGrant?.(event, gesture(event));
299
+ }
300
+ config?.onPanResponderMove?.(event, gesture(event));
301
+ };
302
+ const end = (event) => {
303
+ if (!granted)
304
+ return;
305
+ granted = false;
306
+ config?.onPanResponderRelease?.(event, gesture(event));
307
+ };
308
+ return {
309
+ panHandlers: {
310
+ onMouseDown: start,
311
+ onMouseMove: move,
312
+ onMouseUp: end,
313
+ },
314
+ };
315
+ },
316
+ };
317
+ }
318
+ /** Reads a touch position the way React Native's gesture object does. */
319
+ function gesture(event) {
320
+ const target = event?.currentTarget;
321
+ const rect = target?.getBoundingClientRect?.();
322
+ const x = event?.clientX ?? 0;
323
+ const y = event?.clientY ?? 0;
324
+ const locationX = rect ? x - rect.left : x;
325
+ const locationY = rect ? y - rect.top : y;
326
+ if (event && !event.nativeEvent) {
327
+ event.nativeEvent = { locationX, locationY, pageX: x, pageY: y };
328
+ }
329
+ return { dx: 0, dy: 0, moveX: x, moveY: y, x0: x, y0: y, vx: 0, vy: 0 };
330
+ }
331
+ /** Stand-in for React Native's Easing curves. */
332
+ function easingShim() {
333
+ const identity = (t) => t;
334
+ return {
335
+ out: (fn) => fn,
336
+ inOut: (fn) => fn,
337
+ linear: identity,
338
+ ease: identity,
339
+ quad: identity,
340
+ bezier: () => identity,
341
+ };
342
+ }
343
+ /** Reads a style value that may be an Animated.Value after the shim resolved it. */
344
+ function resolveAnimatedStyle(style) {
345
+ if (!style)
346
+ return style;
347
+ const list = Array.isArray(style) ? style : [style];
348
+ const merged = {};
349
+ for (const entry of list) {
350
+ if (!entry)
351
+ continue;
352
+ Object.assign(merged, entry);
353
+ }
354
+ return merged;
355
+ }
356
+ const LENGTH_PROPS = new Set([
357
+ "width",
358
+ "height",
359
+ "top",
360
+ "left",
361
+ "right",
362
+ "bottom",
363
+ "marginTop",
364
+ "marginBottom",
365
+ "marginLeft",
366
+ "marginRight",
367
+ "paddingTop",
368
+ "paddingBottom",
369
+ "paddingLeft",
370
+ "paddingRight",
371
+ "fontSize",
372
+ "borderRadius",
373
+ "gap",
374
+ ]);
375
+ /** Converts an RN style object to DOM-compatible CSS. */
376
+ function toDomStyle(style) {
377
+ if (!style)
378
+ return style;
379
+ const list = Array.isArray(style) ? style : [style];
380
+ const merged = {};
381
+ for (const entry of list) {
382
+ if (!entry)
383
+ continue;
384
+ for (const [key, value] of Object.entries(entry)) {
385
+ if (value == null)
386
+ continue;
387
+ // Animated values resolve to plain numbers off-device.
388
+ const resolved = typeof value?.interpolate === "function" ? value.__getValue?.() : value;
389
+ merged[key] =
390
+ typeof resolved === "number" && LENGTH_PROPS.has(key) ? `${resolved}px` : resolved;
391
+ }
392
+ }
393
+ return merged;
394
+ }
395
+ /**
396
+ * Records an element's width for gesture maths when the environment has no
397
+ * layout events (the DOM preview). A device never needs it: React Native
398
+ * reports width through `onLayout`.
399
+ */
400
+ function measurePreviewWidth(node, widthRef) {
401
+ if (!node || typeof node.getBoundingClientRect !== "function")
402
+ return;
403
+ const width = node.getBoundingClientRect().width;
404
+ if (width > 0)
405
+ widthRef.current = width;
406
+ }
407
+ let cache = null;
408
+ /** The resolved primitives, computed once per process. */
409
+ function primitives() {
410
+ if (!cache)
411
+ cache = resolve();
412
+ return cache;
413
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.colors = exports.springs = exports.radii = void 0;
3
+ exports.colors = exports.typeScale = exports.springs = exports.radii = void 0;
4
+ exports.toneColor = toneColor;
4
5
  const glacia_tokens_1 = require("glacia-tokens");
5
6
  exports.radii = {
6
7
  sm: glacia_tokens_1.radii.sm.number,
@@ -14,6 +15,27 @@ exports.springs = {
14
15
  snappy: glacia_tokens_1.springs.snappy,
15
16
  bouncy: glacia_tokens_1.springs.bouncy,
16
17
  };
18
+ /**
19
+ * The package's type scale, in React Native points.
20
+ *
21
+ * Text maps its variants onto these names so every component in the library —
22
+ * and every app built on it — sizes type the same way.
23
+ */
24
+ exports.typeScale = {
25
+ title: { fontSize: 28, lineHeight: 34, fontWeight: "700" },
26
+ heading: { fontSize: 20, lineHeight: 26, fontWeight: "600" },
27
+ body: { fontSize: 16, lineHeight: 22, fontWeight: "400" },
28
+ label: { fontSize: 13, lineHeight: 18, fontWeight: "600" },
29
+ caption: { fontSize: 12, lineHeight: 16, fontWeight: "400" },
30
+ };
31
+ /**
32
+ * Theme colours in the form React Native accepts.
33
+ *
34
+ * The shared tokens express colours as CSS colour strings (`rgb(r g b / a)`),
35
+ * which is right for the web package and rejected by React Native. The values
36
+ * below are the same colours written as `rgba(...)`/hex, sourced from the same
37
+ * token file, so the two platforms stay in step.
38
+ */
17
39
  exports.colors = {
18
40
  light: {
19
41
  foreground: "#000000E0",
@@ -21,8 +43,17 @@ exports.colors = {
21
43
  glass: "rgba(255, 255, 255, 0.6)",
22
44
  glassActive: "rgba(236, 236, 240, 0.85)",
23
45
  edge: "rgba(0, 0, 0, 0.08)",
46
+ separator: "rgba(60, 60, 67, 0.18)",
24
47
  fill: "#0088FF",
25
48
  destructive: "#FF3B30",
49
+ on: "#34C759",
50
+ warning: "#FF9500",
51
+ info: "#007AFF",
52
+ // The dimmed layer behind a sheet, drawer or dialog.
53
+ scrim: "rgba(0, 0, 0, 0.45)",
54
+ // Text and icons drawn on top of a filled (tinted) surface.
55
+ onTint: "#FFFFFF",
56
+ skeleton: "rgba(60, 60, 67, 0.12)",
26
57
  // Chart axis and grid lines: low-contrast, so they never compete with data.
27
58
  axis: "#3C3C43",
28
59
  },
@@ -32,8 +63,31 @@ exports.colors = {
32
63
  glass: "rgba(40, 40, 40, 0.62)",
33
64
  glassActive: "rgba(70, 70, 70, 0.62)",
34
65
  edge: "rgba(255, 255, 255, 0.08)",
66
+ separator: "rgba(235, 235, 245, 0.16)",
35
67
  fill: "#0091FF",
36
68
  destructive: "#FF4245",
69
+ on: "#30D158",
70
+ warning: "#FF9F0A",
71
+ info: "#0A84FF",
72
+ scrim: "rgba(0, 0, 0, 0.6)",
73
+ onTint: "#FFFFFF",
74
+ skeleton: "rgba(235, 235, 245, 0.14)",
37
75
  axis: "#EBEBF5",
38
76
  },
39
77
  };
78
+ /** Resolves a tone to its theme colour. */
79
+ function toneColor(theme, tone) {
80
+ switch (tone) {
81
+ case "success":
82
+ return theme.on;
83
+ case "warning":
84
+ return theme.warning;
85
+ case "error":
86
+ return theme.destructive;
87
+ default:
88
+ return theme.info;
89
+ }
90
+ }
91
+ // Referenced so the shared tokens stay a live dependency: a colour removed
92
+ // from glacia-tokens should not silently linger here forever.
93
+ void glacia_tokens_1.colors;
@@ -0,0 +1,121 @@
1
+ import { type ReactNode } from "react";
2
+ import type { StyleProp, ViewStyle } from "react-native";
3
+ export interface SearchBarProps {
4
+ /** Controlled text. Omit and the bar keeps its own. */
5
+ value?: string;
6
+ defaultValue?: string;
7
+ onChangeText?: (text: string) => void;
8
+ onSubmit?: (text: string) => void;
9
+ placeholder?: string;
10
+ /** Shows a cancel button beside the field while it holds text or focus. */
11
+ showCancel?: boolean;
12
+ onCancel?: () => void;
13
+ accessibilityLabel?: string;
14
+ style?: StyleProp<ViewStyle>;
15
+ isDark?: boolean;
16
+ testID?: string;
17
+ }
18
+ /**
19
+ * A search field for a bar or a screen header.
20
+ *
21
+ * Distinct from NativeAIInput: that is an AI composer with send semantics, this
22
+ * is ordinary app search — magnifier, themed placeholder, and a clear button
23
+ * once there is something to clear.
24
+ */
25
+ export declare const SearchBar: import("react").ForwardRefExoticComponent<SearchBarProps & import("react").RefAttributes<any>>;
26
+ export interface ChipProps {
27
+ label: string;
28
+ icon?: ReactNode;
29
+ /** Shows a close affordance; called when it is pressed. */
30
+ onClose?: () => void;
31
+ /** Tapping the chip. Omit to make it a static tag. */
32
+ onPress?: () => void;
33
+ /** Controlled selection. Omit for a plain tag with no selected state. */
34
+ selected?: boolean;
35
+ defaultSelected?: boolean;
36
+ onSelectedChange?: (selected: boolean) => void;
37
+ disabled?: boolean;
38
+ style?: StyleProp<ViewStyle>;
39
+ isDark?: boolean;
40
+ testID?: string;
41
+ }
42
+ /**
43
+ * A filter or tag pill.
44
+ *
45
+ * Selected state is a glass pill tinted with `glassActive` — the same selected
46
+ * treatment SegmentedControl and TabBar use, rather than a new colour.
47
+ */
48
+ export declare const Chip: import("react").ForwardRefExoticComponent<ChipProps & import("react").RefAttributes<any>>;
49
+ export interface FABProps {
50
+ onPress: () => void;
51
+ /** Required: an icon-only circle has no text to announce. */
52
+ accessibilityLabel: string;
53
+ /** The icon. When a label string is also supplied, the FAB is extended. */
54
+ icon?: ReactNode;
55
+ /** Turns the circle into an extended pill with visible text. */
56
+ label?: string;
57
+ size?: "md" | "lg";
58
+ disabled?: boolean;
59
+ style?: StyleProp<ViewStyle>;
60
+ isDark?: boolean;
61
+ testID?: string;
62
+ }
63
+ /**
64
+ * The floating action button.
65
+ *
66
+ * The flagship glass circle of the library: a round `Glass` with `interactive`
67
+ * so the material itself responds to touch. The caller positions it; the
68
+ * component does not assume an edge.
69
+ */
70
+ export declare const FAB: import("react").ForwardRefExoticComponent<FABProps & import("react").RefAttributes<any>>;
71
+ export interface IconButtonProps {
72
+ /** Required: the icon carries no text of its own. */
73
+ accessibilityLabel: string;
74
+ onPress: () => void;
75
+ icon: ReactNode;
76
+ size?: "sm" | "md" | "lg";
77
+ variant?: "glass" | "ghost";
78
+ disabled?: boolean;
79
+ style?: StyleProp<ViewStyle>;
80
+ isDark?: boolean;
81
+ testID?: string;
82
+ }
83
+ /**
84
+ * An icon-only button on glass.
85
+ *
86
+ * Button takes an icon alongside a label; this is the icon-only form, which
87
+ * every kit ships for toolbars and bar actions.
88
+ */
89
+ export declare const IconButton: import("react").ForwardRefExoticComponent<IconButtonProps & import("react").RefAttributes<any>>;
90
+ export interface AppBarAction {
91
+ /** Announced to screen readers; the icon is decorative. */
92
+ accessibilityLabel: string;
93
+ icon: ReactNode;
94
+ onPress: () => void;
95
+ disabled?: boolean;
96
+ }
97
+ export interface AppBarProps {
98
+ title: string;
99
+ /** Optional second line under the title. */
100
+ subtitle?: string;
101
+ /** A back or menu action at the leading edge. */
102
+ leading?: AppBarAction;
103
+ /** Actions at the trailing edge. */
104
+ actions?: AppBarAction[];
105
+ /**
106
+ * The caller's safe-area inset above the bar. Glacia takes it as a prop
107
+ * rather than adding a native insets dependency: on a device the app already
108
+ * knows its insets, and passing a number keeps this component dependency-free.
109
+ */
110
+ topInset?: number;
111
+ style?: StyleProp<ViewStyle>;
112
+ isDark?: boolean;
113
+ testID?: string;
114
+ }
115
+ /**
116
+ * The top bar.
117
+ *
118
+ * A glass bar across the top of the screen with a leading action, a title and
119
+ * trailing actions — the counterpart to the existing bottom TabBar.
120
+ */
121
+ export declare const AppBar: import("react").ForwardRefExoticComponent<AppBarProps & import("react").RefAttributes<any>>;
@@ -1,4 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
+ import type { StyleProp, ViewStyle } from "react-native";
2
3
  export interface ButtonProps {
3
4
  variant?: "glass" | "filled" | "ghost";
4
5
  size?: "sm" | "md" | "lg";
@@ -7,8 +8,17 @@ export interface ButtonProps {
7
8
  accessibilityLabel: string;
8
9
  icon?: ReactNode;
9
10
  children?: ReactNode;
10
- style?: any;
11
+ style?: StyleProp<ViewStyle>;
11
12
  tint?: string;
12
13
  isDark?: boolean;
14
+ /** Passed through to the pressable root so the button is testable. */
15
+ testID?: string;
13
16
  }
17
+ /**
18
+ * A pressable button on Glacia's glass.
19
+ *
20
+ * The root is a Pressable so it gets the platform's own press semantics
21
+ * (focus, screen-reader activation, pressed feedback) while the material —
22
+ * Apple's glass on iOS 26+, Glacia's tint elsewhere — comes from `Glass`.
23
+ */
14
24
  export declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<any>>;