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.
- package/lib/module/Bars.js +269 -0
- package/lib/module/Carousel.js +103 -0
- package/lib/module/Display.js +317 -0
- package/lib/module/Feedback.js +386 -0
- package/lib/module/Forms2.js +454 -0
- package/lib/module/Message.js +88 -0
- package/lib/module/Overlays.js +328 -0
- package/lib/module/Pickers.js +243 -0
- package/lib/module/SegmentedControl.js +5 -1
- package/lib/module/Slider.js +6 -1
- package/lib/module/Switch.js +4 -1
- package/lib/module/TabBar.js +5 -1
- package/lib/module/Text.js +37 -0
- package/lib/module/ai.js +8 -3
- package/lib/module/index.js +79 -1
- package/lib/module/internal/GlassContainer.js +54 -0
- package/lib/module/internal/GlassView.js +31 -7
- package/lib/module/internal/a11y.js +94 -0
- package/lib/module/internal/fallback.js +19 -8
- package/lib/module/internal/glass-routing.js +7 -0
- package/lib/module/internal/haptics.js +54 -0
- package/lib/module/internal/motion.js +10 -1
- package/lib/module/internal/primitives.js +73 -3
- package/lib/module/internal/tokens.js +101 -1
- package/lib/typescript/Bars.d.ts +188 -0
- package/lib/typescript/Carousel.d.ts +47 -0
- package/lib/typescript/Display.d.ts +178 -0
- package/lib/typescript/Feedback.d.ts +196 -0
- package/lib/typescript/Forms2.d.ts +209 -0
- package/lib/typescript/Glass.d.ts +1 -1
- package/lib/typescript/Message.d.ts +71 -0
- package/lib/typescript/Overlays.d.ts +146 -0
- package/lib/typescript/Pickers.d.ts +105 -0
- package/lib/typescript/SegmentedControl.d.ts +2 -0
- package/lib/typescript/Slider.d.ts +2 -0
- package/lib/typescript/Switch.d.ts +2 -0
- package/lib/typescript/TabBar.d.ts +2 -0
- package/lib/typescript/Text.d.ts +28 -0
- package/lib/typescript/index.d.ts +11 -1
- package/lib/typescript/internal/GlassContainer.d.ts +37 -0
- package/lib/typescript/internal/GlassView.d.ts +18 -1
- package/lib/typescript/internal/a11y.d.ts +19 -0
- package/lib/typescript/internal/fallback.d.ts +5 -0
- package/lib/typescript/internal/glass-routing.d.ts +10 -0
- package/lib/typescript/internal/haptics.d.ts +7 -0
- package/lib/typescript/internal/motion.d.ts +4 -0
- package/lib/typescript/internal/primitives.d.ts +21 -0
- package/lib/typescript/internal/tokens.d.ts +114 -0
- package/package.json +2 -2
- package/src/Bars.tsx +797 -0
- package/src/Carousel.tsx +233 -0
- package/src/Display.tsx +778 -0
- package/src/Feedback.tsx +969 -0
- package/src/Forms2.tsx +1014 -0
- package/src/Message.tsx +219 -0
- package/src/Overlays.tsx +685 -0
- package/src/Pickers.tsx +590 -0
- package/src/SegmentedControl.tsx +6 -0
- package/src/Slider.tsx +7 -0
- package/src/Switch.tsx +5 -0
- package/src/TabBar.tsx +6 -0
- package/src/Text.tsx +83 -0
- package/src/ai.tsx +9 -3
- package/src/index.ts +142 -1
- package/src/internal/GlassContainer.tsx +82 -0
- package/src/internal/GlassView.tsx +37 -7
- package/src/internal/a11y.ts +105 -0
- package/src/internal/fallback.tsx +19 -2
- package/src/internal/glass-routing.ts +17 -0
- package/src/internal/haptics.ts +59 -0
- package/src/internal/motion.ts +10 -1
- package/src/internal/primitives.ts +84 -3
- package/src/internal/tokens.ts +110 -0
|
@@ -146,8 +146,10 @@ function resolve() {
|
|
|
146
146
|
domProps.onMouseUp = onMouseUp;
|
|
147
147
|
if (onMouseLeave)
|
|
148
148
|
domProps.onMouseLeave = onMouseLeave;
|
|
149
|
-
if (onPress) {
|
|
149
|
+
if (onPress && !disabled) {
|
|
150
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.
|
|
151
153
|
domProps.onClick = onPress;
|
|
152
154
|
if (domProps.role === "button" ||
|
|
153
155
|
domProps.role === "checkbox" ||
|
|
@@ -179,12 +181,23 @@ function resolve() {
|
|
|
179
181
|
};
|
|
180
182
|
/** An image that reads its remote source in the DOM preview. */
|
|
181
183
|
function imageFallback(props) {
|
|
182
|
-
const { source, accessibilityLabel, style } = props ?? {};
|
|
184
|
+
const { source, accessibilityLabel, accessibilityRole, style, onError, onLoad, testID, ...rest } = props ?? {};
|
|
183
185
|
const { createElement } = require("react");
|
|
186
|
+
const source_ = typeof source === "number" ? undefined : source?.uri;
|
|
184
187
|
return createElement("img", {
|
|
185
|
-
src:
|
|
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.
|
|
186
191
|
alt: accessibilityLabel ?? "",
|
|
192
|
+
"aria-label": accessibilityLabel,
|
|
193
|
+
"aria-role": accessibilityRole,
|
|
194
|
+
"data-testid": testID,
|
|
187
195
|
style: toDomStyle(style),
|
|
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.
|
|
198
|
+
onError,
|
|
199
|
+
onLoad,
|
|
200
|
+
...rest,
|
|
188
201
|
});
|
|
189
202
|
}
|
|
190
203
|
const SvgComponent = svg?.default ?? fallback("svg");
|
|
@@ -200,6 +213,10 @@ function resolve() {
|
|
|
200
213
|
Circle: svg?.Circle ?? fallback("circle"),
|
|
201
214
|
Rect: svg?.Rect ?? fallback("rect"),
|
|
202
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"),
|
|
203
220
|
// TextInput is not an SVG primitive, but resolving it here keeps every
|
|
204
221
|
// component on one runtime-resolution path instead of two.
|
|
205
222
|
TextInput: rn?.TextInput ?? fallback("input"),
|
|
@@ -217,6 +234,18 @@ function resolve() {
|
|
|
217
234
|
isNative: Boolean(rn?.View),
|
|
218
235
|
PanResponder: rn?.PanResponder ?? panResponderShim(),
|
|
219
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
|
+
}),
|
|
220
249
|
};
|
|
221
250
|
}
|
|
222
251
|
/**
|
|
@@ -368,6 +397,39 @@ const LENGTH_PROPS = new Set([
|
|
|
368
397
|
"gap",
|
|
369
398
|
]);
|
|
370
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
|
+
}
|
|
371
433
|
function toDomStyle(style) {
|
|
372
434
|
if (!style)
|
|
373
435
|
return style;
|
|
@@ -381,6 +443,14 @@ function toDomStyle(style) {
|
|
|
381
443
|
continue;
|
|
382
444
|
// Animated values resolve to plain numbers off-device.
|
|
383
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
|
+
}
|
|
384
454
|
merged[key] =
|
|
385
455
|
typeof resolved === "number" && LENGTH_PROPS.has(key) ? `${resolved}px` : resolved;
|
|
386
456
|
}
|
|
@@ -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.controlSizes = exports.palette = 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,54 @@ 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
|
+
* The default colour palette for ColorPicker.
|
|
33
|
+
*
|
|
34
|
+
* A palette is data, not a theme colour — it is the same twelve hues in light
|
|
35
|
+
* and dark — so it lives here rather than in either theme. Keeping it in the
|
|
36
|
+
* token module is also what lets the conformance guard require that component
|
|
37
|
+
* code contains no colour literal at all.
|
|
38
|
+
*/
|
|
39
|
+
exports.palette = {
|
|
40
|
+
default: [
|
|
41
|
+
"#FF3B30", "#FF9500", "#FFCC00", "#34C759", "#32ADE6", "#007AFF",
|
|
42
|
+
"#5856D6", "#AF52DE", "#FF2D55", "#A2845E", "#8E8E93", "#1C1C1E",
|
|
43
|
+
],
|
|
44
|
+
/** The colour a picker starts on when the caller gives none. */
|
|
45
|
+
fallback: "#007AFF",
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Control sizes in points, for components whose dimension is not a radius.
|
|
49
|
+
*
|
|
50
|
+
* Rating's stars are the reason this exists: a star has a size and the size
|
|
51
|
+
* must come from the scale rather than from a literal in the component.
|
|
52
|
+
*/
|
|
53
|
+
exports.controlSizes = {
|
|
54
|
+
star: { sm: 14, md: 20, lg: 28 },
|
|
55
|
+
swatch: { sm: 28, md: 36, lg: 44 },
|
|
56
|
+
picker: { track: 28 },
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Theme colours in the form React Native accepts.
|
|
60
|
+
*
|
|
61
|
+
* The shared tokens express colours as CSS colour strings (`rgb(r g b / a)`),
|
|
62
|
+
* which is right for the web package and rejected by React Native. The values
|
|
63
|
+
* below are the same colours written as `rgba(...)`/hex, sourced from the same
|
|
64
|
+
* token file, so the two platforms stay in step.
|
|
65
|
+
*/
|
|
17
66
|
exports.colors = {
|
|
18
67
|
light: {
|
|
19
68
|
foreground: "#000000E0",
|
|
@@ -21,8 +70,31 @@ exports.colors = {
|
|
|
21
70
|
glass: "rgba(255, 255, 255, 0.6)",
|
|
22
71
|
glassActive: "rgba(236, 236, 240, 0.85)",
|
|
23
72
|
edge: "rgba(0, 0, 0, 0.08)",
|
|
73
|
+
separator: "rgba(60, 60, 67, 0.18)",
|
|
24
74
|
fill: "#0088FF",
|
|
25
75
|
destructive: "#FF3B30",
|
|
76
|
+
on: "#34C759",
|
|
77
|
+
warning: "#FF9500",
|
|
78
|
+
info: "#007AFF",
|
|
79
|
+
// The dimmed layer behind a sheet, drawer or dialog.
|
|
80
|
+
scrim: "rgba(0, 0, 0, 0.45)",
|
|
81
|
+
// Text and icons drawn on top of a filled (tinted) surface.
|
|
82
|
+
onTint: "#FFFFFF",
|
|
83
|
+
skeleton: "rgba(60, 60, 67, 0.12)",
|
|
84
|
+
/**
|
|
85
|
+
* The solid colour glass becomes when the user has asked the system to
|
|
86
|
+
* reduce transparency. Apple's rule is that a translucent surface is
|
|
87
|
+
* replaced by an opaque one, not merely tinted differently.
|
|
88
|
+
*/
|
|
89
|
+
glassSolid: "#F2F2F7",
|
|
90
|
+
/**
|
|
91
|
+
* Neutral colours used by pickers and fields: the field's own wash, and
|
|
92
|
+
* the far end of a saturation gradient (the point of no saturation).
|
|
93
|
+
*/
|
|
94
|
+
fieldWash: "rgba(120, 120, 128, 0.12)",
|
|
95
|
+
/** A flat neutral surface: incoming message bubbles, file chips. */
|
|
96
|
+
wash: "rgba(120, 120, 128, 0.12)",
|
|
97
|
+
neutralTop: "#FFFFFF",
|
|
26
98
|
// Chart axis and grid lines: low-contrast, so they never compete with data.
|
|
27
99
|
axis: "#3C3C43",
|
|
28
100
|
},
|
|
@@ -32,8 +104,36 @@ exports.colors = {
|
|
|
32
104
|
glass: "rgba(40, 40, 40, 0.62)",
|
|
33
105
|
glassActive: "rgba(70, 70, 70, 0.62)",
|
|
34
106
|
edge: "rgba(255, 255, 255, 0.08)",
|
|
107
|
+
separator: "rgba(235, 235, 245, 0.16)",
|
|
35
108
|
fill: "#0091FF",
|
|
36
109
|
destructive: "#FF4245",
|
|
110
|
+
on: "#30D158",
|
|
111
|
+
warning: "#FF9F0A",
|
|
112
|
+
info: "#0A84FF",
|
|
113
|
+
scrim: "rgba(0, 0, 0, 0.6)",
|
|
114
|
+
onTint: "#FFFFFF",
|
|
115
|
+
skeleton: "rgba(235, 235, 245, 0.14)",
|
|
116
|
+
glassSolid: "#1C1C1E",
|
|
117
|
+
fieldWash: "rgba(120, 120, 128, 0.12)",
|
|
118
|
+
/** A flat neutral surface: incoming message bubbles, file chips. */
|
|
119
|
+
wash: "rgba(120, 120, 128, 0.12)",
|
|
120
|
+
neutralTop: "#FFFFFF",
|
|
37
121
|
axis: "#EBEBF5",
|
|
38
122
|
},
|
|
39
123
|
};
|
|
124
|
+
/** Resolves a tone to its theme colour. */
|
|
125
|
+
function toneColor(theme, tone) {
|
|
126
|
+
switch (tone) {
|
|
127
|
+
case "success":
|
|
128
|
+
return theme.on;
|
|
129
|
+
case "warning":
|
|
130
|
+
return theme.warning;
|
|
131
|
+
case "error":
|
|
132
|
+
return theme.destructive;
|
|
133
|
+
default:
|
|
134
|
+
return theme.info;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Referenced so the shared tokens stay a live dependency: a colour removed
|
|
138
|
+
// from glacia-tokens should not silently linger here forever.
|
|
139
|
+
void glacia_tokens_1.colors;
|
|
@@ -0,0 +1,188 @@
|
|
|
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
|
+
/**
|
|
112
|
+
* Whether content has scrolled under the bar.
|
|
113
|
+
*
|
|
114
|
+
* iOS bars sit quiet at the top of a screen and gain a defined edge once
|
|
115
|
+
* content passes beneath them, so the bar reads as a layer over the content
|
|
116
|
+
* rather than as part of it. Wire this to a ScrollView's scroll offset — see
|
|
117
|
+
* the component's documentation for the two-line version.
|
|
118
|
+
*/
|
|
119
|
+
scrolled?: boolean;
|
|
120
|
+
style?: StyleProp<ViewStyle>;
|
|
121
|
+
isDark?: boolean;
|
|
122
|
+
testID?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The top bar.
|
|
126
|
+
*
|
|
127
|
+
* A glass bar across the top of the screen with a leading action, a title and
|
|
128
|
+
* trailing actions — the counterpart to the existing bottom TabBar.
|
|
129
|
+
*
|
|
130
|
+
* `scrolled` mirrors iOS 26's scroll-edge effect. At the top of the screen the
|
|
131
|
+
* bar is quiet: its bottom edge is invisible and the glass blends into the
|
|
132
|
+
* content above it. Once content has scrolled under it, the edge token becomes
|
|
133
|
+
* visible and the surface reads as a distinct layer — the change iOS makes when
|
|
134
|
+
* a navigation bar starts floating over scrolled content.
|
|
135
|
+
*
|
|
136
|
+
* ```
|
|
137
|
+
* const [scrolled, setScrolled] = useState(false);
|
|
138
|
+
* <ScrollView onScroll={(e) => setScrolled(e.nativeEvent.contentOffset.y > 8)}
|
|
139
|
+
* scrollEventThrottle={16}>{...}</ScrollView>
|
|
140
|
+
* <AppBar title="Inbox" scrolled={scrolled} />
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export declare const AppBar: import("react").ForwardRefExoticComponent<AppBarProps & import("react").RefAttributes<any>>;
|
|
144
|
+
export interface FABGroupAction {
|
|
145
|
+
/** A leading node, typically an SVG icon the caller supplies. */
|
|
146
|
+
icon: ReactNode;
|
|
147
|
+
/** The action's name, shown on its mini button. */
|
|
148
|
+
label: string;
|
|
149
|
+
onPress: () => void;
|
|
150
|
+
}
|
|
151
|
+
export interface FABGroupProps {
|
|
152
|
+
/** The actions, listed top to bottom as they appear when expanded. */
|
|
153
|
+
actions: FABGroupAction[];
|
|
154
|
+
/** The icon on the main button. Rotates 45° while open. */
|
|
155
|
+
icon: ReactNode;
|
|
156
|
+
/** The icon on the main button while open. Defaults to the closed one. */
|
|
157
|
+
closeIcon?: ReactNode;
|
|
158
|
+
/** Controlled open state. Omit and the group keeps its own. */
|
|
159
|
+
open?: boolean;
|
|
160
|
+
defaultOpen?: boolean;
|
|
161
|
+
onOpenChange?: (open: boolean) => void;
|
|
162
|
+
/** The main button's accessible name. */
|
|
163
|
+
accessibilityLabel?: string;
|
|
164
|
+
size?: "md" | "lg";
|
|
165
|
+
style?: StyleProp<ViewStyle>;
|
|
166
|
+
isDark?: boolean;
|
|
167
|
+
testID?: string;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* A main button that expands into a stack of labelled mini buttons.
|
|
171
|
+
*
|
|
172
|
+
* The pattern Paper calls `FAB.Group`: one floating button stands in for a set
|
|
173
|
+
* of actions until it is opened, then the actions appear above it, each on its
|
|
174
|
+
* own glass pill with a label. A scrim behind them takes the next press and
|
|
175
|
+
* closes the group, which is how a floating action set gets out of the way
|
|
176
|
+
* without a dismissal button.
|
|
177
|
+
*
|
|
178
|
+
* The mini buttons rise on the bouncy spring with a small stagger, and the main
|
|
179
|
+
* button's icon rotates 45° — both settle instantly under Reduce Motion.
|
|
180
|
+
*
|
|
181
|
+
* **Merging is an iOS 26+ visual effect.** This component is one glass surface
|
|
182
|
+
* plus one per action; to have them blend into a single connected surface, put
|
|
183
|
+
* the group inside a `GlassContainer` on iOS 26. It works standalone — nothing
|
|
184
|
+
* depends on the container — and that composition is left to the caller rather
|
|
185
|
+
* than forced, because a group outside a container is the correct rendering on
|
|
186
|
+
* every other platform anyway.
|
|
187
|
+
*/
|
|
188
|
+
export declare const FABGroup: import("react").ForwardRefExoticComponent<FABGroupProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
export interface CarouselProps {
|
|
4
|
+
/** One node per page. */
|
|
5
|
+
slides: ReactNode[];
|
|
6
|
+
/** Controlled page. Omit and the carousel tracks itself. */
|
|
7
|
+
index?: number;
|
|
8
|
+
defaultIndex?: number;
|
|
9
|
+
/** Fires when a swipe settles on a new page. */
|
|
10
|
+
onIndexChange?: (index: number) => void;
|
|
11
|
+
/** Gap between pages, so neighbours peek at the edges. */
|
|
12
|
+
gap?: number;
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
isDark?: boolean;
|
|
15
|
+
testID?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A horizontally paging swiper.
|
|
19
|
+
*
|
|
20
|
+
* It rides the resolver's ScrollView with `pagingEnabled`, so the paging feel is
|
|
21
|
+
* the platform's own and the pages are plain content the caller supplies. The
|
|
22
|
+
* active page is derived from the scroll offset, which is also what reports
|
|
23
|
+
* `onIndexChange`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Carousel: import("react").ForwardRefExoticComponent<CarouselProps & import("react").RefAttributes<any>>;
|
|
26
|
+
export interface PageControlProps {
|
|
27
|
+
count: number;
|
|
28
|
+
/** Controlled active page. Omit and the control keeps its own. */
|
|
29
|
+
activeIndex?: number;
|
|
30
|
+
defaultActiveIndex?: number;
|
|
31
|
+
/** Called when a dot is tapped. */
|
|
32
|
+
onChange?: (index: number) => void;
|
|
33
|
+
/** Tint the active dot; defaults to the theme accent. */
|
|
34
|
+
tint?: string;
|
|
35
|
+
/** Hide the dots when there is only one page. */
|
|
36
|
+
hidesForSinglePage?: boolean;
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
isDark?: boolean;
|
|
39
|
+
testID?: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The page dots.
|
|
43
|
+
*
|
|
44
|
+
* The active dot elongates and the others stay narrow, which is how iOS reads
|
|
45
|
+
* "you are here". The width change runs on the springs token through Animated.
|
|
46
|
+
*/
|
|
47
|
+
export declare const PageControl: import("react").ForwardRefExoticComponent<PageControlProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
export type AvatarSize = "sm" | "md" | "lg";
|
|
4
|
+
export interface AvatarProps {
|
|
5
|
+
/** Image to show. When absent, or when it fails to load, initials render. */
|
|
6
|
+
source?: {
|
|
7
|
+
uri: string;
|
|
8
|
+
} | number;
|
|
9
|
+
/** The person's name: initials are derived from it when no image loads. */
|
|
10
|
+
name?: string;
|
|
11
|
+
size?: AvatarSize;
|
|
12
|
+
/** Draws a status dot in the corner. */
|
|
13
|
+
status?: "online" | "offline" | "busy";
|
|
14
|
+
style?: StyleProp<ViewStyle>;
|
|
15
|
+
isDark?: boolean;
|
|
16
|
+
testID?: string;
|
|
17
|
+
}
|
|
18
|
+
/** First letters of the first and last word, as an avatar fallback. */
|
|
19
|
+
export declare function initialsOf(name: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* A person or entity: their picture, or their initials when there is none.
|
|
22
|
+
*
|
|
23
|
+
* The frame is Glacia's glass so it belongs to the same family as the rest of
|
|
24
|
+
* the library; the initials sit on it in the theme's foreground colour.
|
|
25
|
+
*/
|
|
26
|
+
export declare const Avatar: import("react").ForwardRefExoticComponent<AvatarProps & import("react").RefAttributes<any>>;
|
|
27
|
+
export interface BadgeProps {
|
|
28
|
+
/** The count or short label. Omit to render a plain dot. */
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
/** Draws the badge in the destructive tone (unread, errors). */
|
|
31
|
+
tone?: "fill" | "destructive" | "success" | "muted";
|
|
32
|
+
/** The element to overlay. Supplying it puts the badge in the corner. */
|
|
33
|
+
overlay?: ReactNode;
|
|
34
|
+
style?: StyleProp<ViewStyle>;
|
|
35
|
+
isDark?: boolean;
|
|
36
|
+
testID?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A small count or dot.
|
|
40
|
+
*
|
|
41
|
+
* Deliberately not glass: a badge is a micro-element, and a translucent 16pt
|
|
42
|
+
* chip loses its contrast against whatever it sits on. It uses the solid theme
|
|
43
|
+
* tint instead, which is what makes it legible in both themes.
|
|
44
|
+
*/
|
|
45
|
+
export declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<any>>;
|
|
46
|
+
export interface SeparatorProps {
|
|
47
|
+
orientation?: "horizontal" | "vertical";
|
|
48
|
+
/** Inset from the leading edge, matching a list row's leading accessory. */
|
|
49
|
+
inset?: number;
|
|
50
|
+
style?: StyleProp<ViewStyle>;
|
|
51
|
+
isDark?: boolean;
|
|
52
|
+
testID?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A hairline divider in the theme's separator colour.
|
|
56
|
+
*
|
|
57
|
+
* A plain View rather than a Glass: a 1pt rule is not a surface, and glass on
|
|
58
|
+
* a line has nothing to refract.
|
|
59
|
+
*/
|
|
60
|
+
export declare const Separator: import("react").ForwardRefExoticComponent<SeparatorProps & import("react").RefAttributes<any>>;
|
|
61
|
+
export interface SkeletonProps {
|
|
62
|
+
/** Rectangles for cards and rows, circles for avatars, lines for a run of text. */
|
|
63
|
+
shape?: "rect" | "circle" | "line";
|
|
64
|
+
width?: number | string;
|
|
65
|
+
height?: number;
|
|
66
|
+
style?: StyleProp<ViewStyle>;
|
|
67
|
+
isDark?: boolean;
|
|
68
|
+
testID?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A loading placeholder.
|
|
72
|
+
*
|
|
73
|
+
* The pulse is opacity only and slow, on the gentle spring, so it reads as
|
|
74
|
+
* "loading" without motion that could bother someone sensitive to movement.
|
|
75
|
+
* Nothing about it is essential to understanding the screen, so it is hidden
|
|
76
|
+
* from screen readers rather than announced.
|
|
77
|
+
*/
|
|
78
|
+
export declare const Skeleton: import("react").ForwardRefExoticComponent<SkeletonProps & import("react").RefAttributes<any>>;
|
|
79
|
+
export type SpinnerSize = "sm" | "md" | "lg";
|
|
80
|
+
export interface SpinnerProps {
|
|
81
|
+
size?: SpinnerSize;
|
|
82
|
+
/** Spinner colour; defaults to the theme's muted foreground. */
|
|
83
|
+
tint?: string;
|
|
84
|
+
/** Announced to screen readers, since a spinner alone has no text. */
|
|
85
|
+
accessibilityLabel?: string;
|
|
86
|
+
style?: StyleProp<ViewStyle>;
|
|
87
|
+
isDark?: boolean;
|
|
88
|
+
testID?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A loading spinner, drawn by Glacia.
|
|
92
|
+
*
|
|
93
|
+
* An SVG arc that rotates on the gentle spring through Animated — not the
|
|
94
|
+
* platform's ActivityIndicator, so it looks the same on every platform and
|
|
95
|
+
* wears the theme's colour instead of inheriting the system tint.
|
|
96
|
+
*/
|
|
97
|
+
export declare const Spinner: import("react").ForwardRefExoticComponent<SpinnerProps & import("react").RefAttributes<any>>;
|
|
98
|
+
export type ProgressVariant = "bar" | "ring";
|
|
99
|
+
export interface ProgressProps {
|
|
100
|
+
/** 0–100. Values outside the range are clamped rather than drawn wrong. */
|
|
101
|
+
value: number;
|
|
102
|
+
variant?: ProgressVariant;
|
|
103
|
+
/** Overrides the fill colour; defaults to the theme accent. */
|
|
104
|
+
tint?: string;
|
|
105
|
+
/** Announced by screen readers, e.g. "Uploading photo". */
|
|
106
|
+
accessibilityLabel?: string;
|
|
107
|
+
style?: StyleProp<ViewStyle>;
|
|
108
|
+
isDark?: boolean;
|
|
109
|
+
testID?: string;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Progress, linear or circular.
|
|
113
|
+
*
|
|
114
|
+
* The track is a glass surface, so it refracts what it sits on exactly like the
|
|
115
|
+
* rest of the library; the fill is the theme accent. Both forms report
|
|
116
|
+
* `progressbar` with a value, which is the contract NativeTask relies on
|
|
117
|
+
* internally — this component generalises it.
|
|
118
|
+
*/
|
|
119
|
+
export declare const Progress: import("react").ForwardRefExoticComponent<ProgressProps & import("react").RefAttributes<any>>;
|
|
120
|
+
export interface RatingProps {
|
|
121
|
+
/** How many stars are filled. Fractions render a partially filled star. */
|
|
122
|
+
value: number;
|
|
123
|
+
/** The number of stars. Defaults to five. */
|
|
124
|
+
max?: number;
|
|
125
|
+
size?: "sm" | "md" | "lg";
|
|
126
|
+
/** Makes the stars tappable. Omit for a read-only rating. */
|
|
127
|
+
onChange?: (value: number) => void;
|
|
128
|
+
disabled?: boolean;
|
|
129
|
+
/** The accessible name, e.g. "Rating". */
|
|
130
|
+
accessibilityLabel?: string;
|
|
131
|
+
style?: StyleProp<ViewStyle>;
|
|
132
|
+
isDark?: boolean;
|
|
133
|
+
testID?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A star rating.
|
|
137
|
+
*
|
|
138
|
+
* The stars are drawn as SVG paths from the resolver, so nothing is a
|
|
139
|
+
* platform control. A fractional value fills part of a star: 3.5 draws three
|
|
140
|
+
* full stars and one half, the half produced by clipping the filled star at the
|
|
141
|
+
* fraction's width rather than by rounding — a 4.5-star average must look like
|
|
142
|
+
* a 4.5-star average.
|
|
143
|
+
*
|
|
144
|
+
* Read-only unless `onChange` is given. With it, each star is tappable, the
|
|
145
|
+
* value is exposed as an adjustable control (increment/decrement through
|
|
146
|
+
* accessibility actions), and each star has its own label so a screen reader
|
|
147
|
+
* can name the exact rating it sets.
|
|
148
|
+
*/
|
|
149
|
+
export declare const Rating: import("react").ForwardRefExoticComponent<RatingProps & import("react").RefAttributes<any>>;
|
|
150
|
+
export interface NativeImageProps {
|
|
151
|
+
/** The image to show. */
|
|
152
|
+
source: {
|
|
153
|
+
uri: string;
|
|
154
|
+
} | number;
|
|
155
|
+
/** A description for screen readers. Required: an image with no name is a hole. */
|
|
156
|
+
accessibilityLabel: string;
|
|
157
|
+
/** Shown behind the image while it loads; a Skeleton when omitted. */
|
|
158
|
+
placeholder?: ReactNode;
|
|
159
|
+
/** Shown when the image fails to load. */
|
|
160
|
+
fallback?: ReactNode;
|
|
161
|
+
/** Fades the image in when it loads. Honours Reduce Motion. */
|
|
162
|
+
fadeIn?: boolean;
|
|
163
|
+
style?: StyleProp<ViewStyle>;
|
|
164
|
+
isDark?: boolean;
|
|
165
|
+
testID?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* A plain image, with the loading and error states every app ends up writing.
|
|
169
|
+
*
|
|
170
|
+
* Three states, because an image on a phone is three states: loading (a
|
|
171
|
+
* Skeleton behind it), loaded (a fade in), and failed (the caller's fallback).
|
|
172
|
+
* Aspect ratio comes from `style`, so a caller sets `aspectRatio` and the height
|
|
173
|
+
* follows.
|
|
174
|
+
*
|
|
175
|
+
* This is the plain one; `NativeImageGeneration` is the AI-specific cousin and
|
|
176
|
+
* keeps its own state machine.
|
|
177
|
+
*/
|
|
178
|
+
export declare const NativeImage: import("react").ForwardRefExoticComponent<NativeImageProps & import("react").RefAttributes<any>>;
|