anhedral 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +29 -38
  2. package/assets/stack/ai-schema.ts.txt +5 -0
  3. package/assets/stack/ai.ts.txt +30 -0
  4. package/assets/stack/api-index.ts.txt +15 -0
  5. package/assets/stack/auth-features.ts.txt +4 -0
  6. package/assets/stack/auth-journal.json.txt +13 -0
  7. package/assets/stack/auth-migration.sql.txt +53 -0
  8. package/assets/stack/auth-routes.ts.txt +11 -0
  9. package/assets/stack/auth-schema.ts.txt +64 -0
  10. package/assets/stack/auth-snapshot.json.txt +346 -0
  11. package/assets/stack/auth.ts.txt +32 -0
  12. package/assets/stack/billing-mode.ts.txt +8 -0
  13. package/assets/stack/billing-schema.ts.txt +11 -0
  14. package/assets/stack/desktop.rs.txt +21 -0
  15. package/assets/stack/entitlement-guard.ts.txt +32 -0
  16. package/assets/stack/entitlements.ts.txt +8 -0
  17. package/assets/stack/events-schema.ts.txt +12 -0
  18. package/assets/stack/events.ts.txt +59 -0
  19. package/assets/stack/mobile-auth.ts.txt +25 -0
  20. package/assets/stack/mobile-billing.tsx.txt +63 -0
  21. package/assets/stack/mobile-session.tsx.txt +83 -0
  22. package/assets/stack/native-button.tsx.txt +108 -0
  23. package/assets/stack/native-global.css.txt +4 -0
  24. package/assets/stack/native-lib-utils.ts.txt +5 -0
  25. package/assets/stack/native-metro.config.js.txt +6 -0
  26. package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
  27. package/assets/stack/native-tailwind.config.js.txt +73 -0
  28. package/assets/stack/native-text.tsx.txt +89 -0
  29. package/assets/stack/purchases.ts.txt +65 -0
  30. package/assets/stack/revenuecat.ts.txt +88 -0
  31. package/assets/stack/rtc-schema.ts.txt +10 -0
  32. package/assets/stack/rtc.ts.txt +122 -0
  33. package/assets/stack/security.ts.txt +31 -0
  34. package/assets/stack/storage.ts.txt +36 -0
  35. package/assets/stack/stripe.ts.txt +126 -0
  36. package/assets/stack/web-sign-in.tsx.txt +51 -0
  37. package/assets/ui/LICENSE.react-native-reusables +21 -0
  38. package/assets/ui/UPSTREAM.json +7 -1
  39. package/assets/ui/catalog.json +891 -0
  40. package/assets/ui/extensions/registry.json +6 -0
  41. package/assets/ui/native/_controls.tsx +521 -0
  42. package/assets/ui/native/_core.tsx +118 -0
  43. package/assets/ui/native/_data.tsx +200 -0
  44. package/assets/ui/native/_display.tsx +453 -0
  45. package/assets/ui/native/_feedback.tsx +242 -0
  46. package/assets/ui/native/_legacy-dialog.tsx +38 -0
  47. package/assets/ui/native/_motion.tsx +520 -0
  48. package/assets/ui/native/_overlay.tsx +402 -0
  49. package/assets/ui/native/_selection.tsx +366 -0
  50. package/assets/ui/native/accordion.tsx +1 -0
  51. package/assets/ui/native/alert-dialog.tsx +11 -0
  52. package/assets/ui/native/alert.tsx +1 -0
  53. package/assets/ui/native/aspect-ratio.tsx +1 -0
  54. package/assets/ui/native/attachment.tsx +8 -0
  55. package/assets/ui/native/avatar.tsx +8 -0
  56. package/assets/ui/native/badge.tsx +1 -0
  57. package/assets/ui/native/breadcrumb.tsx +9 -0
  58. package/assets/ui/native/bubble.tsx +1 -0
  59. package/assets/ui/native/button-group.tsx +1 -0
  60. package/assets/ui/native/button.tsx +2 -1
  61. package/assets/ui/native/calendar.tsx +170 -0
  62. package/assets/ui/native/card.tsx +16 -5
  63. package/assets/ui/native/carousel.tsx +1 -0
  64. package/assets/ui/native/chart.tsx +193 -0
  65. package/assets/ui/native/checkbox.tsx +1 -0
  66. package/assets/ui/native/code-block.tsx +137 -0
  67. package/assets/ui/native/collapsible.tsx +1 -0
  68. package/assets/ui/native/combobox.tsx +1 -0
  69. package/assets/ui/native/command.tsx +11 -0
  70. package/assets/ui/native/context-menu.tsx +16 -0
  71. package/assets/ui/native/data-table.tsx +1 -0
  72. package/assets/ui/native/date-picker.tsx +43 -0
  73. package/assets/ui/native/dialog.tsx +14 -74
  74. package/assets/ui/native/direction.tsx +1 -0
  75. package/assets/ui/native/drawer.tsx +10 -0
  76. package/assets/ui/native/dropdown-menu.tsx +16 -0
  77. package/assets/ui/native/empty.tsx +8 -0
  78. package/assets/ui/native/field.tsx +13 -0
  79. package/assets/ui/native/hover-card.tsx +1 -0
  80. package/assets/ui/native/input-group.tsx +8 -0
  81. package/assets/ui/native/input-otp.tsx +1 -0
  82. package/assets/ui/native/input.tsx +2 -1
  83. package/assets/ui/native/item.tsx +12 -0
  84. package/assets/ui/native/kbd.tsx +1 -0
  85. package/assets/ui/native/marker.tsx +1 -0
  86. package/assets/ui/native/menubar.tsx +17 -0
  87. package/assets/ui/native/message-scroller.tsx +6 -0
  88. package/assets/ui/native/message.tsx +10 -0
  89. package/assets/ui/native/native-select.tsx +1 -0
  90. package/assets/ui/native/navigation-menu.tsx +10 -0
  91. package/assets/ui/native/pagination.tsx +9 -0
  92. package/assets/ui/native/popover.tsx +1 -0
  93. package/assets/ui/native/progress.tsx +1 -0
  94. package/assets/ui/native/questionnaire.tsx +130 -0
  95. package/assets/ui/native/radio-group.tsx +1 -0
  96. package/assets/ui/native/registry.json +1103 -0
  97. package/assets/ui/native/resizable.tsx +1 -0
  98. package/assets/ui/native/scroll-area.tsx +1 -0
  99. package/assets/ui/native/select.tsx +11 -0
  100. package/assets/ui/native/separator.tsx +1 -0
  101. package/assets/ui/native/sheet.tsx +10 -0
  102. package/assets/ui/native/sidebar.tsx +22 -0
  103. package/assets/ui/native/skeleton.tsx +1 -0
  104. package/assets/ui/native/slider.tsx +1 -0
  105. package/assets/ui/native/spinner.tsx +1 -0
  106. package/assets/ui/native/switch.tsx +1 -0
  107. package/assets/ui/native/table.tsx +10 -0
  108. package/assets/ui/native/tabs.tsx +1 -0
  109. package/assets/ui/native/textarea.tsx +1 -0
  110. package/assets/ui/native/toast.tsx +11 -0
  111. package/assets/ui/native/toggle-group.tsx +1 -0
  112. package/assets/ui/native/toggle.tsx +1 -0
  113. package/assets/ui/native/tooltip.tsx +1 -0
  114. package/assets/ui/native/trace.tsx +20 -0
  115. package/assets/ui/native/typography.tsx +15 -0
  116. package/dist/bin.js +7 -12
  117. package/dist/capabilities.d.ts +4 -33
  118. package/dist/capabilities.js +2 -66
  119. package/dist/capability-catalog.d.ts +83 -0
  120. package/dist/capability-catalog.js +121 -0
  121. package/dist/capability-command.d.ts +3 -0
  122. package/dist/capability-command.js +188 -0
  123. package/dist/capability-editor.d.ts +17 -0
  124. package/dist/capability-editor.js +97 -0
  125. package/dist/capability-recipes.d.ts +4 -0
  126. package/dist/capability-recipes.js +520 -0
  127. package/dist/capability-references.d.ts +4 -0
  128. package/dist/capability-references.js +7 -0
  129. package/dist/cli-commands.d.ts +1 -2
  130. package/dist/cli-commands.js +10 -104
  131. package/dist/cli-output.d.ts +1 -2
  132. package/dist/cli-output.js +6 -251
  133. package/dist/command-schema.js +39 -322
  134. package/dist/dependencies.d.ts +29 -6
  135. package/dist/dependencies.js +61 -14
  136. package/dist/index.d.ts +1 -42
  137. package/dist/index.js +1 -27
  138. package/dist/platforms/mobile.js +1 -20
  139. package/dist/platforms/web.d.ts +1 -1
  140. package/dist/platforms/web.js +27 -75
  141. package/dist/project-config.d.ts +2 -13
  142. package/dist/project-config.js +10 -82
  143. package/dist/registry/options.js +1 -5
  144. package/dist/registry/resolve.d.ts +1 -1
  145. package/dist/registry/resolve.js +2 -10
  146. package/dist/registry/usage.js +3 -9
  147. package/dist/scaffold/backend.js +0 -3
  148. package/dist/scaffold/database.js +2 -1
  149. package/dist/scaffold/documentation.js +82 -20
  150. package/dist/scaffold/expo-runtime.js +3 -4
  151. package/dist/scaffold/native-ui.js +12 -7
  152. package/dist/scaffold/stack-documentation.js +1 -1
  153. package/dist/scaffold/storage.d.ts +2 -0
  154. package/dist/scaffold/storage.js +21 -0
  155. package/dist/scaffold/workspace.js +26 -21
  156. package/dist/stack-registry.d.ts +2 -8
  157. package/dist/stack-registry.js +11 -87
  158. package/dist/standard.js +1 -11
  159. package/dist/ui-catalog.d.ts +26 -0
  160. package/dist/ui-catalog.js +31 -0
  161. package/dist/ui-command.d.ts +3 -0
  162. package/dist/ui-command.js +219 -0
  163. package/dist/ui-project.d.ts +22 -0
  164. package/dist/ui-project.js +110 -0
  165. package/dist/version.d.ts +1 -1
  166. package/dist/version.js +1 -1
  167. package/docs/anhedral-stack.md +4 -20
  168. package/docs/capabilities.md +110 -0
  169. package/docs/native-ui.md +102 -0
  170. package/docs/software-factory.md +16 -44
  171. package/docs/stack-standard.md +11 -60
  172. package/docs/ui.md +33 -0
  173. package/docs/verification.md +191 -0
  174. package/package.json +19 -18
  175. package/dist/access.d.ts +0 -10
  176. package/dist/access.js +0 -93
  177. package/dist/auth-schema-snapshot.d.ts +0 -346
  178. package/dist/auth-schema-snapshot.js +0 -347
  179. package/dist/auth-schema.d.ts +0 -1
  180. package/dist/auth-schema.js +0 -57
  181. package/dist/capability-contract.d.ts +0 -47
  182. package/dist/capability-contract.js +0 -129
  183. package/dist/catalog-model.d.ts +0 -24
  184. package/dist/catalog-model.js +0 -1
  185. package/dist/catalog-registration.d.ts +0 -16
  186. package/dist/catalog-registration.js +0 -22
  187. package/dist/catalog-snapshot.d.ts +0 -5
  188. package/dist/catalog-snapshot.js +0 -97
  189. package/dist/cli-delivery.d.ts +0 -3
  190. package/dist/cli-delivery.js +0 -112
  191. package/dist/cloudflare.d.ts +0 -25
  192. package/dist/cloudflare.js +0 -226
  193. package/dist/delivery-evidence.d.ts +0 -62
  194. package/dist/delivery-evidence.js +0 -157
  195. package/dist/delivery.d.ts +0 -82
  196. package/dist/delivery.js +0 -489
  197. package/dist/inspector-model.d.ts +0 -123
  198. package/dist/inspector-model.js +0 -1
  199. package/dist/integration-service-readers.d.ts +0 -12
  200. package/dist/integration-service-readers.js +0 -92
  201. package/dist/lifecycle-model.d.ts +0 -15
  202. package/dist/lifecycle-model.js +0 -20
  203. package/dist/lifecycle.d.ts +0 -11
  204. package/dist/lifecycle.js +0 -91
  205. package/dist/management.d.ts +0 -3
  206. package/dist/management.js +0 -47
  207. package/dist/mobile-delivery.d.ts +0 -77
  208. package/dist/mobile-delivery.js +0 -370
  209. package/dist/project-catalog.d.ts +0 -41
  210. package/dist/project-catalog.js +0 -288
  211. package/dist/project-inspector.d.ts +0 -4
  212. package/dist/project-inspector.js +0 -671
  213. package/dist/project-lifecycle.d.ts +0 -25
  214. package/dist/project-lifecycle.js +0 -57
  215. package/dist/project-state.d.ts +0 -47
  216. package/dist/project-state.js +0 -480
  217. package/dist/provider-auth.d.ts +0 -41
  218. package/dist/provider-auth.js +0 -180
  219. package/dist/provider-readiness.d.ts +0 -30
  220. package/dist/provider-readiness.js +0 -85
  221. package/dist/providers/adapters.d.ts +0 -17
  222. package/dist/providers/adapters.js +0 -103
  223. package/dist/providers/api.d.ts +0 -29
  224. package/dist/providers/api.js +0 -253
  225. package/dist/providers/config.d.ts +0 -15
  226. package/dist/providers/config.js +0 -136
  227. package/dist/providers/definitions.d.ts +0 -115
  228. package/dist/providers/definitions.js +0 -42
  229. package/dist/providers/provision.d.ts +0 -24
  230. package/dist/providers/provision.js +0 -76
  231. package/dist/providers/receipts.d.ts +0 -20
  232. package/dist/providers/receipts.js +0 -56
  233. package/dist/providers/recovery-verification.d.ts +0 -7
  234. package/dist/providers/recovery-verification.js +0 -52
  235. package/dist/providers/recovery.d.ts +0 -30
  236. package/dist/providers/recovery.js +0 -34
  237. package/dist/providers/runtime.d.ts +0 -10
  238. package/dist/providers/runtime.js +0 -234
  239. package/dist/providers/schema.d.ts +0 -28
  240. package/dist/providers/schema.js +0 -49
  241. package/dist/providers/state.d.ts +0 -55
  242. package/dist/providers/state.js +0 -283
  243. package/dist/provision.d.ts +0 -47
  244. package/dist/provision.js +0 -208
  245. package/dist/r2-service-data.d.ts +0 -2
  246. package/dist/r2-service-data.js +0 -136
  247. package/dist/readiness.d.ts +0 -23
  248. package/dist/readiness.js +0 -117
  249. package/dist/registry/add.d.ts +0 -24
  250. package/dist/registry/add.js +0 -210
  251. package/dist/registry/bootstrap.d.ts +0 -3
  252. package/dist/registry/bootstrap.js +0 -5
  253. package/dist/registry/commands.d.ts +0 -3
  254. package/dist/registry/commands.js +0 -83
  255. package/dist/registry/preview.d.ts +0 -11
  256. package/dist/registry/preview.js +0 -91
  257. package/dist/registry/receipt.d.ts +0 -3
  258. package/dist/registry/receipt.js +0 -68
  259. package/dist/repository.d.ts +0 -24
  260. package/dist/repository.js +0 -96
  261. package/dist/scaffold/auth.d.ts +0 -2
  262. package/dist/scaffold/auth.js +0 -76
  263. package/dist/scaffold/billing-config.d.ts +0 -1
  264. package/dist/scaffold/billing-config.js +0 -73
  265. package/dist/scaffold/billing-contracts.d.ts +0 -2
  266. package/dist/scaffold/billing-contracts.js +0 -48
  267. package/dist/scaffold/billing-providers.d.ts +0 -1
  268. package/dist/scaffold/billing-providers.js +0 -249
  269. package/dist/scaffold/billing-schema.d.ts +0 -1
  270. package/dist/scaffold/billing-schema.js +0 -34
  271. package/dist/scaffold/billing-security.d.ts +0 -1
  272. package/dist/scaffold/billing-security.js +0 -46
  273. package/dist/scaffold/billing-server.d.ts +0 -1
  274. package/dist/scaffold/billing-server.js +0 -139
  275. package/dist/scaffold/billing-store.d.ts +0 -1
  276. package/dist/scaffold/billing-store.js +0 -72
  277. package/dist/scaffold/billing.d.ts +0 -2
  278. package/dist/scaffold/billing.js +0 -208
  279. package/dist/scaffold/expo-auth.d.ts +0 -3
  280. package/dist/scaffold/expo-auth.js +0 -203
  281. package/dist/scaffold/expo-billing.d.ts +0 -3
  282. package/dist/scaffold/expo-billing.js +0 -257
  283. package/dist/scaffold/integrations.d.ts +0 -2
  284. package/dist/scaffold/integrations.js +0 -11
  285. package/dist/scaffold/managed-email.d.ts +0 -3
  286. package/dist/scaffold/managed-email.js +0 -47
  287. package/dist/scaffold/password-reset.d.ts +0 -1
  288. package/dist/scaffold/password-reset.js +0 -99
  289. package/dist/scaffold/private-files.d.ts +0 -2
  290. package/dist/scaffold/private-files.js +0 -78
  291. package/dist/scaffold/web-billing.d.ts +0 -2
  292. package/dist/scaffold/web-billing.js +0 -48
  293. package/dist/service-deletion.d.ts +0 -29
  294. package/dist/service-deletion.js +0 -195
  295. package/dist/service-descriptor.d.ts +0 -10
  296. package/dist/service-descriptor.js +0 -71
  297. package/dist/service-model.d.ts +0 -49
  298. package/dist/service-model.js +0 -8
  299. package/dist/service-operations.d.ts +0 -29
  300. package/dist/service-operations.js +0 -48
  301. package/dist/service-readers.d.ts +0 -8
  302. package/dist/service-readers.js +0 -216
  303. package/dist/services-command.d.ts +0 -39
  304. package/dist/services-command.js +0 -96
  305. package/dist/ship.d.ts +0 -35
  306. package/dist/ship.js +0 -107
  307. package/docs/assets/anhedral-stack-light.png +0 -0
  308. package/docs/assets/anhedral-stack.png +0 -0
@@ -0,0 +1,200 @@
1
+ import { useMemo, useState, type ReactNode } from 'react';
2
+ import { ScrollView, type ViewProps } from 'react-native';
3
+ import { Box, LabelText, Muted, row, useControllable } from './_core';
4
+ import { Button, type ButtonProps } from './button';
5
+ import { Input } from './input';
6
+ import { Checkbox } from './_controls';
7
+ export const ScrollArea = ({ children, ...props }: React.ComponentProps<typeof ScrollView>) => (
8
+ <ScrollView {...props}>{children}</ScrollView>
9
+ );
10
+ export const ScrollBar = () => null; // Native ScrollView owns the platform scrollbar.
11
+ export const Table = ({ children, ...props }: React.ComponentProps<typeof ScrollView>) => (
12
+ <ScrollView horizontal accessibilityLabel="Table" {...props}>
13
+ <Box>{children}</Box>
14
+ </ScrollView>
15
+ );
16
+ export const TableHeader = Box;
17
+ export const TableBody = Box;
18
+ export const TableFooter = Box;
19
+ export const TableRow = ({ style, ...props }: ViewProps) => (
20
+ <Box {...props} style={row([{ flexWrap: 'nowrap' }, style])} />
21
+ );
22
+ export const TableHead = ({ style, ...props }: React.ComponentProps<typeof LabelText>) => (
23
+ <LabelText
24
+ accessibilityRole="header"
25
+ {...props}
26
+ style={[{ fontWeight: '600', minWidth: 120, padding: 8 }, style]}
27
+ />
28
+ );
29
+ export const TableCell = ({ style, ...props }: ViewProps) => (
30
+ <Box {...props} style={[{ minWidth: 120, padding: 8, flex: 1 }, style]} />
31
+ );
32
+ export const TableCaption = Muted;
33
+ export const Pagination = ({ style, ...props }: ViewProps) => (
34
+ <Box accessibilityLabel="Pagination" {...props} style={row(style)} />
35
+ );
36
+ export const PaginationContent = ({ style, ...props }: ViewProps) => (
37
+ <Box {...props} style={row(style)} />
38
+ );
39
+ export const PaginationItem = Box;
40
+ export const PaginationLink = ({ isActive, ...props }: ButtonProps & { isActive?: boolean }) => (
41
+ <Button
42
+ variant={isActive ? 'outline' : 'ghost'}
43
+ {...props}
44
+ accessibilityState={{ selected: !!isActive, disabled: !!props.disabled }}
45
+ />
46
+ );
47
+ export const PaginationPrevious = ({
48
+ children = 'Previous',
49
+ ...props
50
+ }: Omit<ButtonProps, 'children'> & { children?: ReactNode }) => (
51
+ <Button {...props} accessibilityLabel={props.accessibilityLabel ?? 'Previous page'}>
52
+ {children}
53
+ </Button>
54
+ );
55
+ export const PaginationNext = ({
56
+ children = 'Next',
57
+ ...props
58
+ }: Omit<ButtonProps, 'children'> & { children?: ReactNode }) => (
59
+ <Button {...props} accessibilityLabel={props.accessibilityLabel ?? 'Next page'}>
60
+ {children}
61
+ </Button>
62
+ );
63
+ export const PaginationEllipsis = () => <Muted accessibilityLabel="More pages">…</Muted>;
64
+ export type DataColumn<T> = {
65
+ id: string;
66
+ header: string;
67
+ accessor: (row: T) => string | number | boolean | null;
68
+ cell?: (row: T) => ReactNode;
69
+ sortable?: boolean;
70
+ };
71
+ export function DataTable<T>({
72
+ data,
73
+ columns,
74
+ getRowId,
75
+ pageSize = 10,
76
+ selectedRowIds,
77
+ defaultSelectedRowIds = [],
78
+ onSelectionChange,
79
+ searchable = true,
80
+ emptyText = 'No results',
81
+ }: {
82
+ data: readonly T[];
83
+ columns: readonly DataColumn<T>[];
84
+ getRowId: (row: T) => string;
85
+ pageSize?: number;
86
+ selectedRowIds?: string[];
87
+ defaultSelectedRowIds?: string[];
88
+ onSelectionChange?: (ids: string[]) => void;
89
+ searchable?: boolean;
90
+ emptyText?: string;
91
+ }) {
92
+ const [query, setQuery] = useState('');
93
+ const [sort, setSort] = useState<{ id: string; descending: boolean } | null>(null);
94
+ const [page, setPage] = useState(0);
95
+ const [selection, setSelection] = useControllable(
96
+ selectedRowIds,
97
+ defaultSelectedRowIds,
98
+ onSelectionChange,
99
+ );
100
+ const size = Math.max(1, Math.floor(pageSize) || 10);
101
+ const filtered = useMemo(() => {
102
+ const rows = data.filter((item) =>
103
+ columns.some((column) =>
104
+ String(column.accessor(item) ?? '')
105
+ .toLocaleLowerCase()
106
+ .includes(query.toLocaleLowerCase()),
107
+ ),
108
+ );
109
+ const column = sort && columns.find((item) => item.id === sort.id);
110
+ return column
111
+ ? [...rows].sort((a, b) => {
112
+ const first = column.accessor(a);
113
+ const second = column.accessor(b);
114
+ return (
115
+ (typeof first === 'number' && typeof second === 'number'
116
+ ? first - second
117
+ : String(first ?? '').localeCompare(String(second ?? ''))) *
118
+ (sort?.descending ? -1 : 1)
119
+ );
120
+ })
121
+ : rows;
122
+ }, [data, columns, query, sort]);
123
+ const pages = Math.max(1, Math.ceil(filtered.length / size));
124
+ const current = Math.min(page, pages - 1);
125
+ const visible = filtered.slice(current * size, (current + 1) * size);
126
+ return (
127
+ <Box>
128
+ {searchable && (
129
+ <Input
130
+ accessibilityLabel="Filter rows"
131
+ value={query}
132
+ onChangeText={(next) => {
133
+ setQuery(next);
134
+ setPage(0);
135
+ }}
136
+ />
137
+ )}
138
+ <Table>
139
+ <TableHeader>
140
+ <TableRow>
141
+ {onSelectionChange && <TableHead>Selected</TableHead>}
142
+ {columns.map((column) => (
143
+ <Button
144
+ key={column.id}
145
+ variant="ghost"
146
+ disabled={column.sortable === false}
147
+ accessibilityLabel={`${column.header}${sort?.id === column.id ? (sort.descending ? ', descending' : ', ascending') : ', unsorted'}`}
148
+ onPress={() => {
149
+ setSort({
150
+ id: column.id,
151
+ descending: sort?.id === column.id && !sort.descending,
152
+ });
153
+ setPage(0);
154
+ }}
155
+ >
156
+ {column.header}
157
+ </Button>
158
+ ))}
159
+ </TableRow>
160
+ </TableHeader>
161
+ <TableBody>
162
+ {visible.map((item) => {
163
+ const id = getRowId(item);
164
+ return (
165
+ <TableRow key={id}>
166
+ {onSelectionChange && (
167
+ <Checkbox
168
+ accessibilityLabel={`Select row ${id}`}
169
+ checked={selection.includes(id)}
170
+ onCheckedChange={(checked) =>
171
+ setSelection(
172
+ checked ? [...selection, id] : selection.filter((key) => key !== id),
173
+ )
174
+ }
175
+ />
176
+ )}
177
+ {columns.map((column) => (
178
+ <TableCell
179
+ key={column.id}
180
+ accessibilityLabel={`${column.header}: ${String(column.accessor(item) ?? '')}`}
181
+ >
182
+ {column.cell?.(item) ?? String(column.accessor(item) ?? '')}
183
+ </TableCell>
184
+ ))}
185
+ </TableRow>
186
+ );
187
+ })}
188
+ {!visible.length && <Muted accessibilityLiveRegion="polite">{emptyText}</Muted>}
189
+ </TableBody>
190
+ </Table>
191
+ <Pagination>
192
+ <PaginationPrevious disabled={current === 0} onPress={() => setPage(current - 1)} />
193
+ <LabelText accessibilityLiveRegion="polite">
194
+ {current + 1} / {pages}
195
+ </LabelText>
196
+ <PaginationNext disabled={current === pages - 1} onPress={() => setPage(current + 1)} />
197
+ </Pagination>
198
+ </Box>
199
+ );
200
+ }
@@ -0,0 +1,453 @@
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;