@agimon-ai/po-native-components 0.0.0-alpha.7 → 0.0.0-alpha.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +149 -22
- package/dist/components/AgentAvatar.d.mts +14 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +87 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/AnnotationSurface.d.mts +69 -0
- package/dist/components/AnnotationSurface.d.mts.map +1 -0
- package/dist/components/AnnotationSurface.mjs +426 -0
- package/dist/components/AnnotationSurface.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +1 -1
- package/dist/components/Button.mjs +2 -2
- package/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +35 -47
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +43 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/Dialog.mjs +3 -3
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +2 -2
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +12 -6
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +148 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/HostFilter.d.mts +17 -0
- package/dist/components/HostFilter.d.mts.map +1 -0
- package/dist/components/HostFilter.mjs +66 -0
- package/dist/components/HostFilter.mjs.map +1 -0
- package/dist/components/HostTag.d.mts +7 -0
- package/dist/components/HostTag.d.mts.map +1 -0
- package/dist/components/HostTag.mjs +47 -0
- package/dist/components/HostTag.mjs.map +1 -0
- package/dist/components/InfoStrip.d.mts +9 -0
- package/dist/components/InfoStrip.d.mts.map +1 -0
- package/dist/components/InfoStrip.mjs +53 -0
- package/dist/components/InfoStrip.mjs.map +1 -0
- package/dist/components/Input.mjs +3 -2
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +38 -6
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/LiveDuration.d.mts +30 -0
- package/dist/components/LiveDuration.d.mts.map +1 -0
- package/dist/components/LiveDuration.mjs +67 -0
- package/dist/components/LiveDuration.mjs.map +1 -0
- package/dist/components/Markdown.d.mts +10 -1
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +330 -27
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +8 -8
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +71 -55
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/Sheet.d.mts +7 -1
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +19 -4
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.d.mts +13 -0
- package/dist/components/SheetFrame.d.mts.map +1 -0
- package/dist/components/SheetFrame.mjs +113 -16
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/SheetList.d.mts +14 -0
- package/dist/components/SheetList.d.mts.map +1 -0
- package/dist/components/SheetList.mjs +34 -0
- package/dist/components/SheetList.mjs.map +1 -0
- package/dist/components/ShowMore.d.mts +10 -0
- package/dist/components/ShowMore.d.mts.map +1 -0
- package/dist/components/ShowMore.mjs +44 -0
- package/dist/components/ShowMore.mjs.map +1 -0
- package/dist/components/Spinner.d.mts +1 -1
- package/dist/components/StatusBadge.d.mts +1 -1
- package/dist/components/SyntaxLine.d.mts +19 -0
- package/dist/components/SyntaxLine.d.mts.map +1 -0
- package/dist/components/SyntaxLine.mjs +134 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.mjs +2 -2
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +40 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/icons/iconGlyphs.d.mts +56 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +56 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +57 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +15 -1
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +17 -4
- package/dist/index.mjs +18 -5
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/markdown.mjs +172 -23
- package/dist/lib/markdown.mjs.map +1 -1
- package/dist/lib/reading.mjs +60 -0
- package/dist/lib/reading.mjs.map +1 -0
- package/dist/lib/useReadingPage.mjs +33 -0
- package/dist/lib/useReadingPage.mjs.map +1 -0
- package/package.json +18 -14
|
@@ -1,37 +1,93 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
1
2
|
import { InsideSheetContext } from "../lib/insideSheet.mjs";
|
|
2
|
-
import {
|
|
3
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
3
5
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
4
|
-
import { BackHandler } from "react-native";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { BackHandler, Keyboard } from "react-native";
|
|
7
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
8
|
+
import { useCallback, useContext, useEffect, useRef, useState } from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { BottomSheetBackdrop, BottomSheetFooter, BottomSheetModal, BottomSheetScrollView } from "@gorhom/bottom-sheet";
|
|
8
11
|
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
9
12
|
|
|
10
13
|
//#region src/components/SheetFrame.tsx
|
|
11
14
|
/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */
|
|
12
15
|
const BACKDROP_ALPHA_PERCENT = 70;
|
|
16
|
+
/** Presented sheets, oldest first: one opened from inside another sits after it. */
|
|
17
|
+
const openSheets = [];
|
|
18
|
+
let yielded = false;
|
|
19
|
+
/** True while a prompt in the conversation holds the screen: a sheet should not open over it on its own. */
|
|
20
|
+
function sheetsYielded() {
|
|
21
|
+
return yielded;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Clear the screen for a prompt in the conversation: close sheets from the top down, as a backdrop tap
|
|
25
|
+
* would. The first sheet that keeps unsaved work stops the walk, and it and every sheet under it stay
|
|
26
|
+
* open showing `note`, since closing a sheet also unmounts the sheets opened inside it. Undefined clears
|
|
27
|
+
* the note and closes nothing.
|
|
28
|
+
*/
|
|
29
|
+
function yieldSheets(note) {
|
|
30
|
+
yielded = note !== void 0;
|
|
31
|
+
if (note === void 0) {
|
|
32
|
+
for (const sheet of openSheets) sheet.setNote(void 0);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
for (let index = openSheets.length - 1; index >= 0; index -= 1) {
|
|
36
|
+
if (openSheets[index].keep()) {
|
|
37
|
+
for (const sheet of openSheets.slice(0, index + 1)) sheet.setNote(note);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
openSheets[index].close();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
13
43
|
/**
|
|
14
44
|
* The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized
|
|
15
45
|
* to its content, closed by dragging down, tapping the backdrop or Android
|
|
16
46
|
* back, clear of the safe area and lifted by the keyboard. Private: the public
|
|
17
47
|
* parts keep bottom-sheet types out of the package API.
|
|
18
48
|
*/
|
|
19
|
-
function SheetFrame({ open, onClose, children }) {
|
|
49
|
+
function SheetFrame({ open, onClose, children, scrollable = true, footer, keep = false }) {
|
|
20
50
|
const { theme } = useUnistyles();
|
|
21
51
|
const insets = useContext(SafeAreaInsetsContext);
|
|
22
52
|
const sheet = useRef(null);
|
|
23
53
|
const openRef = useRef(open);
|
|
24
54
|
const presented = useRef(false);
|
|
55
|
+
const [footerHeight, setFooterHeight] = useState(0);
|
|
56
|
+
const [note, setNote] = useState();
|
|
57
|
+
const latest = useRef({
|
|
58
|
+
keep,
|
|
59
|
+
onClose
|
|
60
|
+
});
|
|
61
|
+
latest.current = {
|
|
62
|
+
keep,
|
|
63
|
+
onClose
|
|
64
|
+
};
|
|
65
|
+
const entry = useRef({
|
|
66
|
+
keep: () => latest.current.keep,
|
|
67
|
+
close: () => latest.current.onClose(),
|
|
68
|
+
setNote
|
|
69
|
+
});
|
|
25
70
|
useEffect(() => {
|
|
26
71
|
openRef.current = open;
|
|
72
|
+
const listed = openSheets.indexOf(entry.current);
|
|
27
73
|
if (open) {
|
|
28
74
|
presented.current = true;
|
|
75
|
+
if (listed < 0) openSheets.push(entry.current);
|
|
76
|
+
Keyboard.dismiss();
|
|
29
77
|
sheet.current?.present();
|
|
30
|
-
} else
|
|
31
|
-
|
|
32
|
-
|
|
78
|
+
} else {
|
|
79
|
+
if (listed >= 0) openSheets.splice(listed, 1);
|
|
80
|
+
setNote(void 0);
|
|
81
|
+
if (presented.current) {
|
|
82
|
+
presented.current = false;
|
|
83
|
+
sheet.current?.dismiss();
|
|
84
|
+
}
|
|
33
85
|
}
|
|
34
86
|
}, [open]);
|
|
87
|
+
useEffect(() => () => {
|
|
88
|
+
const listed = openSheets.indexOf(entry.current);
|
|
89
|
+
if (listed >= 0) openSheets.splice(listed, 1);
|
|
90
|
+
}, []);
|
|
35
91
|
useEffect(() => {
|
|
36
92
|
if (!open) return void 0;
|
|
37
93
|
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
@@ -49,6 +105,24 @@ function SheetFrame({ open, onClose, children }) {
|
|
|
49
105
|
pressBehavior: "close",
|
|
50
106
|
style: [props.style, { backgroundColor: backdropColor }]
|
|
51
107
|
}), [backdropColor]);
|
|
108
|
+
const renderFooter = useCallback((props) => /* @__PURE__ */ jsx(BottomSheetFooter, {
|
|
109
|
+
...props,
|
|
110
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
111
|
+
onLayout: (event) => setFooterHeight(event.nativeEvent.layout.height),
|
|
112
|
+
style: {
|
|
113
|
+
paddingBottom: insets?.bottom ?? 0,
|
|
114
|
+
backgroundColor: theme.colors.rail
|
|
115
|
+
},
|
|
116
|
+
children: /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
117
|
+
value: true,
|
|
118
|
+
children: footer
|
|
119
|
+
})
|
|
120
|
+
})
|
|
121
|
+
}), [
|
|
122
|
+
footer,
|
|
123
|
+
insets?.bottom,
|
|
124
|
+
theme.colors.rail
|
|
125
|
+
]);
|
|
52
126
|
return /* @__PURE__ */ jsx(BottomSheetModal, {
|
|
53
127
|
ref: sheet,
|
|
54
128
|
stackBehavior: "push",
|
|
@@ -58,6 +132,7 @@ function SheetFrame({ open, onClose, children }) {
|
|
|
58
132
|
keyboardBlurBehavior: "restore",
|
|
59
133
|
android_keyboardInputMode: "adjustResize",
|
|
60
134
|
backdropComponent: renderBackdrop,
|
|
135
|
+
...footer === void 0 ? {} : { footerComponent: renderFooter },
|
|
61
136
|
backgroundStyle: {
|
|
62
137
|
backgroundColor: theme.colors.rail,
|
|
63
138
|
borderRadius: theme.borderRadius.lg
|
|
@@ -67,18 +142,40 @@ function SheetFrame({ open, onClose, children }) {
|
|
|
67
142
|
presented.current = false;
|
|
68
143
|
if (openRef.current) onClose();
|
|
69
144
|
},
|
|
70
|
-
children: /* @__PURE__ */
|
|
145
|
+
children: scrollable ? /* @__PURE__ */ jsxs(BottomSheetScrollView, {
|
|
71
146
|
keyboardShouldPersistTaps: "handled",
|
|
72
|
-
contentContainerStyle: [styles.content, { paddingBottom: insets?.bottom ?? 0 }],
|
|
73
|
-
children: /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
147
|
+
contentContainerStyle: [styles.content, { paddingBottom: footer === void 0 ? insets?.bottom ?? 0 : footerHeight }],
|
|
148
|
+
children: [note ? /* @__PURE__ */ jsx(SheetNote, { note }) : null, /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
74
149
|
value: true,
|
|
75
150
|
children
|
|
76
|
-
})
|
|
77
|
-
})
|
|
151
|
+
})]
|
|
152
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [note ? /* @__PURE__ */ jsx(SheetNote, { note }) : null, /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
153
|
+
value: true,
|
|
154
|
+
children
|
|
155
|
+
})] })
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
/** A gentle rose line: the person is asked something below, never told to hurry. */
|
|
159
|
+
function SheetNote({ note }) {
|
|
160
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
161
|
+
style: styles.note,
|
|
162
|
+
accessibilityRole: "alert",
|
|
163
|
+
children: note
|
|
78
164
|
});
|
|
79
165
|
}
|
|
80
|
-
const styles = StyleSheet.create(
|
|
166
|
+
const styles = StyleSheet.create((theme) => ({
|
|
167
|
+
content: { flexGrow: 1 },
|
|
168
|
+
note: {
|
|
169
|
+
marginHorizontal: theme.spacing(4),
|
|
170
|
+
marginBottom: theme.spacing(2),
|
|
171
|
+
color: theme.colors.magenta,
|
|
172
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
173
|
+
fontSize: theme.fontSize.sm,
|
|
174
|
+
lineHeight: theme.lineHeight.sm,
|
|
175
|
+
uni__dependencies: [0]
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
81
178
|
|
|
82
179
|
//#endregion
|
|
83
|
-
export { SheetFrame };
|
|
180
|
+
export { SheetFrame, sheetsYielded, yieldSheets };
|
|
84
181
|
//# sourceMappingURL=SheetFrame.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetFrame.mjs","names":["withAlpha","BottomSheetBackdrop","BottomSheetBackdropProps","BottomSheetModal","BottomSheetScrollView","ReactNode","useCallback","useContext","useEffect","useRef","BackHandler","SafeAreaInsetsContext","StyleSheet","useUnistyles","InsideSheetContext","BACKDROP_ALPHA_PERCENT","SheetFrameProps","open","onClose","children","SheetFrame","theme","insets","sheet","openRef","presented","current","present","dismiss","undefined","subscription","addEventListener","remove","backdropColor","colors","deep","renderBackdrop","props","style","backgroundColor","top","rail","borderRadius","lg","border","styles","content","paddingBottom","bottom","create","flexGrow"],"sources":["../../src/components/SheetFrame.tsx"],"sourcesContent":["import { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport {\n BottomSheetBackdrop,\n type BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport { type ReactNode, useCallback, useContext, useEffect, useRef } from 'react';\nimport { BackHandler } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { InsideSheetContext } from '../lib/insideSheet';\n\n/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n\nexport interface SheetFrameProps {\n open: boolean;\n /** The sheet asked to close: a drag down, a backdrop tap or Android back. */\n onClose: () => void;\n children?: ReactNode;\n}\n\n/**\n * The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized\n * to its content, closed by dragging down, tapping the backdrop or Android\n * back, clear of the safe area and lifted by the keyboard. Private: the public\n * parts keep bottom-sheet types out of the package API.\n */\nexport function SheetFrame({ open, onClose, children }: SheetFrameProps) {\n const { theme } = useUnistyles();\n const insets = useContext(SafeAreaInsetsContext);\n const sheet = useRef<BottomSheetModal>(null);\n const openRef = useRef(open);\n const presented = useRef(false);\n\n useEffect(() => {\n openRef.current = open;\n if (open) {\n presented.current = true;\n sheet.current?.present();\n } else if (presented.current) {\n // Only a presented sheet is dismissed. Dismissing one that never opened leaves bottom-sheet's\n // modal stuck in its dismissing status, and the next present() then never draws.\n presented.current = false;\n sheet.current?.dismiss();\n }\n }, [open]);\n\n useEffect(() => {\n if (!open) return undefined;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n onClose();\n return true;\n });\n return () => subscription.remove();\n }, [open, onClose]);\n\n const backdropColor = withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT);\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={1}\n pressBehavior=\"close\"\n style={[props.style, { backgroundColor: backdropColor }]}\n />\n ),\n [backdropColor],\n );\n\n return (\n <BottomSheetModal\n ref={sheet}\n stackBehavior=\"push\"\n enablePanDownToClose\n topInset={insets?.top ?? 0}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n android_keyboardInputMode=\"adjustResize\"\n backdropComponent={renderBackdrop}\n backgroundStyle={{ backgroundColor: theme.colors.rail, borderRadius: theme.borderRadius.lg }}\n handleIndicatorStyle={{ backgroundColor: theme.colors.border }}\n // A sheet the caller closed is already shut; only a close the sheet started is reported.\n onDismiss={() => {\n // Already shut, so the close the parent answers with must not dismiss it a second time.\n presented.current = false;\n if (openRef.current) onClose();\n }}\n >\n <BottomSheetScrollView\n keyboardShouldPersistTaps=\"handled\"\n contentContainerStyle={[styles.content, { paddingBottom: insets?.bottom ?? 0 }]}\n >\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </BottomSheetScrollView>\n </BottomSheetModal>\n );\n}\n\nconst styles = StyleSheet.create({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AAiBlB,MAAMa,OAAOU,OAAO;EAE7D,iBAAiB;GAEfnB,UAAUC,UAAU;GACpB,IAAIF,QAAQE,SAASR,QAAQ;EAC/B;YAEA,oBAAC,uBAAD;GACE,2BAA0B;GAC1B,uBAAuB,CAAC2B,OAAOC,SAAS,EAAEC,eAAezB,QAAQ0B,UAAU,EAAE,CAAC;aAE9E,oBAAC,mBAAmB,UAApB;IAA6B;IAAO7B;GAAsC;EACrD;CACP;AAEtB;AAEA,MAAM0B,SAASjC,WAAWqC,OAAO,EAAEH,SAAS,EAAEI,UAAU,EAAE,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"SheetFrame.mjs","names":["withAlpha","BottomSheetBackdrop","BottomSheetBackdropProps","BottomSheetModal","BottomSheetFooter","BottomSheetFooterProps","BottomSheetScrollView","ReactNode","useCallback","useContext","useEffect","useRef","useState","BackHandler","Keyboard","SafeAreaInsetsContext","StyleSheet","useUnistyles","fontOf","InsideSheetContext","BACKDROP_ALPHA_PERCENT","SheetFrameProps","open","onClose","children","footer","scrollable","keep","OpenSheet","close","setNote","note","openSheets","yielded","sheetsYielded","yieldSheets","undefined","sheet","index","length","slice","SheetFrame","theme","insets","openRef","presented","footerHeight","setFooterHeight","latest","current","entry","listed","indexOf","push","dismiss","present","splice","subscription","addEventListener","remove","backdropColor","colors","deep","renderBackdrop","props","style","backgroundColor","renderFooter","event","nativeEvent","layout","height","paddingBottom","bottom","rail","top","footerComponent","borderRadius","lg","border","styles","content","SheetNote","create","flexGrow","marginHorizontal","spacing","marginBottom","color","magenta","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies"],"sources":["../../src/components/SheetFrame.tsx"],"sourcesContent":["import { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport {\n BottomSheetBackdrop,\n type BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetFooter,\n type BottomSheetFooterProps,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport { type ReactNode, useCallback, useContext, useEffect, useRef, useState } from 'react';\nimport { BackHandler, Keyboard, Text, View } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { InsideSheetContext } from '../lib/insideSheet';\n\n/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n\nexport interface SheetFrameProps {\n open: boolean;\n /** The sheet asked to close: a drag down, a backdrop tap or Android back. */\n onClose: () => void;\n children?: ReactNode;\n footer?: ReactNode;\n /** False when the content supplies its own Gorhom virtualized scroll owner. */\n scrollable?: boolean;\n /** The sheet holds work not yet saved, so a prompt arriving leaves it open with a note instead of closing it. */\n keep?: boolean;\n}\n\ninterface OpenSheet {\n keep: () => boolean;\n close: () => void;\n setNote: (note: string | undefined) => void;\n}\n\n/** Presented sheets, oldest first: one opened from inside another sits after it. */\nconst openSheets: OpenSheet[] = [];\nlet yielded = false;\n\n/** True while a prompt in the conversation holds the screen: a sheet should not open over it on its own. */\nexport function sheetsYielded(): boolean {\n return yielded;\n}\n\n/**\n * Clear the screen for a prompt in the conversation: close sheets from the top down, as a backdrop tap\n * would. The first sheet that keeps unsaved work stops the walk, and it and every sheet under it stay\n * open showing `note`, since closing a sheet also unmounts the sheets opened inside it. Undefined clears\n * the note and closes nothing.\n */\nexport function yieldSheets(note: string | undefined) {\n yielded = note !== undefined;\n if (note === undefined) {\n for (const sheet of openSheets) sheet.setNote(undefined);\n return;\n }\n for (let index = openSheets.length - 1; index >= 0; index -= 1) {\n if (openSheets[index].keep()) {\n for (const sheet of openSheets.slice(0, index + 1)) sheet.setNote(note);\n return;\n }\n openSheets[index].close();\n }\n}\n\n/**\n * The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized\n * to its content, closed by dragging down, tapping the backdrop or Android\n * back, clear of the safe area and lifted by the keyboard. Private: the public\n * parts keep bottom-sheet types out of the package API.\n */\nexport function SheetFrame({ open, onClose, children, scrollable = true, footer, keep = false }: SheetFrameProps) {\n const { theme } = useUnistyles();\n const insets = useContext(SafeAreaInsetsContext);\n const sheet = useRef<BottomSheetModal>(null);\n const openRef = useRef(open);\n const presented = useRef(false);\n const [footerHeight, setFooterHeight] = useState(0);\n const [note, setNote] = useState<string>();\n const latest = useRef({ keep, onClose });\n latest.current = { keep, onClose };\n const entry = useRef<OpenSheet>({\n keep: () => latest.current.keep,\n close: () => latest.current.onClose(),\n setNote,\n });\n\n useEffect(() => {\n openRef.current = open;\n const listed = openSheets.indexOf(entry.current);\n if (open) {\n presented.current = true;\n if (listed < 0) openSheets.push(entry.current);\n // The keyboard of the field behind would cover the sheet; a field inside it focuses after this.\n Keyboard.dismiss();\n sheet.current?.present();\n } else {\n if (listed >= 0) openSheets.splice(listed, 1);\n setNote(undefined);\n if (presented.current) {\n // Only a presented sheet is dismissed. Dismissing one that never opened leaves bottom-sheet's\n // modal stuck in its dismissing status, and the next present() then never draws.\n presented.current = false;\n sheet.current?.dismiss();\n }\n }\n }, [open]);\n\n useEffect(\n () => () => {\n const listed = openSheets.indexOf(entry.current);\n if (listed >= 0) openSheets.splice(listed, 1);\n },\n [],\n );\n\n useEffect(() => {\n if (!open) return undefined;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n onClose();\n return true;\n });\n return () => subscription.remove();\n }, [open, onClose]);\n\n const backdropColor = withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT);\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={1}\n pressBehavior=\"close\"\n style={[props.style, { backgroundColor: backdropColor }]}\n />\n ),\n [backdropColor],\n );\n\n const renderFooter = useCallback(\n (props: BottomSheetFooterProps) => (\n <BottomSheetFooter {...props}>\n <View\n onLayout={(event) => setFooterHeight(event.nativeEvent.layout.height)}\n style={{ paddingBottom: insets?.bottom ?? 0, backgroundColor: theme.colors.rail }}\n >\n <InsideSheetContext.Provider value>{footer}</InsideSheetContext.Provider>\n </View>\n </BottomSheetFooter>\n ),\n [footer, insets?.bottom, theme.colors.rail],\n );\n\n return (\n <BottomSheetModal\n ref={sheet}\n stackBehavior=\"push\"\n enablePanDownToClose\n topInset={insets?.top ?? 0}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n android_keyboardInputMode=\"adjustResize\"\n backdropComponent={renderBackdrop}\n {...(footer === undefined ? {} : { footerComponent: renderFooter })}\n backgroundStyle={{ backgroundColor: theme.colors.rail, borderRadius: theme.borderRadius.lg }}\n handleIndicatorStyle={{ backgroundColor: theme.colors.border }}\n // A sheet the caller closed is already shut; only a close the sheet started is reported.\n onDismiss={() => {\n // Already shut, so the close the parent answers with must not dismiss it a second time.\n presented.current = false;\n if (openRef.current) onClose();\n }}\n >\n {scrollable ? (\n <BottomSheetScrollView\n keyboardShouldPersistTaps=\"handled\"\n contentContainerStyle={[\n styles.content,\n { paddingBottom: footer === undefined ? (insets?.bottom ?? 0) : footerHeight },\n ]}\n >\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </BottomSheetScrollView>\n ) : (\n <>\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </>\n )}\n </BottomSheetModal>\n );\n}\n\n/** A gentle rose line: the person is asked something below, never told to hurry. */\nfunction SheetNote({ note }: { note: string }) {\n return (\n <Text style={styles.note} accessibilityRole=\"alert\">\n {note}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n content: { flexGrow: 1 },\n note: {\n marginHorizontal: theme.spacing(4),\n marginBottom: theme.spacing(2),\n color: theme.colors.magenta,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;;;;AAkBA,MAAMoB,yBAAyB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,MAAMkD,SAASC;EACzBC,YAAYpD,MAAMoD,WAAWD;EAAEE,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FlatListProps } from "react-native";
|
|
2
|
+
//#region src/components/SheetList.d.ts
|
|
3
|
+
export interface SheetListProps<T> extends FlatListProps<T> {
|
|
4
|
+
/** Use inside a persistent SheetContent with scrollable={false}. */
|
|
5
|
+
embedded?: boolean;
|
|
6
|
+
/** Reset the list without replacing its modal owner. */
|
|
7
|
+
listKey?: string;
|
|
8
|
+
/** The sheet holds unsaved work: a prompt arriving in the conversation leaves it open with a note. */
|
|
9
|
+
keep?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** A sheet's only vertical scroll owner. Put headings and controls in its header/footer. */
|
|
12
|
+
export declare function SheetList<T>({ contentContainerStyle, embedded, listKey, keep, ...props }: SheetListProps<T>): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=SheetList.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetList.d.mts","names":[],"sources":["../../src/components/SheetList.tsx"],"mappings":";;iBASiB,eAAe,WAAW,cAAc;;EAEvD;;EAEA;;EAEA;;;wBAMc,UAAU,KAAK,uBAAuB,UAAkB,SAAS,SAAS,SAAS,eAAe,qBAAE,IAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SheetFrame } from "./SheetFrame.mjs";
|
|
2
|
+
import { SheetContext } from "./Sheet.mjs";
|
|
3
|
+
import { withUnistyles } from "react-native-unistyles";
|
|
4
|
+
import { useContext } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { BottomSheetFlatList } from "@gorhom/bottom-sheet";
|
|
7
|
+
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
8
|
+
|
|
9
|
+
//#region src/components/SheetList.tsx
|
|
10
|
+
const ThemedSheetFlatList = withUnistyles(BottomSheetFlatList);
|
|
11
|
+
/** A sheet's only vertical scroll owner. Put headings and controls in its header/footer. */
|
|
12
|
+
function SheetList({ contentContainerStyle, embedded = false, listKey, keep, ...props }) {
|
|
13
|
+
const state = useContext(SheetContext);
|
|
14
|
+
const insets = useContext(SafeAreaInsetsContext);
|
|
15
|
+
const list = /* @__PURE__ */ jsx(SheetContext.Provider, {
|
|
16
|
+
value: state,
|
|
17
|
+
children: /* @__PURE__ */ jsx(ThemedSheetFlatList, {
|
|
18
|
+
keyboardShouldPersistTaps: "handled",
|
|
19
|
+
...props,
|
|
20
|
+
contentContainerStyle: [{ paddingBottom: insets?.bottom ?? 0 }, contentContainerStyle]
|
|
21
|
+
}, listKey)
|
|
22
|
+
});
|
|
23
|
+
return embedded ? list : /* @__PURE__ */ jsx(SheetFrame, {
|
|
24
|
+
open: state.open,
|
|
25
|
+
onClose: () => state.setOpen(false),
|
|
26
|
+
scrollable: false,
|
|
27
|
+
keep,
|
|
28
|
+
children: list
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { SheetList };
|
|
34
|
+
//# sourceMappingURL=SheetList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetList.mjs","names":["BottomSheetFlatList","useContext","FlatListProps","SafeAreaInsetsContext","withUnistyles","SheetContext","SheetFrame","SheetListProps","T","embedded","listKey","keep","ThemedSheetFlatList","SheetList","contentContainerStyle","props","state","insets","list","paddingBottom","bottom","open","setOpen"],"sources":["../../src/components/SheetList.tsx"],"sourcesContent":["import { BottomSheetFlatList } from '@gorhom/bottom-sheet';\nimport { useContext } from 'react';\nimport type { FlatListProps } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { withUnistyles } from 'react-native-unistyles';\n\nimport { SheetContext } from './Sheet';\nimport { SheetFrame } from './SheetFrame';\n\nexport interface SheetListProps<T> extends FlatListProps<T> {\n /** Use inside a persistent SheetContent with scrollable={false}. */\n embedded?: boolean;\n /** Reset the list without replacing its modal owner. */\n listKey?: string;\n /** The sheet holds unsaved work: a prompt arriving in the conversation leaves it open with a note. */\n keep?: boolean;\n}\n\n// Gorhom normalizes scroll styles internally; resolve Unistyles before that boundary.\nconst ThemedSheetFlatList = withUnistyles(BottomSheetFlatList) as typeof BottomSheetFlatList;\n/** A sheet's only vertical scroll owner. Put headings and controls in its header/footer. */\nexport function SheetList<T>({ contentContainerStyle, embedded = false, listKey, keep, ...props }: SheetListProps<T>) {\n const state = useContext(SheetContext);\n const insets = useContext(SafeAreaInsetsContext);\n const list = (\n <SheetContext.Provider value={state}>\n <ThemedSheetFlatList<T>\n key={listKey}\n keyboardShouldPersistTaps=\"handled\"\n {...props}\n contentContainerStyle={[{ paddingBottom: insets?.bottom ?? 0 }, contentContainerStyle]}\n />\n </SheetContext.Provider>\n );\n return embedded ? (\n list\n ) : (\n <SheetFrame open={state.open} onClose={() => state.setOpen(false)} scrollable={false} keep={keep}>\n {list}\n </SheetFrame>\n );\n}\n"],"mappings":";;;;;;;;;AAmBA,MAAMY,sBAAsBR,cAAcJ,mBAAmB;;AAE7D,SAAgBa,UAAa,EAAEC,uBAAuBL,WAAW,OAAOC,SAASC,MAAM,GAAGI,SAA4B;CACpH,MAAMC,QAAQf,WAAWI,YAAY;CACrC,MAAMY,SAAShB,WAAWE,qBAAqB;CAC/C,MAAMe,OACJ,oBAAC,aAAa,UAAd;EAAuB,OAAOF;YAC5B,oBAAC,qBAAD;GAEE,2BAA0B;GAC1B,GAAID;GACJ,uBAAuB,CAAC,EAAEI,eAAeF,QAAQG,UAAU,EAAE,GAAGN,qBAAqB;EAAE,GAHlFJ,OAGkF;CAEpE;CAEzB,OAAOD,WACLS,OAEA,oBAAC,YAAD;EAAY,MAAMF,MAAMK;EAAM,eAAeL,MAAMM,QAAQ,KAAK;EAAG,YAAY;EAAaX;YACzFO;CACS;AAEhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/ShowMore.d.ts
|
|
2
|
+
export interface ShowMoreProps {
|
|
3
|
+
label: string;
|
|
4
|
+
summary?: string;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
}
|
|
7
|
+
/** A bounded preview's explicit next part. The caller keeps the complete source. */
|
|
8
|
+
export declare function ShowMore({ label, summary, onPress }: ShowMoreProps): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=ShowMore.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowMore.d.mts","names":[],"sources":["../../src/components/ShowMore.tsx"],"mappings":";iBAMiB;EACf;EACA;EACA;;;wBAIc,WAAW,OAAO,SAAS,WAAW,gCAAa,IAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { Button } from "./Button.mjs";
|
|
3
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
5
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/ShowMore.tsx
|
|
9
|
+
/** A bounded preview's explicit next part. The caller keeps the complete source. */
|
|
10
|
+
function ShowMore({ label, summary, onPress }) {
|
|
11
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
12
|
+
style: styles.reveal,
|
|
13
|
+
children: [summary ? /* @__PURE__ */ jsx(Text, {
|
|
14
|
+
style: styles.summary,
|
|
15
|
+
children: summary
|
|
16
|
+
}) : null, /* @__PURE__ */ jsx(Button, {
|
|
17
|
+
variant: "ghost",
|
|
18
|
+
onPress,
|
|
19
|
+
style: styles.button,
|
|
20
|
+
children: label
|
|
21
|
+
})]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const styles = StyleSheet.create((theme) => ({
|
|
25
|
+
reveal: {
|
|
26
|
+
gap: theme.spacing(1),
|
|
27
|
+
uni__dependencies: [0]
|
|
28
|
+
},
|
|
29
|
+
summary: {
|
|
30
|
+
color: theme.colors.dim,
|
|
31
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
32
|
+
fontSize: theme.fontSize.sm,
|
|
33
|
+
lineHeight: theme.lineHeightRelaxed.sm,
|
|
34
|
+
uni__dependencies: [0]
|
|
35
|
+
},
|
|
36
|
+
button: {
|
|
37
|
+
alignSelf: "flex-start",
|
|
38
|
+
minHeight: 44
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ShowMore };
|
|
44
|
+
//# sourceMappingURL=ShowMore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowMore.mjs","names":["StyleSheet","fontOf","Button","ShowMoreProps","label","summary","onPress","ShowMore","styles","reveal","button","create","theme","gap","spacing","uni__dependencies","color","colors","dim","fontFamily","sans","fontSize","sm","lineHeight","lineHeightRelaxed","alignSelf","minHeight"],"sources":["../../src/components/ShowMore.tsx"],"sourcesContent":["import { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\n\nexport interface ShowMoreProps {\n label: string;\n summary?: string;\n onPress: () => void;\n}\n\n/** A bounded preview's explicit next part. The caller keeps the complete source. */\nexport function ShowMore({ label, summary, onPress }: ShowMoreProps) {\n return (\n <View style={styles.reveal}>\n {summary ? <Text style={styles.summary}>{summary}</Text> : null}\n <Button variant=\"ghost\" onPress={onPress} style={styles.button}>\n {label}\n </Button>\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n reveal: { gap: theme.spacing(1) },\n summary: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n button: { alignSelf: 'flex-start', minHeight: 44 },\n}));\n"],"mappings":";;;;;;;;;AAaA,SAAgBO,SAAS,EAAEH,OAAOC,SAASC,WAA0B;CACnE,OACE,qBAAC,MAAD;EAAM,OAAOE,OAAOC;YAApB,CACGJ,UAAU,oBAAC,MAAD;GAAM,OAAOG,OAAOH;aAAUA;EAAc,KAAI,MAC3D,oBAAC,QAAD;GAAQ,SAAQ;GAAiBC;GAAS,OAAOE,OAAOE;aACrDN;EACK,EACJ;;AAEV;AAEA,MAAMI,SAASR,WAAWW,QAAQC,WAAW;CAC3CH,QAAQ;EAAEI,KAAKD,MAAME,QAAQ,CAAC;EAACC,mBAAA,CAAA,CAAA;CAAC;CAChCV,SAAS;EACPW,OAAOJ,MAAMK,OAAOC;EACpBC,YAAYlB,OAAOW,MAAMO,WAAWC,IAAI;EACxCC,UAAUT,MAAMS,SAASC;EACzBC,YAAYX,MAAMY,kBAAkBF;EAAEP,mBAAA,CAAA,CAAA;CACxC;CACAL,QAAQ;EAAEe,WAAW;EAAcC,WAAW;CAAG;AACnD,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NativeColorToken } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { NativeColorToken } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
//#region src/components/Spinner.d.ts
|
|
4
4
|
export interface SpinnerProps {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NativeColorToken, StatusTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleProp, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { NativeColorToken, StatusTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/components/StatusBadge.d.ts
|
|
5
5
|
type StatusTone$1 = StatusTone;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SyntaxSpan } from "@agimon-ai/po-web-components/text";
|
|
2
|
+
import { TextProps } from "react-native";
|
|
3
|
+
//#region src/components/SyntaxLine.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Colours `text` as lines of spans, or undefined while loading and for text with
|
|
6
|
+
* no grammar. Pass a whole block, not one line: a line is not a parse unit.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useSyntaxLines(text: string, query?: {
|
|
9
|
+
path?: string | undefined;
|
|
10
|
+
}): readonly (readonly SyntaxSpan[])[] | undefined;
|
|
11
|
+
export interface SyntaxLineProps extends Omit<TextProps, 'children'> {
|
|
12
|
+
/** The line's spans from `useSyntaxLines`, or undefined to show `text` plain. */
|
|
13
|
+
spans?: readonly SyntaxSpan[] | undefined;
|
|
14
|
+
text: string;
|
|
15
|
+
}
|
|
16
|
+
/** One line: coloured when its spans are in, the plain text until then. */
|
|
17
|
+
export declare function SyntaxLine({ spans, text, ...props }: SyntaxLineProps): import("react").JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
//# sourceMappingURL=SyntaxLine.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyntaxLine.d.mts","names":[],"sources":["../../src/components/SyntaxLine.tsx"],"mappings":";;;;;;;wBAgBgB,eAAe,cAAc;EAAS;uBAAgC;iBAyBrE,wBAAwB,KAAK;;EAE5C,iBAAiB;EACjB;;;wBAIc,aAAa,OAAO,SAAS,SAAS,kCAAe,IAAA"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { detectGrammar, highlightToLines } from "@agimon-ai/po-web-components/text";
|
|
2
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
3
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/components/SyntaxLine.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Colours `text` as lines of spans, or undefined while loading and for text with
|
|
10
|
+
* no grammar. Pass a whole block, not one line: a line is not a parse unit.
|
|
11
|
+
*/
|
|
12
|
+
function useSyntaxLines(text, query = {}) {
|
|
13
|
+
const grammar = detectGrammar({
|
|
14
|
+
path: query.path,
|
|
15
|
+
text
|
|
16
|
+
});
|
|
17
|
+
const signature = `${grammar ?? ""}\u0000${text}`;
|
|
18
|
+
const [done, setDone] = useState();
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (grammar === void 0) return;
|
|
21
|
+
let live = true;
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
highlightToLines(text, grammar, controller.signal).then((lines) => {
|
|
24
|
+
if (live && lines !== void 0) setDone({
|
|
25
|
+
signature,
|
|
26
|
+
lines
|
|
27
|
+
});
|
|
28
|
+
}, () => void 0);
|
|
29
|
+
return () => {
|
|
30
|
+
live = false;
|
|
31
|
+
controller.abort();
|
|
32
|
+
};
|
|
33
|
+
}, [
|
|
34
|
+
text,
|
|
35
|
+
grammar,
|
|
36
|
+
signature
|
|
37
|
+
]);
|
|
38
|
+
return done?.signature === signature ? done.lines : void 0;
|
|
39
|
+
}
|
|
40
|
+
/** One line: coloured when its spans are in, the plain text until then. */
|
|
41
|
+
function SyntaxLine({ spans, text, ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
43
|
+
...props,
|
|
44
|
+
children: spans?.map((span, index) => /* @__PURE__ */ jsx(Text, {
|
|
45
|
+
style: span.token === void 0 ? void 0 : syntax[span.token],
|
|
46
|
+
children: span.text
|
|
47
|
+
}, index)) ?? text
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** The web's `PO_SYNTAX_STYLES`, on the native theme's colours. */
|
|
51
|
+
const syntax = StyleSheet.create((theme) => ({
|
|
52
|
+
comment: {
|
|
53
|
+
color: theme.colors.faint,
|
|
54
|
+
fontStyle: "italic",
|
|
55
|
+
uni__dependencies: [0]
|
|
56
|
+
},
|
|
57
|
+
keyword: {
|
|
58
|
+
color: theme.colors.magenta,
|
|
59
|
+
uni__dependencies: [0]
|
|
60
|
+
},
|
|
61
|
+
constant: {
|
|
62
|
+
color: theme.colors.violet,
|
|
63
|
+
uni__dependencies: [0]
|
|
64
|
+
},
|
|
65
|
+
literal: {
|
|
66
|
+
color: theme.colors.orange,
|
|
67
|
+
uni__dependencies: [0]
|
|
68
|
+
},
|
|
69
|
+
string: {
|
|
70
|
+
color: theme.colors.green,
|
|
71
|
+
uni__dependencies: [0]
|
|
72
|
+
},
|
|
73
|
+
regexp: {
|
|
74
|
+
color: theme.colors.teal,
|
|
75
|
+
uni__dependencies: [0]
|
|
76
|
+
},
|
|
77
|
+
operator: {
|
|
78
|
+
color: theme.colors.blue,
|
|
79
|
+
uni__dependencies: [0]
|
|
80
|
+
},
|
|
81
|
+
punctuation: {
|
|
82
|
+
color: theme.colors.dim,
|
|
83
|
+
uni__dependencies: [0]
|
|
84
|
+
},
|
|
85
|
+
variable: {
|
|
86
|
+
color: theme.colors.text,
|
|
87
|
+
uni__dependencies: [0]
|
|
88
|
+
},
|
|
89
|
+
property: {
|
|
90
|
+
color: theme.colors.cyan,
|
|
91
|
+
uni__dependencies: [0]
|
|
92
|
+
},
|
|
93
|
+
callable: {
|
|
94
|
+
color: theme.colors.blue,
|
|
95
|
+
uni__dependencies: [0]
|
|
96
|
+
},
|
|
97
|
+
type: {
|
|
98
|
+
color: theme.colors.yellow,
|
|
99
|
+
uni__dependencies: [0]
|
|
100
|
+
},
|
|
101
|
+
tag: {
|
|
102
|
+
color: theme.colors.red,
|
|
103
|
+
uni__dependencies: [0]
|
|
104
|
+
},
|
|
105
|
+
attribute: {
|
|
106
|
+
color: theme.colors.yellow,
|
|
107
|
+
uni__dependencies: [0]
|
|
108
|
+
},
|
|
109
|
+
meta: {
|
|
110
|
+
color: theme.colors.faint,
|
|
111
|
+
uni__dependencies: [0]
|
|
112
|
+
},
|
|
113
|
+
heading: {
|
|
114
|
+
color: theme.colors.hi,
|
|
115
|
+
fontWeight: "bold",
|
|
116
|
+
uni__dependencies: [0]
|
|
117
|
+
},
|
|
118
|
+
link: {
|
|
119
|
+
color: theme.colors.cyan,
|
|
120
|
+
textDecorationLine: "underline",
|
|
121
|
+
uni__dependencies: [0]
|
|
122
|
+
},
|
|
123
|
+
emphasis: { fontStyle: "italic" },
|
|
124
|
+
strong: { fontWeight: "bold" },
|
|
125
|
+
strikethrough: { textDecorationLine: "line-through" },
|
|
126
|
+
invalid: {
|
|
127
|
+
color: theme.colors.red,
|
|
128
|
+
uni__dependencies: [0]
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
//#endregion
|
|
133
|
+
export { SyntaxLine, useSyntaxLines };
|
|
134
|
+
//# sourceMappingURL=SyntaxLine.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyntaxLine.mjs","names":["detectGrammar","highlightToLines","SyntaxSpan","useEffect","useState","TextProps","StyleSheet","useSyntaxLines","text","query","path","grammar","signature","done","setDone","lines","undefined","live","controller","AbortController","signal","then","abort","SyntaxLineProps","Omit","spans","SyntaxLine","props","map","span","index","token","syntax","create","theme","comment","color","colors","faint","fontStyle","uni__dependencies","keyword","magenta","constant","violet","literal","orange","string","green","regexp","teal","operator","blue","punctuation","dim","variable","property","cyan","callable","type","yellow","tag","red","attribute","meta","heading","hi","fontWeight","link","textDecorationLine","emphasis","strong","strikethrough","invalid"],"sources":["../../src/components/SyntaxLine.tsx"],"sourcesContent":["import { detectGrammar, highlightToLines, type SyntaxSpan } from '@agimon-ai/po-web-components/text';\nimport { useEffect, useState } from 'react';\nimport { Text, type TextProps } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\n/*\n * Read-only code with the editor's colours, as the web's SyntaxText: the same\n * lezer grammars through `@agimon-ai/po-web-components/text`, and the web's\n * `PO_SYNTAX_STYLES` palette on the native theme. Highlighting is async, so the\n * plain text shows first and a result that never highlights stays plain.\n */\n\n/**\n * Colours `text` as lines of spans, or undefined while loading and for text with\n * no grammar. Pass a whole block, not one line: a line is not a parse unit.\n */\nexport function useSyntaxLines(text: string, query: { path?: string | undefined } = {}) {\n const grammar = detectGrammar({ path: query.path, text });\n const signature = `${grammar ?? ''}\\u0000${text}`;\n const [done, setDone] = useState<{ signature: string; lines: readonly (readonly SyntaxSpan[])[] }>();\n\n useEffect(() => {\n if (grammar === undefined) return;\n let live = true;\n const controller = new AbortController();\n void highlightToLines(text, grammar, controller.signal).then(\n (lines) => {\n if (live && lines !== undefined) setDone({ signature, lines });\n },\n // A grammar that fails to load leaves the plain text in place: colour is decoration.\n () => undefined,\n );\n return () => {\n live = false;\n controller.abort();\n };\n }, [text, grammar, signature]);\n\n return done?.signature === signature ? done.lines : undefined;\n}\n\nexport interface SyntaxLineProps extends Omit<TextProps, 'children'> {\n /** The line's spans from `useSyntaxLines`, or undefined to show `text` plain. */\n spans?: readonly SyntaxSpan[] | undefined;\n text: string;\n}\n\n/** One line: coloured when its spans are in, the plain text until then. */\nexport function SyntaxLine({ spans, text, ...props }: SyntaxLineProps) {\n return (\n <Text {...props}>\n {spans?.map((span, index) => (\n <Text key={index} style={span.token === undefined ? undefined : syntax[span.token]}>\n {span.text}\n </Text>\n )) ?? text}\n </Text>\n );\n}\n\n/** The web's `PO_SYNTAX_STYLES`, on the native theme's colours. */\nconst syntax = StyleSheet.create((theme) => ({\n comment: { color: theme.colors.faint, fontStyle: 'italic' },\n keyword: { color: theme.colors.magenta },\n constant: { color: theme.colors.violet },\n literal: { color: theme.colors.orange },\n string: { color: theme.colors.green },\n regexp: { color: theme.colors.teal },\n operator: { color: theme.colors.blue },\n punctuation: { color: theme.colors.dim },\n variable: { color: theme.colors.text },\n property: { color: theme.colors.cyan },\n callable: { color: theme.colors.blue },\n type: { color: theme.colors.yellow },\n tag: { color: theme.colors.red },\n attribute: { color: theme.colors.yellow },\n meta: { color: theme.colors.faint },\n heading: { color: theme.colors.hi, fontWeight: 'bold' },\n link: { color: theme.colors.cyan, textDecorationLine: 'underline' },\n emphasis: { fontStyle: 'italic' },\n strong: { fontWeight: 'bold' },\n strikethrough: { textDecorationLine: 'line-through' },\n invalid: { color: theme.colors.red },\n}));\n"],"mappings":";;;;;;;;;;;AAgBA,SAAgBO,eAAeC,MAAcC,QAAuC,CAAC,GAAG;CACtF,MAAME,UAAUX,cAAc;EAAEU,MAAMD,MAAMC;EAAMF;CAAK,CAAC;CACxD,MAAMI,YAAY,GAAGD,WAAW,GAAE,QAASH;CAC3C,MAAM,CAACK,MAAMC,WAAWV,SAA2E;CAEnGD,gBAAgB;EACd,IAAIQ,YAAYK,QAAW;EAC3B,IAAIC,OAAO;EACX,MAAMC,aAAa,IAAIC,gBAAgB;EACvC,AAAKlB,iBAAiBO,MAAMG,SAASO,WAAWE,MAAM,CAAC,CAACC,MACrDN,UAAU;GACT,IAAIE,QAAQF,UAAUC,QAAWF,QAAQ;IAAEF;IAAWG;GAAM,CAAC;EAC/D,SAEMC,MACR;EACA,aAAa;GACXC,OAAO;GACPC,WAAWI,MAAM;EACnB;CACF,GAAG;EAACd;EAAMG;EAASC;CAAS,CAAC;CAE7B,OAAOC,MAAMD,cAAcA,YAAYC,KAAKE,QAAQC;AACtD;;AASA,SAAgBU,WAAW,EAAED,OAAOjB,MAAM,GAAGmB,SAA0B;CACrE,OACE,oBAAC,MAAD;EAAM,GAAIA;YACPF,OAAOG,KAAKC,MAAMC,UACjB,oBAAC,MAAD;GAAkB,OAAOD,KAAKE,UAAUf,SAAYA,SAAYgB,OAAOH,KAAKE;aACzEF,KAAKrB;EACF,GAFKsB,KAEL,CACP,KAAKtB;CACF;AAEV;;AAGA,MAAMwB,SAAS1B,WAAW2B,QAAQC,WAAW;CAC3CC,SAAS;EAAEC,OAAOF,MAAMG,OAAOC;EAAOC,WAAW;EAAQC,mBAAA,CAAA,CAAA;CAAC;CAC1DC,SAAS;EAAEL,OAAOF,MAAMG,OAAOK;EAAOF,mBAAA,CAAA,CAAA;CAAC;CACvCG,UAAU;EAAEP,OAAOF,MAAMG,OAAOO;EA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e,EAAEH,oBAAoB,eAAe;CACpDI,SAAS;EAAErC,OAAOF,MAAMG,OAAOyB;EAAGtB,mBAAA,CAAA,CAAA;CAAC;AACrC,EAAE"}
|
package/dist/components/Tabs.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
-
import { wrapText } from "../lib/wrapText.mjs";
|
|
3
2
|
import { selectionTick } from "../lib/haptics.mjs";
|
|
3
|
+
import { wrapText } from "../lib/wrapText.mjs";
|
|
4
4
|
import { useControllable } from "../lib/useControllable.mjs";
|
|
5
5
|
import { View } from "react-native-unistyles/components/native/View";
|
|
6
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
7
6
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
7
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
8
8
|
import { createContext, useContext } from "react";
|
|
9
9
|
import { jsx } from "react/jsx-runtime";
|
|
10
10
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TextProps } from "react-native";
|
|
2
|
+
//#region src/components/ToolPathLink.d.ts
|
|
3
|
+
export interface ToolPathLinkProps extends Omit<TextProps, 'children' | 'onPress'> {
|
|
4
|
+
path: string;
|
|
5
|
+
/** Opens the file; omitted when nothing installed can show it. */
|
|
6
|
+
onOpen?: () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function ToolPathLink({ path, onOpen, style, ...props }: ToolPathLinkProps): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=ToolPathLink.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolPathLink.d.mts","names":[],"sources":["../../src/components/ToolPathLink.tsx"],"mappings":";;iBAYiB,0BAA0B,KAAK;EAC9C;;EAEA;;wBAGc,eAAe,MAAM,QAAQ,UAAU,SAAS,oCAAiB,IAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
3
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/components/ToolPathLink.tsx
|
|
7
|
+
function ToolPathLink({ path, onOpen, style, ...props }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
9
|
+
numberOfLines: 1,
|
|
10
|
+
ellipsizeMode: "middle",
|
|
11
|
+
testID: "tool-path",
|
|
12
|
+
...onOpen === void 0 ? {} : {
|
|
13
|
+
accessibilityRole: "link",
|
|
14
|
+
accessibilityHint: `open ${path}`,
|
|
15
|
+
onPress: onOpen
|
|
16
|
+
},
|
|
17
|
+
style: [
|
|
18
|
+
styles.path,
|
|
19
|
+
onOpen !== void 0 && styles.link,
|
|
20
|
+
style
|
|
21
|
+
],
|
|
22
|
+
...props,
|
|
23
|
+
children: path
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const styles = StyleSheet.create((theme) => ({
|
|
27
|
+
path: {
|
|
28
|
+
flexShrink: 1,
|
|
29
|
+
color: theme.colors.text,
|
|
30
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
31
|
+
fontSize: theme.fontSize.base,
|
|
32
|
+
lineHeight: theme.lineHeight.base,
|
|
33
|
+
uni__dependencies: [0]
|
|
34
|
+
},
|
|
35
|
+
link: { textDecorationLine: "underline" }
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
export { ToolPathLink };
|
|
40
|
+
//# sourceMappingURL=ToolPathLink.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolPathLink.mjs","names":["TextProps","StyleSheet","fontOf","ToolPathLinkProps","Omit","path","onOpen","ToolPathLink","style","props","undefined","accessibilityRole","const","accessibilityHint","onPress","styles","link","create","theme","flexShrink","color","colors","text","fontFamily","sans","fontSize","base","lineHeight","uni__dependencies","textDecorationLine"],"sources":["../../src/components/ToolPathLink.tsx"],"sourcesContent":["import { Text, type TextProps } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\n\n/*\n * The file path in a tool call's header, as a link when something can open it,\n * as the web's ToolPathLink. The host decides whether the path opens and hands\n * the answer down as `onOpen`; without one the path stays plain text, because\n * a link that opens nothing is worse than no link.\n */\n\nexport interface ToolPathLinkProps extends Omit<TextProps, 'children' | 'onPress'> {\n path: string;\n /** Opens the file; omitted when nothing installed can show it. */\n onOpen?: () => void;\n}\n\nexport function ToolPathLink({ path, onOpen, style, ...props }: ToolPathLinkProps) {\n return (\n <Text\n numberOfLines={1}\n ellipsizeMode=\"middle\"\n testID=\"tool-path\"\n {...(onOpen === undefined\n ? {}\n : { accessibilityRole: 'link' as const, accessibilityHint: `open ${path}`, onPress: onOpen })}\n style={[styles.path, onOpen !== undefined && styles.link, style]}\n {...props}\n >\n {path}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n path: {\n flexShrink: 1,\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n link: { textDecorationLine: 'underline' },\n}));\n"],"mappings":";;;;;;AAkBA,SAAgBO,aAAa,EAAEF,MAAMC,QAAQE,OAAO,GAAGC,SAA4B;CACjF,OACE,oBAAC,MAAD;EACE,eAAe;EACf,eAAc;EACd,QAAO;EACP,GAAKH,WAAWI,SACZ,CAAC,IACD;GAAEC,mBAAmB;GAAiBE,mBAAmB,QAAQR;GAAQS,SAASR;EAAO;EAC7F,OAAO;GAACS,OAAOV;GAAMC,WAAWI,UAAaK,OAAOC;GAAMR;EAAK;EAC/D,GAAIC;YAEHJ;CACG;AAEV;AAEA,MAAMU,SAASd,WAAWgB,QAAQC,WAAW;CAC3Cb,MAAM;EACJc,YAAY;EACZC,OAAOF,MAAMG,OAAOC;EACpBC,YAAYrB,OAAOgB,MAAMK,WAAWC,IAAI;EACxCC,UAAUP,MAAMO,SAASC;EACzBC,YAAYT,MAAMS,WAAWD;EAAIE,mBAAA,CAAA,CAAA;CACnC;CACAZ,MAAM,EAAEa,oBAAoB,YAAY;AAC1C,EAAE"}
|