glacia-native 0.3.4 → 0.4.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.
- package/lib/module/Button.js +15 -2
- package/lib/module/Card.js +29 -14
- package/lib/module/Dialog.js +43 -32
- package/lib/module/Form.js +51 -12
- package/lib/module/Glass.js +11 -2
- package/lib/module/Input.js +19 -7
- package/lib/module/SegmentedControl.js +65 -21
- package/lib/module/Slider.js +121 -25
- package/lib/module/Switch.js +33 -15
- package/lib/module/TabBar.js +63 -25
- package/lib/module/Table.js +24 -6
- package/lib/module/Tabs.js +55 -33
- package/lib/module/ai.js +49 -20
- package/lib/module/charts/BarChart.js +4 -2
- package/lib/module/charts/FunnelChart.js +4 -2
- package/lib/module/charts/HeatmapChart.js +4 -2
- package/lib/module/charts/LineChart.js +4 -2
- package/lib/module/charts/PlotChart.js +11 -3
- package/lib/module/charts/RadarChart.js +4 -2
- package/lib/module/charts/RingChart.js +4 -2
- package/lib/module/charts/ScatterChart.js +20 -3
- package/lib/module/charts/WaterfallChart.js +12 -3
- package/lib/module/charts/advanced.js +12 -6
- package/lib/module/charts/extra.js +6 -3
- package/lib/module/internal/GlassView.js +17 -19
- package/lib/module/internal/fallback.js +14 -3
- package/lib/module/internal/glass-routing.js +56 -0
- package/lib/module/internal/motion.js +55 -0
- package/lib/module/internal/primitives.js +408 -0
- package/lib/typescript/Button.d.ts +11 -1
- package/lib/typescript/Card.d.ts +20 -8
- package/lib/typescript/Dialog.d.ts +19 -6
- package/lib/typescript/Form.d.ts +27 -11
- package/lib/typescript/Glass.d.ts +9 -0
- package/lib/typescript/Input.d.ts +11 -1
- package/lib/typescript/SegmentedControl.d.ts +11 -1
- package/lib/typescript/Slider.d.ts +13 -1
- package/lib/typescript/Switch.d.ts +12 -1
- package/lib/typescript/TabBar.d.ts +13 -1
- package/lib/typescript/Table.d.ts +14 -5
- package/lib/typescript/Tabs.d.ts +8 -5
- package/lib/typescript/ai.d.ts +12 -9
- package/lib/typescript/charts/BarChart.d.ts +1 -1
- package/lib/typescript/charts/FunnelChart.d.ts +1 -1
- package/lib/typescript/charts/HeatmapChart.d.ts +1 -1
- package/lib/typescript/charts/LineChart.d.ts +1 -1
- package/lib/typescript/charts/PlotChart.d.ts +1 -1
- package/lib/typescript/charts/RadarChart.d.ts +1 -1
- package/lib/typescript/charts/RingChart.d.ts +1 -1
- package/lib/typescript/charts/ScatterChart.d.ts +1 -1
- package/lib/typescript/charts/WaterfallChart.d.ts +1 -1
- package/lib/typescript/charts/advanced.d.ts +5 -5
- package/lib/typescript/charts/extra.d.ts +2 -2
- package/lib/typescript/internal/GlassView.d.ts +11 -3
- package/lib/typescript/internal/fallback.d.ts +10 -1
- package/lib/typescript/internal/glass-routing.d.ts +30 -0
- package/lib/typescript/internal/motion.d.ts +19 -0
- package/lib/typescript/internal/primitives.d.ts +41 -0
- package/package.json +2 -2
- package/src/Button.tsx +47 -22
- package/src/Card.tsx +52 -31
- package/src/Dialog.tsx +99 -64
- package/src/Form.tsx +90 -25
- package/src/Glass.tsx +24 -1
- package/src/Input.tsx +33 -12
- package/src/SegmentedControl.tsx +104 -32
- package/src/Slider.tsx +151 -47
- package/src/Switch.tsx +56 -32
- package/src/TabBar.tsx +100 -30
- package/src/Table.tsx +38 -14
- package/src/Tabs.tsx +85 -32
- package/src/ai.tsx +77 -31
- package/src/charts/BarChart.tsx +4 -2
- package/src/charts/FunnelChart.tsx +4 -2
- package/src/charts/HeatmapChart.tsx +4 -2
- package/src/charts/LineChart.tsx +4 -2
- package/src/charts/PlotChart.tsx +23 -3
- package/src/charts/RadarChart.tsx +4 -2
- package/src/charts/RingChart.tsx +4 -2
- package/src/charts/ScatterChart.tsx +24 -3
- package/src/charts/WaterfallChart.tsx +21 -3
- package/src/charts/advanced.tsx +12 -6
- package/src/charts/extra.tsx +6 -3
- package/src/internal/GlassView.tsx +31 -21
- package/src/internal/fallback.tsx +23 -8
- package/src/internal/glass-routing.ts +68 -0
- package/src/internal/motion.ts +60 -0
- package/src/internal/primitives.ts +477 -0
- package/lib/module/charts/primitives.js +0 -212
- package/lib/typescript/charts/primitives.d.ts +0 -23
- package/src/charts/primitives.ts +0 -262
package/src/Table.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
2
3
|
|
|
3
4
|
import { colors } from "./internal/tokens";
|
|
4
|
-
import { primitives } from "./
|
|
5
|
+
import { primitives } from "./internal/primitives";
|
|
6
|
+
import { useIsDark } from "./internal/motion";
|
|
5
7
|
|
|
6
8
|
export interface NativeTableColumn {
|
|
7
9
|
key: string;
|
|
@@ -17,6 +19,12 @@ export interface NativeTableColumn {
|
|
|
17
19
|
export interface NativeTableRow {
|
|
18
20
|
id: string;
|
|
19
21
|
cells: Record<string, ReactNode>;
|
|
22
|
+
/**
|
|
23
|
+
* What screen readers announce when the row is pressable. Use it when the
|
|
24
|
+
* cells hold elements rather than text; without it the primary cell is used
|
|
25
|
+
* only if it is a string or number.
|
|
26
|
+
*/
|
|
27
|
+
accessibilityLabel?: string;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
30
|
export interface NativeTableProps {
|
|
@@ -24,11 +32,13 @@ export interface NativeTableProps {
|
|
|
24
32
|
rows: NativeTableRow[];
|
|
25
33
|
/** Tap handler for a whole row. */
|
|
26
34
|
onRowPress?: (row: NativeTableRow) => void;
|
|
27
|
-
/**
|
|
35
|
+
/** A caption describing the table's contents, shown above it. */
|
|
28
36
|
caption?: string;
|
|
29
37
|
isDark?: boolean;
|
|
30
|
-
style?:
|
|
38
|
+
style?: StyleProp<ViewStyle>;
|
|
31
39
|
emptyMessage?: string;
|
|
40
|
+
/** Passed through to the table root so it is testable. */
|
|
41
|
+
testID?: string;
|
|
32
42
|
}
|
|
33
43
|
|
|
34
44
|
/**
|
|
@@ -44,16 +54,18 @@ export function NativeTable({
|
|
|
44
54
|
rows,
|
|
45
55
|
onRowPress,
|
|
46
56
|
caption,
|
|
47
|
-
isDark
|
|
57
|
+
isDark: isDarkProp,
|
|
48
58
|
style,
|
|
49
59
|
emptyMessage = "No rows to display",
|
|
60
|
+
testID,
|
|
50
61
|
}: NativeTableProps) {
|
|
62
|
+
const isDark = useIsDark(isDarkProp);
|
|
51
63
|
const theme = isDark ? colors.dark : colors.light;
|
|
52
64
|
const { View, Text, Pressable } = primitives();
|
|
53
65
|
|
|
54
66
|
if (rows.length === 0) {
|
|
55
67
|
return (
|
|
56
|
-
<View style={[{ paddingVertical: 20, alignItems: "center" }, style]}>
|
|
68
|
+
<View style={[{ paddingVertical: 20, alignItems: "center" }, style as ViewStyle]}>
|
|
57
69
|
<Text style={{ fontSize: 12, color: theme.muted }}>{emptyMessage}</Text>
|
|
58
70
|
</View>
|
|
59
71
|
);
|
|
@@ -65,7 +77,7 @@ export function NativeTable({
|
|
|
65
77
|
const detailColumns = columns.filter((column) => column.key !== primaryKey);
|
|
66
78
|
|
|
67
79
|
return (
|
|
68
|
-
<View style={style}>
|
|
80
|
+
<View style={style as ViewStyle} testID={testID}>
|
|
69
81
|
{caption && (
|
|
70
82
|
<Text style={{ fontSize: 11, color: theme.muted, marginBottom: 8 }}>{caption}</Text>
|
|
71
83
|
)}
|
|
@@ -75,7 +87,7 @@ export function NativeTable({
|
|
|
75
87
|
const wrapperProps = onRowPress
|
|
76
88
|
? {
|
|
77
89
|
accessibilityRole: "button",
|
|
78
|
-
accessibilityLabel:
|
|
90
|
+
accessibilityLabel: rowAccessibilityLabel(row, primaryKey),
|
|
79
91
|
onPress: () => onRowPress(row),
|
|
80
92
|
}
|
|
81
93
|
: { accessibilityRole: "text" };
|
|
@@ -136,6 +148,20 @@ export function NativeTable({
|
|
|
136
148
|
);
|
|
137
149
|
}
|
|
138
150
|
|
|
151
|
+
/**
|
|
152
|
+
* What screen readers announce for a pressable row.
|
|
153
|
+
*
|
|
154
|
+
* A cell can be any element, and `String(cell)` of an element announces
|
|
155
|
+
* "[object Object]". So: an explicit row label wins, then a textual primary
|
|
156
|
+
* cell, then a neutral fallback.
|
|
157
|
+
*/
|
|
158
|
+
function rowAccessibilityLabel(row: NativeTableRow, primaryKey: string | undefined): string {
|
|
159
|
+
if (row.accessibilityLabel) return row.accessibilityLabel;
|
|
160
|
+
const primary = primaryKey ? row.cells[primaryKey] : undefined;
|
|
161
|
+
if (typeof primary === "string" || typeof primary === "number") return String(primary);
|
|
162
|
+
return "Row";
|
|
163
|
+
}
|
|
164
|
+
|
|
139
165
|
export interface NativeScrollAreaProps {
|
|
140
166
|
children?: ReactNode;
|
|
141
167
|
/** Fixed height. Without one the area grows with its content. */
|
|
@@ -144,7 +170,7 @@ export interface NativeScrollAreaProps {
|
|
|
144
170
|
bordered?: boolean;
|
|
145
171
|
horizontal?: boolean;
|
|
146
172
|
isDark?: boolean;
|
|
147
|
-
style?:
|
|
173
|
+
style?: StyleProp<ViewStyle>;
|
|
148
174
|
/** Announced to screen readers. */
|
|
149
175
|
accessibilityLabel?: string;
|
|
150
176
|
}
|
|
@@ -161,10 +187,11 @@ export function NativeScrollArea({
|
|
|
161
187
|
maxHeight,
|
|
162
188
|
bordered = false,
|
|
163
189
|
horizontal = false,
|
|
164
|
-
isDark
|
|
190
|
+
isDark: isDarkProp,
|
|
165
191
|
style,
|
|
166
192
|
accessibilityLabel,
|
|
167
193
|
}: NativeScrollAreaProps) {
|
|
194
|
+
const isDark = useIsDark(isDarkProp);
|
|
168
195
|
const theme = isDark ? colors.dark : colors.light;
|
|
169
196
|
const { View, getScrollView } = primitives();
|
|
170
197
|
|
|
@@ -176,17 +203,14 @@ export function NativeScrollArea({
|
|
|
176
203
|
borderWidth: bordered ? 1 : 0,
|
|
177
204
|
borderColor: theme.edge,
|
|
178
205
|
overflow: "hidden",
|
|
179
|
-
...style,
|
|
206
|
+
...(style as ViewStyle),
|
|
180
207
|
};
|
|
181
208
|
|
|
182
209
|
if (!ScrollView) {
|
|
183
210
|
// Off-device there is no ScrollView; render the content in a clipped box so
|
|
184
211
|
// layout still matches instead of dropping children.
|
|
185
212
|
return (
|
|
186
|
-
<View
|
|
187
|
-
accessibilityLabel={accessibilityLabel}
|
|
188
|
-
style={{ ...containerStyle, overflow: "auto" }}
|
|
189
|
-
>
|
|
213
|
+
<View accessibilityLabel={accessibilityLabel} style={containerStyle}>
|
|
190
214
|
{children}
|
|
191
215
|
</View>
|
|
192
216
|
);
|
package/src/Tabs.tsx
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forwardRef, useState, type ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
|
|
2
4
|
import { Glass } from "./Glass";
|
|
3
5
|
import { colors, radii } from "./internal/tokens";
|
|
6
|
+
import { primitives } from "./internal/primitives";
|
|
7
|
+
import { useIsDark, useSpring } from "./internal/motion";
|
|
4
8
|
|
|
5
9
|
export interface TabItem {
|
|
6
10
|
/** Stable identifier for the tab. */
|
|
@@ -17,18 +21,20 @@ export interface TabsProps {
|
|
|
17
21
|
activeId?: string;
|
|
18
22
|
defaultActiveId?: string;
|
|
19
23
|
onTabChange?: (id: string) => void;
|
|
20
|
-
style?:
|
|
24
|
+
style?: StyleProp<ViewStyle>;
|
|
21
25
|
isDark?: boolean;
|
|
26
|
+
/** Passed through to the rail so it is testable. */
|
|
27
|
+
testID?: string;
|
|
22
28
|
}
|
|
23
29
|
|
|
24
30
|
/**
|
|
25
31
|
* A row of tabs on a glass rail, in the reference implementation's style: the
|
|
26
32
|
* selected tab is a lifted inner pane rather than a flat highlight.
|
|
27
33
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
34
|
+
* Same conventions as every other component here — React Native primitives
|
|
35
|
+
* only, no browser APIs. The rail is Apple's real glass on iOS 26+ and
|
|
36
|
+
* Glacia's translucent fallback of the same shape on older iOS and Android, so
|
|
37
|
+
* the layout never shifts between platforms.
|
|
32
38
|
*/
|
|
33
39
|
export const Tabs = forwardRef<any, TabsProps>(function Tabs(
|
|
34
40
|
{
|
|
@@ -37,70 +43,117 @@ export const Tabs = forwardRef<any, TabsProps>(function Tabs(
|
|
|
37
43
|
defaultActiveId,
|
|
38
44
|
onTabChange,
|
|
39
45
|
style,
|
|
40
|
-
isDark
|
|
46
|
+
isDark: isDarkProp,
|
|
47
|
+
testID,
|
|
41
48
|
...props
|
|
42
49
|
},
|
|
43
50
|
ref,
|
|
44
51
|
) {
|
|
52
|
+
const isDark = useIsDark(isDarkProp);
|
|
53
|
+
const themeColors = isDark ? colors.dark : colors.light;
|
|
54
|
+
const { View, Text, Pressable, Animated } = primitives();
|
|
55
|
+
|
|
45
56
|
const [internalId, setInternalId] = useState(defaultActiveId || items[0]?.id || "");
|
|
46
57
|
const activeId = activeProp !== undefined ? activeProp : internalId;
|
|
47
|
-
|
|
58
|
+
|
|
59
|
+
const activeIndex = Math.max(
|
|
60
|
+
0,
|
|
61
|
+
items.findIndex((tab) => tab.id === activeId),
|
|
62
|
+
);
|
|
63
|
+
const { value: slide, animated } = useSpring(activeIndex, "snappy");
|
|
48
64
|
|
|
49
65
|
const handleSelect = (id: string) => {
|
|
50
66
|
if (activeProp === undefined) setInternalId(id);
|
|
51
67
|
onTabChange?.(id);
|
|
52
68
|
};
|
|
53
69
|
|
|
70
|
+
const count = Math.max(items.length, 1);
|
|
71
|
+
const itemWidth = `${100 / count}%`;
|
|
72
|
+
|
|
73
|
+
// The selection is a lens, not a fill: a lifted pane on the rail.
|
|
74
|
+
const paneStyle = {
|
|
75
|
+
position: "absolute" as const,
|
|
76
|
+
top: 4,
|
|
77
|
+
bottom: 4,
|
|
78
|
+
left: 4,
|
|
79
|
+
width: itemWidth,
|
|
80
|
+
borderRadius: radii.pill,
|
|
81
|
+
backgroundColor: isDark ? "rgba(255,255,255,0.16)" : "rgba(255,255,255,0.72)",
|
|
82
|
+
borderWidth: 0.5,
|
|
83
|
+
borderColor: themeColors.edge,
|
|
84
|
+
};
|
|
85
|
+
|
|
54
86
|
return (
|
|
55
87
|
<Glass
|
|
56
88
|
ref={ref}
|
|
57
89
|
effect="regular"
|
|
90
|
+
isDark={isDark}
|
|
58
91
|
style={{
|
|
59
|
-
display: "flex",
|
|
60
92
|
flexDirection: "row",
|
|
61
93
|
alignItems: "center",
|
|
94
|
+
alignSelf: "flex-start",
|
|
62
95
|
gap: 2,
|
|
63
96
|
padding: 4,
|
|
64
97
|
borderRadius: radii.pill,
|
|
65
|
-
...style,
|
|
98
|
+
...(style as ViewStyle),
|
|
66
99
|
}}
|
|
100
|
+
testID={testID}
|
|
67
101
|
{...props}
|
|
68
102
|
>
|
|
103
|
+
{animated ? (
|
|
104
|
+
<Animated.View
|
|
105
|
+
pointerEvents="none"
|
|
106
|
+
style={{
|
|
107
|
+
...paneStyle,
|
|
108
|
+
transform: [
|
|
109
|
+
{
|
|
110
|
+
translateX: slide.interpolate({
|
|
111
|
+
inputRange: [0, Math.max(count - 1, 1)],
|
|
112
|
+
outputRange: ["0%", `${((count - 1) * 100) / count}%`],
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
) : (
|
|
119
|
+
<View
|
|
120
|
+
pointerEvents="none"
|
|
121
|
+
style={{ ...paneStyle, left: `${(activeIndex * 100) / count}%` }}
|
|
122
|
+
/>
|
|
123
|
+
)}
|
|
124
|
+
|
|
69
125
|
{items.map((tab) => {
|
|
70
126
|
const isActive = tab.id === activeId;
|
|
71
127
|
return (
|
|
72
|
-
<
|
|
128
|
+
<Pressable
|
|
73
129
|
key={tab.id}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
130
|
+
accessibilityRole="tab"
|
|
131
|
+
accessibilityLabel={tab.label}
|
|
132
|
+
accessibilityState={{ selected: isActive }}
|
|
133
|
+
onPress={() => handleSelect(tab.id)}
|
|
78
134
|
style={{
|
|
79
135
|
flex: 1,
|
|
80
|
-
|
|
136
|
+
height: 36,
|
|
81
137
|
flexDirection: "row",
|
|
82
138
|
alignItems: "center",
|
|
83
139
|
justifyContent: "center",
|
|
84
140
|
gap: 6,
|
|
85
|
-
|
|
86
|
-
border: 0,
|
|
141
|
+
paddingHorizontal: 12,
|
|
87
142
|
borderRadius: radii.pill,
|
|
88
|
-
// The selection is a lens, not a fill: a lifted pane on the rail.
|
|
89
|
-
background: isActive
|
|
90
|
-
? isDark
|
|
91
|
-
? "rgba(255,255,255,0.16)"
|
|
92
|
-
: "rgba(255,255,255,0.72)"
|
|
93
|
-
: "transparent",
|
|
94
|
-
color: isActive ? themeColors.foreground : themeColors.muted,
|
|
95
|
-
fontSize: 13,
|
|
96
|
-
fontWeight: isActive ? 600 : 500,
|
|
97
|
-
cursor: "pointer",
|
|
98
|
-
whiteSpace: "nowrap",
|
|
99
143
|
}}
|
|
100
144
|
>
|
|
101
|
-
{tab.icon
|
|
102
|
-
<
|
|
103
|
-
|
|
145
|
+
{tab.icon ?? null}
|
|
146
|
+
<Text
|
|
147
|
+
numberOfLines={1}
|
|
148
|
+
style={{
|
|
149
|
+
fontSize: 13,
|
|
150
|
+
fontWeight: isActive ? "600" : "500",
|
|
151
|
+
color: isActive ? themeColors.foreground : themeColors.muted,
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
{tab.label}
|
|
155
|
+
</Text>
|
|
156
|
+
</Pressable>
|
|
104
157
|
);
|
|
105
158
|
})}
|
|
106
159
|
</Glass>
|
package/src/ai.tsx
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState, type ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
2
3
|
|
|
3
4
|
import { colors, radii } from "./internal/tokens";
|
|
4
|
-
import { primitives } from "./
|
|
5
|
+
import { primitives } from "./internal/primitives";
|
|
6
|
+
import { useIsDark } from "./internal/motion";
|
|
5
7
|
|
|
6
8
|
export interface NativePlanStep {
|
|
7
9
|
id: string;
|
|
@@ -23,7 +25,8 @@ export interface NativePlanProps {
|
|
|
23
25
|
* Each step carries its own status, so a half-finished plan is legible instead
|
|
24
26
|
* of appearing blank until the whole thing completes.
|
|
25
27
|
*/
|
|
26
|
-
export function NativePlan({ title = "Plan", steps, isDark
|
|
28
|
+
export function NativePlan({ title = "Plan", steps, isDark: isDarkProp, style }: NativePlanProps) {
|
|
29
|
+
const isDark = useIsDark(isDarkProp);
|
|
27
30
|
const theme = isDark ? colors.dark : colors.light;
|
|
28
31
|
const { View, Text } = primitives();
|
|
29
32
|
const done = steps.filter((step) => step.status === "done").length;
|
|
@@ -124,10 +127,11 @@ export interface NativeSourcesProps {
|
|
|
124
127
|
export function NativeSources({
|
|
125
128
|
sources,
|
|
126
129
|
title = "Sources",
|
|
127
|
-
isDark
|
|
130
|
+
isDark: isDarkProp,
|
|
128
131
|
style,
|
|
129
132
|
onSourcePress,
|
|
130
133
|
}: NativeSourcesProps) {
|
|
134
|
+
const isDark = useIsDark(isDarkProp);
|
|
131
135
|
const theme = isDark ? colors.dark : colors.light;
|
|
132
136
|
const { View, Text, Pressable } = primitives();
|
|
133
137
|
|
|
@@ -197,9 +201,10 @@ export function NativeResponse({
|
|
|
197
201
|
text,
|
|
198
202
|
revealed,
|
|
199
203
|
streaming,
|
|
200
|
-
isDark
|
|
204
|
+
isDark: isDarkProp,
|
|
201
205
|
style,
|
|
202
206
|
}: NativeResponseProps) {
|
|
207
|
+
const isDark = useIsDark(isDarkProp);
|
|
203
208
|
const theme = isDark ? colors.dark : colors.light;
|
|
204
209
|
const { View, Text } = primitives();
|
|
205
210
|
|
|
@@ -237,7 +242,8 @@ export interface NativeTaskProps {
|
|
|
237
242
|
}
|
|
238
243
|
|
|
239
244
|
/** Progress of a long-running background task. */
|
|
240
|
-
export function NativeTask({ task, isDark
|
|
245
|
+
export function NativeTask({ task, isDark: isDarkProp, style }: NativeTaskProps) {
|
|
246
|
+
const isDark = useIsDark(isDarkProp);
|
|
241
247
|
const theme = isDark ? colors.dark : colors.light;
|
|
242
248
|
const { View, Text } = primitives();
|
|
243
249
|
|
|
@@ -251,10 +257,13 @@ export function NativeTask({ task, isDark = false, style }: NativeTaskProps) {
|
|
|
251
257
|
<View
|
|
252
258
|
accessibilityRole="progressbar"
|
|
253
259
|
accessibilityLabel={task.label ?? "Task progress"}
|
|
260
|
+
// Without the value, a screen reader only reads the label and never says
|
|
261
|
+
// how far along the task is.
|
|
262
|
+
accessibilityValue={percent == null ? undefined : { min: 0, max: 100, now: percent }}
|
|
254
263
|
accessibilityState={{
|
|
255
264
|
disabled: false,
|
|
256
265
|
}}
|
|
257
|
-
style={style}
|
|
266
|
+
style={style as StyleProp<ViewStyle>}
|
|
258
267
|
>
|
|
259
268
|
<View
|
|
260
269
|
style={{ flexDirection: "row", justifyContent: "space-between", marginBottom: 6 }}
|
|
@@ -318,10 +327,11 @@ export function NativeSoundwave({
|
|
|
318
327
|
active = true,
|
|
319
328
|
height = 40,
|
|
320
329
|
color,
|
|
321
|
-
isDark
|
|
330
|
+
isDark: isDarkProp,
|
|
322
331
|
style,
|
|
323
332
|
label = "Audio level",
|
|
324
333
|
}: NativeSoundwaveProps) {
|
|
334
|
+
const isDark = useIsDark(isDarkProp);
|
|
325
335
|
const theme = isDark ? colors.dark : colors.light;
|
|
326
336
|
const { View } = primitives();
|
|
327
337
|
|
|
@@ -374,9 +384,10 @@ export function NativeThinkingOrb({
|
|
|
374
384
|
label = "Thinking",
|
|
375
385
|
size = 22,
|
|
376
386
|
paused = false,
|
|
377
|
-
isDark
|
|
387
|
+
isDark: isDarkProp,
|
|
378
388
|
style,
|
|
379
389
|
}: NativeThinkingOrbProps) {
|
|
390
|
+
const isDark = useIsDark(isDarkProp);
|
|
380
391
|
const theme = isDark ? colors.dark : colors.light;
|
|
381
392
|
const { View, Text } = primitives();
|
|
382
393
|
const [tick, setTick] = useState(0);
|
|
@@ -435,10 +446,11 @@ export function NativePanelside({
|
|
|
435
446
|
items,
|
|
436
447
|
value,
|
|
437
448
|
onValueChange,
|
|
438
|
-
isDark
|
|
449
|
+
isDark: isDarkProp,
|
|
439
450
|
style,
|
|
440
451
|
title,
|
|
441
452
|
}: NativePanelsideProps) {
|
|
453
|
+
const isDark = useIsDark(isDarkProp);
|
|
442
454
|
const theme = isDark ? colors.dark : colors.light;
|
|
443
455
|
const { View, Text, Pressable } = primitives();
|
|
444
456
|
|
|
@@ -490,7 +502,10 @@ export function NativePanelside({
|
|
|
490
502
|
}
|
|
491
503
|
|
|
492
504
|
export interface NativeAIInputProps {
|
|
505
|
+
/** Controlled text. Omit it and the composer keeps its own. */
|
|
493
506
|
value?: string;
|
|
507
|
+
/** Starting text for uncontrolled use. */
|
|
508
|
+
defaultValue?: string;
|
|
494
509
|
onChangeText?: (text: string) => void;
|
|
495
510
|
onSubmit?: () => void;
|
|
496
511
|
placeholder?: string;
|
|
@@ -510,24 +525,38 @@ export interface NativeAIInputProps {
|
|
|
510
525
|
* that prevents empty submissions rather than a validation message afterwards.
|
|
511
526
|
*/
|
|
512
527
|
export function NativeAIInput({
|
|
513
|
-
value
|
|
528
|
+
value: valueProp,
|
|
529
|
+
defaultValue,
|
|
514
530
|
onChangeText,
|
|
515
531
|
onSubmit,
|
|
516
532
|
placeholder = "Ask anything",
|
|
517
533
|
disabled = false,
|
|
518
534
|
busy = false,
|
|
519
535
|
sendLabel = "Send",
|
|
520
|
-
isDark
|
|
536
|
+
isDark: isDarkProp,
|
|
521
537
|
style,
|
|
522
538
|
footer,
|
|
523
539
|
}: NativeAIInputProps) {
|
|
540
|
+
const isDark = useIsDark(isDarkProp);
|
|
524
541
|
const theme = isDark ? colors.dark : colors.light;
|
|
525
542
|
const { View, Text, TextInput, Pressable } = primitives();
|
|
526
543
|
|
|
544
|
+
// Uncontrolled support: the composer owns its text when no `value` is given,
|
|
545
|
+
// which is what makes typed text appear in plain uncontrolled use.
|
|
546
|
+
const [internalText, setInternalText] = useState(defaultValue ?? "");
|
|
547
|
+
const value = valueProp !== undefined ? valueProp : internalText;
|
|
548
|
+
const handleChangeText = (next: string) => {
|
|
549
|
+
if (valueProp === undefined) setInternalText(next);
|
|
550
|
+
onChangeText?.(next);
|
|
551
|
+
};
|
|
552
|
+
|
|
527
553
|
const canSend = !disabled && !busy && value.trim().length > 0;
|
|
554
|
+
// The themed placeholder is drawn as a Text, matching Input: the OS default
|
|
555
|
+
// placeholder colour ignores the theme.
|
|
556
|
+
const showPlaceholder = !value && Boolean(placeholder);
|
|
528
557
|
|
|
529
558
|
return (
|
|
530
|
-
<View style={style}>
|
|
559
|
+
<View style={style as StyleProp<ViewStyle>}>
|
|
531
560
|
<View
|
|
532
561
|
style={{
|
|
533
562
|
flexDirection: "row",
|
|
@@ -541,24 +570,40 @@ export function NativeAIInput({
|
|
|
541
570
|
opacity: disabled ? 0.5 : 1,
|
|
542
571
|
}}
|
|
543
572
|
>
|
|
544
|
-
<
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
573
|
+
<View style={{ flex: 1, justifyContent: "center" }}>
|
|
574
|
+
{showPlaceholder && (
|
|
575
|
+
<Text
|
|
576
|
+
pointerEvents="none"
|
|
577
|
+
numberOfLines={1}
|
|
578
|
+
style={{
|
|
579
|
+
position: "absolute",
|
|
580
|
+
left: 6,
|
|
581
|
+
fontSize: 14,
|
|
582
|
+
color: theme.muted,
|
|
583
|
+
}}
|
|
584
|
+
>
|
|
585
|
+
{placeholder}
|
|
586
|
+
</Text>
|
|
587
|
+
)}
|
|
588
|
+
|
|
589
|
+
<TextInput
|
|
590
|
+
value={value}
|
|
591
|
+
onChangeText={handleChangeText}
|
|
592
|
+
editable={!disabled}
|
|
593
|
+
multiline
|
|
594
|
+
numberOfLines={3}
|
|
595
|
+
accessibilityLabel={placeholder}
|
|
596
|
+
accessibilityState={{ disabled }}
|
|
597
|
+
style={{
|
|
598
|
+
minHeight: 34,
|
|
599
|
+
maxHeight: 120,
|
|
600
|
+
paddingHorizontal: 6,
|
|
601
|
+
paddingVertical: 7,
|
|
602
|
+
fontSize: 14,
|
|
603
|
+
color: theme.foreground,
|
|
604
|
+
}}
|
|
605
|
+
/>
|
|
606
|
+
</View>
|
|
562
607
|
|
|
563
608
|
<Pressable
|
|
564
609
|
accessibilityRole="button"
|
|
@@ -611,9 +656,10 @@ export function NativeImageGeneration({
|
|
|
611
656
|
image,
|
|
612
657
|
prompt,
|
|
613
658
|
status = "queued",
|
|
614
|
-
isDark
|
|
659
|
+
isDark: isDarkProp,
|
|
615
660
|
style,
|
|
616
661
|
}: NativeImageGenerationProps) {
|
|
662
|
+
const isDark = useIsDark(isDarkProp);
|
|
617
663
|
const theme = isDark ? colors.dark : colors.light;
|
|
618
664
|
const { View, Text, Image } = primitives();
|
|
619
665
|
|
package/src/charts/BarChart.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useMemo, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { colors } from "../internal/tokens";
|
|
4
|
-
import {
|
|
4
|
+
import { useIsDark } from "../internal/motion";
|
|
5
|
+
import { primitives } from "../internal/primitives";
|
|
5
6
|
import { bandScale, formatValue, linearScale, niceDomain, seriesColor, ticks } from "./scales";
|
|
6
7
|
|
|
7
8
|
export interface NativeBarSeries {
|
|
@@ -33,12 +34,13 @@ export function NativeBarChart({
|
|
|
33
34
|
height = 200,
|
|
34
35
|
stacked = false,
|
|
35
36
|
radius = 4,
|
|
36
|
-
isDark
|
|
37
|
+
isDark: isDarkProp,
|
|
37
38
|
palette,
|
|
38
39
|
style,
|
|
39
40
|
onBarPress,
|
|
40
41
|
}: NativeBarChartProps) {
|
|
41
42
|
const [active, setActive] = useState<number | null>(null);
|
|
43
|
+
const isDark = useIsDark(isDarkProp);
|
|
42
44
|
const theme = isDark ? colors.dark : colors.light;
|
|
43
45
|
const { View, Text, Pressable, Svg, G, Line, Rect, SvgText } = primitives();
|
|
44
46
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { colors } from "../internal/tokens";
|
|
4
|
-
import {
|
|
4
|
+
import { useIsDark } from "../internal/motion";
|
|
5
|
+
import { primitives } from "../internal/primitives";
|
|
5
6
|
import { formatValue, seriesColor } from "./scales";
|
|
6
7
|
|
|
7
8
|
export interface NativeFunnelStage {
|
|
@@ -35,12 +36,13 @@ export function NativeFunnelChart({
|
|
|
35
36
|
width = 320,
|
|
36
37
|
stageHeight = 38,
|
|
37
38
|
baseline,
|
|
38
|
-
isDark
|
|
39
|
+
isDark: isDarkProp,
|
|
39
40
|
palette,
|
|
40
41
|
style,
|
|
41
42
|
onStagePress,
|
|
42
43
|
}: NativeFunnelChartProps) {
|
|
43
44
|
const [active, setActive] = useState<number | null>(null);
|
|
45
|
+
const isDark = useIsDark(isDarkProp);
|
|
44
46
|
const theme = isDark ? colors.dark : colors.light;
|
|
45
47
|
const { View, Text, Pressable } = primitives();
|
|
46
48
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { colors } from "../internal/tokens";
|
|
4
|
-
import {
|
|
4
|
+
import { useIsDark } from "../internal/motion";
|
|
5
|
+
import { primitives } from "../internal/primitives";
|
|
5
6
|
import { formatValue } from "./scales";
|
|
6
7
|
|
|
7
8
|
export interface NativeHeatmapChartProps {
|
|
@@ -46,13 +47,14 @@ export function NativeHeatmapChart({
|
|
|
46
47
|
columns,
|
|
47
48
|
cellSize = 28,
|
|
48
49
|
cellGap = 3,
|
|
49
|
-
isDark
|
|
50
|
+
isDark: isDarkProp,
|
|
50
51
|
minColor = "#e8eef7",
|
|
51
52
|
maxColor = "#0088ff",
|
|
52
53
|
style,
|
|
53
54
|
onCellPress,
|
|
54
55
|
}: NativeHeatmapChartProps) {
|
|
55
56
|
const [active, setActive] = useState<{ r: number; c: number } | null>(null);
|
|
57
|
+
const isDark = useIsDark(isDarkProp);
|
|
56
58
|
const theme = isDark ? colors.dark : colors.light;
|
|
57
59
|
const { View, Text, Pressable } = primitives();
|
|
58
60
|
|
package/src/charts/LineChart.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useMemo, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { colors, radii } from "../internal/tokens";
|
|
4
|
-
import {
|
|
4
|
+
import { useIsDark } from "../internal/motion";
|
|
5
|
+
import { primitives } from "../internal/primitives";
|
|
5
6
|
import {
|
|
6
7
|
bandScale,
|
|
7
8
|
formatValue,
|
|
@@ -53,12 +54,13 @@ export function NativeLineChart({
|
|
|
53
54
|
area = false,
|
|
54
55
|
smooth = true,
|
|
55
56
|
showDots = false,
|
|
56
|
-
isDark
|
|
57
|
+
isDark: isDarkProp,
|
|
57
58
|
palette,
|
|
58
59
|
style,
|
|
59
60
|
onPointPress,
|
|
60
61
|
}: NativeLineChartProps) {
|
|
61
62
|
const [active, setActive] = useState<number | null>(null);
|
|
63
|
+
const isDark = useIsDark(isDarkProp);
|
|
62
64
|
const theme = isDark ? colors.dark : colors.light;
|
|
63
65
|
const { View, Text, Pressable, Svg, G, Line, Path, Circle, SvgText } = primitives();
|
|
64
66
|
|