glacia-native 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +29 -4
- package/README.md +27 -0
- package/lib/module/Bars.js +103 -9
- package/lib/module/Button.js +11 -8
- package/lib/module/Card.js +2 -2
- package/lib/module/Dialog.js +16 -17
- package/lib/module/Display.js +86 -8
- package/lib/module/Feedback.js +244 -21
- package/lib/module/Form.js +29 -33
- package/lib/module/Forms2.js +257 -13
- package/lib/module/Glass.js +2 -2
- package/lib/module/Input.js +12 -10
- package/lib/module/Message.js +84 -0
- package/lib/module/Overlays.js +195 -17
- package/lib/module/Pickers.js +16 -16
- package/lib/module/SegmentedControl.js +24 -11
- package/lib/module/Slider.js +24 -10
- package/lib/module/Switch.js +25 -10
- package/lib/module/TabBar.js +23 -13
- package/lib/module/Table.js +4 -3
- package/lib/module/Tabs.js +3 -2
- package/lib/module/ai.js +26 -18
- package/lib/module/charts/BarChart.js +11 -3
- package/lib/module/index.js +23 -2
- package/lib/module/internal/GlassContainer.js +54 -0
- package/lib/module/internal/GlassView.js +10 -2
- package/lib/module/internal/a11y.js +94 -0
- package/lib/module/internal/blur.js +78 -0
- package/lib/module/internal/fallback.js +120 -19
- package/lib/module/internal/glass-routing.js +7 -0
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/haptics.js +54 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/motion.js +10 -1
- package/lib/module/internal/primitives.js +70 -4
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +80 -2
- package/lib/typescript/Bars.d.ts +67 -0
- package/lib/typescript/Display.d.ts +59 -0
- package/lib/typescript/Feedback.d.ts +58 -0
- package/lib/typescript/Forms2.d.ts +81 -0
- package/lib/typescript/Message.d.ts +67 -0
- package/lib/typescript/Overlays.d.ts +41 -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/index.d.ts +9 -6
- package/lib/typescript/internal/GlassContainer.d.ts +37 -0
- package/lib/typescript/internal/GlassView.d.ts +21 -0
- package/lib/typescript/internal/a11y.d.ts +19 -0
- package/lib/typescript/internal/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +32 -2
- package/lib/typescript/internal/glass-routing.d.ts +10 -0
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/haptics.d.ts +7 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/motion.d.ts +4 -0
- package/lib/typescript/internal/primitives.d.ts +23 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +89 -0
- package/package.json +12 -3
- package/src/Bars.tsx +239 -2
- package/src/Button.tsx +16 -9
- package/src/Card.tsx +2 -2
- package/src/Dialog.tsx +37 -26
- package/src/Display.tsx +237 -6
- package/src/Feedback.tsx +448 -35
- package/src/Form.tsx +60 -40
- package/src/Forms2.tsx +455 -8
- package/src/Glass.tsx +4 -0
- package/src/Input.tsx +15 -11
- package/src/Message.tsx +218 -0
- package/src/Overlays.tsx +269 -39
- package/src/Pickers.tsx +11 -6
- package/src/SegmentedControl.tsx +39 -9
- package/src/Slider.tsx +26 -10
- package/src/Switch.tsx +29 -10
- package/src/TabBar.tsx +39 -12
- package/src/Table.tsx +4 -3
- package/src/Tabs.tsx +5 -0
- package/src/ai.tsx +37 -23
- package/src/charts/BarChart.tsx +41 -3
- package/src/index.ts +43 -1
- package/src/internal/GlassContainer.tsx +82 -0
- package/src/internal/GlassView.tsx +25 -0
- package/src/internal/a11y.ts +105 -0
- package/src/internal/blur.ts +90 -0
- package/src/internal/fallback.tsx +170 -15
- package/src/internal/glass-routing.ts +17 -0
- package/src/internal/glow.tsx +62 -0
- package/src/internal/haptics.ts +59 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/motion.ts +10 -1
- package/src/internal/primitives.ts +83 -4
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +82 -1
package/lib/module/TabBar.js
CHANGED
|
@@ -7,7 +7,11 @@ 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
|
|
10
|
+
const haptics_1 = require("./internal/haptics");
|
|
11
|
+
const lens_1 = require("./internal/lens");
|
|
12
|
+
// The web bar: a 40pt rail (32pt tabs in a 4pt inset) with a 20pt radius, a
|
|
13
|
+
// glass lens filling the active slot, and 13pt labels at 500/400 weight.
|
|
14
|
+
const BAR_HEIGHT = 40;
|
|
11
15
|
/**
|
|
12
16
|
* The bottom bar of an app: a row of tabs on one glass surface.
|
|
13
17
|
*
|
|
@@ -17,16 +21,20 @@ const BAR_HEIGHT = 52;
|
|
|
17
21
|
* Glacia's bar. The items are always our Pressables and Texts — no native tab
|
|
18
22
|
* bar is used on any platform.
|
|
19
23
|
*/
|
|
20
|
-
exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: activeProp, defaultActiveId, onTabChange, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
24
|
+
exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: activeProp, defaultActiveId, onTabChange, haptics = true, style, isDark: isDarkProp, testID, ...props }, ref) {
|
|
21
25
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
22
26
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
23
27
|
const { View, Text, Pressable, Animated } = (0, primitives_1.primitives)();
|
|
24
28
|
const [internalId, setInternalId] = (0, react_1.useState)(defaultActiveId || items[0]?.id || "");
|
|
29
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
25
30
|
const activeId = activeProp !== undefined ? activeProp : internalId;
|
|
26
31
|
const activeIndex = Math.max(0, items.findIndex((item) => item.id === activeId));
|
|
27
32
|
// The active wash slides between equally wide items on the springs token.
|
|
28
33
|
const { value: slide, animated } = (0, motion_1.useSpring)(activeIndex, "snappy");
|
|
29
34
|
const handleSelect = (id) => {
|
|
35
|
+
// Selecting the tab already active is not a change, so it does not tick.
|
|
36
|
+
if (haptics && id !== activeId)
|
|
37
|
+
(0, haptics_1.hapticSelection)();
|
|
30
38
|
if (activeProp === undefined)
|
|
31
39
|
setInternalId(id);
|
|
32
40
|
onTabChange?.(id);
|
|
@@ -36,23 +44,25 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
|
|
|
36
44
|
alignItems: "center",
|
|
37
45
|
justifyContent: "space-around",
|
|
38
46
|
height: BAR_HEIGHT,
|
|
39
|
-
paddingHorizontal:
|
|
40
|
-
borderRadius: tokens_1.radii.
|
|
47
|
+
paddingHorizontal: 4,
|
|
48
|
+
borderRadius: tokens_1.radii.lg,
|
|
41
49
|
...style,
|
|
42
50
|
};
|
|
43
51
|
const count = Math.max(items.length, 1);
|
|
44
52
|
const itemWidth = `${100 / count}%`;
|
|
45
53
|
const indicatorStyle = {
|
|
46
54
|
position: "absolute",
|
|
47
|
-
top:
|
|
48
|
-
bottom:
|
|
49
|
-
left:
|
|
55
|
+
top: 4,
|
|
56
|
+
bottom: 4,
|
|
57
|
+
left: 4,
|
|
50
58
|
width: itemWidth,
|
|
51
|
-
borderRadius: tokens_1.radii.
|
|
59
|
+
borderRadius: tokens_1.radii.pill,
|
|
52
60
|
backgroundColor: themeColors.glassActive,
|
|
53
61
|
opacity: 0.75,
|
|
62
|
+
// A lens, not a wash: it lifts off the rail and carries the rim.
|
|
63
|
+
...(0, lens_1.lensShadow)(isDark),
|
|
54
64
|
};
|
|
55
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, style: barStyle, testID: testID, ...props, children: [animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { pointerEvents: "none", style: {
|
|
65
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", pressed: held, isDark: isDark, style: barStyle, testID: testID, ...props, children: [animated ? ((0, jsx_runtime_1.jsx)(Animated.View, { pointerEvents: "none", style: {
|
|
56
66
|
...indicatorStyle,
|
|
57
67
|
transform: [
|
|
58
68
|
{
|
|
@@ -65,9 +75,9 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
|
|
|
65
75
|
}),
|
|
66
76
|
},
|
|
67
77
|
],
|
|
68
|
-
} })) : ((0, jsx_runtime_1.jsx)(View, { pointerEvents: "none", style: { ...indicatorStyle, left: `${(activeIndex * 100) / count}%` } })), items.map((tab) => {
|
|
78
|
+
}, children: (0, jsx_runtime_1.jsx)(lens_1.LensRim, { radius: tokens_1.radii.pill, isDark: isDark }) })) : ((0, jsx_runtime_1.jsx)(View, { pointerEvents: "none", style: { ...indicatorStyle, left: `${(activeIndex * 100) / count}%` }, children: (0, jsx_runtime_1.jsx)(lens_1.LensRim, { radius: tokens_1.radii.pill, isDark: isDark }) })), items.map((tab) => {
|
|
69
79
|
const isActive = tab.id === activeId;
|
|
70
|
-
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), style: {
|
|
80
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: {
|
|
71
81
|
flex: 1,
|
|
72
82
|
height: "100%",
|
|
73
83
|
flexDirection: "column",
|
|
@@ -77,8 +87,8 @@ exports.TabBar = (0, react_1.forwardRef)(function TabBar({ items, activeId: acti
|
|
|
77
87
|
paddingHorizontal: 8,
|
|
78
88
|
paddingVertical: 4,
|
|
79
89
|
}, children: [tab.icon ?? null, (0, jsx_runtime_1.jsx)(Text, { numberOfLines: 1, style: {
|
|
80
|
-
fontSize:
|
|
81
|
-
fontWeight: isActive ? "
|
|
90
|
+
fontSize: 13,
|
|
91
|
+
fontWeight: isActive ? "500" : "400",
|
|
82
92
|
color: isActive ? themeColors.fill : themeColors.muted,
|
|
83
93
|
}, children: tab.label })] }, tab.id));
|
|
84
94
|
})] }));
|
package/lib/module/Table.js
CHANGED
|
@@ -25,7 +25,7 @@ function NativeTable({ columns, rows, onRowPress, caption, isDark: isDarkProp, s
|
|
|
25
25
|
const primaryKey = columns.find((column) => column.primary)?.key ?? columns[0]?.key;
|
|
26
26
|
const primaryColumn = columns.find((column) => column.key === primaryKey);
|
|
27
27
|
const detailColumns = columns.filter((column) => column.key !== primaryKey);
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, testID: testID, children: [caption && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize:
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)(View, { style: style, testID: testID, children: [caption && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, color: theme.muted, marginBottom: 8 }, children: caption })), rows.map((row) => {
|
|
29
29
|
const RowWrapper = onRowPress ? Pressable : View;
|
|
30
30
|
const wrapperProps = onRowPress
|
|
31
31
|
? {
|
|
@@ -35,7 +35,8 @@ function NativeTable({ columns, rows, onRowPress, caption, isDark: isDarkProp, s
|
|
|
35
35
|
}
|
|
36
36
|
: { accessibilityRole: "text" };
|
|
37
37
|
return ((0, jsx_runtime_1.jsxs)(RowWrapper, { ...wrapperProps, style: {
|
|
38
|
-
paddingVertical:
|
|
38
|
+
paddingVertical: 12,
|
|
39
|
+
paddingHorizontal: 16,
|
|
39
40
|
borderBottomWidth: 1,
|
|
40
41
|
borderBottomColor: theme.edge,
|
|
41
42
|
}, children: [primaryColumn && ((0, jsx_runtime_1.jsx)(Text, { style: {
|
|
@@ -48,7 +49,7 @@ function NativeTable({ columns, rows, onRowPress, caption, isDark: isDarkProp, s
|
|
|
48
49
|
justifyContent: "space-between",
|
|
49
50
|
alignItems: "baseline",
|
|
50
51
|
gap: 12,
|
|
51
|
-
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize:
|
|
52
|
+
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "600", color: theme.muted }, children: column.header }), (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
52
53
|
fontSize: 12,
|
|
53
54
|
color: theme.foreground,
|
|
54
55
|
textAlign: column.align ?? "left",
|
package/lib/module/Tabs.js
CHANGED
|
@@ -21,6 +21,7 @@ exports.Tabs = (0, react_1.forwardRef)(function Tabs({ items, activeId: activePr
|
|
|
21
21
|
const themeColors = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
22
22
|
const { View, Text, Pressable, Animated } = (0, primitives_1.primitives)();
|
|
23
23
|
const [internalId, setInternalId] = (0, react_1.useState)(defaultActiveId || items[0]?.id || "");
|
|
24
|
+
const [held, setHeld] = (0, react_1.useState)(false);
|
|
24
25
|
const activeId = activeProp !== undefined ? activeProp : internalId;
|
|
25
26
|
const activeIndex = Math.max(0, items.findIndex((tab) => tab.id === activeId));
|
|
26
27
|
const { value: slide, animated } = (0, motion_1.useSpring)(activeIndex, "snappy");
|
|
@@ -43,7 +44,7 @@ exports.Tabs = (0, react_1.forwardRef)(function Tabs({ items, activeId: activePr
|
|
|
43
44
|
borderWidth: 0.5,
|
|
44
45
|
borderColor: themeColors.edge,
|
|
45
46
|
};
|
|
46
|
-
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", isDark: isDark, style: {
|
|
47
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { ref: ref, effect: "regular", surface: "rail", pressed: held, isDark: isDark, style: {
|
|
47
48
|
flexDirection: "row",
|
|
48
49
|
alignItems: "center",
|
|
49
50
|
alignSelf: "flex-start",
|
|
@@ -63,7 +64,7 @@ exports.Tabs = (0, react_1.forwardRef)(function Tabs({ items, activeId: activePr
|
|
|
63
64
|
],
|
|
64
65
|
} })) : ((0, jsx_runtime_1.jsx)(View, { pointerEvents: "none", style: { ...paneStyle, left: `${(activeIndex * 100) / count}%` } })), items.map((tab) => {
|
|
65
66
|
const isActive = tab.id === activeId;
|
|
66
|
-
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), style: {
|
|
67
|
+
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "tab", accessibilityLabel: tab.label, accessibilityState: { selected: isActive }, onPress: () => handleSelect(tab.id), onPressIn: () => setHeld(true), onPressOut: () => setHeld(false), style: {
|
|
67
68
|
flex: 1,
|
|
68
69
|
height: 36,
|
|
69
70
|
flexDirection: "row",
|
package/lib/module/ai.js
CHANGED
|
@@ -11,9 +11,12 @@ exports.NativeAIInput = NativeAIInput;
|
|
|
11
11
|
exports.NativeImageGeneration = NativeImageGeneration;
|
|
12
12
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
13
13
|
const react_1 = require("react");
|
|
14
|
+
const Glass_1 = require("./Glass");
|
|
14
15
|
const tokens_1 = require("./internal/tokens");
|
|
15
16
|
const primitives_1 = require("./internal/primitives");
|
|
16
17
|
const motion_1 = require("./internal/motion");
|
|
18
|
+
const lens_1 = require("./internal/lens");
|
|
19
|
+
const a11y_1 = require("./internal/a11y");
|
|
17
20
|
/**
|
|
18
21
|
* The ordered steps a model intends to take.
|
|
19
22
|
*
|
|
@@ -32,7 +35,7 @@ function NativePlan({ title = "Plan", steps, isDark: isDarkProp, style }) {
|
|
|
32
35
|
: status === "running"
|
|
33
36
|
? theme.fill
|
|
34
37
|
: theme.muted;
|
|
35
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsxs)(View, { style: {
|
|
36
39
|
flexDirection: "row",
|
|
37
40
|
justifyContent: "space-between",
|
|
38
41
|
alignItems: "center",
|
|
@@ -64,7 +67,7 @@ function NativeSources({ sources, title = "Sources", isDark: isDarkProp, style,
|
|
|
64
67
|
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
65
68
|
if (sources.length === 0)
|
|
66
69
|
return null;
|
|
67
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title }), sources.map((source, index) => ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "link", accessibilityLabel: source.title, onPress: () => onSourcePress?.(source), style: {
|
|
68
71
|
flexDirection: "row",
|
|
69
72
|
gap: 9,
|
|
70
73
|
paddingVertical: 7,
|
|
@@ -87,7 +90,7 @@ function NativeResponse({ text, revealed, streaming, isDark: isDarkProp, style,
|
|
|
87
90
|
const { View, Text } = (0, primitives_1.primitives)();
|
|
88
91
|
const shown = revealed == null ? text : text.slice(0, Math.max(0, revealed));
|
|
89
92
|
const isStreaming = streaming ?? (revealed != null && revealed < text.length);
|
|
90
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
93
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsxs)(Text, { accessibilityRole: "text", accessibilityLabel: shown, style: { fontSize: 14, lineHeight: 21, color: theme.foreground }, children: [shown, isStreaming ? "▍" : ""] }), (0, jsx_runtime_1.jsx)(Text, { accessibilityRole: "alert", style: { height: 0, opacity: 0, fontSize: 0 }, children: isStreaming ? "Response streaming" : "Response complete" })] }));
|
|
91
94
|
}
|
|
92
95
|
/** Progress of a long-running background task. */
|
|
93
96
|
function NativeTask({ task, isDark: isDarkProp, style }) {
|
|
@@ -97,12 +100,12 @@ function NativeTask({ task, isDark: isDarkProp, style }) {
|
|
|
97
100
|
const percent = task.progress == null ? null : Math.round(Math.min(1, Math.max(0, task.progress)) * 100);
|
|
98
101
|
const status = task.status ?? "running";
|
|
99
102
|
const fillColor = status === "failed" ? theme.destructive : status === "done" ? "#34c759" : theme.fill;
|
|
100
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
103
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, accessibilityRole: "progressbar", accessibilityLabel: task.label ?? "Task progress",
|
|
101
104
|
// Without the value, a screen reader only reads the label and never says
|
|
102
105
|
// how far along the task is.
|
|
103
106
|
accessibilityValue: percent == null ? undefined : { min: 0, max: 100, now: percent }, accessibilityState: {
|
|
104
107
|
disabled: false,
|
|
105
|
-
}, style: style, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", justifyContent: "space-between", marginBottom: 6 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "500", color: theme.foreground }, children: task.label ?? "Task" }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: percent == null ? "…" : `${percent}%` })] }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
108
|
+
}, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [(0, jsx_runtime_1.jsxs)(View, { style: { flexDirection: "row", justifyContent: "space-between", marginBottom: 6 }, children: [(0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 12, fontWeight: "500", color: theme.foreground }, children: task.label ?? "Task" }), (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, color: theme.muted }, children: percent == null ? "…" : `${percent}%` })] }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
106
109
|
height: 6,
|
|
107
110
|
borderRadius: 3,
|
|
108
111
|
backgroundColor: isDark ? "rgba(235,235,245,0.15)" : "rgba(0,0,0,0.08)",
|
|
@@ -153,14 +156,18 @@ function NativeThinkingOrb({ label = "Thinking", size = 22, paused = false, isDa
|
|
|
153
156
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
154
157
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
155
158
|
const { View, Text } = (0, primitives_1.primitives)();
|
|
159
|
+
const reducedMotion = (0, a11y_1.useReducedMotion)();
|
|
156
160
|
const [tick, setTick] = (0, react_1.useState)(0);
|
|
161
|
+
// Reduce Motion: the orb stops pulsing and holds a steady size. The label is
|
|
162
|
+
// what carries the meaning, so nothing is lost by not moving.
|
|
163
|
+
const still = paused || reducedMotion;
|
|
157
164
|
(0, react_1.useEffect)(() => {
|
|
158
|
-
if (
|
|
165
|
+
if (still)
|
|
159
166
|
return;
|
|
160
167
|
const timer = setInterval(() => setTick((value) => value + 1), 700);
|
|
161
168
|
return () => clearInterval(timer);
|
|
162
|
-
}, [
|
|
163
|
-
const scale =
|
|
169
|
+
}, [still]);
|
|
170
|
+
const scale = still ? 1 : [1, 1.12, 1][tick % 3];
|
|
164
171
|
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
172
|
width: size,
|
|
166
173
|
height: size,
|
|
@@ -180,7 +187,7 @@ function NativePanelside({ items, value, onValueChange, isDark: isDarkProp, styl
|
|
|
180
187
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
181
188
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
182
189
|
const { View, Text, Pressable } = (0, primitives_1.primitives)();
|
|
183
|
-
return ((0, jsx_runtime_1.jsxs)(
|
|
190
|
+
return ((0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "panel", isDark: isDark, style: [{ paddingHorizontal: 14, paddingVertical: 12, borderRadius: tokens_1.radii.lg }, style], children: [title && ((0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 11, fontWeight: "600", color: theme.muted, marginBottom: 6 }, children: title })), items.map((item) => {
|
|
184
191
|
const isActive = item.id === value;
|
|
185
192
|
return ((0, jsx_runtime_1.jsxs)(Pressable, { accessibilityRole: "button", accessibilityState: { selected: isActive }, accessibilityLabel: item.label, onPress: () => onValueChange?.(item.id), style: {
|
|
186
193
|
flexDirection: "row",
|
|
@@ -189,9 +196,9 @@ function NativePanelside({ items, value, onValueChange, isDark: isDarkProp, styl
|
|
|
189
196
|
paddingVertical: 9,
|
|
190
197
|
paddingHorizontal: 11,
|
|
191
198
|
borderRadius: tokens_1.radii.md,
|
|
192
|
-
backgroundColor:
|
|
199
|
+
backgroundColor: "transparent",
|
|
193
200
|
marginBottom: 2,
|
|
194
|
-
}, children: [(0, jsx_runtime_1.jsx)(Text, { style: {
|
|
201
|
+
}, children: [isActive ? (0, jsx_runtime_1.jsx)(lens_1.SelectedLens, { radius: tokens_1.radii.md, isDark: isDark, style: lens_1.lensFill }) : null, (0, jsx_runtime_1.jsx)(Text, { style: {
|
|
195
202
|
fontSize: 13,
|
|
196
203
|
color: isActive ? theme.foreground : theme.muted,
|
|
197
204
|
fontWeight: isActive ? "600" : "400",
|
|
@@ -221,15 +228,14 @@ function NativeAIInput({ value: valueProp, defaultValue, onChangeText, onSubmit,
|
|
|
221
228
|
// The themed placeholder is drawn as a Text, matching Input: the OS default
|
|
222
229
|
// placeholder colour ignores the theme.
|
|
223
230
|
const showPlaceholder = !value && Boolean(placeholder);
|
|
224
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(
|
|
231
|
+
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Glass_1.Glass, { surface: "field", isDark: isDark, style: {
|
|
225
232
|
flexDirection: "row",
|
|
226
233
|
alignItems: "flex-end",
|
|
227
234
|
gap: 8,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
backgroundColor: theme.glass,
|
|
235
|
+
paddingVertical: 6,
|
|
236
|
+
paddingRight: 6,
|
|
237
|
+
paddingLeft: 16,
|
|
238
|
+
borderRadius: tokens_1.radii.pill,
|
|
233
239
|
opacity: disabled ? 0.5 : 1,
|
|
234
240
|
}, children: [(0, jsx_runtime_1.jsxs)(View, { style: { flex: 1, justifyContent: "center" }, children: [showPlaceholder && ((0, jsx_runtime_1.jsx)(Text, { pointerEvents: "none", numberOfLines: 1, style: {
|
|
235
241
|
position: "absolute",
|
|
@@ -244,8 +250,10 @@ function NativeAIInput({ value: valueProp, defaultValue, onChangeText, onSubmit,
|
|
|
244
250
|
fontSize: 14,
|
|
245
251
|
color: theme.foreground,
|
|
246
252
|
} })] }), (0, jsx_runtime_1.jsx)(Pressable, { accessibilityRole: "button", accessibilityLabel: sendLabel, accessibilityState: { disabled: !canSend }, disabled: !canSend, onPress: () => canSend && onSubmit?.(), style: {
|
|
247
|
-
|
|
253
|
+
height: 34,
|
|
248
254
|
paddingHorizontal: 14,
|
|
255
|
+
alignItems: "center",
|
|
256
|
+
justifyContent: "center",
|
|
249
257
|
borderRadius: tokens_1.radii.pill,
|
|
250
258
|
backgroundColor: canSend ? theme.fill : theme.edge,
|
|
251
259
|
}, children: (0, jsx_runtime_1.jsx)(Text, { style: { fontSize: 13, fontWeight: "600", color: canSend ? "#fff" : theme.muted }, children: busy ? "…" : sendLabel }) })] }), footer] }));
|
|
@@ -13,7 +13,7 @@ function NativeBarChart({ labels, series, width = 320, height = 200, stacked = f
|
|
|
13
13
|
const [active, setActive] = (0, react_1.useState)(null);
|
|
14
14
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
15
15
|
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
16
|
-
const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = (0, primitives_1.primitives)();
|
|
16
|
+
const { View, Text, Pressable, Svg, G, Line, Rect, SvgText, Defs, LinearGradient, Stop, } = (0, primitives_1.primitives)();
|
|
17
17
|
const plot = {
|
|
18
18
|
x: PADDING.left,
|
|
19
19
|
y: PADDING.top,
|
|
@@ -31,12 +31,18 @@ function NativeBarChart({ labels, series, width = 320, height = 200, stacked = f
|
|
|
31
31
|
}, [totals.join(",")]);
|
|
32
32
|
const y = (0, scales_1.linearScale)(domain, [bottom, plot.y], { nice: false });
|
|
33
33
|
const bands = (0, scales_1.bandScale)(labels.length, [plot.x, right], 0.32);
|
|
34
|
+
const seriesColors = series.map((s, si) => s.color ?? (0, scales_1.seriesColor)(si, palette));
|
|
35
|
+
// One gradient per series, so the SVG can reference them by id.
|
|
36
|
+
const gradientKey = (0, react_1.useId)().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
34
37
|
const barWidth = stacked ? bands.width : bands.width / Math.max(1, series.length);
|
|
35
38
|
const yTicks = (0, scales_1.ticks)(domain, 4);
|
|
36
39
|
if (labels.length === 0 || series.length === 0) {
|
|
37
40
|
return ((0, jsx_runtime_1.jsx)(View, { style: [{ width, height, alignItems: "center", justifyContent: "center" }, style], children: (0, jsx_runtime_1.jsx)(Text, { style: { color: theme.muted, fontSize: 12 }, children: "No bars to display" }) }));
|
|
38
41
|
}
|
|
39
|
-
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)(View, { style: style, children: [(0, jsx_runtime_1.jsxs)(Svg, { width: width, height: height, children: [(0, jsx_runtime_1.jsx)(Defs, { children: seriesColors.map((color, si) => (
|
|
43
|
+
// The web's bar fill runs from the series colour at the top to
|
|
44
|
+
// transparent at the base, so a bar reads as lit from above.
|
|
45
|
+
(0, jsx_runtime_1.jsxs)(LinearGradient, { id: `bar-${gradientKey}-${si}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)(Stop, { offset: "0", stopColor: color, stopOpacity: 1 }), (0, jsx_runtime_1.jsx)(Stop, { offset: "0.55", stopColor: color, stopOpacity: 0.62 }), (0, jsx_runtime_1.jsx)(Stop, { offset: "1", stopColor: color, stopOpacity: 0.04 })] }, `grad-${si}`))) }), yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(Line, { x1: plot.x, x2: right, y1: y(tick), y2: y(tick), stroke: theme.axis, strokeOpacity: 0.24, strokeWidth: 1 }, `grid-${i}`))), labels.map((label, i) => {
|
|
40
46
|
let stackTop = bottom;
|
|
41
47
|
return ((0, jsx_runtime_1.jsx)(G, { children: series.map((s, si) => {
|
|
42
48
|
const value = s.values[i] ?? 0;
|
|
@@ -49,7 +55,9 @@ function NativeBarChart({ labels, series, width = 320, height = 200, stacked = f
|
|
|
49
55
|
const w = stacked ? bands.width : Math.max(1, barWidth - (si > 0 ? 1 : 0));
|
|
50
56
|
if (stacked)
|
|
51
57
|
stackTop -= barHeight;
|
|
52
|
-
return ((0, jsx_runtime_1.jsx)(Rect, { x: barX, y: barY, width: w, height: barHeight, rx: Math.min(radius, w / 2), fill:
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)(Rect, { x: barX, y: barY, width: w, height: barHeight, rx: Math.min(radius, w / 2), fill: `url(#bar-${gradientKey}-${si})`,
|
|
59
|
+
// The inset edge the web draws inside every bar.
|
|
60
|
+
stroke: color, strokeOpacity: 0.35, strokeWidth: 0.5, opacity: active === null || active === i ? 1 : 0.45 }, s.name));
|
|
53
61
|
}) }, label + i));
|
|
54
62
|
}), yTicks.map((tick, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: plot.x - 6, y: y(tick) + 3, fill: theme.muted, fontSize: 9, textAnchor: "end", children: (0, scales_1.formatValue)(tick, { compact: true }) }, `y-${i}`))), labels.map((label, i) => ((0, jsx_runtime_1.jsx)(SvgText, { x: bands.center(i), y: height - 8, fill: theme.muted, fontSize: 9, textAnchor: "middle", children: label }, `x-${i}`)))] }), (0, jsx_runtime_1.jsx)(View, { style: {
|
|
55
63
|
position: "absolute",
|
package/lib/module/index.js
CHANGED
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
exports.toneColor = exports.typeScale = exports.springs = exports.radii = exports.colors = exports.isGlassSupported = exports.MONTHS = exports.WEEKDAYS = exports.formatTime = exports.parseTime = exports.sameDay = exports.startOfDay = exports.monthGrid = exports.TimePicker = exports.DatePicker = exports.Calendar = exports.ButtonGroup = exports.InputOTP = exports.ToggleGroup = exports.Toggle = exports.Stepper = exports.PageControl = exports.Carousel = exports.anchorPopover = exports.Drawer = exports.Sheet = exports.Menu = exports.AppBar = exports.IconButton = exports.FAB = exports.Chip = exports.SearchBar = void 0;
|
|
17
|
+
exports.ListItem = exports.List = exports.Banner = exports.Toast = exports.NativeImage = exports.Rating = exports.initialsOf = exports.Progress = exports.Spinner = exports.Skeleton = exports.Separator = exports.Badge = exports.Avatar = exports.Text = exports.NativeScrollArea = exports.NativeTable = exports.NativeImageGeneration = exports.NativeAIInput = exports.NativePanelside = exports.NativeThinkingOrb = exports.NativeSoundwave = exports.NativeTask = exports.NativeResponse = exports.NativeSources = exports.NativePlan = exports.ActionSheet = exports.AlertDialog = exports.DialogTrigger = exports.Dialog = exports.Select = exports.RadioGroup = exports.Checkbox = exports.Field = exports.Label = exports.Textarea = exports.Input = exports.CardFooter = exports.CardBody = exports.CardContent = exports.CardDescription = exports.CardTitle = exports.CardHeader = exports.Card = exports.Tabs = exports.TabBar = exports.SegmentedControl = exports.Slider = exports.Switch = exports.Button = exports.Glass = void 0;
|
|
18
|
+
exports.toneColor = exports.typeScale = exports.springs = exports.radii = exports.palette = exports.controlSizes = exports.colors = exports.GlassContainer = exports.isGlassSupported = exports.MessageAttachment = exports.MessageBubble = exports.Message = exports.MONTHS = exports.WEEKDAYS = exports.formatTime = exports.parseTime = exports.sameDay = exports.startOfDay = exports.monthGrid = exports.TimePicker = exports.DatePicker = exports.Calendar = exports.Combobox = exports.hueGradientColors = exports.rgbToHex = exports.hexToRgb = exports.DEFAULT_PALETTE = exports.ColorPicker = exports.ButtonGroup = exports.InputOTP = exports.ToggleGroup = exports.Toggle = exports.Stepper = exports.PageControl = exports.Carousel = exports.nearestSnapPoint = exports.resolveSnapPoint = exports.anchorPopover = exports.Drawer = exports.Sheet = exports.Menu = exports.FABGroup = exports.AppBar = exports.IconButton = exports.FAB = exports.Chip = exports.SearchBar = exports.ToastViewport = exports.Accordion = exports.ListSection = void 0;
|
|
19
19
|
var Glass_1 = require("./Glass");
|
|
20
20
|
Object.defineProperty(exports, "Glass", { enumerable: true, get: function () { return Glass_1.Glass; } });
|
|
21
21
|
var Button_1 = require("./Button");
|
|
@@ -82,6 +82,8 @@ Object.defineProperty(exports, "Skeleton", { enumerable: true, get: function ()
|
|
|
82
82
|
Object.defineProperty(exports, "Spinner", { enumerable: true, get: function () { return Display_1.Spinner; } });
|
|
83
83
|
Object.defineProperty(exports, "Progress", { enumerable: true, get: function () { return Display_1.Progress; } });
|
|
84
84
|
Object.defineProperty(exports, "initialsOf", { enumerable: true, get: function () { return Display_1.initialsOf; } });
|
|
85
|
+
Object.defineProperty(exports, "Rating", { enumerable: true, get: function () { return Display_1.Rating; } });
|
|
86
|
+
Object.defineProperty(exports, "NativeImage", { enumerable: true, get: function () { return Display_1.NativeImage; } });
|
|
85
87
|
// Feedback and display.
|
|
86
88
|
var Feedback_1 = require("./Feedback");
|
|
87
89
|
Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Feedback_1.Toast; } });
|
|
@@ -90,6 +92,7 @@ Object.defineProperty(exports, "List", { enumerable: true, get: function () { re
|
|
|
90
92
|
Object.defineProperty(exports, "ListItem", { enumerable: true, get: function () { return Feedback_1.ListItem; } });
|
|
91
93
|
Object.defineProperty(exports, "ListSection", { enumerable: true, get: function () { return Feedback_1.ListSection; } });
|
|
92
94
|
Object.defineProperty(exports, "Accordion", { enumerable: true, get: function () { return Feedback_1.Accordion; } });
|
|
95
|
+
Object.defineProperty(exports, "ToastViewport", { enumerable: true, get: function () { return Feedback_1.ToastViewport; } });
|
|
93
96
|
// Bars, buttons and navigation.
|
|
94
97
|
var Bars_1 = require("./Bars");
|
|
95
98
|
Object.defineProperty(exports, "SearchBar", { enumerable: true, get: function () { return Bars_1.SearchBar; } });
|
|
@@ -97,12 +100,15 @@ Object.defineProperty(exports, "Chip", { enumerable: true, get: function () { re
|
|
|
97
100
|
Object.defineProperty(exports, "FAB", { enumerable: true, get: function () { return Bars_1.FAB; } });
|
|
98
101
|
Object.defineProperty(exports, "IconButton", { enumerable: true, get: function () { return Bars_1.IconButton; } });
|
|
99
102
|
Object.defineProperty(exports, "AppBar", { enumerable: true, get: function () { return Bars_1.AppBar; } });
|
|
103
|
+
Object.defineProperty(exports, "FABGroup", { enumerable: true, get: function () { return Bars_1.FABGroup; } });
|
|
100
104
|
// Overlays.
|
|
101
105
|
var Overlays_1 = require("./Overlays");
|
|
102
106
|
Object.defineProperty(exports, "Menu", { enumerable: true, get: function () { return Overlays_1.Menu; } });
|
|
103
107
|
Object.defineProperty(exports, "Sheet", { enumerable: true, get: function () { return Overlays_1.Sheet; } });
|
|
104
108
|
Object.defineProperty(exports, "Drawer", { enumerable: true, get: function () { return Overlays_1.Drawer; } });
|
|
105
109
|
Object.defineProperty(exports, "anchorPopover", { enumerable: true, get: function () { return Overlays_1.anchorPopover; } });
|
|
110
|
+
Object.defineProperty(exports, "resolveSnapPoint", { enumerable: true, get: function () { return Overlays_1.resolveSnapPoint; } });
|
|
111
|
+
Object.defineProperty(exports, "nearestSnapPoint", { enumerable: true, get: function () { return Overlays_1.nearestSnapPoint; } });
|
|
106
112
|
// Carousel.
|
|
107
113
|
var Carousel_1 = require("./Carousel");
|
|
108
114
|
Object.defineProperty(exports, "Carousel", { enumerable: true, get: function () { return Carousel_1.Carousel; } });
|
|
@@ -114,6 +120,12 @@ Object.defineProperty(exports, "Toggle", { enumerable: true, get: function () {
|
|
|
114
120
|
Object.defineProperty(exports, "ToggleGroup", { enumerable: true, get: function () { return Forms2_1.ToggleGroup; } });
|
|
115
121
|
Object.defineProperty(exports, "InputOTP", { enumerable: true, get: function () { return Forms2_1.InputOTP; } });
|
|
116
122
|
Object.defineProperty(exports, "ButtonGroup", { enumerable: true, get: function () { return Forms2_1.ButtonGroup; } });
|
|
123
|
+
Object.defineProperty(exports, "ColorPicker", { enumerable: true, get: function () { return Forms2_1.ColorPicker; } });
|
|
124
|
+
Object.defineProperty(exports, "DEFAULT_PALETTE", { enumerable: true, get: function () { return Forms2_1.DEFAULT_PALETTE; } });
|
|
125
|
+
Object.defineProperty(exports, "hexToRgb", { enumerable: true, get: function () { return Forms2_1.hexToRgb; } });
|
|
126
|
+
Object.defineProperty(exports, "rgbToHex", { enumerable: true, get: function () { return Forms2_1.rgbToHex; } });
|
|
127
|
+
Object.defineProperty(exports, "hueGradientColors", { enumerable: true, get: function () { return Forms2_1.hueGradientColors; } });
|
|
128
|
+
Object.defineProperty(exports, "Combobox", { enumerable: true, get: function () { return Forms2_1.Combobox; } });
|
|
117
129
|
var Pickers_1 = require("./Pickers");
|
|
118
130
|
Object.defineProperty(exports, "Calendar", { enumerable: true, get: function () { return Pickers_1.Calendar; } });
|
|
119
131
|
Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return Pickers_1.DatePicker; } });
|
|
@@ -125,10 +137,19 @@ Object.defineProperty(exports, "parseTime", { enumerable: true, get: function ()
|
|
|
125
137
|
Object.defineProperty(exports, "formatTime", { enumerable: true, get: function () { return Pickers_1.formatTime; } });
|
|
126
138
|
Object.defineProperty(exports, "WEEKDAYS", { enumerable: true, get: function () { return Pickers_1.WEEKDAYS; } });
|
|
127
139
|
Object.defineProperty(exports, "MONTHS", { enumerable: true, get: function () { return Pickers_1.MONTHS; } });
|
|
140
|
+
// Chat. Bubbles are flat tints; the composer (NativeAIInput) is the glass.
|
|
141
|
+
var Message_1 = require("./Message");
|
|
142
|
+
Object.defineProperty(exports, "Message", { enumerable: true, get: function () { return Message_1.Message; } });
|
|
143
|
+
Object.defineProperty(exports, "MessageBubble", { enumerable: true, get: function () { return Message_1.MessageBubble; } });
|
|
144
|
+
Object.defineProperty(exports, "MessageAttachment", { enumerable: true, get: function () { return Message_1.MessageAttachment; } });
|
|
128
145
|
var GlassView_1 = require("./internal/GlassView");
|
|
129
146
|
Object.defineProperty(exports, "isGlassSupported", { enumerable: true, get: function () { return GlassView_1.isGlassSupported; } });
|
|
147
|
+
var GlassContainer_1 = require("./internal/GlassContainer");
|
|
148
|
+
Object.defineProperty(exports, "GlassContainer", { enumerable: true, get: function () { return GlassContainer_1.GlassContainer; } });
|
|
130
149
|
var tokens_1 = require("./internal/tokens");
|
|
131
150
|
Object.defineProperty(exports, "colors", { enumerable: true, get: function () { return tokens_1.colors; } });
|
|
151
|
+
Object.defineProperty(exports, "controlSizes", { enumerable: true, get: function () { return tokens_1.controlSizes; } });
|
|
152
|
+
Object.defineProperty(exports, "palette", { enumerable: true, get: function () { return tokens_1.palette; } });
|
|
132
153
|
Object.defineProperty(exports, "radii", { enumerable: true, get: function () { return tokens_1.radii; } });
|
|
133
154
|
Object.defineProperty(exports, "springs", { enumerable: true, get: function () { return tokens_1.springs; } });
|
|
134
155
|
Object.defineProperty(exports, "typeScale", { enumerable: true, get: function () { return tokens_1.typeScale; } });
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GlassContainer = void 0;
|
|
4
|
+
exports.resetGlassContainerRouter = resetGlassContainerRouter;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const glass_routing_1 = require("./glass-routing");
|
|
8
|
+
const primitives_1 = require("./primitives");
|
|
9
|
+
const motion_1 = require("./motion");
|
|
10
|
+
/**
|
|
11
|
+
* The installed module's routing decision, memoised so a container and the
|
|
12
|
+
* surfaces inside it always agree about which branch is rendering.
|
|
13
|
+
*/
|
|
14
|
+
let cachedRouter = null;
|
|
15
|
+
function router() {
|
|
16
|
+
if (cachedRouter === null)
|
|
17
|
+
cachedRouter = (0, glass_routing_1.defaultRouter)();
|
|
18
|
+
return cachedRouter;
|
|
19
|
+
}
|
|
20
|
+
/** Clears the memoised decision. Only tests call this, to drive both branches. */
|
|
21
|
+
function resetGlassContainerRouter() {
|
|
22
|
+
cachedRouter = null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Groups glass surfaces so iOS 26 can merge them into one surface.
|
|
26
|
+
*
|
|
27
|
+
* On iOS 26, Apple's Liquid Glass is a connected material: two glass elements
|
|
28
|
+
* placed close enough run together into a single shape with one shared edge,
|
|
29
|
+
* rather than reading as two separate panes. `GlassContainer` is the component
|
|
30
|
+
* that opts into that — a bar and the floating button above it, or a pair of
|
|
31
|
+
* adjacent buttons, become one piece of glass.
|
|
32
|
+
*
|
|
33
|
+
* **Merging is an iOS 26+ visual effect and a no-op everywhere else.** On
|
|
34
|
+
* older iOS, Android, Expo Go and the web preview this renders a plain wrapper
|
|
35
|
+
* with identical layout: the children are the same components, drawn at the
|
|
36
|
+
* same positions, they simply keep their own separate edges. Nothing changes
|
|
37
|
+
* shape or shifts, so a container costs nothing on the platforms that cannot
|
|
38
|
+
* blend.
|
|
39
|
+
*
|
|
40
|
+
* Use it only around surfaces that should read as one; glass inside glass is
|
|
41
|
+
* still forbidden, so a container's children are `Glass` surfaces placed side
|
|
42
|
+
* by side, not a panel wrapping another panel.
|
|
43
|
+
*/
|
|
44
|
+
exports.GlassContainer = (0, react_1.forwardRef)(function GlassContainer({ spacing = 0, style, children, isDark: isDarkProp, testID, ...props }, ref) {
|
|
45
|
+
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
46
|
+
const decision = router();
|
|
47
|
+
const { View } = (0, primitives_1.primitives)();
|
|
48
|
+
if (decision.supported && decision.LiquidGlassContainerView) {
|
|
49
|
+
const ContentContainer = decision.LiquidGlassContainerView;
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(ContentContainer, { ref: ref, spacing: spacing, testID: testID, style: style, ...props, children: children }));
|
|
51
|
+
}
|
|
52
|
+
// Unsupported: a wrapper with the same layout, so nothing shifts.
|
|
53
|
+
return ((0, jsx_runtime_1.jsx)(View, { ref: ref, testID: testID, style: style, ...props, children: children }));
|
|
54
|
+
});
|
|
@@ -32,13 +32,21 @@ exports.isGlassSupported = (0, glass_routing_1.defaultRouter)().supported;
|
|
|
32
32
|
* Platform Glass View — the single place a glass surface is chosen:
|
|
33
33
|
* - iOS 26+: Real UIGlassEffect via @callstack/liquid-glass
|
|
34
34
|
* - iOS < 26 / Android / Expo Go: translucent tint View with identical layout
|
|
35
|
+
*
|
|
36
|
+
* Reduce Transparency is honoured on the fallback branch only: there the
|
|
37
|
+
* translucent tint is replaced by the theme's solid glass colour, with the same
|
|
38
|
+
* radius and the same hairline border, because a translucent surface is what
|
|
39
|
+
* the user asked the system to remove. On iOS 26 the system applies its own
|
|
40
|
+
* treatment to `UIGlassEffect` and this component does not second-guess it —
|
|
41
|
+
* overriding Apple's accessibility treatment would be worse than deferring to
|
|
42
|
+
* it, so the real glass is left exactly as the system renders it.
|
|
35
43
|
*/
|
|
36
|
-
exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, testID, style, children, isDark: isDarkProp, ...props }, ref) {
|
|
44
|
+
exports.GlassView = (0, react_1.forwardRef)(function GlassView({ effect = "regular", tintColor, interactive = false, surface = "panel", pressed, testID, style, children, isDark: isDarkProp, ...props }, ref) {
|
|
37
45
|
const isDark = (0, motion_1.useIsDark)(isDarkProp);
|
|
38
46
|
const decision = router();
|
|
39
47
|
if (decision.supported && decision.LiquidGlassView) {
|
|
40
48
|
const LiquidGlassView = decision.LiquidGlassView;
|
|
41
49
|
return ((0, jsx_runtime_1.jsx)(LiquidGlassView, { ref: ref, effect: effect, tintColor: tintColor, interactive: interactive, testID: testID, style: style, ...props, children: children }));
|
|
42
50
|
}
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, testID: testID, isDark: isDark, style: style, ...props, children: children }));
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(fallback_1.FallbackGlassView, { ref: ref, effect: effect, tintColor: tintColor, surface: surface, pressed: pressed, testID: testID, isDark: isDark, style: style, ...props, children: children }));
|
|
44
52
|
});
|
|
@@ -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
|
+
}
|