@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.
- package/LICENSE +21 -149
- package/README.md +9 -51
- package/dist/components/AgentAvatar.d.mts +19 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +88 -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 +431 -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 +3 -3
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +42 -47
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/ComputerRow.d.mts +15 -0
- package/dist/components/ComputerRow.d.mts.map +1 -0
- package/dist/components/ComputerRow.mjs +107 -0
- package/dist/components/ComputerRow.mjs.map +1 -0
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +49 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/CountBadge.d.mts +15 -0
- package/dist/components/CountBadge.d.mts.map +1 -0
- package/dist/components/CountBadge.mjs +49 -0
- package/dist/components/CountBadge.mjs.map +1 -0
- package/dist/components/CtaCard.d.mts +19 -0
- package/dist/components/CtaCard.d.mts.map +1 -0
- package/dist/components/CtaCard.mjs +92 -0
- package/dist/components/CtaCard.mjs.map +1 -0
- package/dist/components/Dialog.d.mts +2 -2
- package/dist/components/Dialog.d.mts.map +1 -1
- package/dist/components/Dialog.mjs +16 -10
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +2 -2
- package/dist/components/DropdownMenu.d.mts +3 -1
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +21 -14
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/EmptyState.d.mts +31 -3
- package/dist/components/EmptyState.d.mts.map +1 -1
- package/dist/components/EmptyState.mjs +303 -29
- package/dist/components/EmptyState.mjs.map +1 -1
- package/dist/components/FileList.d.mts +48 -0
- package/dist/components/FileList.d.mts.map +1 -0
- package/dist/components/FileList.mjs +737 -0
- package/dist/components/FileList.mjs.map +1 -0
- package/dist/components/FilePreview.d.mts +33 -0
- package/dist/components/FilePreview.d.mts.map +1 -0
- package/dist/components/FilePreview.mjs +102 -0
- package/dist/components/FilePreview.mjs.map +1 -0
- package/dist/components/FileViewer.d.mts +57 -0
- package/dist/components/FileViewer.d.mts.map +1 -0
- package/dist/components/FileViewer.mjs +345 -0
- package/dist/components/FileViewer.mjs.map +1 -0
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +153 -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 +68 -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 +48 -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.d.mts +3 -1
- package/dist/components/Input.d.mts.map +1 -1
- package/dist/components/Input.mjs +4 -3
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/LinkText.d.mts +13 -0
- package/dist/components/LinkText.d.mts.map +1 -0
- package/dist/components/LinkText.mjs +32 -0
- package/dist/components/LinkText.mjs.map +1 -0
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +50 -11
- 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/LoadingState.d.mts +17 -0
- package/dist/components/LoadingState.d.mts.map +1 -0
- package/dist/components/LoadingState.mjs +90 -0
- package/dist/components/LoadingState.mjs.map +1 -0
- package/dist/components/Markdown.d.mts +24 -2
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +356 -27
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +10 -15
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +94 -68
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/NativeShellState.d.mts +30 -0
- package/dist/components/NativeShellState.d.mts.map +1 -0
- package/dist/components/NativeShellState.mjs +61 -0
- package/dist/components/NativeShellState.mjs.map +1 -0
- package/dist/components/RailItem.d.mts +13 -0
- package/dist/components/RailItem.d.mts.map +1 -0
- package/dist/components/RailItem.mjs +61 -0
- package/dist/components/RailItem.mjs.map +1 -0
- package/dist/components/ReferenceChip.d.mts +18 -0
- package/dist/components/ReferenceChip.d.mts.map +1 -0
- package/dist/components/ReferenceChip.mjs +38 -0
- package/dist/components/ReferenceChip.mjs.map +1 -0
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/SeekBar.d.mts +17 -0
- package/dist/components/SeekBar.d.mts.map +1 -0
- package/dist/components/SeekBar.mjs +97 -0
- package/dist/components/SeekBar.mjs.map +1 -0
- package/dist/components/Select.d.mts +39 -0
- package/dist/components/Select.d.mts.map +1 -0
- package/dist/components/Select.mjs +288 -0
- package/dist/components/Select.mjs.map +1 -0
- package/dist/components/Sheet.d.mts +17 -2
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +34 -11
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.mjs +149 -28
- 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/Switch.d.mts +14 -0
- package/dist/components/Switch.d.mts.map +1 -0
- package/dist/components/Switch.mjs +37 -0
- package/dist/components/Switch.mjs.map +1 -0
- 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.d.mts.map +1 -1
- package/dist/components/Tabs.mjs +8 -7
- package/dist/components/Tabs.mjs.map +1 -1
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +42 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/components/ToolResultImage.d.mts +21 -0
- package/dist/components/ToolResultImage.d.mts.map +1 -0
- package/dist/components/ToolResultImage.mjs +60 -0
- package/dist/components/ToolResultImage.mjs.map +1 -0
- package/dist/icons/IconColorContext.d.mts +2 -1
- package/dist/icons/IconColorContext.d.mts.map +1 -1
- package/dist/icons/IconColorContext.mjs.map +1 -1
- package/dist/icons/iconGlyphs.d.mts +132 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +132 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +133 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +35 -2
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +31 -7
- package/dist/index.mjs +36 -12
- package/dist/lib/fileKindLabel.mjs +17 -0
- package/dist/lib/fileKindLabel.mjs.map +1 -0
- 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/insideSheet.d.mts +10 -0
- package/dist/lib/insideSheet.d.mts.map +1 -0
- package/dist/lib/markdown.mjs +310 -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/useControllable.mjs +14 -6
- package/dist/lib/useControllable.mjs.map +1 -1
- package/dist/lib/useReadingPage.mjs +33 -0
- package/dist/lib/useReadingPage.mjs.map +1 -0
- package/dist/po-runtime-identity.json +1 -0
- package/dist/shell.d.mts +6 -0
- package/dist/shell.mjs +7 -0
- package/locales/vi.json +112 -0
- package/locales/zh-CN.json +112 -0
- package/package.json +43 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItem.d.mts","names":[],"sources":["../../src/components/MessageItem.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageItem.d.mts","names":[],"sources":["../../src/components/MessageItem.tsx"],"mappings":";;;;;;wBAsCgB,kBAAkB;;wBAKlB,SAAS;EAAS;EAAkB;IAAqB;;qBAK5D,cAAc,SAAS,OAAO;;qBA8B9B,cAAc,SAAS,OAAO;iBAmB1B,yBAAyB,KAAK;EAC7C,OAAO;;EAEP;EACA;;EAEA;EACA,oBAAoB;;EAEpB,WAAW,cAAc,OAAO,qBAAqB;EACrD,QAAQ,UAAU;;wBAGJ,cACd,MACA,YACA,iBACA,UACA,kBACA,UACA,UACG,SACF,mCAAgB,IAAA;iBA8FF,8BAA8B,KAAK;EAClD,OAAO;;EAEP,OAAO;;EAEP,UAAU;;EAEV,QAAQ;EACR,WAAW;EACX,QAAQ,UAAU;;;;;;;wBAQJ,mBACd,MACA,OACA,SACA,OACA,UACA,UACG,SACF,wCAAqB,IAAA;iBAoBP,+BAA+B,KAAK;;EAEnD,OAAO;;EAEP,QAAQ;;EAER,WAAW;EACX,QAAQ,UAAU;;;;;;;wBAQJ,oBAAoB,OAAO,OAAO,UAAU,UAAU,SAAS,yCAAsB,IAAA;iBAyCpF,6BAA6B,KAAK;EACjD,WAAW;EACX,QAAQ,UAAU;;;wBAIJ,kBAAkB,UAAU,UAAU,SAAS,uCAAoB,IAAA;iBAQlE,+BAA+B,KAAK;EACnD,OAAO;;EAEP;;EAEA;EACA,WAAW;;EAEX,iBAAiB,UAAU;;;wBAIb,oBACd,MACA,OACA,SACA,UACA,gBACA,UACG,SACF,yCAAsB,IAAA"}
|
|
@@ -7,28 +7,28 @@ import { AlertIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, WrenchIcon } f
|
|
|
7
7
|
import { useControllable } from "../lib/useControllable.mjs";
|
|
8
8
|
import { STATUS_EDGE, StatusBadge } from "./StatusBadge.mjs";
|
|
9
9
|
import { View } from "react-native-unistyles/components/native/View";
|
|
10
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
11
10
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
12
|
+
import { useContext, useMemo } from "react";
|
|
13
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
15
|
+
import { useT } from "@agimon-ai/po-core/native";
|
|
16
|
+
import { MessageItemContext, MessageItemGroupContext } from "@agimon-ai/po-native-components/shell";
|
|
15
17
|
|
|
16
18
|
//#region src/components/MessageItem.tsx
|
|
19
|
+
/** Tones whose outcome reads as an icon alone; the rest keep their worded badge. */
|
|
20
|
+
const ICON_TONES = /* @__PURE__ */ new Set([
|
|
21
|
+
"running",
|
|
22
|
+
"ok",
|
|
23
|
+
"error"
|
|
24
|
+
]);
|
|
17
25
|
const MIN_ROW_HEIGHT = 44;
|
|
18
26
|
const LEAD_CHIP = 36;
|
|
19
27
|
const ROW_EDGE_WIDTH = 2;
|
|
20
|
-
const MessageItemContext = createContext({
|
|
21
|
-
tone: "neutral",
|
|
22
|
-
expandable: false,
|
|
23
|
-
expanded: false,
|
|
24
|
-
toggle: () => void 0
|
|
25
|
-
});
|
|
26
28
|
/** The enclosing item's state, for a part that lives deeper than the item's render prop. */
|
|
27
29
|
function useMessageItem() {
|
|
28
30
|
return useContext(MessageItemContext);
|
|
29
31
|
}
|
|
30
|
-
/** The group an item is a row of, or null for an item that is a card of its own. */
|
|
31
|
-
const MessageItemGroupContext = createContext(null);
|
|
32
32
|
/** The tone a tool call's item wears: running while the tool runs, then its outcome. */
|
|
33
33
|
function toolTone(state) {
|
|
34
34
|
return state.running ? "running" : state.isError ? "error" : "ok";
|
|
@@ -42,6 +42,17 @@ const STATUS_LABEL = {
|
|
|
42
42
|
info: "Info",
|
|
43
43
|
accent: "Note"
|
|
44
44
|
};
|
|
45
|
+
/** STATUS_LABEL in the reader's language. */
|
|
46
|
+
function statusLabel(tone, t) {
|
|
47
|
+
switch (tone) {
|
|
48
|
+
case "running": return t("nativeComponents.messageItem.status.running", "Running");
|
|
49
|
+
case "ok": return t("nativeComponents.messageItem.status.ok", "Completed");
|
|
50
|
+
case "error": return t("nativeComponents.messageItem.status.error", "Failed");
|
|
51
|
+
case "info": return t("nativeComponents.messageItem.status.info", "Info");
|
|
52
|
+
case "accent": return t("nativeComponents.messageItem.status.accent", "Note");
|
|
53
|
+
default: return STATUS_LABEL[tone];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
45
56
|
/** The glyph a tone reads as in a status line. */
|
|
46
57
|
const STATUS_GLYPH = {
|
|
47
58
|
neutral: "…",
|
|
@@ -89,91 +100,107 @@ function Summary({ children }) {
|
|
|
89
100
|
});
|
|
90
101
|
}
|
|
91
102
|
/** The card's lead: the tool chip, the "Tool call" caption, then the name and its summary on one line. */
|
|
92
|
-
function ToolCallLead({ title, children }) {
|
|
93
|
-
|
|
103
|
+
function ToolCallLead({ title, caption: captionProp, children }) {
|
|
104
|
+
const t = useT();
|
|
105
|
+
const caption = captionProp === void 0 ? t("nativeComponents.messageItem.toolCall", "Tool call") : captionProp;
|
|
106
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(View, {
|
|
94
107
|
accessible: false,
|
|
95
108
|
style: styles.chip,
|
|
96
109
|
children: /* @__PURE__ */ jsx(WrenchIcon, { size: 16 })
|
|
97
110
|
}), /* @__PURE__ */ jsxs(View, {
|
|
98
111
|
style: styles.lead,
|
|
99
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
112
|
+
children: [caption === null ? null : /* @__PURE__ */ jsx(Text, {
|
|
100
113
|
style: styles.caption,
|
|
101
|
-
children:
|
|
114
|
+
children: caption
|
|
102
115
|
}), /* @__PURE__ */ jsxs(View, {
|
|
103
116
|
style: styles.titleLine,
|
|
104
117
|
children: [wrapText(title, styles.title), /* @__PURE__ */ jsx(Summary, { children })]
|
|
105
118
|
})]
|
|
106
119
|
})] });
|
|
107
120
|
}
|
|
108
|
-
/**
|
|
109
|
-
function
|
|
121
|
+
/** A row's lead inside a group: the name and its summary, no chip or caption, since the group header carries them. */
|
|
122
|
+
function RowLead({ title, children }) {
|
|
123
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
124
|
+
style: [styles.lead, styles.titleLine],
|
|
125
|
+
children: [wrapText(title, styles.title), /* @__PURE__ */ jsx(Summary, { children })]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/** The outcome: an icon for running, done and failed, announced by its label; a worded badge for other tones. */
|
|
129
|
+
function Outcome({ tone, children }) {
|
|
130
|
+
const t = useT();
|
|
110
131
|
const ink = STATUS_COLORS[tone].ink;
|
|
111
|
-
return /* @__PURE__ */ jsxs(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
132
|
+
if (ICON_TONES.has(tone)) return /* @__PURE__ */ jsxs(View, {
|
|
133
|
+
accessible: true,
|
|
134
|
+
accessibilityRole: "image",
|
|
135
|
+
accessibilityLabel: typeof children === "string" ? children : statusLabel(tone, t),
|
|
136
|
+
style: styles.outcomeIcon,
|
|
115
137
|
children: [
|
|
116
138
|
tone === "running" ? /* @__PURE__ */ jsx(Spinner, { color: ink }) : null,
|
|
117
139
|
tone === "ok" ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
118
|
-
size:
|
|
140
|
+
size: 14,
|
|
119
141
|
color: ink
|
|
120
142
|
}) : null,
|
|
121
143
|
tone === "error" ? /* @__PURE__ */ jsx(AlertIcon, {
|
|
122
|
-
size:
|
|
144
|
+
size: 14,
|
|
123
145
|
color: ink
|
|
124
|
-
}) : null
|
|
125
|
-
children
|
|
146
|
+
}) : null
|
|
126
147
|
]
|
|
127
148
|
});
|
|
149
|
+
return /* @__PURE__ */ jsx(StatusBadge, {
|
|
150
|
+
tone,
|
|
151
|
+
size: "md",
|
|
152
|
+
style: styles.outcome,
|
|
153
|
+
children
|
|
154
|
+
});
|
|
128
155
|
}
|
|
129
156
|
/**
|
|
130
|
-
* One frame around a run of items that belong together.
|
|
131
|
-
* becomes a row
|
|
132
|
-
* an edge down its left side.
|
|
157
|
+
* One frame around a run of items that belong together. It stays open: each
|
|
158
|
+
* item inside becomes a row with its own name, outcome and expand, no card of
|
|
159
|
+
* its own, and its tone an edge down its left side.
|
|
133
160
|
*/
|
|
134
161
|
function MessageItemGroup({ tone = "neutral", title, summary, badge, children, style, ...props }) {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
162
|
+
const t = useT();
|
|
163
|
+
const label = badge === void 0 ? statusLabel(tone, t) : badge;
|
|
164
|
+
const group = useMemo(() => ({ tone }), [tone]);
|
|
165
|
+
return /* @__PURE__ */ jsxs(MessageItem, {
|
|
166
|
+
tone,
|
|
167
|
+
style,
|
|
168
|
+
...props,
|
|
169
|
+
children: [/* @__PURE__ */ jsxs(View, {
|
|
170
|
+
style: styles.header,
|
|
171
|
+
children: [/* @__PURE__ */ jsx(ToolCallLead, {
|
|
172
|
+
title,
|
|
173
|
+
caption: null,
|
|
174
|
+
children: summary
|
|
175
|
+
}), label !== null && label !== "" ? /* @__PURE__ */ jsx(Outcome, {
|
|
176
|
+
tone,
|
|
177
|
+
children: label
|
|
178
|
+
}) : null]
|
|
179
|
+
}), /* @__PURE__ */ jsx(MessageItemGroupContext.Provider, {
|
|
180
|
+
value: group,
|
|
181
|
+
children: /* @__PURE__ */ jsx(View, { children })
|
|
182
|
+
})]
|
|
157
183
|
});
|
|
158
184
|
}
|
|
159
|
-
/** Inside a group these two are the quiet outcome: the group's header has already said it. */
|
|
160
|
-
const SILENT_IN_GROUP = /* @__PURE__ */ new Set(["ok", "neutral"]);
|
|
161
185
|
/**
|
|
162
|
-
* The title row: label, summary, the tone's
|
|
186
|
+
* The title row: label, summary, the tone's outcome and, when the item is
|
|
163
187
|
* expandable, a chevron; the whole row is the toggle. A row inside a group
|
|
164
|
-
*
|
|
188
|
+
* keeps its name but drops the chip and caption the group header carries.
|
|
165
189
|
*/
|
|
166
190
|
function MessageItemHeader({ title, badge, children, style, ...props }) {
|
|
167
191
|
const { tone, expandable, expanded, toggle } = useMessageItem();
|
|
168
192
|
const group = useContext(MessageItemGroupContext);
|
|
169
|
-
const
|
|
170
|
-
const label = badge === void 0 ?
|
|
171
|
-
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
193
|
+
const t = useT();
|
|
194
|
+
const label = badge === void 0 ? statusLabel(tone, t) : badge;
|
|
195
|
+
const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
172
196
|
group === null ? /* @__PURE__ */ jsx(ToolCallLead, {
|
|
173
197
|
title,
|
|
174
198
|
children
|
|
175
|
-
}) : /* @__PURE__ */ jsx(
|
|
176
|
-
|
|
199
|
+
}) : /* @__PURE__ */ jsx(RowLead, {
|
|
200
|
+
title,
|
|
201
|
+
children
|
|
202
|
+
}),
|
|
203
|
+
label !== null && label !== "" ? /* @__PURE__ */ jsx(Outcome, {
|
|
177
204
|
tone,
|
|
178
205
|
children: label
|
|
179
206
|
}) : null,
|
|
@@ -187,7 +214,7 @@ function MessageItemHeader({ title, badge, children, style, ...props }) {
|
|
|
187
214
|
return /* @__PURE__ */ jsx(Pressable, {
|
|
188
215
|
accessibilityRole: "button",
|
|
189
216
|
accessibilityState: { expanded },
|
|
190
|
-
accessibilityHint: expanded ? "collapse" : "expand",
|
|
217
|
+
accessibilityHint: expanded ? t("nativeComponents.messageItem.collapseHint", "collapse") : t("nativeComponents.messageItem.expandHint", "expand"),
|
|
191
218
|
onPress: toggle,
|
|
192
219
|
style: ({ pressed }) => [
|
|
193
220
|
styles.header,
|
|
@@ -315,18 +342,17 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
315
342
|
lineHeight: theme.lineHeight.base,
|
|
316
343
|
uni__dependencies: [0]
|
|
317
344
|
},
|
|
318
|
-
faint: {
|
|
319
|
-
flexShrink: 1,
|
|
320
|
-
color: theme.colors.faint,
|
|
321
|
-
fontFamily: fontOf(theme.fontFamily.sans),
|
|
322
|
-
fontSize: theme.fontSize.base,
|
|
323
|
-
lineHeight: theme.lineHeight.base,
|
|
324
|
-
uni__dependencies: [0]
|
|
325
|
-
},
|
|
326
345
|
outcome: {
|
|
327
346
|
gap: theme.spacing(1),
|
|
328
347
|
uni__dependencies: [0]
|
|
329
348
|
},
|
|
349
|
+
outcomeIcon: {
|
|
350
|
+
alignItems: "center",
|
|
351
|
+
justifyContent: "center",
|
|
352
|
+
width: 20,
|
|
353
|
+
height: 20,
|
|
354
|
+
flexShrink: 0
|
|
355
|
+
},
|
|
330
356
|
body: {
|
|
331
357
|
gap: theme.spacing(1),
|
|
332
358
|
borderTopWidth: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageItem.mjs","names":["NativeColorToken","createContext","ReactNode","useContext","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","AlertIcon","CheckIcon","ChevronDownIcon","ChevronRightIcon","WrenchIcon","fontOf","STATUS_COLORS","useControllable","wrapText","Button","Spinner","STATUS_EDGE","StatusBadge","StatusTone","MIN_ROW_HEIGHT","LEAD_CHIP","ROW_EDGE_WIDTH","MessageItemState","tone","expandable","expanded","toggle","MessageItemContext","undefined","useMessageItem","MessageItemGroupContext","toolTone","state","running","isError","STATUS_LABEL","Readonly","Record","neutral","ok","error","info","accent","STATUS_GLYPH","cardEdge","rowEdge","MessageItemProps","Omit","defaultExpanded","onExpandedChange","children","style","MessageItem","props","current","setExpanded","group","styles","Summary","summary","summaryText","ToolCallLead","title","chip","lead","caption","titleLine","OutcomeBadge","ink","outcome","MessageItemGroupProps","badge","MessageItemGroup","label","header","faint","MessageItemHeaderProps","SILENT_IN_GROUP","ReadonlySet","Set","MessageItemHeader","defaultLabel","has","content","pressed","headerPressed","MessageItemPartProps","MessageItemBody","body","bodyText","MessageItemStatusProps","glyph","expands","containerStyle","MessageItemStatus","line","status","more","create","theme","token","overflow","borderRadius","lg","borderWidth","borderColor","colors","uni__dependencies","borderTopWidth","borderTopColor","borderLeftWidth","borderLeftColor","flexDirection","alignItems","gap","spacing","minHeight","paddingHorizontal","paddingVertical","backgroundColor","panel","justifyContent","width","height","flexShrink","full","rail","flex","minWidth","color","dim","fontFamily","sans","fontSize","sm","lineHeight","hi","base","fontWeight","semibold","alignSelf"],"sources":["../../src/components/MessageItem.tsx"],"sourcesContent":["import type { NativeColorToken } from '@agimon-ai/po-web-components/nativeTheme';\nimport { createContext, type ReactNode, useContext } from 'react';\nimport { Pressable, type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { AlertIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, WrenchIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { STATUS_COLORS } from '../lib/tone';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button } from './Button';\nimport { Spinner } from './Spinner';\nimport { STATUS_EDGE, StatusBadge, type StatusTone } from './StatusBadge';\n\n/*\n * The message item: the timeline card a tool call, a run or a notice sits in.\n * The item owns its outcome tone and its expand state; the header, body and\n * status parts read both from it, so a card composes the parts and never\n * threads `expanded` by hand. The header is one Pressable that expands the\n * item, the native stand-in for the web's small chevron button.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst LEAD_CHIP = 36;\nconst ROW_EDGE_WIDTH = 2;\n\nexport interface MessageItemState {\n tone: StatusTone;\n /** Whether the header offers the toggle; an item that hides nothing offers none. */\n expandable: boolean;\n expanded: boolean;\n toggle: () => void;\n}\n\nconst MessageItemContext = createContext<MessageItemState>({\n tone: 'neutral',\n expandable: false,\n expanded: false,\n toggle: () => undefined,\n});\n\n/** The enclosing item's state, for a part that lives deeper than the item's render prop. */\nexport function useMessageItem(): MessageItemState {\n return useContext(MessageItemContext);\n}\n\n/** The group an item is a row of, or null for an item that is a card of its own. */\nconst MessageItemGroupContext = createContext<{ tone: StatusTone } | null>(null);\n\n/** The tone a tool call's item wears: running while the tool runs, then its outcome. */\nexport function toolTone(state: { running: boolean; isError: boolean }): StatusTone {\n return state.running ? 'running' : state.isError ? 'error' : 'ok';\n}\n\n/** The badge text a tone reads as when the header is not told otherwise; empty hides the badge. */\nexport const STATUS_LABEL: Readonly<Record<StatusTone, string>> = {\n neutral: '',\n running: 'Running',\n ok: 'Completed',\n error: 'Failed',\n info: 'Info',\n accent: 'Note',\n};\n\n/** The glyph a tone reads as in a status line. */\nexport const STATUS_GLYPH: Readonly<Record<StatusTone, string>> = {\n neutral: '\\u2026',\n running: '\\u25d0',\n ok: '\\u2713',\n error: '\\u2717',\n info: '\\u25cf',\n accent: '\\u25cf',\n};\n\n/** A settled OK is the calm default and keeps the soft border; only work in flight or a failure colours the edge. */\nfunction cardEdge(tone: StatusTone): NativeColorToken {\n return tone === 'ok' ? 'border-soft' : STATUS_EDGE[tone];\n}\n\n/** As a row, a settled or neutral item keeps a quiet edge. */\nfunction rowEdge(tone: StatusTone): NativeColorToken | undefined {\n return tone === 'ok' || tone === 'neutral' ? undefined : STATUS_EDGE[tone];\n}\n\nexport interface MessageItemProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** Whether the header offers the expand toggle. A toggle that reveals nothing reads as broken, so the card decides. */\n expandable?: boolean;\n defaultExpanded?: boolean;\n /** Controlled mode; pair with onExpandedChange. Omit it and the item keeps its own state. */\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Plain content, or a function of the item's state for a card that picks its lines by `expanded`. */\n children?: ReactNode | ((state: MessageItemState) => ReactNode);\n style?: StyleProp<ViewStyle>;\n}\n\nexport function MessageItem({\n tone = 'neutral',\n expandable = false,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n children,\n style,\n ...props\n}: MessageItemProps) {\n const [current, setExpanded] = useControllable(expanded, defaultExpanded, onExpandedChange);\n const group = useContext(MessageItemGroupContext);\n const state: MessageItemState = { tone, expandable, expanded: current, toggle: () => setExpanded(!current) };\n return (\n <MessageItemContext.Provider value={state}>\n <View\n style={[group === null ? styles.cardEdge(cardEdge(tone)) : styles.rowEdge(rowEdge(tone)), style]}\n {...props}\n >\n {typeof children === 'function' ? children(state) : children}\n </View>\n </MessageItemContext.Provider>\n );\n}\n\n/** The line beside the title; a bare string stays on one line and truncates, as the web's `truncate`. */\nfunction Summary({ children }: { children?: ReactNode }) {\n return (\n <View style={styles.summary}>\n {typeof children === 'string' ? (\n <Text numberOfLines={1} style={styles.summaryText}>\n {children}\n </Text>\n ) : (\n wrapText(children, styles.summaryText)\n )}\n </View>\n );\n}\n\n/** The card's lead: the tool chip, the \"Tool call\" caption, then the name and its summary on one line. */\nfunction ToolCallLead({ title, children }: { title: ReactNode; children?: ReactNode }) {\n return (\n <>\n <View accessible={false} style={styles.chip}>\n <WrenchIcon size={16} />\n </View>\n <View style={styles.lead}>\n <Text style={styles.caption}>Tool call</Text>\n <View style={styles.titleLine}>\n {wrapText(title, styles.title)}\n <Summary>{children}</Summary>\n </View>\n </View>\n </>\n );\n}\n\n/** The sentence-case outcome pill, led by the tone's icon. */\nfunction OutcomeBadge({ tone, children }: { tone: StatusTone; children: ReactNode }) {\n const ink = STATUS_COLORS[tone].ink;\n return (\n <StatusBadge tone={tone} size=\"md\" style={styles.outcome}>\n {tone === 'running' ? <Spinner color={ink} /> : null}\n {tone === 'ok' ? <CheckIcon size={12} color={ink} /> : null}\n {tone === 'error' ? <AlertIcon size={12} color={ink} /> : null}\n {children}\n </StatusBadge>\n );\n}\n\nexport interface MessageItemGroupProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** The bold label at the left of the group header: the tool the run belongs to. */\n title: ReactNode;\n /** The line beside it, such as how many calls the group holds. */\n summary?: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * One frame around a run of items that belong together. Each item inside\n * becomes a row: same header, same expand, no card of its own, and its tone\n * an edge down its left side.\n */\nexport function MessageItemGroup({\n tone = 'neutral',\n title,\n summary,\n badge,\n children,\n style,\n ...props\n}: MessageItemGroupProps) {\n const label = badge === undefined ? STATUS_LABEL[tone] : badge;\n return (\n <MessageItemGroupContext.Provider value={{ tone }}>\n <View style={[styles.cardEdge(cardEdge(tone)), style]} {...props}>\n <View accessibilityRole=\"header\" style={styles.header}>\n <ToolCallLead title={title}>\n {typeof summary === 'string' ? (\n <Text numberOfLines={1} style={styles.faint}>\n {summary}\n </Text>\n ) : (\n summary\n )}\n </ToolCallLead>\n {label !== null && label !== '' ? <OutcomeBadge tone={tone}>{label}</OutcomeBadge> : null}\n </View>\n <View>{children}</View>\n </View>\n </MessageItemGroupContext.Provider>\n );\n}\n\nexport interface MessageItemHeaderProps extends Omit<ViewProps, 'children' | 'style'> {\n /** The bold label at the left: the tool name. */\n title: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n /** The summary beside the title; it gets the remaining width. */\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** Inside a group these two are the quiet outcome: the group's header has already said it. */\nconst SILENT_IN_GROUP: ReadonlySet<StatusTone> = new Set<StatusTone>(['ok', 'neutral']);\n\n/**\n * The title row: label, summary, the tone's badge and, when the item is\n * expandable, a chevron; the whole row is the toggle. A row inside a group\n * drops its title and speaks up only when something failed or is running.\n */\nexport function MessageItemHeader({ title, badge, children, style, ...props }: MessageItemHeaderProps) {\n const { tone, expandable, expanded, toggle } = useMessageItem();\n const group = useContext(MessageItemGroupContext);\n const defaultLabel = group !== null && SILENT_IN_GROUP.has(tone) ? null : STATUS_LABEL[tone];\n const label = badge === undefined ? defaultLabel : badge;\n const content = (\n <>\n {group === null ? <ToolCallLead title={title}>{children}</ToolCallLead> : <Summary>{children}</Summary>}\n {label !== null && label !== '' ? <OutcomeBadge tone={tone}>{label}</OutcomeBadge> : null}\n {expandable ? expanded ? <ChevronDownIcon size={16} /> : <ChevronRightIcon size={16} /> : null}\n </>\n );\n if (!expandable) {\n return (\n <View style={[styles.header, style]} {...props}>\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded }}\n accessibilityHint={expanded ? 'collapse' : 'expand'}\n onPress={toggle}\n style={({ pressed }) => [styles.header, pressed && styles.headerPressed, style]}\n {...props}\n >\n {content}\n </Pressable>\n );\n}\n\nexport interface MessageItemPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The body under the header, on the card's own surface. */\nexport function MessageItemBody({ children, style, ...props }: MessageItemPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.bodyText)}\n </View>\n );\n}\n\nexport interface MessageItemStatusProps extends Omit<TextProps, 'children'> {\n tone?: StatusTone;\n /** Replaces the tone's glyph. */\n glyph?: string;\n /** Renders as a button that expands the item: the \"N more line(s)\" hint. */\n expands?: boolean;\n children?: ReactNode;\n /** Applied to the row; with `expands`, to the button. */\n containerStyle?: StyleProp<ViewStyle>;\n}\n\n/** The one-line status under a body: `running`, `failed`, `done`, or the hint that more is hidden. */\nexport function MessageItemStatus({\n tone = 'neutral',\n glyph,\n expands = false,\n children,\n containerStyle,\n style,\n ...props\n}: MessageItemStatusProps) {\n const { toggle } = useMessageItem();\n const line = (\n <Text style={[styles.status, style]} {...props}>\n <Text style={styles.glyph(tone)}>{glyph ?? STATUS_GLYPH[tone]}</Text> {children}\n </Text>\n );\n if (expands) {\n return (\n <Button variant=\"ghost\" size=\"xs\" onPress={toggle} style={[styles.more, containerStyle]}>\n {line}\n </Button>\n );\n }\n return <View style={containerStyle}>{line}</View>;\n}\n\nconst styles = StyleSheet.create((theme) => ({\n cardEdge: (token: NativeColorToken) => ({\n overflow: 'hidden',\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors[token],\n }),\n // A row's top rule is the group's separator; its left edge carries the tone.\n rowEdge: (token: NativeColorToken | undefined) => ({\n overflow: 'hidden',\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n borderLeftWidth: ROW_EDGE_WIDTH,\n borderLeftColor: token === undefined ? 'transparent' : theme.colors[token],\n }),\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: MIN_ROW_HEIGHT,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n headerPressed: { backgroundColor: theme.colors.panel },\n chip: {\n alignItems: 'center',\n justifyContent: 'center',\n width: LEAD_CHIP,\n height: LEAD_CHIP,\n flexShrink: 0,\n borderRadius: theme.borderRadius.full,\n backgroundColor: theme.colors.rail,\n },\n lead: { flex: 1, minWidth: 0 },\n caption: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n titleLine: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n title: {\n flexShrink: 0,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n },\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n summaryText: {\n flexShrink: 1,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n faint: {\n flexShrink: 1,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n outcome: { gap: theme.spacing(1) },\n body: {\n gap: theme.spacing(1),\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n bodyText: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n status: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n glyph: (tone: StatusTone) => ({ color: theme.colors[STATUS_COLORS[tone].ink] }),\n more: { alignSelf: 'flex-start' },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,MAAMuB,iBAAiB;AACvB,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;AAUvB,MAAMM,qBAAqB9B,cAAgC;CACzD0B,MAAM;CACNC,YAAY;CACZC,UAAU;CACVC,cAAcE;AAChB,CAAC;;AAGD,SAAgBC,iBAAmC;CACjD,OAAO9B,WAAW4B,kBAAkB;AACtC;;AAGA,MAAMG,0BAA0BjC,cAA2C,IAAI;;AAG/E,SAAgBkC,SAASC,OAA2D;CAClF,OAAOA,MAAMC,UAAU,YAAYD,MAAME,UAAU,UAAU;AAC/D;;AAGA,MAAaC,eAAqD;CAChEG,SAAS;CACTL,SAAS;CACTM,IAAI;CACJC,OAAO;CACPC,MAAM;CACNC,QAAQ;AACV;;AAGA,MAAaC,eAAqD;CAChEL,SAAS;CACTL,SAAS;CACTM,IAAI;CACJC,OAAO;CACPC,MAAM;CACNC,QAAQ;AACV;;AAGA,SAASE,SAASrB,MAAoC;CACpD,OAAOA,SAAS,OAAO,gBAAgBP,YAAYO;AACrD;;AAGA,SAASsB,QAAQtB,MAAgD;CAC/D,OAAOA,SAAS,QAAQA,SAAS,YAAYK,SAAYZ,YAAYO;AACvE;AAeA,SAAgB6B,YAAY,EAC1B7B,OAAO,WACPC,aAAa,OACbwB,kBAAkB,OAClBvB,UACAwB,kBACAC,UACAC,OACA,GAAGE,SACgB;CACnB,MAAM,CAACC,SAASC,eAAe3C,gBAAgBa,UAAUuB,iBAAiBC,gBAAgB;CAC1F,MAAMO,QAAQzD,WAAW+B,uBAAuB;CAChD,MAAME,QAA0B;EAAET;EAAMC;EAAYC,UAAU6B;EAAS5B,cAAc6B,YAAY,CAACD,OAAO;CAAE;CAC3G,OACE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ACzBC,YAAYpC,MAAMoC,WAAWD;EAAE3B,mBAAA,CAAA,CAAA;CACjC;CACAhB,QAAQpE,UAAsB;EAAE0G,OAAO9B,MAAMO,OAAO/F,cAAcY,KAAK,CAAC6C;EAAIuC,mBAAA,CAAA,CAAA;CAAC;CAC7EV,MAAM,EAAE2C,WAAW,aAAa;AAClC,EAAE"}
|
|
1
|
+
{"version":3,"file":"MessageItem.mjs","names":["useT","MessageItemContext","MessageItemGroupContext","MessageItemState","NativeColorToken","ReactNode","useContext","useMemo","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","AlertIcon","CheckIcon","ChevronDownIcon","ChevronRightIcon","WrenchIcon","fontOf","STATUS_COLORS","useControllable","wrapText","Button","Spinner","STATUS_EDGE","StatusBadge","StatusTone","ICON_TONES","ReadonlySet","Set","MIN_ROW_HEIGHT","LEAD_CHIP","ROW_EDGE_WIDTH","useMessageItem","toolTone","state","running","isError","STATUS_LABEL","Readonly","Record","neutral","ok","error","info","accent","Translate","ReturnType","statusLabel","tone","t","STATUS_GLYPH","cardEdge","rowEdge","undefined","MessageItemProps","Omit","expandable","defaultExpanded","expanded","onExpandedChange","children","style","MessageItem","props","current","setExpanded","group","toggle","styles","Summary","summary","summaryText","ToolCallLead","title","caption","captionProp","chip","lead","titleLine","RowLead","Outcome","ink","has","outcomeIcon","outcome","MessageItemGroupProps","badge","MessageItemGroup","label","header","MessageItemHeaderProps","MessageItemHeader","content","pressed","headerPressed","MessageItemPartProps","MessageItemBody","body","bodyText","MessageItemStatusProps","glyph","expands","containerStyle","MessageItemStatus","line","status","more","create","theme","token","overflow","borderRadius","lg","borderWidth","borderColor","colors","uni__dependencies","borderTopWidth","borderTopColor","borderLeftWidth","borderLeftColor","flexDirection","alignItems","gap","spacing","minHeight","paddingHorizontal","paddingVertical","backgroundColor","panel","justifyContent","width","height","flexShrink","full","rail","flex","minWidth","color","dim","fontFamily","sans","fontSize","sm","lineHeight","hi","base","fontWeight","semibold","faint","alignSelf"],"sources":["../../src/components/MessageItem.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport {\n MessageItemContext,\n MessageItemGroupContext,\n type MessageItemState,\n} from '@agimon-ai/po-native-components/shell';\nimport type { NativeColorToken } from '@agimon-ai/po-web-components/nativeTheme';\nimport { type ReactNode, useContext, useMemo } from 'react';\nimport { Pressable, type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { AlertIcon, CheckIcon, ChevronDownIcon, ChevronRightIcon, WrenchIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { STATUS_COLORS } from '../lib/tone';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button } from './Button';\nimport { Spinner } from './Spinner';\nimport { STATUS_EDGE, StatusBadge, type StatusTone } from './StatusBadge';\n\n/** Tones whose outcome reads as an icon alone; the rest keep their worded badge. */\nconst ICON_TONES: ReadonlySet<StatusTone> = new Set<StatusTone>(['running', 'ok', 'error']);\n\n/*\n * The message item: the timeline card a tool call, a run or a notice sits in.\n * The item owns its outcome tone and its expand state; the header, body and\n * status parts read both from it, so a card composes the parts and never\n * threads `expanded` by hand. The header is one Pressable that expands the\n * item, the native stand-in for the web's small chevron button.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst LEAD_CHIP = 36;\nconst ROW_EDGE_WIDTH = 2;\n\nexport type { MessageItemState } from '@agimon-ai/po-native-components/shell';\n\n/** The enclosing item's state, for a part that lives deeper than the item's render prop. */\nexport function useMessageItem(): MessageItemState {\n return useContext(MessageItemContext);\n}\n\n/** The tone a tool call's item wears: running while the tool runs, then its outcome. */\nexport function toolTone(state: { running: boolean; isError: boolean }): StatusTone {\n return state.running ? 'running' : state.isError ? 'error' : 'ok';\n}\n\n/** The badge text a tone reads as when the header is not told otherwise; empty hides the badge. */\nexport const STATUS_LABEL: Readonly<Record<StatusTone, string>> = {\n neutral: '',\n running: 'Running',\n ok: 'Completed',\n error: 'Failed',\n info: 'Info',\n accent: 'Note',\n};\n\ntype Translate = ReturnType<typeof useT>;\n\n/** STATUS_LABEL in the reader's language. */\nfunction statusLabel(tone: StatusTone, t: Translate): string {\n switch (tone) {\n case 'running':\n return t('nativeComponents.messageItem.status.running', 'Running');\n case 'ok':\n return t('nativeComponents.messageItem.status.ok', 'Completed');\n case 'error':\n return t('nativeComponents.messageItem.status.error', 'Failed');\n case 'info':\n return t('nativeComponents.messageItem.status.info', 'Info');\n case 'accent':\n return t('nativeComponents.messageItem.status.accent', 'Note');\n default:\n return STATUS_LABEL[tone];\n }\n}\n\n/** The glyph a tone reads as in a status line. */\nexport const STATUS_GLYPH: Readonly<Record<StatusTone, string>> = {\n neutral: '\\u2026',\n running: '\\u25d0',\n ok: '\\u2713',\n error: '\\u2717',\n info: '\\u25cf',\n accent: '\\u25cf',\n};\n\n/** A settled OK is the calm default and keeps the soft border; only work in flight or a failure colours the edge. */\nfunction cardEdge(tone: StatusTone): NativeColorToken {\n return tone === 'ok' ? 'border-soft' : STATUS_EDGE[tone];\n}\n\n/** As a row, a settled or neutral item keeps a quiet edge. */\nfunction rowEdge(tone: StatusTone): NativeColorToken | undefined {\n return tone === 'ok' || tone === 'neutral' ? undefined : STATUS_EDGE[tone];\n}\n\nexport interface MessageItemProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** Whether the header offers the expand toggle. A toggle that reveals nothing reads as broken, so the card decides. */\n expandable?: boolean;\n defaultExpanded?: boolean;\n /** Controlled mode; pair with onExpandedChange. Omit it and the item keeps its own state. */\n expanded?: boolean;\n onExpandedChange?: (expanded: boolean) => void;\n /** Plain content, or a function of the item's state for a card that picks its lines by `expanded`. */\n children?: ReactNode | ((state: MessageItemState) => ReactNode);\n style?: StyleProp<ViewStyle>;\n}\n\nexport function MessageItem({\n tone = 'neutral',\n expandable = false,\n defaultExpanded = false,\n expanded,\n onExpandedChange,\n children,\n style,\n ...props\n}: MessageItemProps) {\n const [current, setExpanded] = useControllable(expanded, defaultExpanded, onExpandedChange);\n const group = useContext(MessageItemGroupContext);\n const state: MessageItemState = { tone, expandable, expanded: current, toggle: () => setExpanded(!current) };\n return (\n <MessageItemContext.Provider value={state}>\n <View\n style={[group === null ? styles.cardEdge(cardEdge(tone)) : styles.rowEdge(rowEdge(tone)), style]}\n {...props}\n >\n {typeof children === 'function' ? children(state) : children}\n </View>\n </MessageItemContext.Provider>\n );\n}\n\n/** The line beside the title; a bare string stays on one line and truncates, as the web's `truncate`. */\nfunction Summary({ children }: { children?: ReactNode }) {\n return (\n <View style={styles.summary}>\n {typeof children === 'string' ? (\n <Text numberOfLines={1} style={styles.summaryText}>\n {children}\n </Text>\n ) : (\n wrapText(children, styles.summaryText)\n )}\n </View>\n );\n}\n\n/** The card's lead: the tool chip, the \"Tool call\" caption, then the name and its summary on one line. */\nfunction ToolCallLead({\n title,\n caption: captionProp,\n children,\n}: {\n title: ReactNode;\n caption?: string | null;\n children?: ReactNode;\n}) {\n const t = useT();\n const caption = captionProp === undefined ? t('nativeComponents.messageItem.toolCall', 'Tool call') : captionProp;\n return (\n <>\n <View accessible={false} style={styles.chip}>\n <WrenchIcon size={16} />\n </View>\n <View style={styles.lead}>\n {caption === null ? null : <Text style={styles.caption}>{caption}</Text>}\n <View style={styles.titleLine}>\n {wrapText(title, styles.title)}\n <Summary>{children}</Summary>\n </View>\n </View>\n </>\n );\n}\n\n/** A row's lead inside a group: the name and its summary, no chip or caption, since the group header carries them. */\nfunction RowLead({ title, children }: { title: ReactNode; children?: ReactNode }) {\n return (\n <View style={[styles.lead, styles.titleLine]}>\n {wrapText(title, styles.title)}\n <Summary>{children}</Summary>\n </View>\n );\n}\n\n/** The outcome: an icon for running, done and failed, announced by its label; a worded badge for other tones. */\nfunction Outcome({ tone, children }: { tone: StatusTone; children: ReactNode }) {\n const t = useT();\n const ink = STATUS_COLORS[tone].ink;\n if (ICON_TONES.has(tone)) {\n return (\n <View\n accessible\n accessibilityRole=\"image\"\n accessibilityLabel={typeof children === 'string' ? children : statusLabel(tone, t)}\n style={styles.outcomeIcon}\n >\n {tone === 'running' ? <Spinner color={ink} /> : null}\n {tone === 'ok' ? <CheckIcon size={14} color={ink} /> : null}\n {tone === 'error' ? <AlertIcon size={14} color={ink} /> : null}\n </View>\n );\n }\n return (\n <StatusBadge tone={tone} size=\"md\" style={styles.outcome}>\n {children}\n </StatusBadge>\n );\n}\n\nexport interface MessageItemGroupProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: StatusTone;\n /** The bold label at the left of the group header, such as \"7 tool calls\". */\n title: ReactNode;\n /** The line beside it, such as which tools the group holds. */\n summary?: ReactNode;\n /** The outcome's label; defaults to the tone's label, null hides the outcome. */\n badge?: ReactNode | null;\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * One frame around a run of items that belong together. It stays open: each\n * item inside becomes a row with its own name, outcome and expand, no card of\n * its own, and its tone an edge down its left side.\n */\nexport function MessageItemGroup({\n tone = 'neutral',\n title,\n summary,\n badge,\n children,\n style,\n ...props\n}: MessageItemGroupProps) {\n const t = useT();\n const label = badge === undefined ? statusLabel(tone, t) : badge;\n // A stable value, so a group re-render does not re-render every memoised row's item.\n const group = useMemo(() => ({ tone }), [tone]);\n return (\n <MessageItem tone={tone} style={style} {...props}>\n <View style={styles.header}>\n <ToolCallLead title={title} caption={null}>\n {summary}\n </ToolCallLead>\n {label !== null && label !== '' ? <Outcome tone={tone}>{label}</Outcome> : null}\n </View>\n <MessageItemGroupContext.Provider value={group}>\n <View>{children}</View>\n </MessageItemGroupContext.Provider>\n </MessageItem>\n );\n}\n\nexport interface MessageItemHeaderProps extends Omit<ViewProps, 'children' | 'style'> {\n /** The bold label at the left: the tool name. */\n title: ReactNode;\n /** The badge text; defaults to the tone's label, null hides the badge. */\n badge?: ReactNode | null;\n /** The summary beside the title; it gets the remaining width. */\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/**\n * The title row: label, summary, the tone's outcome and, when the item is\n * expandable, a chevron; the whole row is the toggle. A row inside a group\n * keeps its name but drops the chip and caption the group header carries.\n */\nexport function MessageItemHeader({ title, badge, children, style, ...props }: MessageItemHeaderProps) {\n const { tone, expandable, expanded, toggle } = useMessageItem();\n const group = useContext(MessageItemGroupContext);\n const t = useT();\n const label = badge === undefined ? statusLabel(tone, t) : badge;\n const content = (\n <>\n {group === null ? (\n <ToolCallLead title={title}>{children}</ToolCallLead>\n ) : (\n <RowLead title={title}>{children}</RowLead>\n )}\n {label !== null && label !== '' ? <Outcome tone={tone}>{label}</Outcome> : null}\n {expandable ? expanded ? <ChevronDownIcon size={16} /> : <ChevronRightIcon size={16} /> : null}\n </>\n );\n if (!expandable) {\n return (\n <View style={[styles.header, style]} {...props}>\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityState={{ expanded }}\n accessibilityHint={\n expanded\n ? t('nativeComponents.messageItem.collapseHint', 'collapse')\n : t('nativeComponents.messageItem.expandHint', 'expand')\n }\n onPress={toggle}\n style={({ pressed }) => [styles.header, pressed && styles.headerPressed, style]}\n {...props}\n >\n {content}\n </Pressable>\n );\n}\n\nexport interface MessageItemPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The body under the header, on the card's own surface. */\nexport function MessageItemBody({ children, style, ...props }: MessageItemPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.bodyText)}\n </View>\n );\n}\n\nexport interface MessageItemStatusProps extends Omit<TextProps, 'children'> {\n tone?: StatusTone;\n /** Replaces the tone's glyph. */\n glyph?: string;\n /** Renders as a button that expands the item: the \"N more line(s)\" hint. */\n expands?: boolean;\n children?: ReactNode;\n /** Applied to the row; with `expands`, to the button. */\n containerStyle?: StyleProp<ViewStyle>;\n}\n\n/** The one-line status under a body: `running`, `failed`, `done`, or the hint that more is hidden. */\nexport function MessageItemStatus({\n tone = 'neutral',\n glyph,\n expands = false,\n children,\n containerStyle,\n style,\n ...props\n}: MessageItemStatusProps) {\n const { toggle } = useMessageItem();\n const line = (\n <Text style={[styles.status, style]} {...props}>\n <Text style={styles.glyph(tone)}>{glyph ?? STATUS_GLYPH[tone]}</Text> {children}\n </Text>\n );\n if (expands) {\n return (\n <Button variant=\"ghost\" size=\"xs\" onPress={toggle} style={[styles.more, containerStyle]}>\n {line}\n </Button>\n );\n }\n return <View style={containerStyle}>{line}</View>;\n}\n\nconst styles = StyleSheet.create((theme) => ({\n cardEdge: (token: NativeColorToken) => ({\n overflow: 'hidden',\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors[token],\n }),\n // A row's top rule is the group's separator; its left edge carries the tone.\n rowEdge: (token: NativeColorToken | undefined) => ({\n overflow: 'hidden',\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n borderLeftWidth: ROW_EDGE_WIDTH,\n borderLeftColor: token === undefined ? 'transparent' : theme.colors[token],\n }),\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: MIN_ROW_HEIGHT,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n headerPressed: { backgroundColor: theme.colors.panel },\n chip: {\n alignItems: 'center',\n justifyContent: 'center',\n width: LEAD_CHIP,\n height: LEAD_CHIP,\n flexShrink: 0,\n borderRadius: theme.borderRadius.full,\n backgroundColor: theme.colors.rail,\n },\n lead: { flex: 1, minWidth: 0 },\n caption: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n titleLine: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n title: {\n flexShrink: 0,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.semibold,\n },\n summary: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), minWidth: 0 },\n summaryText: {\n flexShrink: 1,\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n outcome: { gap: theme.spacing(1) },\n outcomeIcon: { alignItems: 'center', justifyContent: 'center', width: 20, height: 20, flexShrink: 0 },\n body: {\n gap: theme.spacing(1),\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n bodyText: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n status: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n glyph: (tone: StatusTone) => ({ color: theme.colors[STATUS_COLORS[tone].ink] }),\n more: { alignSelf: 'flex-start' },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,MAAM2B,6BAAsC,IAAIE,IAAgB;CAAC;CAAW;CAAM;AAAO,CAAC;AAU1F,MAAMC,iBAAiB;AACvB,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;;AAKvB,SAAgBC,iBAAmC;CACjD,OAAO3B,WAAWL,kBAAkB;AACtC;;AAGA,SAAgBiC,SAASC,OAA2D;CAClF,OAAOA,MAAMC,UAAU,YAAYD,MAAME,UAAU,UAAU;AAC/D;;AAGA,MAAaC,eAAqD;CAChEG,SAAS;CACTL,SAAS;CACTM,IAAI;CACJC,OAAO;CACPC,MAAM;CACNC,QAAQ;AACV;;AAKA,SAASG,YAAYC,MAAkBC,GAAsB;CAC3D,QAAQD,MAAR;EACE,KAAK,WACH,OAAOC,EAAE,+CAA+C,SAAS;EACnE,KAAK,MACH,OAAOA,EAAE,0CAA0C,WAAW;EAChE,KA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A,CAAA,CAAA;CAAC;CAC7EV,MAAM,EAAE4C,WAAW,aAAa;AAClC,EAAE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StatusTone } from "./StatusBadge.mjs";
|
|
2
|
+
//#region src/components/NativeShellState.d.ts
|
|
3
|
+
/** State shared by shell-rendered timeline frames and downloaded tool content. */
|
|
4
|
+
export interface MessageItemState {
|
|
5
|
+
tone: StatusTone;
|
|
6
|
+
expandable: boolean;
|
|
7
|
+
expanded: boolean;
|
|
8
|
+
toggle: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const MessageItemContext: import("react").Context<MessageItemState>;
|
|
11
|
+
export declare const MessageItemGroupContext: import("react").Context<{
|
|
12
|
+
tone: StatusTone;
|
|
13
|
+
} | null>;
|
|
14
|
+
export interface OpenSheet {
|
|
15
|
+
keep: () => boolean;
|
|
16
|
+
close: () => void;
|
|
17
|
+
setNote: (note: string | undefined) => void;
|
|
18
|
+
}
|
|
19
|
+
/** Closing sheets still occlude their canvas until native dismissal or unmount. */
|
|
20
|
+
export declare function hasPresentedSheets(): boolean;
|
|
21
|
+
export declare function subscribePresentedSheets(listener: () => void): () => void;
|
|
22
|
+
export declare function registerSheet(sheet: OpenSheet): void;
|
|
23
|
+
export declare function dismissSheet(sheet: OpenSheet): void;
|
|
24
|
+
export declare function unregisterSheet(sheet: OpenSheet): void;
|
|
25
|
+
/** A prompt holds the screen, so sheets must not open over it without a person's action. */
|
|
26
|
+
export declare function sheetsYielded(): boolean;
|
|
27
|
+
/** Close top-down until unsaved work keeps a sheet open; undefined only clears the note. */
|
|
28
|
+
export declare function yieldSheets(note: string | undefined): void;
|
|
29
|
+
//#endregion
|
|
30
|
+
//# sourceMappingURL=NativeShellState.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeShellState.d.mts","names":[],"sources":["../../src/components/NativeShellState.tsx"],"mappings":";;;iBAKiB;EACf,MAAM;EACN;EACA;EACA;;qBAGW,oCAAkB,QAAA;qBAOlB,yCAAuB;EAAyB,MAAA;;iBAE5C;EACf;EACA;EACA,UAAU;;;wBAUI;wBAIA,yBAAyB;wBAOzB,cAAc,OAAO;wBAOrB,aAAa,OAAO;wBAIpB,gBAAgB,OAAO;;wBAMvB;;wBAKA,YAAY"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/components/NativeShellState.tsx
|
|
4
|
+
const MessageItemContext = createContext({
|
|
5
|
+
tone: "neutral",
|
|
6
|
+
expandable: false,
|
|
7
|
+
expanded: false,
|
|
8
|
+
toggle: () => void 0
|
|
9
|
+
});
|
|
10
|
+
const MessageItemGroupContext = createContext(null);
|
|
11
|
+
/** One shell-owned list across every downloaded UI module, oldest sheet first. */
|
|
12
|
+
const openSheets = [];
|
|
13
|
+
const presentedSheets = /* @__PURE__ */ new Set();
|
|
14
|
+
const sheetListeners = /* @__PURE__ */ new Set();
|
|
15
|
+
let yielded = false;
|
|
16
|
+
/** Closing sheets still occlude their canvas until native dismissal or unmount. */
|
|
17
|
+
function hasPresentedSheets() {
|
|
18
|
+
return presentedSheets.size > 0;
|
|
19
|
+
}
|
|
20
|
+
function subscribePresentedSheets(listener) {
|
|
21
|
+
sheetListeners.add(listener);
|
|
22
|
+
return () => {
|
|
23
|
+
sheetListeners.delete(listener);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function registerSheet(sheet) {
|
|
27
|
+
if (!openSheets.includes(sheet)) openSheets.push(sheet);
|
|
28
|
+
if (presentedSheets.has(sheet)) return;
|
|
29
|
+
presentedSheets.add(sheet);
|
|
30
|
+
for (const listener of sheetListeners) listener();
|
|
31
|
+
}
|
|
32
|
+
function dismissSheet(sheet) {
|
|
33
|
+
if (presentedSheets.delete(sheet)) for (const listener of sheetListeners) listener();
|
|
34
|
+
}
|
|
35
|
+
function unregisterSheet(sheet) {
|
|
36
|
+
const index = openSheets.indexOf(sheet);
|
|
37
|
+
if (index >= 0) openSheets.splice(index, 1);
|
|
38
|
+
}
|
|
39
|
+
/** A prompt holds the screen, so sheets must not open over it without a person's action. */
|
|
40
|
+
function sheetsYielded() {
|
|
41
|
+
return yielded;
|
|
42
|
+
}
|
|
43
|
+
/** Close top-down until unsaved work keeps a sheet open; undefined only clears the note. */
|
|
44
|
+
function yieldSheets(note) {
|
|
45
|
+
yielded = note !== void 0;
|
|
46
|
+
if (note === void 0) {
|
|
47
|
+
for (const sheet of openSheets) sheet.setNote(void 0);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
for (let index = openSheets.length - 1; index >= 0; index -= 1) {
|
|
51
|
+
if (openSheets[index].keep()) {
|
|
52
|
+
for (const sheet of openSheets.slice(0, index + 1)) sheet.setNote(note);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
openSheets[index].close();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { MessageItemContext, MessageItemGroupContext, dismissSheet, hasPresentedSheets, registerSheet, sheetsYielded, subscribePresentedSheets, unregisterSheet, yieldSheets };
|
|
61
|
+
//# sourceMappingURL=NativeShellState.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativeShellState.mjs","names":[],"sources":["../../src/components/NativeShellState.tsx"],"sourcesContent":["import { createContext } from 'react';\n\nimport type { StatusTone } from './StatusBadge';\n\n/** State shared by shell-rendered timeline frames and downloaded tool content. */\nexport interface MessageItemState {\n tone: StatusTone;\n expandable: boolean;\n expanded: boolean;\n toggle: () => void;\n}\n\nexport const MessageItemContext = createContext<MessageItemState>({\n tone: 'neutral',\n expandable: false,\n expanded: false,\n toggle: () => undefined,\n});\n\nexport const MessageItemGroupContext = createContext<{ tone: StatusTone } | null>(null);\n\nexport interface OpenSheet {\n keep: () => boolean;\n close: () => void;\n setNote: (note: string | undefined) => void;\n}\n\n/** One shell-owned list across every downloaded UI module, oldest sheet first. */\nconst openSheets: OpenSheet[] = [];\nconst presentedSheets = new Set<OpenSheet>();\nconst sheetListeners = new Set<() => void>();\nlet yielded = false;\n\n/** Closing sheets still occlude their canvas until native dismissal or unmount. */\nexport function hasPresentedSheets(): boolean {\n return presentedSheets.size > 0;\n}\n\nexport function subscribePresentedSheets(listener: () => void): () => void {\n sheetListeners.add(listener);\n return () => {\n sheetListeners.delete(listener);\n };\n}\n\nexport function registerSheet(sheet: OpenSheet): void {\n if (!openSheets.includes(sheet)) openSheets.push(sheet);\n if (presentedSheets.has(sheet)) return;\n presentedSheets.add(sheet);\n for (const listener of sheetListeners) listener();\n}\n\nexport function dismissSheet(sheet: OpenSheet): void {\n if (presentedSheets.delete(sheet)) for (const listener of sheetListeners) listener();\n}\n\nexport function unregisterSheet(sheet: OpenSheet): void {\n const index = openSheets.indexOf(sheet);\n if (index >= 0) openSheets.splice(index, 1);\n}\n\n/** A prompt holds the screen, so sheets must not open over it without a person's action. */\nexport function sheetsYielded(): boolean {\n return yielded;\n}\n\n/** Close top-down until unsaved work keeps a sheet open; undefined only clears the note. */\nexport function yieldSheets(note: string | undefined): void {\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"],"mappings":";;;AAYA,MAAa,qBAAqB,cAAgC;CAChE,MAAM;CACN,YAAY;CACZ,UAAU;CACV,cAAc;AAChB,CAAC;AAED,MAAa,0BAA0B,cAA2C,IAAI;;AAStF,MAAM,aAA0B,CAAC;AACjC,MAAM,kCAAkB,IAAI,IAAe;AAC3C,MAAM,iCAAiB,IAAI,IAAgB;AAC3C,IAAI,UAAU;;AAGd,SAAgB,qBAA8B;CAC5C,OAAO,gBAAgB,OAAO;AAChC;AAEA,SAAgB,yBAAyB,UAAkC;CACzE,eAAe,IAAI,QAAQ;CAC3B,aAAa;EACX,eAAe,OAAO,QAAQ;CAChC;AACF;AAEA,SAAgB,cAAc,OAAwB;CACpD,IAAI,CAAC,WAAW,SAAS,KAAK,GAAG,WAAW,KAAK,KAAK;CACtD,IAAI,gBAAgB,IAAI,KAAK,GAAG;CAChC,gBAAgB,IAAI,KAAK;CACzB,KAAK,MAAM,YAAY,gBAAgB,SAAS;AAClD;AAEA,SAAgB,aAAa,OAAwB;CACnD,IAAI,gBAAgB,OAAO,KAAK,GAAG,KAAK,MAAM,YAAY,gBAAgB,SAAS;AACrF;AAEA,SAAgB,gBAAgB,OAAwB;CACtD,MAAM,QAAQ,WAAW,QAAQ,KAAK;CACtC,IAAI,SAAS,GAAG,WAAW,OAAO,OAAO,CAAC;AAC5C;;AAGA,SAAgB,gBAAyB;CACvC,OAAO;AACT;;AAGA,SAAgB,YAAY,MAAgC;CAC1D,UAAU,SAAS;CACnB,IAAI,SAAS,QAAW;EACtB,KAAK,MAAM,SAAS,YAAY,MAAM,QAAQ,MAAS;EACvD;CACF;CACA,KAAK,IAAI,QAAQ,WAAW,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG;EAC9D,IAAI,WAAW,MAAM,CAAC,KAAK,GAAG;GAC5B,KAAK,MAAM,SAAS,WAAW,MAAM,GAAG,QAAQ,CAAC,GAAG,MAAM,QAAQ,IAAI;GACtE;EACF;EACA,WAAW,MAAM,CAAC,MAAM;CAC1B;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IconProps } from "../icons/icons.mjs";
|
|
2
|
+
import { ComponentType } from "react";
|
|
3
|
+
//#region src/components/RailItem.d.ts
|
|
4
|
+
export interface RailItemProps {
|
|
5
|
+
icon: ComponentType<IconProps>;
|
|
6
|
+
label: string;
|
|
7
|
+
onPress: () => void;
|
|
8
|
+
testID?: string;
|
|
9
|
+
}
|
|
10
|
+
/** One row of the phone drawer's Po menu, the native form of the web rail's plugin rows: icon, label, chevron. */
|
|
11
|
+
export declare function RailItem({ icon: Icon, label, onPress, testID }: RailItemProps): import("react").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=RailItem.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RailItem.d.mts","names":[],"sources":["../../src/components/RailItem.tsx"],"mappings":";;;iBASiB;EACf,MAAM,cAAc;EACpB;EACA;EACA;;;wBAIc,WAAW,MAAM,MAAM,OAAO,SAAS,UAAU,gCAAa,IAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { ChevronRightIcon } from "../icons/icons.mjs";
|
|
3
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
4
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
7
|
+
|
|
8
|
+
//#region src/components/RailItem.tsx
|
|
9
|
+
const MIN_ROW_HEIGHT = 48;
|
|
10
|
+
/** One row of the phone drawer's Po menu, the native form of the web rail's plugin rows: icon, label, chevron. */
|
|
11
|
+
function RailItem({ icon: Icon, label, onPress, testID }) {
|
|
12
|
+
return /* @__PURE__ */ jsxs(Pressable, {
|
|
13
|
+
accessibilityRole: "button",
|
|
14
|
+
accessibilityLabel: label,
|
|
15
|
+
onPress,
|
|
16
|
+
testID,
|
|
17
|
+
style: ({ pressed }) => [styles.row, pressed && styles.pressed],
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
20
|
+
size: 20,
|
|
21
|
+
color: "green"
|
|
22
|
+
}),
|
|
23
|
+
/* @__PURE__ */ jsx(Text, {
|
|
24
|
+
style: styles.label,
|
|
25
|
+
numberOfLines: 1,
|
|
26
|
+
children: label
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
29
|
+
size: 14,
|
|
30
|
+
color: "faint"
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const styles = StyleSheet.create((theme) => ({
|
|
36
|
+
row: {
|
|
37
|
+
flexDirection: "row",
|
|
38
|
+
alignItems: "center",
|
|
39
|
+
gap: theme.spacing(3),
|
|
40
|
+
minHeight: MIN_ROW_HEIGHT,
|
|
41
|
+
paddingHorizontal: theme.spacing(3),
|
|
42
|
+
borderRadius: theme.borderRadius.md,
|
|
43
|
+
backgroundColor: theme.colors.panel,
|
|
44
|
+
uni__dependencies: [0]
|
|
45
|
+
},
|
|
46
|
+
pressed: { opacity: .7 },
|
|
47
|
+
label: {
|
|
48
|
+
flex: 1,
|
|
49
|
+
minWidth: 0,
|
|
50
|
+
color: theme.colors.hi,
|
|
51
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
52
|
+
fontSize: theme.fontSize.base,
|
|
53
|
+
lineHeight: theme.lineHeight.base,
|
|
54
|
+
fontWeight: theme.fontWeight.medium,
|
|
55
|
+
uni__dependencies: [0]
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
export { RailItem };
|
|
61
|
+
//# sourceMappingURL=RailItem.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RailItem.mjs","names":["ComponentType","StyleSheet","ChevronRightIcon","IconProps","fontOf","MIN_ROW_HEIGHT","RailItemProps","icon","label","onPress","testID","RailItem","Icon","pressed","styles","row","create","theme","flexDirection","alignItems","gap","spacing","minHeight","paddingHorizontal","borderRadius","md","backgroundColor","colors","panel","uni__dependencies","opacity","flex","minWidth","color","hi","fontFamily","sans","fontSize","base","lineHeight","fontWeight","medium"],"sources":["../../src/components/RailItem.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\nimport { Pressable, Text } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { ChevronRightIcon, type IconProps } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\n\nconst MIN_ROW_HEIGHT = 48;\n\nexport interface RailItemProps {\n icon: ComponentType<IconProps>;\n label: string;\n onPress: () => void;\n testID?: string;\n}\n\n/** One row of the phone drawer's Po menu, the native form of the web rail's plugin rows: icon, label, chevron. */\nexport function RailItem({ icon: Icon, label, onPress, testID }: RailItemProps) {\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={label}\n onPress={onPress}\n testID={testID}\n style={({ pressed }) => [styles.row, pressed && styles.pressed]}\n >\n <Icon size={20} color=\"green\" />\n <Text style={styles.label} numberOfLines={1}>\n {label}\n </Text>\n <ChevronRightIcon size={14} color=\"faint\" />\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: MIN_ROW_HEIGHT,\n paddingHorizontal: theme.spacing(3),\n borderRadius: theme.borderRadius.md,\n backgroundColor: theme.colors.panel,\n },\n pressed: { opacity: 0.7 },\n label: {\n flex: 1,\n minWidth: 0,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.medium,\n },\n}));\n"],"mappings":";;;;;;;;AAOA,MAAMK,iBAAiB;;AAUvB,SAAgBM,SAAS,EAAEJ,MAAMK,MAAMJ,OAAOC,SAASC,UAAyB;CAC9E,OACE,qBAAC,WAAD;EACE,mBAAkB;EAClB,oBAAoBF;EACXC;EACDC;EACR,QAAQ,EAAEG,cAAc,CAACC,OAAOC,KAAKF,WAAWC,OAAOD,OAAO;YALhE;GAOE,oBAAC,MAAD;IAAM,MAAM;IAAI,OAAM;GAAO;GAC7B,oBAAC,MAAD;IAAM,OAAOC,OAAON;IAAO,eAAe;cACvCA;GACG;GACN,oBAAC,kBAAD;IAAkB,MAAM;IAAI,OAAM;GAAO;EAChC;;AAEf;AAEA,MAAMM,SAASb,WAAWe,QAAQC,WAAW;CAC3CF,KAAK;EACHG,eAAe;EACfC,YAAY;EACZC,KAAKH,MAAMI,QAAQ,CAAC;EACpBC,WAAWjB;EACXkB,mBAAmBN,MAAMI,QAAQ,CAAC;EAClCG,cAAcP,MAAMO,aAAaC;EACjCC,iBAAiBT,MAAMU,OAAOC;EAAKC,mBAAA,CAAA,CAAA;CACrC;CACAhB,SAAS,EAAEiB,SAAS,GAAI;CACxBtB,OAAO;EACLuB,MAAM;EACNC,UAAU;EACVC,OAAOhB,MAAMU,OAAOO;EACpBC,YAAY/B,OAAOa,MAAMkB,WAAWC,IAAI;EACxCC,UAAUpB,MAAMoB,SAASC;EACzBC,YAAYtB,MAAMsB,WAAWD;EAC7BE,YAAYvB,MAAMuB,WAAWC;EAAMZ,mBAAA,CAAA,CAAA;CACrC;AACF,EAAE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/components/ReferenceChip.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* An `@scheme:value` reference drawn inline in prose: a short label on a tint that opens what it
|
|
4
|
+
* names. It is Text all the way down, so it wraps with the sentence it sits in; a View, Pressable or
|
|
5
|
+
* icon inside Text does not lay out reliably on both platforms. The full reference stays the
|
|
6
|
+
* accessible name, so a shortened label never hides which file or session it is.
|
|
7
|
+
* ponytail: inline, so its target is the line height rather than 44 points, like any inline link.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ReferenceChip({ label, reference, onOpen, onLongPress }: {
|
|
10
|
+
label: string;
|
|
11
|
+
/** The reference as written, with its `@`, for the accessible name. */
|
|
12
|
+
reference: string;
|
|
13
|
+
onOpen: () => void;
|
|
14
|
+
/** The surrounding text's long press, so holding the chip still reaches it. */
|
|
15
|
+
onLongPress?: () => void;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
//# sourceMappingURL=ReferenceChip.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReferenceChip.d.mts","names":[],"sources":["../../src/components/ReferenceChip.tsx"],"mappings":";;;;;;;;wBAagB,gBACd,OACA,WACA,QACA;EAEA;;EAEA;EACA;;EAEA;oBACD,IAAA"}
|