anhedral 0.16.0 → 0.18.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/README.md +42 -20
- package/assets/contracts/LICENSE +201 -0
- package/assets/contracts/LICENSE.environment +201 -0
- package/assets/contracts/LICENSE.operations +201 -0
- package/assets/contracts/deployment-provenance.json +15 -0
- package/assets/contracts/environment-provenance.json +11 -0
- package/assets/contracts/operations-provenance.json +11 -0
- package/assets/launch/application.server.ts.txt +13 -0
- package/assets/launch/auth-client.ts.txt +4 -0
- package/assets/launch/home.tsx.txt +20 -0
- package/assets/launch/minimal-application.server.ts.txt +5 -0
- package/assets/launch/minimal-server.ts.txt +7 -0
- package/assets/launch/request-context.ts.txt +3 -0
- package/assets/launch/root.tsx.txt +27 -0
- package/assets/launch/router.tsx.txt +21 -0
- package/assets/launch/server.ts.txt +13 -0
- package/assets/launch/sign-in.tsx.txt +53 -0
- package/assets/launch/styles.css.txt +19 -0
- package/assets/security/credential-patterns.d.mts +3 -0
- package/assets/security/credential-patterns.mjs +59 -0
- package/assets/stack/api-index.ts.txt +6 -1
- package/assets/stack/event-retention.sql.txt +10 -0
- package/assets/stack/stripe.ts.txt +30 -13
- package/assets/ui/UPSTREAM.json +1 -18
- package/dist/bin.js +55 -36
- package/dist/capabilities.d.ts +1 -1
- package/dist/capability-catalog.d.ts +44 -11
- package/dist/capability-catalog.js +96 -11
- package/dist/capability-command.d.ts +2 -2
- package/dist/capability-command.js +178 -27
- package/dist/capability-editor.js +6 -5
- package/dist/capability-recipes.js +54 -6
- package/dist/cli-arguments.d.ts +2 -0
- package/dist/cli-arguments.js +101 -50
- package/dist/cli-commands.d.ts +1 -1
- package/dist/cli-commands.js +30 -6
- package/dist/cli-errors.d.ts +18 -0
- package/dist/cli-errors.js +63 -0
- package/dist/cli-output.d.ts +22 -0
- package/dist/cli-output.js +42 -7
- package/dist/command-runner.d.ts +1 -0
- package/dist/command-runner.js +88 -0
- package/dist/command-schema.d.ts +16 -0
- package/dist/command-schema.js +390 -21
- package/dist/completion.d.ts +2 -0
- package/dist/completion.js +201 -0
- package/dist/composition.d.ts +35 -0
- package/dist/composition.js +28 -0
- package/dist/contracts/cli-transport.d.ts +217 -0
- package/dist/contracts/cli-transport.js +167 -0
- package/dist/contracts/deployment.d.ts +282 -0
- package/dist/contracts/deployment.js +234 -0
- package/dist/contracts/environment-file.d.ts +7 -0
- package/dist/contracts/environment-file.js +112 -0
- package/dist/contracts/environment-transport.d.ts +79 -0
- package/dist/contracts/environment-transport.js +110 -0
- package/dist/contracts/runtime-logs-transport.d.ts +127 -0
- package/dist/contracts/runtime-logs-transport.js +50 -0
- package/dist/contracts/source-bundle.d.ts +11 -0
- package/dist/contracts/source-bundle.js +197 -0
- package/dist/contracts/source-profile.d.ts +4 -0
- package/dist/contracts/source-profile.js +5 -0
- package/dist/contracts/staging-transport.d.ts +79 -0
- package/dist/contracts/staging-transport.js +43 -0
- package/dist/dependencies.d.ts +10 -4
- package/dist/dependencies.js +17 -54
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/launch.d.ts +21 -0
- package/dist/launch.js +250 -0
- package/dist/platform-command.d.ts +9 -0
- package/dist/platform-command.js +584 -0
- package/dist/platform-environment.d.ts +18 -0
- package/dist/platform-environment.js +257 -0
- package/dist/platform-operations.d.ts +26 -0
- package/dist/platform-operations.js +155 -0
- package/dist/platform-source.d.ts +8 -0
- package/dist/platform-source.js +111 -0
- package/dist/platform-state.d.ts +13 -0
- package/dist/platform-state.js +207 -0
- package/dist/platforms/tanstack.d.ts +8 -0
- package/dist/platforms/tanstack.js +155 -0
- package/dist/registry/options.js +34 -31
- package/dist/registry/resolve.js +2 -0
- package/dist/registry/usage.d.ts +4 -1
- package/dist/registry/usage.js +58 -4
- package/dist/scaffold/documentation.js +17 -48
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/workspace.js +11 -7
- package/dist/stack-registry.d.ts +2 -4
- package/dist/stack-registry.js +1 -11
- package/dist/standard.js +21 -6
- package/dist/transaction.js +28 -3
- package/dist/ui-command.d.ts +4 -2
- package/dist/ui-command.js +79 -38
- package/dist/ui-project.d.ts +2 -0
- package/dist/ui-project.js +38 -8
- package/dist/util.js +40 -61
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/capabilities.md +22 -88
- package/docs/software-factory.md +189 -16
- package/docs/stack-standard.md +6 -18
- package/docs/ui.md +9 -22
- package/docs/verification.md +6 -1067
- package/package.json +33 -22
- package/assets/ui/native/_controls.tsx +0 -521
- package/assets/ui/native/_core.tsx +0 -118
- package/assets/ui/native/_data.tsx +0 -200
- package/assets/ui/native/_display.tsx +0 -453
- package/assets/ui/native/_feedback.tsx +0 -242
- package/assets/ui/native/_legacy-dialog.tsx +0 -38
- package/assets/ui/native/_motion.tsx +0 -520
- package/assets/ui/native/_overlay.tsx +0 -402
- package/assets/ui/native/_selection.tsx +0 -366
- package/assets/ui/native/accordion.tsx +0 -1
- package/assets/ui/native/alert-dialog.tsx +0 -11
- package/assets/ui/native/alert.tsx +0 -1
- package/assets/ui/native/aspect-ratio.tsx +0 -1
- package/assets/ui/native/attachment.tsx +0 -8
- package/assets/ui/native/avatar.tsx +0 -8
- package/assets/ui/native/badge.tsx +0 -1
- package/assets/ui/native/breadcrumb.tsx +0 -9
- package/assets/ui/native/bubble.tsx +0 -1
- package/assets/ui/native/button-group.tsx +0 -1
- package/assets/ui/native/button.tsx +0 -86
- package/assets/ui/native/calendar.tsx +0 -170
- package/assets/ui/native/card.tsx +0 -44
- package/assets/ui/native/carousel.tsx +0 -1
- package/assets/ui/native/chart.tsx +0 -193
- package/assets/ui/native/checkbox.tsx +0 -1
- package/assets/ui/native/code-block.tsx +0 -137
- package/assets/ui/native/collapsible.tsx +0 -1
- package/assets/ui/native/combobox.tsx +0 -1
- package/assets/ui/native/command.tsx +0 -11
- package/assets/ui/native/context-menu.tsx +0 -16
- package/assets/ui/native/data-table.tsx +0 -1
- package/assets/ui/native/date-picker.tsx +0 -43
- package/assets/ui/native/dialog.tsx +0 -15
- package/assets/ui/native/direction.tsx +0 -1
- package/assets/ui/native/drawer.tsx +0 -10
- package/assets/ui/native/dropdown-menu.tsx +0 -16
- package/assets/ui/native/empty.tsx +0 -8
- package/assets/ui/native/field.tsx +0 -13
- package/assets/ui/native/hover-card.tsx +0 -1
- package/assets/ui/native/input-group.tsx +0 -8
- package/assets/ui/native/input-otp.tsx +0 -1
- package/assets/ui/native/input.tsx +0 -28
- package/assets/ui/native/item.tsx +0 -12
- package/assets/ui/native/kbd.tsx +0 -1
- package/assets/ui/native/label.tsx +0 -4
- package/assets/ui/native/layout.tsx +0 -26
- package/assets/ui/native/marker.tsx +0 -1
- package/assets/ui/native/menubar.tsx +0 -17
- package/assets/ui/native/message-scroller.tsx +0 -6
- package/assets/ui/native/message.tsx +0 -10
- package/assets/ui/native/native-select.tsx +0 -1
- package/assets/ui/native/navigation-menu.tsx +0 -10
- package/assets/ui/native/pagination.tsx +0 -9
- package/assets/ui/native/popover.tsx +0 -1
- package/assets/ui/native/progress.tsx +0 -1
- package/assets/ui/native/questionnaire.tsx +0 -130
- package/assets/ui/native/radio-group.tsx +0 -1
- package/assets/ui/native/registry.json +0 -1103
- package/assets/ui/native/resizable.tsx +0 -1
- package/assets/ui/native/scroll-area.tsx +0 -1
- package/assets/ui/native/select.tsx +0 -11
- package/assets/ui/native/separator.tsx +0 -1
- package/assets/ui/native/sheet.tsx +0 -10
- package/assets/ui/native/sidebar.tsx +0 -22
- package/assets/ui/native/skeleton.tsx +0 -1
- package/assets/ui/native/slider.tsx +0 -1
- package/assets/ui/native/spinner.tsx +0 -1
- package/assets/ui/native/switch.tsx +0 -1
- package/assets/ui/native/table.tsx +0 -10
- package/assets/ui/native/tabs.tsx +0 -1
- package/assets/ui/native/text.tsx +0 -20
- package/assets/ui/native/textarea.tsx +0 -1
- package/assets/ui/native/theme-switcher.tsx +0 -22
- package/assets/ui/native/toast.tsx +0 -11
- package/assets/ui/native/toggle-group.tsx +0 -1
- package/assets/ui/native/toggle.tsx +0 -1
- package/assets/ui/native/tooltip.tsx +0 -1
- package/assets/ui/native/trace.tsx +0 -20
- package/assets/ui/native/typography.tsx +0 -15
- package/assets/ui/theme-storage.ts +0 -25
- package/assets/ui/theme.tsx +0 -66
- package/dist/platforms/mobile.d.ts +0 -2
- package/dist/platforms/mobile.js +0 -137
- package/dist/scaffold/expo-runtime.d.ts +0 -3
- package/dist/scaffold/expo-runtime.js +0 -42
- package/dist/scaffold/native-ui.d.ts +0 -2
- package/dist/scaffold/native-ui.js +0 -74
- package/docs/anhedral-stack.md +0 -7
- package/docs/native-ui.md +0 -102
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useState, useEffect, useRef, type ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
View,
|
|
4
|
-
Image,
|
|
5
|
-
ActivityIndicator,
|
|
6
|
-
Animated,
|
|
7
|
-
AccessibilityInfo,
|
|
8
|
-
type ImageProps,
|
|
9
|
-
type ViewProps,
|
|
10
|
-
type TextProps,
|
|
11
|
-
} from 'react-native';
|
|
12
|
-
import { useTheme } from '../theme';
|
|
13
|
-
import { Box, LabelText, Muted, Surface, row, monospace } from './_core';
|
|
14
|
-
import { Button, type ButtonProps } from './button';
|
|
15
|
-
|
|
16
|
-
export function Alert({
|
|
17
|
-
variant = 'default',
|
|
18
|
-
style,
|
|
19
|
-
...props
|
|
20
|
-
}: ViewProps & { variant?: 'default' | 'destructive' }) {
|
|
21
|
-
const { colors } = useTheme();
|
|
22
|
-
return (
|
|
23
|
-
<Surface
|
|
24
|
-
accessibilityRole="alert"
|
|
25
|
-
{...props}
|
|
26
|
-
style={[
|
|
27
|
-
{ borderColor: variant === 'destructive' ? colors.destructive : colors.border },
|
|
28
|
-
style,
|
|
29
|
-
]}
|
|
30
|
-
/>
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
export const AlertTitle = ({ style, ...props }: TextProps) => (
|
|
34
|
-
<LabelText accessibilityRole="header" {...props} style={[{ fontWeight: '600' }, style]} />
|
|
35
|
-
);
|
|
36
|
-
export const AlertDescription = Muted;
|
|
37
|
-
export function AspectRatio({ ratio = 1, style, ...props }: ViewProps & { ratio?: number }) {
|
|
38
|
-
return (
|
|
39
|
-
<View
|
|
40
|
-
{...props}
|
|
41
|
-
style={[
|
|
42
|
-
{ aspectRatio: Number.isFinite(ratio) && ratio > 0 ? ratio : 1, width: '100%' },
|
|
43
|
-
style,
|
|
44
|
-
]}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
export function Badge({
|
|
49
|
-
variant = 'default',
|
|
50
|
-
children,
|
|
51
|
-
style,
|
|
52
|
-
...props
|
|
53
|
-
}: ViewProps & { variant?: 'default' | 'secondary' | 'destructive' | 'outline' }) {
|
|
54
|
-
const { colors } = useTheme();
|
|
55
|
-
const filled = variant !== 'outline';
|
|
56
|
-
const backgroundColor =
|
|
57
|
-
variant === 'destructive'
|
|
58
|
-
? colors.destructive
|
|
59
|
-
: variant === 'secondary'
|
|
60
|
-
? colors.secondary
|
|
61
|
-
: colors.primary;
|
|
62
|
-
return (
|
|
63
|
-
<View
|
|
64
|
-
{...props}
|
|
65
|
-
style={[
|
|
66
|
-
{
|
|
67
|
-
alignSelf: 'flex-start',
|
|
68
|
-
paddingHorizontal: 8,
|
|
69
|
-
paddingVertical: 2,
|
|
70
|
-
borderRadius: 12,
|
|
71
|
-
borderWidth: 1,
|
|
72
|
-
borderColor: filled ? backgroundColor : colors.border,
|
|
73
|
-
backgroundColor: filled ? backgroundColor : colors.background,
|
|
74
|
-
},
|
|
75
|
-
style,
|
|
76
|
-
]}
|
|
77
|
-
>
|
|
78
|
-
<LabelText
|
|
79
|
-
style={{
|
|
80
|
-
color:
|
|
81
|
-
filled && variant !== 'secondary' ? colors['primary-foreground'] : colors.foreground,
|
|
82
|
-
fontSize: 12,
|
|
83
|
-
}}
|
|
84
|
-
>
|
|
85
|
-
{children}
|
|
86
|
-
</LabelText>
|
|
87
|
-
</View>
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
const AvatarContext = createContext({ loaded: false, setLoaded: (_value: boolean) => {} });
|
|
91
|
-
export function Avatar({ children, style, ...props }: ViewProps) {
|
|
92
|
-
const [loaded, setLoaded] = useState(false);
|
|
93
|
-
const { colors } = useTheme();
|
|
94
|
-
return (
|
|
95
|
-
<AvatarContext.Provider value={{ loaded, setLoaded }}>
|
|
96
|
-
<View
|
|
97
|
-
{...props}
|
|
98
|
-
style={[
|
|
99
|
-
{
|
|
100
|
-
width: 40,
|
|
101
|
-
height: 40,
|
|
102
|
-
borderRadius: 20,
|
|
103
|
-
overflow: 'hidden',
|
|
104
|
-
alignItems: 'center',
|
|
105
|
-
justifyContent: 'center',
|
|
106
|
-
backgroundColor: colors.muted,
|
|
107
|
-
},
|
|
108
|
-
style,
|
|
109
|
-
]}
|
|
110
|
-
>
|
|
111
|
-
{children}
|
|
112
|
-
</View>
|
|
113
|
-
</AvatarContext.Provider>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
export function AvatarImage({ onLoad, onError, source, style, ...props }: ImageProps) {
|
|
117
|
-
const { loaded, setLoaded } = useContext(AvatarContext);
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
setLoaded(false);
|
|
120
|
-
}, [source, setLoaded]);
|
|
121
|
-
return (
|
|
122
|
-
<Image
|
|
123
|
-
{...props}
|
|
124
|
-
source={source}
|
|
125
|
-
onLoad={(event) => {
|
|
126
|
-
setLoaded(true);
|
|
127
|
-
onLoad?.(event);
|
|
128
|
-
}}
|
|
129
|
-
onError={(event) => {
|
|
130
|
-
setLoaded(false);
|
|
131
|
-
onError?.(event);
|
|
132
|
-
}}
|
|
133
|
-
accessibilityElementsHidden={!loaded}
|
|
134
|
-
style={[
|
|
135
|
-
{ position: 'absolute', width: '100%', height: '100%', opacity: loaded ? 1 : 0 },
|
|
136
|
-
style,
|
|
137
|
-
]}
|
|
138
|
-
/>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
export function AvatarFallback(props: TextProps) {
|
|
142
|
-
return useContext(AvatarContext).loaded ? null : <LabelText {...props} />;
|
|
143
|
-
}
|
|
144
|
-
export const AvatarBadge = Badge;
|
|
145
|
-
export const AvatarGroup = ({ style, ...props }: ViewProps) => (
|
|
146
|
-
<Box {...props} style={row(style)} />
|
|
147
|
-
);
|
|
148
|
-
export const AvatarGroupCount = Badge;
|
|
149
|
-
export function Separator({
|
|
150
|
-
orientation = 'horizontal',
|
|
151
|
-
decorative = true,
|
|
152
|
-
style,
|
|
153
|
-
...props
|
|
154
|
-
}: ViewProps & { orientation?: 'horizontal' | 'vertical'; decorative?: boolean }) {
|
|
155
|
-
const { colors } = useTheme();
|
|
156
|
-
return (
|
|
157
|
-
<View
|
|
158
|
-
accessible={!decorative}
|
|
159
|
-
accessibilityLabel={decorative ? undefined : 'Separator'}
|
|
160
|
-
{...props}
|
|
161
|
-
style={[
|
|
162
|
-
{ backgroundColor: colors.border },
|
|
163
|
-
orientation === 'horizontal'
|
|
164
|
-
? { height: 1, alignSelf: 'stretch' }
|
|
165
|
-
: { width: 1, alignSelf: 'stretch' },
|
|
166
|
-
style,
|
|
167
|
-
]}
|
|
168
|
-
/>
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
export const ButtonGroup = ({
|
|
172
|
-
orientation = 'horizontal',
|
|
173
|
-
style,
|
|
174
|
-
...props
|
|
175
|
-
}: ViewProps & { orientation?: 'horizontal' | 'vertical' }) => (
|
|
176
|
-
<Box
|
|
177
|
-
{...props}
|
|
178
|
-
style={[{ flexDirection: orientation === 'horizontal' ? 'row' : 'column', gap: 2 }, style]}
|
|
179
|
-
/>
|
|
180
|
-
);
|
|
181
|
-
export const ButtonGroupText = LabelText;
|
|
182
|
-
export const ButtonGroupSeparator = Separator;
|
|
183
|
-
export const Empty = ({ style, ...props }: ViewProps) => (
|
|
184
|
-
<Surface {...props} style={[{ alignItems: 'center', padding: 24 }, style]} />
|
|
185
|
-
);
|
|
186
|
-
export const EmptyHeader = Box;
|
|
187
|
-
export const EmptyTitle = AlertTitle;
|
|
188
|
-
export const EmptyDescription = Muted;
|
|
189
|
-
export const EmptyContent = Box;
|
|
190
|
-
export const EmptyMedia = Box;
|
|
191
|
-
export const Item = Surface;
|
|
192
|
-
export const ItemGroup = Box;
|
|
193
|
-
export const ItemContent = Box;
|
|
194
|
-
export const ItemTitle = AlertTitle;
|
|
195
|
-
export const ItemDescription = Muted;
|
|
196
|
-
export const ItemActions = ({ style, ...props }: ViewProps) => (
|
|
197
|
-
<Box {...props} style={row(style)} />
|
|
198
|
-
);
|
|
199
|
-
export const ItemMedia = Box;
|
|
200
|
-
export const ItemHeader = Box;
|
|
201
|
-
export const ItemFooter = ItemActions;
|
|
202
|
-
export const ItemSeparator = Separator;
|
|
203
|
-
export const Kbd = ({ style, ...props }: TextProps) => {
|
|
204
|
-
const { colors } = useTheme();
|
|
205
|
-
return (
|
|
206
|
-
<LabelText
|
|
207
|
-
{...props}
|
|
208
|
-
style={[
|
|
209
|
-
{
|
|
210
|
-
backgroundColor: colors.muted,
|
|
211
|
-
fontFamily: monospace,
|
|
212
|
-
paddingHorizontal: 6,
|
|
213
|
-
borderRadius: 4,
|
|
214
|
-
},
|
|
215
|
-
style,
|
|
216
|
-
]}
|
|
217
|
-
/>
|
|
218
|
-
);
|
|
219
|
-
};
|
|
220
|
-
export const KbdGroup = ItemActions;
|
|
221
|
-
export const Typography = LabelText;
|
|
222
|
-
export const TypographyH1 = ({ style, ...props }: TextProps) => (
|
|
223
|
-
<LabelText
|
|
224
|
-
accessibilityRole="header"
|
|
225
|
-
{...props}
|
|
226
|
-
style={[{ fontSize: 32, lineHeight: 40, fontWeight: '700' }, style]}
|
|
227
|
-
/>
|
|
228
|
-
);
|
|
229
|
-
export const TypographyH2 = ({ style, ...props }: TextProps) => (
|
|
230
|
-
<TypographyH1 {...props} style={[{ fontSize: 26, lineHeight: 34 }, style]} />
|
|
231
|
-
);
|
|
232
|
-
export const TypographyH3 = ({ style, ...props }: TextProps) => (
|
|
233
|
-
<TypographyH1 {...props} style={[{ fontSize: 22, lineHeight: 30 }, style]} />
|
|
234
|
-
);
|
|
235
|
-
export const TypographyH4 = AlertTitle;
|
|
236
|
-
export const TypographyP = LabelText;
|
|
237
|
-
export const TypographyMuted = Muted;
|
|
238
|
-
export const TypographyLead = ({ style, ...props }: TextProps) => (
|
|
239
|
-
<Muted {...props} style={[{ fontSize: 18, lineHeight: 27 }, style]} />
|
|
240
|
-
);
|
|
241
|
-
export const TypographyLarge = AlertTitle;
|
|
242
|
-
export const TypographySmall = ({ style, ...props }: TextProps) => (
|
|
243
|
-
<LabelText {...props} style={[{ fontSize: 12 }, style]} />
|
|
244
|
-
);
|
|
245
|
-
export const TypographyBlockquote = ({ style, ...props }: TextProps) => {
|
|
246
|
-
const { colors } = useTheme();
|
|
247
|
-
return (
|
|
248
|
-
<LabelText
|
|
249
|
-
{...props}
|
|
250
|
-
style={[
|
|
251
|
-
{ borderStartWidth: 2, borderColor: colors.border, paddingStart: 12, fontStyle: 'italic' },
|
|
252
|
-
style,
|
|
253
|
-
]}
|
|
254
|
-
/>
|
|
255
|
-
);
|
|
256
|
-
};
|
|
257
|
-
export const TypographyInlineCode = Kbd;
|
|
258
|
-
export const TypographyList = Box;
|
|
259
|
-
export function Progress({
|
|
260
|
-
value = 0,
|
|
261
|
-
max = 100,
|
|
262
|
-
style,
|
|
263
|
-
...props
|
|
264
|
-
}: ViewProps & { value?: number; max?: number }) {
|
|
265
|
-
const { colors } = useTheme();
|
|
266
|
-
const maximum = Number.isFinite(max) && max > 0 ? max : 100;
|
|
267
|
-
const current = Math.min(maximum, Math.max(0, Number.isFinite(value) ? value : 0));
|
|
268
|
-
return (
|
|
269
|
-
<View
|
|
270
|
-
accessible
|
|
271
|
-
accessibilityRole="progressbar"
|
|
272
|
-
accessibilityValue={{ min: 0, max: maximum, now: current }}
|
|
273
|
-
{...props}
|
|
274
|
-
style={[
|
|
275
|
-
{ height: 8, backgroundColor: colors.secondary, borderRadius: 4, overflow: 'hidden' },
|
|
276
|
-
style,
|
|
277
|
-
]}
|
|
278
|
-
>
|
|
279
|
-
<View
|
|
280
|
-
style={{
|
|
281
|
-
height: '100%',
|
|
282
|
-
width: `${(100 * current) / maximum}%`,
|
|
283
|
-
backgroundColor: colors.primary,
|
|
284
|
-
}}
|
|
285
|
-
/>
|
|
286
|
-
</View>
|
|
287
|
-
);
|
|
288
|
-
}
|
|
289
|
-
export function Spinner({
|
|
290
|
-
size = 'small',
|
|
291
|
-
...props
|
|
292
|
-
}: React.ComponentProps<typeof ActivityIndicator>) {
|
|
293
|
-
const { colors } = useTheme();
|
|
294
|
-
return (
|
|
295
|
-
<ActivityIndicator
|
|
296
|
-
accessibilityLabel="Loading"
|
|
297
|
-
accessibilityRole="progressbar"
|
|
298
|
-
color={colors.primary}
|
|
299
|
-
size={size}
|
|
300
|
-
{...props}
|
|
301
|
-
/>
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
export function Skeleton({ style, ...props }: ViewProps) {
|
|
305
|
-
const { colors } = useTheme();
|
|
306
|
-
const opacity = useRef(new Animated.Value(1)).current;
|
|
307
|
-
useEffect(() => {
|
|
308
|
-
let active = true;
|
|
309
|
-
let animation: Animated.CompositeAnimation | undefined;
|
|
310
|
-
const update = (reduce: boolean) => {
|
|
311
|
-
animation?.stop();
|
|
312
|
-
opacity.setValue(1);
|
|
313
|
-
if (!reduce && active) {
|
|
314
|
-
animation = Animated.loop(
|
|
315
|
-
Animated.sequence([
|
|
316
|
-
Animated.timing(opacity, { toValue: 0.4, duration: 800, useNativeDriver: true }),
|
|
317
|
-
Animated.timing(opacity, { toValue: 1, duration: 800, useNativeDriver: true }),
|
|
318
|
-
]),
|
|
319
|
-
);
|
|
320
|
-
animation.start();
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
void AccessibilityInfo.isReduceMotionEnabled()
|
|
324
|
-
.then((reduce) => {
|
|
325
|
-
if (active) update(reduce);
|
|
326
|
-
})
|
|
327
|
-
.catch(() => {
|
|
328
|
-
/* Keep the static placeholder if the native preference is unavailable. */
|
|
329
|
-
});
|
|
330
|
-
const subscription = AccessibilityInfo.addEventListener('reduceMotionChanged', update);
|
|
331
|
-
return () => {
|
|
332
|
-
active = false;
|
|
333
|
-
animation?.stop();
|
|
334
|
-
subscription.remove();
|
|
335
|
-
};
|
|
336
|
-
}, [opacity]);
|
|
337
|
-
return (
|
|
338
|
-
<Animated.View
|
|
339
|
-
accessibilityLabel="Loading content"
|
|
340
|
-
{...props}
|
|
341
|
-
style={[{ minHeight: 20, backgroundColor: colors.muted, borderRadius: 6, opacity }, style]}
|
|
342
|
-
/>
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
export const Breadcrumb = ({ style, ...props }: ViewProps) => (
|
|
346
|
-
<Box accessibilityLabel="Breadcrumb" {...props} style={row(style)} />
|
|
347
|
-
);
|
|
348
|
-
export const BreadcrumbList = ItemActions;
|
|
349
|
-
export const BreadcrumbItem = Box;
|
|
350
|
-
export const BreadcrumbLink = (props: ButtonProps) => (
|
|
351
|
-
<Button variant="link" {...props} accessibilityRole="link" />
|
|
352
|
-
);
|
|
353
|
-
export const BreadcrumbPage = ({ style, ...props }: TextProps) => (
|
|
354
|
-
<LabelText
|
|
355
|
-
{...props}
|
|
356
|
-
accessibilityState={{ selected: true }}
|
|
357
|
-
style={[{ fontWeight: '600' }, style]}
|
|
358
|
-
/>
|
|
359
|
-
);
|
|
360
|
-
export const BreadcrumbSeparator = () => <Muted accessibilityElementsHidden>›</Muted>;
|
|
361
|
-
export const BreadcrumbEllipsis = () => <Muted accessibilityLabel="More breadcrumb items">…</Muted>;
|
|
362
|
-
export const Bubble = ({
|
|
363
|
-
side = 'start',
|
|
364
|
-
style,
|
|
365
|
-
...props
|
|
366
|
-
}: ViewProps & { side?: 'start' | 'end' }) => {
|
|
367
|
-
const { colors } = useTheme();
|
|
368
|
-
return (
|
|
369
|
-
<Surface
|
|
370
|
-
{...props}
|
|
371
|
-
style={[
|
|
372
|
-
{
|
|
373
|
-
alignSelf: side === 'end' ? 'flex-end' : 'flex-start',
|
|
374
|
-
backgroundColor: side === 'end' ? colors.secondary : colors.muted,
|
|
375
|
-
maxWidth: '90%',
|
|
376
|
-
},
|
|
377
|
-
style,
|
|
378
|
-
]}
|
|
379
|
-
/>
|
|
380
|
-
);
|
|
381
|
-
};
|
|
382
|
-
export const BubbleContent = Box;
|
|
383
|
-
export const BubbleActions = ItemActions;
|
|
384
|
-
export const BubbleHeader = Box;
|
|
385
|
-
export const BubbleFooter = Box;
|
|
386
|
-
export const Marker = ({ style, ...props }: ViewProps) => <Box {...props} style={row(style)} />;
|
|
387
|
-
export const MarkerContent = Muted;
|
|
388
|
-
export const MarkerIcon = Box;
|
|
389
|
-
export const Message = ({
|
|
390
|
-
from = 'assistant',
|
|
391
|
-
style,
|
|
392
|
-
...props
|
|
393
|
-
}: ViewProps & { from?: 'user' | 'assistant' | 'system' }) => (
|
|
394
|
-
<Box {...props} style={[{ alignItems: from === 'user' ? 'flex-end' : 'stretch' }, style]} />
|
|
395
|
-
);
|
|
396
|
-
export const MessageContent = Box;
|
|
397
|
-
export const MessageHeader = ItemActions;
|
|
398
|
-
export const MessageFooter = ItemActions;
|
|
399
|
-
export const MessageActions = ItemActions;
|
|
400
|
-
export const MessageAction = Button;
|
|
401
|
-
export const MessageAvatar = Avatar;
|
|
402
|
-
export const MessageTimestamp = Muted;
|
|
403
|
-
export function Attachment({
|
|
404
|
-
name,
|
|
405
|
-
uri,
|
|
406
|
-
progress,
|
|
407
|
-
onRemove,
|
|
408
|
-
onOpen,
|
|
409
|
-
children,
|
|
410
|
-
}: {
|
|
411
|
-
name: string;
|
|
412
|
-
uri?: string;
|
|
413
|
-
progress?: number;
|
|
414
|
-
onRemove?: () => void;
|
|
415
|
-
onOpen?: () => void;
|
|
416
|
-
children?: ReactNode;
|
|
417
|
-
}) {
|
|
418
|
-
return (
|
|
419
|
-
<Surface>
|
|
420
|
-
{uri && (
|
|
421
|
-
<Image
|
|
422
|
-
source={{ uri }}
|
|
423
|
-
accessibilityLabel={name}
|
|
424
|
-
style={{ width: 80, height: 80, borderRadius: 6 }}
|
|
425
|
-
/>
|
|
426
|
-
)}
|
|
427
|
-
<Button
|
|
428
|
-
variant="ghost"
|
|
429
|
-
onPress={onOpen}
|
|
430
|
-
disabled={!onOpen}
|
|
431
|
-
accessibilityLabel={`Open ${name}`}
|
|
432
|
-
>
|
|
433
|
-
{name}
|
|
434
|
-
</Button>
|
|
435
|
-
{progress !== undefined && (
|
|
436
|
-
<Progress value={progress} accessibilityLabel={`Uploading ${name}`} />
|
|
437
|
-
)}
|
|
438
|
-
{children}
|
|
439
|
-
{onRemove && (
|
|
440
|
-
<Button variant="ghost" onPress={onRemove} accessibilityLabel={`Remove ${name}`}>
|
|
441
|
-
Remove
|
|
442
|
-
</Button>
|
|
443
|
-
)}
|
|
444
|
-
</Surface>
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
export const AttachmentGroup = ItemActions;
|
|
448
|
-
export const AttachmentPreview = ({ style, ...props }: ImageProps) => (
|
|
449
|
-
<Image {...props} style={[{ width: 80, height: 80 }, style]} />
|
|
450
|
-
);
|
|
451
|
-
export const AttachmentName = LabelText;
|
|
452
|
-
export const AttachmentMetadata = Muted;
|
|
453
|
-
export const AttachmentActions = ItemActions;
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, useEffect, useRef, useState, type ReactNode } from 'react';
|
|
2
|
-
import { ScrollView, View, AccessibilityInfo, type ViewProps } from 'react-native';
|
|
3
|
-
import { Box, LabelText, Muted, Surface, row } from './_core';
|
|
4
|
-
import { Button, type ButtonProps } from './button';
|
|
5
|
-
import { OverlayRoot, OverlayTrigger, OverlayContent } from './_overlay';
|
|
6
|
-
export type ToastMessage = {
|
|
7
|
-
id?: string;
|
|
8
|
-
title: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
duration?: number;
|
|
11
|
-
action?: { label: string; onPress: () => void };
|
|
12
|
-
};
|
|
13
|
-
const ToastContext = createContext<{
|
|
14
|
-
messages: (ToastMessage & { id: string })[];
|
|
15
|
-
toast: (message: ToastMessage) => string;
|
|
16
|
-
dismiss: (id?: string) => void;
|
|
17
|
-
} | null>(null);
|
|
18
|
-
export function ToastProvider({ children }: { children: ReactNode }) {
|
|
19
|
-
const [messages, set] = useState<(ToastMessage & { id: string })[]>([]);
|
|
20
|
-
const counter = useRef(0);
|
|
21
|
-
const dismiss = (id?: string) =>
|
|
22
|
-
set((before) => (id ? before.filter((item) => item.id !== id) : []));
|
|
23
|
-
const toast = (message: ToastMessage) => {
|
|
24
|
-
const id = message.id ?? `toast-${++counter.current}`;
|
|
25
|
-
set((before) => [...before.filter((item) => item.id !== id), { ...message, id }]);
|
|
26
|
-
AccessibilityInfo.announceForAccessibility(
|
|
27
|
-
[message.title, message.description].filter(Boolean).join('. '),
|
|
28
|
-
);
|
|
29
|
-
return id;
|
|
30
|
-
};
|
|
31
|
-
return (
|
|
32
|
-
<ToastContext.Provider value={{ messages, toast, dismiss }}>{children}</ToastContext.Provider>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
export function useToast() {
|
|
36
|
-
const value = useContext(ToastContext);
|
|
37
|
-
if (!value) throw Error('useToast requires ToastProvider.');
|
|
38
|
-
return value;
|
|
39
|
-
}
|
|
40
|
-
export function Toast({ message }: { message: ToastMessage & { id: string } }) {
|
|
41
|
-
const { dismiss } = useToast();
|
|
42
|
-
const latest = useRef(dismiss);
|
|
43
|
-
latest.current = dismiss;
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
const duration = message.duration ?? 5000;
|
|
46
|
-
if (!Number.isFinite(duration) || duration <= 0) return;
|
|
47
|
-
const timer = setTimeout(() => latest.current(message.id), duration);
|
|
48
|
-
return () => clearTimeout(timer);
|
|
49
|
-
}, [message.id, message.duration]);
|
|
50
|
-
return (
|
|
51
|
-
<Surface accessibilityRole="alert" accessibilityLiveRegion="polite">
|
|
52
|
-
<ToastTitle>{message.title}</ToastTitle>
|
|
53
|
-
{message.description && <ToastDescription>{message.description}</ToastDescription>}
|
|
54
|
-
{message.action && (
|
|
55
|
-
<Button
|
|
56
|
-
onPress={() => {
|
|
57
|
-
message.action?.onPress();
|
|
58
|
-
dismiss(message.id);
|
|
59
|
-
}}
|
|
60
|
-
>
|
|
61
|
-
{message.action.label}
|
|
62
|
-
</Button>
|
|
63
|
-
)}
|
|
64
|
-
<Button
|
|
65
|
-
variant="ghost"
|
|
66
|
-
accessibilityLabel={`Dismiss ${message.title}`}
|
|
67
|
-
onPress={() => dismiss(message.id)}
|
|
68
|
-
>
|
|
69
|
-
Dismiss
|
|
70
|
-
</Button>
|
|
71
|
-
</Surface>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
export function Toaster(props: ViewProps) {
|
|
75
|
-
const { messages } = useToast();
|
|
76
|
-
return (
|
|
77
|
-
<Box {...props}>
|
|
78
|
-
{messages.map((message) => (
|
|
79
|
-
<Toast key={message.id} message={message} />
|
|
80
|
-
))}
|
|
81
|
-
</Box>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
export const ToastViewport = Toaster;
|
|
85
|
-
export const ToastTitle = ({ style, ...props }: React.ComponentProps<typeof LabelText>) => (
|
|
86
|
-
<LabelText {...props} style={[{ fontWeight: '600' }, style]} />
|
|
87
|
-
);
|
|
88
|
-
export const ToastDescription = Muted;
|
|
89
|
-
export const ToastAction = Button;
|
|
90
|
-
export function ToastClose({
|
|
91
|
-
id,
|
|
92
|
-
children = 'Dismiss',
|
|
93
|
-
...props
|
|
94
|
-
}: Omit<ButtonProps, 'children'> & { id: string; children?: ReactNode }) {
|
|
95
|
-
const { dismiss } = useToast();
|
|
96
|
-
return (
|
|
97
|
-
<Button {...props} onPress={() => dismiss(id)}>
|
|
98
|
-
{children}
|
|
99
|
-
</Button>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
const SidebarContext = createContext<{ open: boolean; setOpen: (value: boolean) => void } | null>(
|
|
103
|
-
null,
|
|
104
|
-
);
|
|
105
|
-
export function SidebarProvider({
|
|
106
|
-
open,
|
|
107
|
-
defaultOpen = false,
|
|
108
|
-
onOpenChange,
|
|
109
|
-
children,
|
|
110
|
-
}: {
|
|
111
|
-
open?: boolean;
|
|
112
|
-
defaultOpen?: boolean;
|
|
113
|
-
onOpenChange?: (open: boolean) => void;
|
|
114
|
-
children: ReactNode;
|
|
115
|
-
}) {
|
|
116
|
-
const [internal, setInternal] = useState(defaultOpen);
|
|
117
|
-
const selected = open ?? internal;
|
|
118
|
-
const setOpen = (value: boolean) => {
|
|
119
|
-
if (open === undefined) setInternal(value);
|
|
120
|
-
onOpenChange?.(value);
|
|
121
|
-
};
|
|
122
|
-
return (
|
|
123
|
-
<SidebarContext.Provider value={{ open: selected, setOpen }}>
|
|
124
|
-
<OverlayRoot open={selected} onOpenChange={setOpen}>
|
|
125
|
-
{children}
|
|
126
|
-
</OverlayRoot>
|
|
127
|
-
</SidebarContext.Provider>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
export function useSidebar() {
|
|
131
|
-
const state = useContext(SidebarContext);
|
|
132
|
-
if (!state) throw Error('Sidebar requires SidebarProvider.');
|
|
133
|
-
return { ...state, toggleSidebar: () => state.setOpen(!state.open) };
|
|
134
|
-
}
|
|
135
|
-
export const Sidebar = (props: React.ComponentProps<typeof OverlayContent>) => (
|
|
136
|
-
<OverlayContent {...props} side="left" />
|
|
137
|
-
);
|
|
138
|
-
export const SidebarTrigger = ({
|
|
139
|
-
children = 'Menu',
|
|
140
|
-
...props
|
|
141
|
-
}: Omit<ButtonProps, 'children'> & { children?: ReactNode }) => (
|
|
142
|
-
<OverlayTrigger accessibilityLabel="Toggle sidebar" {...props}>
|
|
143
|
-
{children}
|
|
144
|
-
</OverlayTrigger>
|
|
145
|
-
);
|
|
146
|
-
export const SidebarInset = Box;
|
|
147
|
-
export const SidebarHeader = Box;
|
|
148
|
-
export const SidebarFooter = Box;
|
|
149
|
-
export const SidebarContent = ScrollView;
|
|
150
|
-
export const SidebarGroup = Box;
|
|
151
|
-
export const SidebarGroupContent = Box;
|
|
152
|
-
export const SidebarGroupLabel = Muted;
|
|
153
|
-
export const SidebarMenu = Box;
|
|
154
|
-
export const SidebarMenuItem = Box;
|
|
155
|
-
export const SidebarMenuButton = ({ isActive, ...props }: ButtonProps & { isActive?: boolean }) => (
|
|
156
|
-
<Button
|
|
157
|
-
variant={isActive ? 'secondary' : 'ghost'}
|
|
158
|
-
{...props}
|
|
159
|
-
accessibilityState={{ selected: !!isActive, disabled: !!props.disabled }}
|
|
160
|
-
/>
|
|
161
|
-
);
|
|
162
|
-
export const SidebarMenuAction = Button;
|
|
163
|
-
export const SidebarMenuBadge = Muted;
|
|
164
|
-
export const SidebarSeparator = () => <View style={{ height: 8 }} />;
|
|
165
|
-
export const SidebarMenuSub = Box;
|
|
166
|
-
export const SidebarMenuSubItem = Box;
|
|
167
|
-
export const SidebarMenuSubButton = SidebarMenuButton;
|
|
168
|
-
const ScrollerContext = createContext<{
|
|
169
|
-
bottom: boolean;
|
|
170
|
-
setBottom: (value: boolean) => void;
|
|
171
|
-
scroll: React.RefObject<ScrollView | null>;
|
|
172
|
-
} | null>(null);
|
|
173
|
-
export function MessageScroller(props: ViewProps) {
|
|
174
|
-
const [bottom, setBottom] = useState(true);
|
|
175
|
-
const scroll = useRef<ScrollView>(null);
|
|
176
|
-
return (
|
|
177
|
-
<ScrollerContext.Provider value={{ bottom, setBottom, scroll }}>
|
|
178
|
-
<Box {...props} />
|
|
179
|
-
</ScrollerContext.Provider>
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
export function MessageScrollerContent({
|
|
183
|
-
onScroll,
|
|
184
|
-
onContentSizeChange,
|
|
185
|
-
children,
|
|
186
|
-
...props
|
|
187
|
-
}: React.ComponentProps<typeof ScrollView>) {
|
|
188
|
-
const state = useContext(ScrollerContext);
|
|
189
|
-
if (!state) throw Error('MessageScrollerContent requires MessageScroller.');
|
|
190
|
-
const frame = useRef<number | undefined>(undefined);
|
|
191
|
-
useEffect(
|
|
192
|
-
() => () => {
|
|
193
|
-
if (frame.current !== undefined) cancelAnimationFrame(frame.current);
|
|
194
|
-
},
|
|
195
|
-
[],
|
|
196
|
-
);
|
|
197
|
-
return (
|
|
198
|
-
<ScrollView
|
|
199
|
-
{...props}
|
|
200
|
-
ref={state.scroll}
|
|
201
|
-
scrollEventThrottle={16}
|
|
202
|
-
onScroll={(event) => {
|
|
203
|
-
const { layoutMeasurement, contentOffset, contentSize } = event.nativeEvent;
|
|
204
|
-
state.setBottom(contentOffset.y + layoutMeasurement.height >= contentSize.height - 40);
|
|
205
|
-
onScroll?.(event);
|
|
206
|
-
}}
|
|
207
|
-
onContentSizeChange={(width, height) => {
|
|
208
|
-
if (state.bottom) {
|
|
209
|
-
if (frame.current !== undefined) cancelAnimationFrame(frame.current);
|
|
210
|
-
frame.current = requestAnimationFrame(() =>
|
|
211
|
-
state.scroll.current?.scrollToEnd({ animated: false }),
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
onContentSizeChange?.(width, height);
|
|
215
|
-
}}
|
|
216
|
-
>
|
|
217
|
-
{children}
|
|
218
|
-
</ScrollView>
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
export function MessageScrollerScrollButton({
|
|
222
|
-
children = 'Latest messages',
|
|
223
|
-
...props
|
|
224
|
-
}: Omit<ButtonProps, 'children'> & { children?: ReactNode }) {
|
|
225
|
-
const state = useContext(ScrollerContext);
|
|
226
|
-
if (!state || state.bottom) return null;
|
|
227
|
-
return (
|
|
228
|
-
<Button
|
|
229
|
-
accessibilityLabel="Scroll to latest messages"
|
|
230
|
-
{...props}
|
|
231
|
-
onPress={() => {
|
|
232
|
-
state.scroll.current?.scrollToEnd({ animated: false });
|
|
233
|
-
state.setBottom(true);
|
|
234
|
-
}}
|
|
235
|
-
>
|
|
236
|
-
{children}
|
|
237
|
-
</Button>
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
export const MessageScrollerFooter = ({ style, ...props }: ViewProps) => (
|
|
241
|
-
<Box {...props} style={row(style)} />
|
|
242
|
-
);
|