@agimon-ai/po-native-components 0.0.0-alpha.21 → 0.0.0-alpha.210

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 (195) hide show
  1. package/LICENSE +21 -149
  2. package/README.md +9 -51
  3. package/dist/components/AgentAvatar.d.mts +19 -0
  4. package/dist/components/AgentAvatar.d.mts.map +1 -0
  5. package/dist/components/AgentAvatar.mjs +88 -0
  6. package/dist/components/AgentAvatar.mjs.map +1 -0
  7. package/dist/components/AnnotationSurface.d.mts +69 -0
  8. package/dist/components/AnnotationSurface.d.mts.map +1 -0
  9. package/dist/components/AnnotationSurface.mjs +431 -0
  10. package/dist/components/AnnotationSurface.mjs.map +1 -0
  11. package/dist/components/Badge.d.mts +1 -1
  12. package/dist/components/Badge.mjs +1 -1
  13. package/dist/components/Button.mjs +3 -3
  14. package/dist/components/Button.mjs.map +1 -1
  15. package/dist/components/CodeBlock.d.mts +3 -1
  16. package/dist/components/CodeBlock.d.mts.map +1 -1
  17. package/dist/components/CodeBlock.mjs +42 -47
  18. package/dist/components/CodeBlock.mjs.map +1 -1
  19. package/dist/components/ComputerRow.d.mts +15 -0
  20. package/dist/components/ComputerRow.d.mts.map +1 -0
  21. package/dist/components/ComputerRow.mjs +107 -0
  22. package/dist/components/ComputerRow.mjs.map +1 -0
  23. package/dist/components/CopyButton.d.mts +13 -0
  24. package/dist/components/CopyButton.d.mts.map +1 -0
  25. package/dist/components/CopyButton.mjs +49 -0
  26. package/dist/components/CopyButton.mjs.map +1 -0
  27. package/dist/components/CountBadge.d.mts +15 -0
  28. package/dist/components/CountBadge.d.mts.map +1 -0
  29. package/dist/components/CountBadge.mjs +49 -0
  30. package/dist/components/CountBadge.mjs.map +1 -0
  31. package/dist/components/CtaCard.d.mts +19 -0
  32. package/dist/components/CtaCard.d.mts.map +1 -0
  33. package/dist/components/CtaCard.mjs +92 -0
  34. package/dist/components/CtaCard.mjs.map +1 -0
  35. package/dist/components/Dialog.d.mts +2 -2
  36. package/dist/components/Dialog.d.mts.map +1 -1
  37. package/dist/components/Dialog.mjs +16 -10
  38. package/dist/components/Dialog.mjs.map +1 -1
  39. package/dist/components/Dot.d.mts +1 -1
  40. package/dist/components/Dot.mjs +2 -2
  41. package/dist/components/DropdownMenu.d.mts +3 -1
  42. package/dist/components/DropdownMenu.d.mts.map +1 -1
  43. package/dist/components/DropdownMenu.mjs +21 -14
  44. package/dist/components/DropdownMenu.mjs.map +1 -1
  45. package/dist/components/EmptyState.d.mts +31 -3
  46. package/dist/components/EmptyState.d.mts.map +1 -1
  47. package/dist/components/EmptyState.mjs +303 -29
  48. package/dist/components/EmptyState.mjs.map +1 -1
  49. package/dist/components/FileList.d.mts +48 -0
  50. package/dist/components/FileList.d.mts.map +1 -0
  51. package/dist/components/FileList.mjs +737 -0
  52. package/dist/components/FileList.mjs.map +1 -0
  53. package/dist/components/FilePreview.d.mts +33 -0
  54. package/dist/components/FilePreview.d.mts.map +1 -0
  55. package/dist/components/FilePreview.mjs +102 -0
  56. package/dist/components/FilePreview.mjs.map +1 -0
  57. package/dist/components/FileViewer.d.mts +57 -0
  58. package/dist/components/FileViewer.d.mts.map +1 -0
  59. package/dist/components/FileViewer.mjs +345 -0
  60. package/dist/components/FileViewer.mjs.map +1 -0
  61. package/dist/components/HashlineLines.d.mts +13 -0
  62. package/dist/components/HashlineLines.d.mts.map +1 -0
  63. package/dist/components/HashlineLines.mjs +153 -0
  64. package/dist/components/HashlineLines.mjs.map +1 -0
  65. package/dist/components/HostFilter.d.mts +17 -0
  66. package/dist/components/HostFilter.d.mts.map +1 -0
  67. package/dist/components/HostFilter.mjs +68 -0
  68. package/dist/components/HostFilter.mjs.map +1 -0
  69. package/dist/components/HostTag.d.mts +7 -0
  70. package/dist/components/HostTag.d.mts.map +1 -0
  71. package/dist/components/HostTag.mjs +48 -0
  72. package/dist/components/HostTag.mjs.map +1 -0
  73. package/dist/components/InfoStrip.d.mts +9 -0
  74. package/dist/components/InfoStrip.d.mts.map +1 -0
  75. package/dist/components/InfoStrip.mjs +53 -0
  76. package/dist/components/InfoStrip.mjs.map +1 -0
  77. package/dist/components/Input.d.mts +3 -1
  78. package/dist/components/Input.d.mts.map +1 -1
  79. package/dist/components/Input.mjs +4 -3
  80. package/dist/components/Input.mjs.map +1 -1
  81. package/dist/components/Label.mjs +1 -1
  82. package/dist/components/LinkText.d.mts +13 -0
  83. package/dist/components/LinkText.d.mts.map +1 -0
  84. package/dist/components/LinkText.mjs +32 -0
  85. package/dist/components/LinkText.mjs.map +1 -0
  86. package/dist/components/List.d.mts.map +1 -1
  87. package/dist/components/List.mjs +50 -11
  88. package/dist/components/List.mjs.map +1 -1
  89. package/dist/components/LiveDuration.d.mts +30 -0
  90. package/dist/components/LiveDuration.d.mts.map +1 -0
  91. package/dist/components/LiveDuration.mjs +67 -0
  92. package/dist/components/LiveDuration.mjs.map +1 -0
  93. package/dist/components/LoadingState.d.mts +17 -0
  94. package/dist/components/LoadingState.d.mts.map +1 -0
  95. package/dist/components/LoadingState.mjs +90 -0
  96. package/dist/components/LoadingState.mjs.map +1 -0
  97. package/dist/components/Markdown.d.mts +24 -2
  98. package/dist/components/Markdown.d.mts.map +1 -1
  99. package/dist/components/Markdown.mjs +356 -27
  100. package/dist/components/Markdown.mjs.map +1 -1
  101. package/dist/components/MessageItem.d.mts +10 -15
  102. package/dist/components/MessageItem.d.mts.map +1 -1
  103. package/dist/components/MessageItem.mjs +94 -68
  104. package/dist/components/MessageItem.mjs.map +1 -1
  105. package/dist/components/NativeShellState.d.mts +30 -0
  106. package/dist/components/NativeShellState.d.mts.map +1 -0
  107. package/dist/components/NativeShellState.mjs +61 -0
  108. package/dist/components/NativeShellState.mjs.map +1 -0
  109. package/dist/components/RailItem.d.mts +13 -0
  110. package/dist/components/RailItem.d.mts.map +1 -0
  111. package/dist/components/RailItem.mjs +61 -0
  112. package/dist/components/RailItem.mjs.map +1 -0
  113. package/dist/components/ReferenceChip.d.mts +18 -0
  114. package/dist/components/ReferenceChip.d.mts.map +1 -0
  115. package/dist/components/ReferenceChip.mjs +38 -0
  116. package/dist/components/ReferenceChip.mjs.map +1 -0
  117. package/dist/components/SectionLabel.mjs +1 -1
  118. package/dist/components/SeekBar.d.mts +17 -0
  119. package/dist/components/SeekBar.d.mts.map +1 -0
  120. package/dist/components/SeekBar.mjs +97 -0
  121. package/dist/components/SeekBar.mjs.map +1 -0
  122. package/dist/components/Select.d.mts +39 -0
  123. package/dist/components/Select.d.mts.map +1 -0
  124. package/dist/components/Select.mjs +288 -0
  125. package/dist/components/Select.mjs.map +1 -0
  126. package/dist/components/Sheet.d.mts +17 -2
  127. package/dist/components/Sheet.d.mts.map +1 -1
  128. package/dist/components/Sheet.mjs +34 -11
  129. package/dist/components/Sheet.mjs.map +1 -1
  130. package/dist/components/SheetFrame.mjs +149 -28
  131. package/dist/components/SheetFrame.mjs.map +1 -1
  132. package/dist/components/SheetList.d.mts +14 -0
  133. package/dist/components/SheetList.d.mts.map +1 -0
  134. package/dist/components/SheetList.mjs +34 -0
  135. package/dist/components/SheetList.mjs.map +1 -0
  136. package/dist/components/ShowMore.d.mts +10 -0
  137. package/dist/components/ShowMore.d.mts.map +1 -0
  138. package/dist/components/ShowMore.mjs +44 -0
  139. package/dist/components/ShowMore.mjs.map +1 -0
  140. package/dist/components/Spinner.d.mts +1 -1
  141. package/dist/components/StatusBadge.d.mts +1 -1
  142. package/dist/components/Switch.d.mts +14 -0
  143. package/dist/components/Switch.d.mts.map +1 -0
  144. package/dist/components/Switch.mjs +37 -0
  145. package/dist/components/Switch.mjs.map +1 -0
  146. package/dist/components/SyntaxLine.d.mts +19 -0
  147. package/dist/components/SyntaxLine.d.mts.map +1 -0
  148. package/dist/components/SyntaxLine.mjs +134 -0
  149. package/dist/components/SyntaxLine.mjs.map +1 -0
  150. package/dist/components/Tabs.d.mts.map +1 -1
  151. package/dist/components/Tabs.mjs +8 -7
  152. package/dist/components/Tabs.mjs.map +1 -1
  153. package/dist/components/ToolPathLink.d.mts +10 -0
  154. package/dist/components/ToolPathLink.d.mts.map +1 -0
  155. package/dist/components/ToolPathLink.mjs +42 -0
  156. package/dist/components/ToolPathLink.mjs.map +1 -0
  157. package/dist/components/ToolResultImage.d.mts +21 -0
  158. package/dist/components/ToolResultImage.d.mts.map +1 -0
  159. package/dist/components/ToolResultImage.mjs +60 -0
  160. package/dist/components/ToolResultImage.mjs.map +1 -0
  161. package/dist/icons/IconColorContext.d.mts +2 -1
  162. package/dist/icons/IconColorContext.d.mts.map +1 -1
  163. package/dist/icons/IconColorContext.mjs.map +1 -1
  164. package/dist/icons/iconGlyphs.d.mts +132 -0
  165. package/dist/icons/iconGlyphs.d.mts.map +1 -1
  166. package/dist/icons/iconGlyphs.mjs +132 -0
  167. package/dist/icons/iconGlyphs.mjs.map +1 -1
  168. package/dist/icons/icons.d.mts +133 -1
  169. package/dist/icons/icons.d.mts.map +1 -1
  170. package/dist/icons/icons.mjs +35 -2
  171. package/dist/icons/icons.mjs.map +1 -1
  172. package/dist/index.d.mts +31 -7
  173. package/dist/index.mjs +36 -12
  174. package/dist/lib/fileKindLabel.mjs +17 -0
  175. package/dist/lib/fileKindLabel.mjs.map +1 -0
  176. package/dist/lib/fonts.d.mts +3 -1
  177. package/dist/lib/fonts.d.mts.map +1 -1
  178. package/dist/lib/fonts.mjs +4 -2
  179. package/dist/lib/fonts.mjs.map +1 -1
  180. package/dist/lib/insideSheet.d.mts +10 -0
  181. package/dist/lib/insideSheet.d.mts.map +1 -0
  182. package/dist/lib/markdown.mjs +310 -23
  183. package/dist/lib/markdown.mjs.map +1 -1
  184. package/dist/lib/reading.mjs +60 -0
  185. package/dist/lib/reading.mjs.map +1 -0
  186. package/dist/lib/useControllable.mjs +14 -6
  187. package/dist/lib/useControllable.mjs.map +1 -1
  188. package/dist/lib/useReadingPage.mjs +33 -0
  189. package/dist/lib/useReadingPage.mjs.map +1 -0
  190. package/dist/po-runtime-identity.json +1 -0
  191. package/dist/shell.d.mts +6 -0
  192. package/dist/shell.mjs +7 -0
  193. package/locales/vi.json +112 -0
  194. package/locales/zh-CN.json +112 -0
  195. package/package.json +43 -30
@@ -0,0 +1,737 @@
1
+ import { fontOf } from "../lib/fonts.mjs";
2
+ import { Button } from "./Button.mjs";
3
+ import { ChevronDownIcon, ChevronRightIcon, CloseIcon, FileIcon, FolderIcon, ImageIcon, SearchIcon, SlidersIcon } from "../icons/icons.mjs";
4
+ import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "./DropdownMenu.mjs";
5
+ import { EmptyState } from "./EmptyState.mjs";
6
+ import { Input } from "./Input.mjs";
7
+ import { fileKindLabel } from "../lib/fileKindLabel.mjs";
8
+ import { SegmentedControl } from "./SegmentedControl.mjs";
9
+ import { Sheet, SheetContent } from "./Sheet.mjs";
10
+ import { SheetList } from "./SheetList.mjs";
11
+ import { fileKind, isFileLayout, sizeLabel } from "@agimon-ai/po-web-components/text";
12
+ import { View } from "react-native-unistyles/components/native/View";
13
+ import { Text } from "react-native-unistyles/components/native/Text";
14
+ import { StyleSheet } from "react-native-unistyles";
15
+ import { createElement, useCallback, useEffect, useRef, useState } from "react";
16
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
17
+ import { currentLocale, useT } from "@agimon-ai/po-core/native";
18
+ import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
19
+ import { FlatList } from "react-native-unistyles/components/native/FlatList";
20
+
21
+ //#region src/components/FileList.tsx
22
+ /** A folder of files on the phone: recent rows, or a browser with layouts, filters and a swipeable selection. Presentation only. */
23
+ function FileList({ items, onOpen, loading, error, onRetry, grid = false, browser, label, emptyText }) {
24
+ const t = useT();
25
+ if (browser) return /* @__PURE__ */ jsx(FileBrowserList, {
26
+ label,
27
+ emptyText,
28
+ items,
29
+ onOpen,
30
+ loading,
31
+ error,
32
+ onRetry,
33
+ browser
34
+ });
35
+ return /* @__PURE__ */ jsxs(View, {
36
+ testID: grid ? "file-list-grid" : "file-list-recent",
37
+ style: styles.list,
38
+ children: [
39
+ error ? /* @__PURE__ */ jsx(ListFailure, {
40
+ error,
41
+ retained: items.length > 0,
42
+ onRetry
43
+ }) : null,
44
+ loading ? /* @__PURE__ */ jsx(Text, {
45
+ style: styles.meta,
46
+ children: t("nativeComponents.fileList.loading", "Loading files...")
47
+ }) : null,
48
+ !loading && !error && items.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
49
+ size: "compact",
50
+ surface: "plain",
51
+ icon: /* @__PURE__ */ jsx(FolderIcon, { size: 16 }),
52
+ title: t("nativeComponents.fileList.emptyTitle", "Nothing here yet"),
53
+ description: emptyText
54
+ }) : null,
55
+ items.map((item) => /* @__PURE__ */ jsxs(Button, {
56
+ variant: grid ? "outline" : "ghost",
57
+ size: "card",
58
+ accessibilityLabel: t("nativeComponents.fileList.open", "Open {path}", { path: item.path }),
59
+ testID: `file-${item.path}`,
60
+ onPress: () => onOpen(item.path),
61
+ style: styles.item,
62
+ children: [/* @__PURE__ */ jsx(FileIcon, {
63
+ size: 18,
64
+ color: "dim"
65
+ }), /* @__PURE__ */ jsxs(View, {
66
+ style: styles.label,
67
+ children: [
68
+ /* @__PURE__ */ jsx(Text, {
69
+ numberOfLines: 1,
70
+ style: styles.name,
71
+ children: item.name
72
+ }),
73
+ grid || item.path !== item.name ? /* @__PURE__ */ jsx(Text, {
74
+ numberOfLines: 1,
75
+ style: styles.path,
76
+ children: item.path
77
+ }) : null,
78
+ grid ? /* @__PURE__ */ jsx(Text, {
79
+ style: styles.meta,
80
+ children: t("nativeComponents.fileList.bytes", "{size} bytes", { size: item.size.toLocaleString(currentLocale()) })
81
+ }) : null
82
+ ]
83
+ })]
84
+ }, item.path))
85
+ ]
86
+ });
87
+ }
88
+ const layoutOptions = (t) => [
89
+ {
90
+ value: "tree",
91
+ label: t("nativeComponents.fileList.layout.tree", "Tree")
92
+ },
93
+ {
94
+ value: "list",
95
+ label: t("nativeComponents.fileList.layout.list", "List")
96
+ },
97
+ {
98
+ value: "grid",
99
+ label: t("nativeComponents.fileList.layout.grid", "Grid")
100
+ }
101
+ ];
102
+ const TYPES = [
103
+ "any",
104
+ "Markdown",
105
+ "Image",
106
+ "Code",
107
+ "Data",
108
+ "Document",
109
+ "Other"
110
+ ];
111
+ const modifiedOptions = (t) => [
112
+ {
113
+ value: "any",
114
+ label: t("nativeComponents.fileList.modified.any", "Any time")
115
+ },
116
+ {
117
+ value: "today",
118
+ label: t("nativeComponents.fileList.modified.today", "Today")
119
+ },
120
+ {
121
+ value: "7days",
122
+ label: t("nativeComponents.fileList.modified.7days", "Last 7 days")
123
+ },
124
+ {
125
+ value: "30days",
126
+ label: t("nativeComponents.fileList.modified.30days", "Last 30 days")
127
+ }
128
+ ];
129
+ const sortOptions = (t) => [
130
+ {
131
+ value: "name",
132
+ label: t("nativeComponents.fileList.sort.name", "Name")
133
+ },
134
+ {
135
+ value: "modified",
136
+ label: t("nativeComponents.fileList.sort.modified", "Modified")
137
+ },
138
+ {
139
+ value: "size",
140
+ label: t("nativeComponents.fileList.sort.size", "Size")
141
+ }
142
+ ];
143
+ const ROW_HEIGHT = 48;
144
+ const IMAGE_VIEWABILITY = { itemVisiblePercentThreshold: 1 };
145
+ /** Past this the dots stop reading as positions; the counter beside the name still does. */
146
+ const MAX_DOTS = 7;
147
+ const PREVIEW_HEIGHT = 320;
148
+ /** A failed read: kept files stay listed under it, as the approved RetainedContent target shows. */
149
+ function ListFailure({ error, retained, onRetry }) {
150
+ const t = useT();
151
+ return /* @__PURE__ */ jsx(EmptyState, {
152
+ size: "compact",
153
+ surface: "plain",
154
+ tone: "error",
155
+ title: retained ? t("nativeComponents.fileList.refreshFailed", "Couldn't refresh the file list") : t("nativeComponents.fileList.loadFailed", "Couldn't load the file list"),
156
+ description: retained ? t("nativeComponents.fileList.lastSeen", "These are the files Po saw last.") : error,
157
+ action: onRetry ? {
158
+ label: t("nativeComponents.fileList.retry", "Try again"),
159
+ onAction: onRetry
160
+ } : void 0
161
+ });
162
+ }
163
+ function FileBrowserList({ items, onOpen, loading, error, onRetry, browser: b, label, emptyText }) {
164
+ const t = useT();
165
+ const LAYOUTS = layoutOptions(t);
166
+ const MODIFIED = modifiedOptions(t);
167
+ const SORTS = sortOptions(t);
168
+ const grid = b.layout === "grid";
169
+ const onViewableImagesChange = b.onViewableImagesChange;
170
+ const onViewableItemsChanged = useCallback(({ viewableItems }) => {
171
+ onViewableImagesChange?.(viewableItems.flatMap(({ item, isViewable }) => isViewable && item.kind === "file" && fileKind(item.item.path) === "Image" ? [item.item.path] : []));
172
+ }, [onViewableImagesChange]);
173
+ const rows = b.layout === "tree" ? b.rows : items.map((item) => ({
174
+ kind: "file",
175
+ item,
176
+ depth: 0
177
+ }));
178
+ const files = rows.flatMap((row) => row.kind === "file" ? [row.item] : []);
179
+ const at = b.selected ? files.findIndex((file) => file.path === b.selected?.path) : -1;
180
+ const List = b.sheet ? SheetList : FlatList;
181
+ const list = /* @__PURE__ */ createElement(List, {
182
+ ...b.sheet ? { embedded: true } : {},
183
+ key: b.layout,
184
+ testID: "file-list-browser",
185
+ onViewableItemsChanged,
186
+ viewabilityConfig: IMAGE_VIEWABILITY,
187
+ data: loading ? [] : rows,
188
+ numColumns: grid ? 2 : 1,
189
+ columnWrapperStyle: grid ? styles.columns : void 0,
190
+ keyExtractor: (row) => row.kind === "dir" ? `dir:${row.path}` : row.item.path,
191
+ keyboardShouldPersistTaps: "handled",
192
+ ListHeaderComponent: /* @__PURE__ */ jsxs(Fragment$1, { children: [b.header, /* @__PURE__ */ jsxs(View, {
193
+ style: styles.head,
194
+ children: [
195
+ /* @__PURE__ */ jsx(SegmentedControl, {
196
+ accessibilityLabel: t("nativeComponents.fileList.layoutLabel", "{label} layout", { label }),
197
+ options: LAYOUTS,
198
+ value: b.layout,
199
+ onValueChange: (value) => {
200
+ if (isFileLayout(value)) b.onLayoutChange(value);
201
+ }
202
+ }),
203
+ /* @__PURE__ */ jsxs(View, {
204
+ style: styles.toolbar,
205
+ children: [/* @__PURE__ */ jsxs(View, {
206
+ style: styles.search,
207
+ children: [/* @__PURE__ */ jsx(SearchIcon, { size: 18 }), /* @__PURE__ */ jsx(Input, {
208
+ variant: "bare",
209
+ accessibilityLabel: t("nativeComponents.fileList.search", "Search {label}", { label }),
210
+ placeholder: t("nativeComponents.fileList.search", "Search {label}", { label }),
211
+ value: b.query,
212
+ onChangeText: b.onQueryChange,
213
+ style: styles.searchInput,
214
+ autoCapitalize: "none"
215
+ })]
216
+ }), /* @__PURE__ */ jsxs(DropdownMenu, { children: [/* @__PURE__ */ jsxs(DropdownMenuTrigger, {
217
+ variant: "outline",
218
+ accessibilityLabel: t("nativeComponents.fileList.filters", "Filters"),
219
+ children: [/* @__PURE__ */ jsx(SlidersIcon, {}), t("nativeComponents.fileList.filters", "Filters")]
220
+ }), /* @__PURE__ */ jsxs(DropdownMenuContent, { children: [
221
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: t("nativeComponents.fileList.typeHeading", "Type") }),
222
+ TYPES.map((type) => /* @__PURE__ */ jsx(DropdownMenuCheckboxItem, {
223
+ checked: b.type === type,
224
+ onCheckedChange: () => b.onTypeChange(type),
225
+ children: type === "any" ? t("nativeComponents.fileList.allTypes", "All types") : fileKindLabel(type, t)
226
+ }, type)),
227
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
228
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: t("nativeComponents.fileList.sort.modified", "Modified") }),
229
+ MODIFIED.map(({ value, label }) => /* @__PURE__ */ jsx(DropdownMenuCheckboxItem, {
230
+ checked: b.modified === value,
231
+ onCheckedChange: () => b.onModifiedChange(value),
232
+ children: label
233
+ }, value)),
234
+ /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
235
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: t("nativeComponents.fileList.sortHeading", "Sort") }),
236
+ SORTS.map(({ value, label }) => /* @__PURE__ */ jsx(DropdownMenuCheckboxItem, {
237
+ checked: b.sort === value,
238
+ onCheckedChange: () => b.onSortChange(value),
239
+ children: label
240
+ }, value)),
241
+ /* @__PURE__ */ jsx(DropdownMenuCheckboxItem, {
242
+ checked: b.direction === "asc",
243
+ onCheckedChange: () => b.onDirectionChange("asc"),
244
+ children: t("nativeComponents.fileList.ascending", "Ascending")
245
+ }),
246
+ /* @__PURE__ */ jsx(DropdownMenuCheckboxItem, {
247
+ checked: b.direction === "desc",
248
+ onCheckedChange: () => b.onDirectionChange("desc"),
249
+ children: t("nativeComponents.fileList.descending", "Descending")
250
+ })
251
+ ] })] })]
252
+ }),
253
+ /* @__PURE__ */ jsxs(View, {
254
+ style: styles.chips,
255
+ children: [
256
+ b.query ? /* @__PURE__ */ jsxs(Button, {
257
+ variant: "outline",
258
+ accessibilityLabel: t("nativeComponents.fileList.removeSearch", "Remove search filter"),
259
+ onPress: () => b.onQueryChange(""),
260
+ children: [t("nativeComponents.fileList.searchChip", "Search: {query}", { query: b.query }), /* @__PURE__ */ jsx(CloseIcon, {})]
261
+ }) : null,
262
+ b.type !== "any" ? /* @__PURE__ */ jsxs(Button, {
263
+ variant: "outline",
264
+ accessibilityLabel: t("nativeComponents.fileList.removeType", "Remove type filter"),
265
+ onPress: () => b.onTypeChange("any"),
266
+ children: [fileKindLabel(b.type, t), /* @__PURE__ */ jsx(CloseIcon, {})]
267
+ }) : null,
268
+ b.modified !== "any" ? /* @__PURE__ */ jsxs(Button, {
269
+ variant: "outline",
270
+ accessibilityLabel: t("nativeComponents.fileList.removeModified", "Remove modified filter"),
271
+ onPress: () => b.onModifiedChange("any"),
272
+ children: [MODIFIED.find((option) => option.value === b.modified)?.label, /* @__PURE__ */ jsx(CloseIcon, {})]
273
+ }) : null
274
+ ]
275
+ }),
276
+ error ? /* @__PURE__ */ jsx(ListFailure, {
277
+ error,
278
+ retained: items.length > 0,
279
+ onRetry
280
+ }) : null,
281
+ loading ? /* @__PURE__ */ jsx(Text, {
282
+ style: styles.meta,
283
+ children: t("nativeComponents.fileList.loading", "Loading files...")
284
+ }) : null
285
+ ]
286
+ })] }),
287
+ ListEmptyComponent: loading || error ? void 0 : b.totalCount ? /* @__PURE__ */ jsx(EmptyState, {
288
+ size: "compact",
289
+ surface: "plain",
290
+ icon: /* @__PURE__ */ jsx(SearchIcon, { size: 16 }),
291
+ title: t("nativeComponents.fileList.noMatch", "No files match"),
292
+ secondaryAction: {
293
+ label: t("nativeComponents.fileList.clearFilters", "Clear filters"),
294
+ onAction: () => {
295
+ b.onQueryChange("");
296
+ b.onTypeChange("any");
297
+ b.onModifiedChange("any");
298
+ }
299
+ },
300
+ style: styles.inset
301
+ }) : /* @__PURE__ */ jsx(EmptyState, {
302
+ size: "compact",
303
+ surface: "plain",
304
+ icon: /* @__PURE__ */ jsx(FolderIcon, { size: 16 }),
305
+ title: t("nativeComponents.fileList.emptyTitle", "Nothing here yet"),
306
+ description: emptyText,
307
+ style: styles.inset
308
+ }),
309
+ renderItem: ({ item: row }) => {
310
+ if (row.kind === "dir") return /* @__PURE__ */ jsxs(Button, {
311
+ variant: "ghost",
312
+ style: [styles.row, styles.indent(row.depth)],
313
+ accessibilityLabel: row.open ? t("nativeComponents.fileList.collapse", "Collapse {path}", { path: row.path }) : t("nativeComponents.fileList.expand", "Expand {path}", { path: row.path }),
314
+ accessibilityState: { expanded: row.open },
315
+ onPress: () => b.onToggleDirectory(row.path),
316
+ children: [
317
+ row.open ? /* @__PURE__ */ jsx(ChevronDownIcon, {}) : /* @__PURE__ */ jsx(ChevronRightIcon, {}),
318
+ /* @__PURE__ */ jsx(FolderIcon, {}),
319
+ /* @__PURE__ */ jsx(Text, {
320
+ numberOfLines: 1,
321
+ style: [styles.name, styles.label],
322
+ children: row.name
323
+ }),
324
+ /* @__PURE__ */ jsx(Text, {
325
+ style: styles.meta,
326
+ children: row.count
327
+ })
328
+ ]
329
+ });
330
+ const item = row.item;
331
+ const image = fileKind(item.path) === "Image";
332
+ const selected = b.selected?.path === item.path;
333
+ return /* @__PURE__ */ jsxs(Button, {
334
+ variant: "ghost",
335
+ size: "card",
336
+ testID: `file-${item.path}`,
337
+ accessibilityLabel: t("nativeComponents.fileList.select", "Select {path}", { path: item.path }),
338
+ accessibilityState: { selected },
339
+ onPress: () => b.onSelect(item),
340
+ style: [
341
+ grid ? styles.tile : styles.row,
342
+ selected && styles.selected,
343
+ !grid && styles.indent(row.depth)
344
+ ],
345
+ children: [
346
+ b.layout === "tree" ? /* @__PURE__ */ jsx(View, {
347
+ accessible: false,
348
+ style: styles.chevronGutter
349
+ }) : null,
350
+ grid ? /* @__PURE__ */ jsx(View, {
351
+ style: styles.thumbnail,
352
+ children: image && b.renderImage ? b.renderImage(item, false) : image ? /* @__PURE__ */ jsx(ImageIcon, { size: 28 }) : /* @__PURE__ */ jsx(FileIcon, { size: 28 })
353
+ }) : /* @__PURE__ */ jsx(View, {
354
+ style: styles.rowThumbnail,
355
+ children: image && b.renderImage ? b.renderImage(item, true) : image ? /* @__PURE__ */ jsx(ImageIcon, { size: 18 }) : /* @__PURE__ */ jsx(FileIcon, { size: 18 })
356
+ }),
357
+ /* @__PURE__ */ jsxs(View, {
358
+ style: styles.label,
359
+ children: [/* @__PURE__ */ jsx(Text, {
360
+ numberOfLines: 1,
361
+ style: styles.name,
362
+ children: item.name
363
+ }), /* @__PURE__ */ jsx(Text, {
364
+ numberOfLines: 1,
365
+ style: styles.path,
366
+ children: item.path
367
+ })]
368
+ }),
369
+ /* @__PURE__ */ jsx(Text, {
370
+ style: styles.meta,
371
+ children: sizeLabel(item.size)
372
+ })
373
+ ]
374
+ });
375
+ },
376
+ ListFooterComponent: /* @__PURE__ */ jsx(View, {
377
+ style: styles.foot,
378
+ children: /* @__PURE__ */ jsx(Text, {
379
+ style: styles.meta,
380
+ children: t("nativeComponents.fileList.count", "{shown} of {total} files", {
381
+ shown: items.length,
382
+ total: b.totalCount
383
+ })
384
+ })
385
+ })
386
+ });
387
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [list, /* @__PURE__ */ jsx(Sheet, {
388
+ open: b.selected !== void 0,
389
+ onOpenChange: (open) => {
390
+ if (!open) b.onCloseSelection();
391
+ },
392
+ children: /* @__PURE__ */ jsx(SheetContent, { children: b.selected ? /* @__PURE__ */ jsx(View, {
393
+ style: styles.foot,
394
+ children: /* @__PURE__ */ jsxs(View, {
395
+ style: styles.selection,
396
+ testID: "file-selection",
397
+ children: [
398
+ /* @__PURE__ */ jsxs(View, {
399
+ style: styles.titleRow,
400
+ children: [/* @__PURE__ */ jsx(Text, {
401
+ accessibilityRole: "header",
402
+ numberOfLines: 1,
403
+ style: [styles.name, styles.label],
404
+ children: b.selected.name
405
+ }), files.length > 1 ? /* @__PURE__ */ jsx(Text, {
406
+ accessibilityLiveRegion: "polite",
407
+ style: styles.meta,
408
+ children: t("nativeComponents.fileList.position", "{index} of {total}", {
409
+ index: Math.max(0, at) + 1,
410
+ total: files.length
411
+ })
412
+ }) : null]
413
+ }),
414
+ /* @__PURE__ */ jsx(SelectionSlides, {
415
+ files: at < 0 ? [b.selected] : files,
416
+ selected: b.selected,
417
+ onSelect: b.onSelect,
418
+ renderImage: b.renderImage
419
+ }),
420
+ /* @__PURE__ */ jsx(Text, {
421
+ numberOfLines: 2,
422
+ style: styles.path,
423
+ children: b.selected.path
424
+ }),
425
+ /* @__PURE__ */ jsxs(Text, {
426
+ style: styles.meta,
427
+ children: [
428
+ fileKindLabel(fileKind(b.selected.path), t),
429
+ " · ",
430
+ sizeLabel(b.selected.size)
431
+ ]
432
+ }),
433
+ /* @__PURE__ */ jsxs(View, {
434
+ style: styles.actions,
435
+ children: [/* @__PURE__ */ jsx(Button, {
436
+ variant: "outline",
437
+ onPress: b.onCloseSelection,
438
+ children: t("nativeComponents.fileList.close", "Close")
439
+ }), /* @__PURE__ */ jsx(Button, {
440
+ variant: "primary",
441
+ onPress: () => {
442
+ if (b.selected) {
443
+ b.onCloseSelection();
444
+ onOpen(b.selected.path);
445
+ }
446
+ },
447
+ children: t("nativeComponents.fileList.openAction", "Open")
448
+ })]
449
+ })
450
+ ]
451
+ })
452
+ }) : null })
453
+ })] });
454
+ }
455
+ /** The selected file large; swiping and the arrows select its neighbours in the list. */
456
+ function SelectionSlides({ files, selected, onSelect, renderImage }) {
457
+ const t = useT();
458
+ const index = Math.max(0, files.findIndex((file) => file.path === selected.path));
459
+ const [width, setWidth] = useState(0);
460
+ const scroller = useRef(null);
461
+ const placed = useRef(false);
462
+ useEffect(() => {
463
+ if (width === 0) return;
464
+ scroller.current?.scrollTo({
465
+ x: index * width,
466
+ animated: placed.current
467
+ });
468
+ placed.current = true;
469
+ }, [index, width]);
470
+ const step = (by) => {
471
+ const next = files[index + by];
472
+ if (next) onSelect(next);
473
+ };
474
+ return /* @__PURE__ */ jsxs(View, { children: [
475
+ /* @__PURE__ */ jsx(ScrollView, {
476
+ ref: scroller,
477
+ horizontal: true,
478
+ pagingEnabled: true,
479
+ showsHorizontalScrollIndicator: false,
480
+ onLayout: (event) => setWidth(event.nativeEvent.layout.width),
481
+ onMomentumScrollEnd: (event) => {
482
+ if (width > 0) step(Math.round(event.nativeEvent.contentOffset.x / width) - index);
483
+ },
484
+ style: styles.preview,
485
+ children: files.map((file, page) => /* @__PURE__ */ jsx(View, {
486
+ accessibilityElementsHidden: page !== index,
487
+ importantForAccessibility: page === index ? "auto" : "no-hide-descendants",
488
+ style: [styles.page, { width }],
489
+ children: Math.abs(page - index) > 1 ? null : fileKind(file.path) !== "Image" ? /* @__PURE__ */ jsx(FileIcon, { size: 28 }) : renderImage ? renderImage(file, false) : /* @__PURE__ */ jsx(ImageIcon, { size: 28 })
490
+ }, file.path))
491
+ }),
492
+ files.length > 1 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
493
+ variant: "ghost",
494
+ size: "icon-md",
495
+ accessibilityLabel: t("nativeComponents.fileList.previous", "Previous file"),
496
+ disabled: index === 0,
497
+ onPress: () => step(-1),
498
+ style: [styles.arrow, styles.previous],
499
+ children: /* @__PURE__ */ jsx(View, {
500
+ style: styles.flip,
501
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, {
502
+ size: 18,
503
+ color: "hi"
504
+ })
505
+ })
506
+ }), /* @__PURE__ */ jsx(Button, {
507
+ variant: "ghost",
508
+ size: "icon-md",
509
+ accessibilityLabel: t("nativeComponents.fileList.next", "Next file"),
510
+ disabled: index === files.length - 1,
511
+ onPress: () => step(1),
512
+ style: [styles.arrow, styles.next],
513
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, {
514
+ size: 18,
515
+ color: "hi"
516
+ })
517
+ })] }) : null,
518
+ files.length > 1 && files.length <= MAX_DOTS ? /* @__PURE__ */ jsx(View, {
519
+ accessible: false,
520
+ style: styles.dots,
521
+ children: files.map((file, page) => /* @__PURE__ */ jsx(View, { style: [styles.dot, page === index && styles.dotActive] }, file.path))
522
+ }) : null
523
+ ] });
524
+ }
525
+ const styles = StyleSheet.create((theme) => ({
526
+ head: {
527
+ gap: theme.spacing(3),
528
+ padding: theme.spacing(4),
529
+ paddingBottom: theme.spacing(3),
530
+ uni__dependencies: [0]
531
+ },
532
+ foot: {
533
+ gap: theme.spacing(3),
534
+ padding: theme.spacing(4),
535
+ paddingTop: theme.spacing(3),
536
+ uni__dependencies: [0]
537
+ },
538
+ inset: {
539
+ paddingHorizontal: theme.spacing(4),
540
+ uni__dependencies: [0]
541
+ },
542
+ toolbar: {
543
+ flexDirection: "row",
544
+ alignItems: "center",
545
+ gap: theme.spacing(2),
546
+ uni__dependencies: [0]
547
+ },
548
+ search: {
549
+ flex: 1,
550
+ minWidth: 0,
551
+ flexDirection: "row",
552
+ alignItems: "center",
553
+ gap: theme.spacing(2),
554
+ paddingHorizontal: theme.spacing(2),
555
+ borderWidth: 1,
556
+ borderColor: theme.colors.border,
557
+ borderRadius: theme.borderRadius.DEFAULT,
558
+ backgroundColor: theme.colors.deep,
559
+ uni__dependencies: [0]
560
+ },
561
+ searchInput: { flex: 1 },
562
+ chips: {
563
+ flexDirection: "row",
564
+ flexWrap: "wrap",
565
+ gap: theme.spacing(2),
566
+ uni__dependencies: [0]
567
+ },
568
+ row: {
569
+ marginHorizontal: theme.spacing(4),
570
+ marginBottom: theme.spacing(2),
571
+ minHeight: ROW_HEIGHT,
572
+ flexDirection: "row",
573
+ alignItems: "center",
574
+ justifyContent: "flex-start",
575
+ gap: theme.spacing(2),
576
+ borderWidth: 1,
577
+ borderColor: theme.colors["border-soft"],
578
+ borderRadius: theme.borderRadius.DEFAULT,
579
+ paddingVertical: theme.spacing(2),
580
+ paddingRight: theme.spacing(3),
581
+ uni__dependencies: [0]
582
+ },
583
+ indent: (depth) => ({
584
+ paddingLeft: theme.spacing(3) + depth * 16,
585
+ uni__dependencies: [0]
586
+ }),
587
+ chevronGutter: { width: 16 },
588
+ columns: {
589
+ gap: theme.spacing(2),
590
+ paddingHorizontal: theme.spacing(4),
591
+ uni__dependencies: [0]
592
+ },
593
+ tile: {
594
+ flex: 1,
595
+ maxWidth: "50%",
596
+ flexDirection: "column",
597
+ alignItems: "stretch",
598
+ gap: theme.spacing(2),
599
+ borderWidth: 1,
600
+ borderColor: theme.colors["border-soft"],
601
+ marginBottom: theme.spacing(2),
602
+ uni__dependencies: [0]
603
+ },
604
+ thumbnail: {
605
+ height: 96,
606
+ backgroundColor: theme.colors.deep,
607
+ borderRadius: theme.borderRadius.DEFAULT,
608
+ overflow: "hidden",
609
+ alignItems: "center",
610
+ justifyContent: "center",
611
+ uni__dependencies: [0]
612
+ },
613
+ rowThumbnail: {
614
+ width: 40,
615
+ height: 40,
616
+ borderRadius: theme.borderRadius.sm,
617
+ overflow: "hidden",
618
+ alignItems: "center",
619
+ justifyContent: "center",
620
+ uni__dependencies: [0]
621
+ },
622
+ selected: {
623
+ backgroundColor: theme.colors["tint-green"],
624
+ borderColor: theme.colors["edge-green"],
625
+ uni__dependencies: [0]
626
+ },
627
+ selection: {
628
+ flexShrink: 0,
629
+ padding: theme.spacing(3),
630
+ gap: theme.spacing(2),
631
+ borderWidth: 1,
632
+ borderColor: theme.colors.border,
633
+ borderRadius: theme.borderRadius.DEFAULT,
634
+ backgroundColor: theme.colors.panel,
635
+ uni__dependencies: [0]
636
+ },
637
+ actions: {
638
+ flexDirection: "row",
639
+ justifyContent: "flex-end",
640
+ gap: theme.spacing(2),
641
+ uni__dependencies: [0]
642
+ },
643
+ titleRow: {
644
+ flexDirection: "row",
645
+ alignItems: "center",
646
+ gap: theme.spacing(2),
647
+ uni__dependencies: [0]
648
+ },
649
+ preview: {
650
+ height: PREVIEW_HEIGHT,
651
+ backgroundColor: theme.colors.deep,
652
+ borderRadius: theme.borderRadius.DEFAULT,
653
+ uni__dependencies: [0]
654
+ },
655
+ page: {
656
+ height: PREVIEW_HEIGHT,
657
+ alignItems: "center",
658
+ justifyContent: "center"
659
+ },
660
+ arrow: {
661
+ position: "absolute",
662
+ top: PREVIEW_HEIGHT / 2 - 22,
663
+ width: 44,
664
+ height: 44,
665
+ borderRadius: 22,
666
+ backgroundColor: theme.colors.panel,
667
+ uni__dependencies: [0]
668
+ },
669
+ previous: {
670
+ left: theme.spacing(2),
671
+ uni__dependencies: [0]
672
+ },
673
+ next: {
674
+ right: theme.spacing(2),
675
+ uni__dependencies: [0]
676
+ },
677
+ flip: { transform: [{ rotate: "180deg" }] },
678
+ dots: {
679
+ flexDirection: "row",
680
+ justifyContent: "center",
681
+ gap: theme.spacing(2),
682
+ paddingTop: theme.spacing(2),
683
+ uni__dependencies: [0]
684
+ },
685
+ dot: {
686
+ width: 6,
687
+ height: 6,
688
+ borderRadius: 3,
689
+ backgroundColor: theme.colors.faint,
690
+ uni__dependencies: [0]
691
+ },
692
+ dotActive: {
693
+ backgroundColor: theme.colors.green,
694
+ uni__dependencies: [0]
695
+ },
696
+ list: {
697
+ gap: theme.spacing(2),
698
+ uni__dependencies: [0]
699
+ },
700
+ item: {
701
+ minHeight: 44,
702
+ flexDirection: "row",
703
+ justifyContent: "flex-start",
704
+ alignItems: "center",
705
+ gap: theme.spacing(3),
706
+ uni__dependencies: [0]
707
+ },
708
+ label: {
709
+ flex: 1,
710
+ gap: theme.spacing(1),
711
+ minWidth: 0,
712
+ uni__dependencies: [0]
713
+ },
714
+ name: {
715
+ fontFamily: fontOf(theme.fontFamily.sans),
716
+ fontWeight: "600",
717
+ fontSize: theme.fontSize.base,
718
+ color: theme.colors.text,
719
+ uni__dependencies: [0]
720
+ },
721
+ path: {
722
+ fontFamily: fontOf(theme.fontFamily.mono),
723
+ fontSize: theme.fontSize.sm,
724
+ color: theme.colors.dim,
725
+ uni__dependencies: [0]
726
+ },
727
+ meta: {
728
+ fontFamily: fontOf(theme.fontFamily.sans),
729
+ fontSize: theme.fontSize.sm,
730
+ color: theme.colors.dim,
731
+ uni__dependencies: [0]
732
+ }
733
+ }));
734
+
735
+ //#endregion
736
+ export { FileList };
737
+ //# sourceMappingURL=FileList.mjs.map