@agimon-ai/po-native-components 0.0.0-alpha.4 → 0.0.0-alpha.41
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/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +1 -1
- package/dist/components/Button.mjs +1 -1
- 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 +11 -5
- 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/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 +6 -2
- package/dist/components/List.mjs.map +1 -1
- 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 +3 -1
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +11 -4
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.mjs +6 -3
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/SheetList.d.mts +12 -0
- package/dist/components/SheetList.d.mts.map +1 -0
- package/dist/components/SheetList.mjs +33 -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 +1 -1
- 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 +36 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +36 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +37 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +10 -1
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +11 -4
- package/dist/index.mjs +11 -4
- 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 +16 -13
|
@@ -7,13 +7,19 @@ 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 {
|
|
11
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
12
|
+
import { createContext, useContext, useMemo } from "react";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
15
15
|
|
|
16
16
|
//#region src/components/MessageItem.tsx
|
|
17
|
+
/** Tones whose outcome reads as an icon alone; the rest keep their worded badge. */
|
|
18
|
+
const ICON_TONES = /* @__PURE__ */ new Set([
|
|
19
|
+
"running",
|
|
20
|
+
"ok",
|
|
21
|
+
"error"
|
|
22
|
+
]);
|
|
17
23
|
const MIN_ROW_HEIGHT = 44;
|
|
18
24
|
const LEAD_CHIP = 36;
|
|
19
25
|
const ROW_EDGE_WIDTH = 2;
|
|
@@ -89,91 +95,102 @@ function Summary({ children }) {
|
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
97
|
/** 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 }) {
|
|
98
|
+
function ToolCallLead({ title, caption = "Tool call", children }) {
|
|
93
99
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(View, {
|
|
94
100
|
accessible: false,
|
|
95
101
|
style: styles.chip,
|
|
96
102
|
children: /* @__PURE__ */ jsx(WrenchIcon, { size: 16 })
|
|
97
103
|
}), /* @__PURE__ */ jsxs(View, {
|
|
98
104
|
style: styles.lead,
|
|
99
|
-
children: [/* @__PURE__ */ jsx(Text, {
|
|
105
|
+
children: [caption === null ? null : /* @__PURE__ */ jsx(Text, {
|
|
100
106
|
style: styles.caption,
|
|
101
|
-
children:
|
|
107
|
+
children: caption
|
|
102
108
|
}), /* @__PURE__ */ jsxs(View, {
|
|
103
109
|
style: styles.titleLine,
|
|
104
110
|
children: [wrapText(title, styles.title), /* @__PURE__ */ jsx(Summary, { children })]
|
|
105
111
|
})]
|
|
106
112
|
})] });
|
|
107
113
|
}
|
|
108
|
-
/**
|
|
109
|
-
function
|
|
114
|
+
/** A row's lead inside a group: the name and its summary, no chip or caption, since the group header carries them. */
|
|
115
|
+
function RowLead({ title, children }) {
|
|
116
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
117
|
+
style: [styles.lead, styles.titleLine],
|
|
118
|
+
children: [wrapText(title, styles.title), /* @__PURE__ */ jsx(Summary, { children })]
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
/** The outcome: an icon for running, done and failed, announced by its label; a worded badge for other tones. */
|
|
122
|
+
function Outcome({ tone, children }) {
|
|
110
123
|
const ink = STATUS_COLORS[tone].ink;
|
|
111
|
-
return /* @__PURE__ */ jsxs(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
124
|
+
if (ICON_TONES.has(tone)) return /* @__PURE__ */ jsxs(View, {
|
|
125
|
+
accessible: true,
|
|
126
|
+
accessibilityRole: "image",
|
|
127
|
+
accessibilityLabel: typeof children === "string" ? children : STATUS_LABEL[tone],
|
|
128
|
+
style: styles.outcomeIcon,
|
|
115
129
|
children: [
|
|
116
130
|
tone === "running" ? /* @__PURE__ */ jsx(Spinner, { color: ink }) : null,
|
|
117
131
|
tone === "ok" ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
118
|
-
size:
|
|
132
|
+
size: 14,
|
|
119
133
|
color: ink
|
|
120
134
|
}) : null,
|
|
121
135
|
tone === "error" ? /* @__PURE__ */ jsx(AlertIcon, {
|
|
122
|
-
size:
|
|
136
|
+
size: 14,
|
|
123
137
|
color: ink
|
|
124
|
-
}) : null
|
|
125
|
-
children
|
|
138
|
+
}) : null
|
|
126
139
|
]
|
|
127
140
|
});
|
|
141
|
+
return /* @__PURE__ */ jsx(StatusBadge, {
|
|
142
|
+
tone,
|
|
143
|
+
size: "md",
|
|
144
|
+
style: styles.outcome,
|
|
145
|
+
children
|
|
146
|
+
});
|
|
128
147
|
}
|
|
129
148
|
/**
|
|
130
|
-
* One frame around a run of items that belong together.
|
|
131
|
-
* becomes a row
|
|
132
|
-
* an edge down its left side.
|
|
149
|
+
* One frame around a run of items that belong together. It stays open: each
|
|
150
|
+
* item inside becomes a row with its own name, outcome and expand, no card of
|
|
151
|
+
* its own, and its tone an edge down its left side.
|
|
133
152
|
*/
|
|
134
153
|
function MessageItemGroup({ tone = "neutral", title, summary, badge, children, style, ...props }) {
|
|
135
154
|
const label = badge === void 0 ? STATUS_LABEL[tone] : badge;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}), /* @__PURE__ */ jsx(View, { children })]
|
|
156
|
-
})
|
|
155
|
+
const group = useMemo(() => ({ tone }), [tone]);
|
|
156
|
+
return /* @__PURE__ */ jsxs(MessageItem, {
|
|
157
|
+
tone,
|
|
158
|
+
style,
|
|
159
|
+
...props,
|
|
160
|
+
children: [/* @__PURE__ */ jsxs(View, {
|
|
161
|
+
style: styles.header,
|
|
162
|
+
children: [/* @__PURE__ */ jsx(ToolCallLead, {
|
|
163
|
+
title,
|
|
164
|
+
caption: null,
|
|
165
|
+
children: summary
|
|
166
|
+
}), label !== null && label !== "" ? /* @__PURE__ */ jsx(Outcome, {
|
|
167
|
+
tone,
|
|
168
|
+
children: label
|
|
169
|
+
}) : null]
|
|
170
|
+
}), /* @__PURE__ */ jsx(MessageItemGroupContext.Provider, {
|
|
171
|
+
value: group,
|
|
172
|
+
children: /* @__PURE__ */ jsx(View, { children })
|
|
173
|
+
})]
|
|
157
174
|
});
|
|
158
175
|
}
|
|
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
176
|
/**
|
|
162
|
-
* The title row: label, summary, the tone's
|
|
177
|
+
* The title row: label, summary, the tone's outcome and, when the item is
|
|
163
178
|
* expandable, a chevron; the whole row is the toggle. A row inside a group
|
|
164
|
-
*
|
|
179
|
+
* keeps its name but drops the chip and caption the group header carries.
|
|
165
180
|
*/
|
|
166
181
|
function MessageItemHeader({ title, badge, children, style, ...props }) {
|
|
167
182
|
const { tone, expandable, expanded, toggle } = useMessageItem();
|
|
168
183
|
const group = useContext(MessageItemGroupContext);
|
|
169
|
-
const
|
|
170
|
-
const label = badge === void 0 ? defaultLabel : badge;
|
|
184
|
+
const label = badge === void 0 ? STATUS_LABEL[tone] : badge;
|
|
171
185
|
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
172
186
|
group === null ? /* @__PURE__ */ jsx(ToolCallLead, {
|
|
173
187
|
title,
|
|
174
188
|
children
|
|
175
|
-
}) : /* @__PURE__ */ jsx(
|
|
176
|
-
|
|
189
|
+
}) : /* @__PURE__ */ jsx(RowLead, {
|
|
190
|
+
title,
|
|
191
|
+
children
|
|
192
|
+
}),
|
|
193
|
+
label !== null && label !== "" ? /* @__PURE__ */ jsx(Outcome, {
|
|
177
194
|
tone,
|
|
178
195
|
children: label
|
|
179
196
|
}) : null,
|
|
@@ -315,18 +332,17 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
315
332
|
lineHeight: theme.lineHeight.base,
|
|
316
333
|
uni__dependencies: [0]
|
|
317
334
|
},
|
|
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
335
|
outcome: {
|
|
327
336
|
gap: theme.spacing(1),
|
|
328
337
|
uni__dependencies: [0]
|
|
329
338
|
},
|
|
339
|
+
outcomeIcon: {
|
|
340
|
+
alignItems: "center",
|
|
341
|
+
justifyContent: "center",
|
|
342
|
+
width: 20,
|
|
343
|
+
height: 20,
|
|
344
|
+
flexShrink: 0
|
|
345
|
+
},
|
|
330
346
|
body: {
|
|
331
347
|
gap: theme.spacing(1),
|
|
332
348
|
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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C,OAAO9B,MAAMO,OAAOwB;EACpBC,YAAYzH,OAAOyF,MAAMgC,WAAWC,IAAI;EACxCC,UAAUlC,MAAMkC,SAASI;EACzBF,YAAYpC,MAAMoC,WAAWE;EAAI9B,mBAAA,CAAA,CAAA;CACnC;CACAX,QAAQ;EACNiC,OAAO9B,MAAMO,OAAO/B;EACpBwD,YAAYzH,OAAOyF,MAAMgC,WAAWC,IAAI;EACxCC,UAAUlC,MAAMkC,SAASC;EACzBC,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":["NativeColorToken","createContext","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","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","caption","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 type { NativeColorToken } from '@agimon-ai/po-web-components/nativeTheme';\nimport { createContext, 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 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({\n title,\n caption = 'Tool call',\n children,\n}: {\n title: ReactNode;\n caption?: string | null;\n children?: ReactNode;\n}) {\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 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 : STATUS_LABEL[tone]}\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 label = badge === undefined ? STATUS_LABEL[tone] : 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 label = badge === undefined ? STATUS_LABEL[tone] : 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={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 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":";;;;;;;;;;;;;;;;;AAeA,MAAMwB,6BAAsC,IAAIE,IAAgB;CAAC;CAAW;CAAM;AAAO,CAAC;AAU1F,MAAMC,iBAAiB;AACvB,MAAMC,YAAY;AAClB,MAAMC,iBAAiB;AAUvB,MAAMM,qBAAqBlC,cAAgC;CACzD8B,MAAM;CACNC,YAAY;CACZC,UAAU;CACVC,cAAcE;AAChB,CAAC;;AAGD,SAAgBC,iBAAmC;CACjD,OAAOlC,WAAWgC,kBAAkB;AACtC;;AAGA,MAAMG,0BAA0BrC,cAA2C,IAAI;;AAG/E,SAAgBsC,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,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AAUC,OAAO;EAAIC,QAAQ;EAAIC,YAAY;CAAE;CACpGpC,MAAM;EACJ0B,KAAKf,MAAMgB,QAAQ,CAAC;EACpBP,gBAAgB;EAChBC,gBAAgBV,MAAMO,OAAO;EAC7BW,mBAAmBlB,MAAMgB,QAAQ,CAAC;EAClCG,iBAAiBnB,MAAMgB,QAAQ,CAAC;EAACR,mBAAA,CAAA,CAAA;CACnC;CACAlB,UAAU;EACRwC,OAAO9B,MAAMO,OAAOwB;EACpBC,YAAYzH,OAAOyF,MAAMgC,WAAWC,IAAI;EACxCC,UAAUlC,MAAMkC,SAASI;EACzBF,YAAYpC,MAAMoC,WAAWE;EAAI9B,mBAAA,CAAA,CAAA;CACnC;CACAX,QAAQ;EACNiC,OAAO9B,MAAMO,OAAOkC;EACpBT,YAAYzH,OAAOyF,MAAMgC,WAAWC,IAAI;EACxCC,UAAUlC,MAAMkC,SAASC;EACzBC,YAAYpC,MAAMoC,WAAWD;EAAE3B,mBAAA,CAAA,CAAA;CACjC;CACAhB,QAAQjE,UAAsB;EAAEuG,OAAO9B,MAAMO,OAAO/F,cAAce,KAAK,CAAC8C;EAAImC,mBAAA,CAAA,CAAA;CAAC;CAC7EV,MAAM,EAAE4C,WAAW,aAAa;AAClC,EAAE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
3
2
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
3
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
|
|
6
6
|
//#region src/components/SectionLabel.tsx
|
|
@@ -16,9 +16,11 @@ export declare function SheetTrigger({ onPress, ...props }: ButtonProps): import
|
|
|
16
16
|
export declare function SheetClose({ onPress, ...props }: ButtonProps): import("react").JSX.Element;
|
|
17
17
|
export interface SheetContentProps {
|
|
18
18
|
children?: ReactNode;
|
|
19
|
+
/** False when an embedded SheetList owns vertical scrolling. */
|
|
20
|
+
scrollable?: boolean;
|
|
19
21
|
}
|
|
20
22
|
/** The sheet surface. Fields inside it switch to the sheet's own input so the keyboard lifts the sheet. */
|
|
21
|
-
export declare function SheetContent({ children }: SheetContentProps): import("react").JSX.Element;
|
|
23
|
+
export declare function SheetContent({ children, scrollable }: SheetContentProps): import("react").JSX.Element;
|
|
22
24
|
export interface SheetPartProps extends Omit<ViewProps, 'children' | 'style'> {
|
|
23
25
|
children?: ReactNode;
|
|
24
26
|
style?: StyleProp<ViewStyle>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.d.mts","names":[],"sources":["../../src/components/Sheet.tsx"],"mappings":";;;;iBAwBiB;;EAEf;EACA;EACA,gBAAgB;EAChB,WAAW;;wBAGG,QAAQ,MAAM,aAAqB,cAAc,YAAY,6BAAU,IAAA;;wBAMvE,eAAe,YAAY,SAAS,8BAAW,IAAA;;wBAc/C,aAAa,YAAY,SAAS,8BAAW,IAAA;iBAa5C;EACf,WAAW;;;
|
|
1
|
+
{"version":3,"file":"Sheet.d.mts","names":[],"sources":["../../src/components/Sheet.tsx"],"mappings":";;;;iBAwBiB;;EAEf;EACA;EACA,gBAAgB;EAChB,WAAW;;wBAGG,QAAQ,MAAM,aAAqB,cAAc,YAAY,6BAAU,IAAA;;wBAMvE,eAAe,YAAY,SAAS,8BAAW,IAAA;;wBAc/C,aAAa,YAAY,SAAS,8BAAW,IAAA;iBAa5C;EACf,WAAW;;EAEX;;;wBAIc,eAAe,UAAU,cAAqB,oCAAiB,IAAA;iBAS9D,uBAAuB,KAAK;EAC3C,WAAW;EACX,QAAQ,UAAU;;iBAGH,yBAAyB;;EAExC;;EAEA;;wBAGc,cAAc,aAAoB,YAAsB,OAAO,aAAa,SAAS,mCAAgB,IAAA;wBAoBrG,aAAa,UAAU,SAAS,4BAAS,IAAA;wBAIzC,mBAAmB,UAAU,SAAS,4BAAS,IAAA;;wBAK/C,YAAY,OAAO,aAAa,SAAS,iCAAc,IAAA;wBAQvD,cAAc,OAAO,aAAa,SAAS,iCAAc,IAAA"}
|
|
@@ -5,8 +5,8 @@ import { CloseIcon } from "../icons/icons.mjs";
|
|
|
5
5
|
import { useControllable } from "../lib/useControllable.mjs";
|
|
6
6
|
import { SheetFrame } from "./SheetFrame.mjs";
|
|
7
7
|
import { View } from "react-native-unistyles/components/native/View";
|
|
8
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
9
8
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
9
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
10
10
|
import { createContext, useContext } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
|
|
@@ -48,12 +48,19 @@ function SheetClose({ onPress, ...props }) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
/** The sheet surface. Fields inside it switch to the sheet's own input so the keyboard lifts the sheet. */
|
|
51
|
-
function SheetContent({ children }) {
|
|
51
|
+
function SheetContent({ children, scrollable = true }) {
|
|
52
52
|
const { open, setOpen } = useContext(SheetContext);
|
|
53
53
|
return /* @__PURE__ */ jsx(SheetFrame, {
|
|
54
54
|
open,
|
|
55
55
|
onClose: () => setOpen(false),
|
|
56
|
-
|
|
56
|
+
scrollable,
|
|
57
|
+
children: /* @__PURE__ */ jsx(SheetContext.Provider, {
|
|
58
|
+
value: {
|
|
59
|
+
open,
|
|
60
|
+
setOpen
|
|
61
|
+
},
|
|
62
|
+
children
|
|
63
|
+
})
|
|
57
64
|
});
|
|
58
65
|
}
|
|
59
66
|
function SheetHeader({ dismissible = true, closeLabel = "close", style, children, ...props }) {
|
|
@@ -162,5 +169,5 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
162
169
|
}));
|
|
163
170
|
|
|
164
171
|
//#endregion
|
|
165
|
-
export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
|
172
|
+
export { Sheet, SheetBody, SheetClose, SheetContent, SheetContext, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
|
166
173
|
//# sourceMappingURL=Sheet.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.mjs","names":["createContext","ReactNode","useContext","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","CloseIcon","fontOf","useControllable","wrapText","Button","ButtonProps","SheetFrame","SheetState","open","setOpen","SheetContext","undefined","SheetProps","defaultOpen","onOpenChange","children","Sheet","current","SheetTrigger","onPress","props","event","SheetClose","SheetContentProps","SheetContent","SheetPartProps","Omit","style","SheetHeaderProps","dismissible","closeLabel","SheetHeader","styles","header","close","SheetTitle","title","SheetDescription","description","SheetBody","body","SheetFooter","footer","hint","create","theme","flexDirection","alignItems","gap","spacing","minWidth","height","borderBottomWidth","borderBottomColor","colors","border","paddingHorizontal","uni__dependencies","marginLeft","flexShrink","color","hi","fontFamily","sans","fontSize","lg","lineHeight","fontWeight","semibold","dim","sm","lineHeightRelaxed","paddingVertical","flexWrap","justifyContent","minHeight","borderTopWidth","borderTopColor","backgroundColor","deep","faint"],"sources":["../../src/components/Sheet.tsx"],"sourcesContent":["import { createContext, type ReactNode, useContext } from 'react';\nimport { type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { CloseIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button, type ButtonProps } from './Button';\nimport { SheetFrame } from './SheetFrame';\n\n/*\n * The web Sheet as a bottom sheet: the native shape for a detail view or a\n * short form over what the reader was looking at. `side` and `width` are\n * dropped; a phone sheet rises from the bottom edge and takes the width.\n */\n\ninterface SheetState {\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nconst SheetContext = createContext<SheetState>({ open: false, setOpen: () => undefined });\n\nexport interface SheetProps {\n /** Controlled mode; pair with onOpenChange. Omit it and the sheet keeps its own state. */\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\nexport function Sheet({ open, defaultOpen = false, onOpenChange, children }: SheetProps) {\n const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);\n return <SheetContext.Provider value={{ open: current, setOpen }}>{children}</SheetContext.Provider>;\n}\n\n/** A Button that opens the enclosing sheet. */\nexport function SheetTrigger({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(true);\n }}\n {...props}\n />\n );\n}\n\n/** A Button that closes the enclosing sheet. */\nexport function SheetClose({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(false);\n }}\n {...props}\n />\n );\n}\n\nexport interface SheetContentProps {\n children?: ReactNode;\n}\n\n/** The sheet surface. Fields inside it switch to the sheet's own input so the keyboard lifts the sheet. */\nexport function SheetContent({ children }: SheetContentProps) {\n const { open, setOpen } = useContext(SheetContext);\n return (\n <SheetFrame open={open} onClose={() => setOpen(false)}>\n {children}\n </SheetFrame>\n );\n}\n\nexport interface SheetPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\nexport interface SheetHeaderProps extends SheetPartProps {\n /** Show the close control at the right of the strip. On by default: a sheet is dismissed, not answered. */\n dismissible?: boolean;\n /** What the close control announces. */\n closeLabel?: string;\n}\n\nexport function SheetHeader({ dismissible = true, closeLabel = 'close', style, children, ...props }: SheetHeaderProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <View style={[styles.header, style]} {...props}>\n {children}\n {dismissible ? (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n accessibilityLabel={closeLabel}\n onPress={() => setOpen(false)}\n style={styles.close}\n >\n <CloseIcon size={12} color=\"faint\" />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport function SheetTitle({ style, ...props }: TextProps) {\n return <Text accessibilityRole=\"header\" numberOfLines={1} style={[styles.title, style]} {...props} />;\n}\n\nexport function SheetDescription({ style, ...props }: TextProps) {\n return <Text style={[styles.description, style]} {...props} />;\n}\n\n/** The scrolling middle; the sheet itself scrolls, so this only spaces its children. */\nexport function SheetBody({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.description)}\n </View>\n );\n}\n\nexport function SheetFooter({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.footer, style]} {...props}>\n {wrapText(children, styles.hint)}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2.5),\n minWidth: 0,\n height: theme.spacing(11),\n borderBottomWidth: 1,\n borderBottomColor: theme.colors.border,\n paddingHorizontal: theme.spacing(4),\n },\n close: { marginLeft: 'auto' },\n title: {\n flexShrink: 1,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n fontWeight: theme.fontWeight.semibold,\n },\n description: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n body: {\n gap: theme.spacing(3),\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n footer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: theme.spacing(2),\n minHeight: 34,\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.deep,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(1.5),\n },\n hint: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize['2xs'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qB,WAAWD;EAC7BE,YAAYtB,MAAMsB,WAAWC;EAAQX,mBAAA,CAAA,CAAA;CACvC;CACAnB,aAAa;EACXsB,OAAOf,MAAMS,OAAOe;EACpBP,YAAY7D,OAAO4C,MAAMiB,WAAWC,IAAI;EACxCC,UAAUnB,MAAMmB,SAASM;EACzBJ,YAAYrB,MAAM0B,kBAAkBD;EAAEb,mBAAA,CAAA,CAAA;CACxC;CACAjB,MAAM;EACJQ,KAAKH,MAAMI,QAAQ,CAAC;EACpBO,mBAAmBX,MAAMI,QAAQ,CAAC;EAClCuB,iBAAiB3B,MAAMI,QAAQ,CAAC;EAACQ,mBAAA,CAAA,CAAA;CACnC;CACAf,QAAQ;EACNI,eAAe;EACf2B,UAAU;EACV1B,YAAY;EACZ2B,gBAAgB;EAChB1B,KAAKH,MAAMI,QAAQ,CAAC;EACpB0B,WAAW;EACXC,gBAAgB;EAChBC,gBAAgBhC,MAAMS,OAAO;EAC7BwB,iBAAiBjC,MAAMS,OAAOyB;EAC9BvB,mBAAmBX,MAAMI,QAAQ,CAAC;EAClCuB,iBAAiB3B,MAAMI,QAAQ,GAAG;EAACQ,mBAAA,CAAA,CAAA;CACrC;CACAd,MAAM;EACJiB,OAAOf,MAAMS,OAAO0B;EACpBlB,YAAY7D,OAAO4C,MAAMiB,WAAWC,IAAI;EACxCC,UAAUnB,MAAMmB,SAAS;EACzBE,YAAYrB,MAAMqB,WAAW;EAAMT,mBAAA,CAAA,CAAA;CACrC;AACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"Sheet.mjs","names":["createContext","ReactNode","useContext","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","CloseIcon","fontOf","useControllable","wrapText","Button","ButtonProps","SheetFrame","SheetState","open","setOpen","SheetContext","undefined","SheetProps","defaultOpen","onOpenChange","children","Sheet","current","SheetTrigger","onPress","props","event","SheetClose","SheetContentProps","scrollable","SheetContent","SheetPartProps","Omit","style","SheetHeaderProps","dismissible","closeLabel","SheetHeader","styles","header","close","SheetTitle","title","SheetDescription","description","SheetBody","body","SheetFooter","footer","hint","create","theme","flexDirection","alignItems","gap","spacing","minWidth","height","borderBottomWidth","borderBottomColor","colors","border","paddingHorizontal","uni__dependencies","marginLeft","flexShrink","color","hi","fontFamily","sans","fontSize","lg","lineHeight","fontWeight","semibold","dim","sm","lineHeightRelaxed","paddingVertical","flexWrap","justifyContent","minHeight","borderTopWidth","borderTopColor","backgroundColor","deep","faint"],"sources":["../../src/components/Sheet.tsx"],"sourcesContent":["import { createContext, type ReactNode, useContext } from 'react';\nimport { type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { CloseIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button, type ButtonProps } from './Button';\nimport { SheetFrame } from './SheetFrame';\n\n/*\n * The web Sheet as a bottom sheet: the native shape for a detail view or a\n * short form over what the reader was looking at. `side` and `width` are\n * dropped; a phone sheet rises from the bottom edge and takes the width.\n */\n\ninterface SheetState {\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const SheetContext = createContext<SheetState>({ open: false, setOpen: () => undefined });\n\nexport interface SheetProps {\n /** Controlled mode; pair with onOpenChange. Omit it and the sheet keeps its own state. */\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\nexport function Sheet({ open, defaultOpen = false, onOpenChange, children }: SheetProps) {\n const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);\n return <SheetContext.Provider value={{ open: current, setOpen }}>{children}</SheetContext.Provider>;\n}\n\n/** A Button that opens the enclosing sheet. */\nexport function SheetTrigger({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(true);\n }}\n {...props}\n />\n );\n}\n\n/** A Button that closes the enclosing sheet. */\nexport function SheetClose({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(false);\n }}\n {...props}\n />\n );\n}\n\nexport interface SheetContentProps {\n children?: ReactNode;\n /** False when an embedded SheetList owns vertical scrolling. */\n scrollable?: boolean;\n}\n\n/** The sheet surface. Fields inside it switch to the sheet's own input so the keyboard lifts the sheet. */\nexport function SheetContent({ children, scrollable = true }: SheetContentProps) {\n const { open, setOpen } = useContext(SheetContext);\n return (\n <SheetFrame open={open} onClose={() => setOpen(false)} scrollable={scrollable}>\n <SheetContext.Provider value={{ open, setOpen }}>{children}</SheetContext.Provider>\n </SheetFrame>\n );\n}\n\nexport interface SheetPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\nexport interface SheetHeaderProps extends SheetPartProps {\n /** Show the close control at the right of the strip. On by default: a sheet is dismissed, not answered. */\n dismissible?: boolean;\n /** What the close control announces. */\n closeLabel?: string;\n}\n\nexport function SheetHeader({ dismissible = true, closeLabel = 'close', style, children, ...props }: SheetHeaderProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <View style={[styles.header, style]} {...props}>\n {children}\n {dismissible ? (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n accessibilityLabel={closeLabel}\n onPress={() => setOpen(false)}\n style={styles.close}\n >\n <CloseIcon size={12} color=\"faint\" />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport function SheetTitle({ style, ...props }: TextProps) {\n return <Text accessibilityRole=\"header\" numberOfLines={1} style={[styles.title, style]} {...props} />;\n}\n\nexport function SheetDescription({ style, ...props }: TextProps) {\n return <Text style={[styles.description, style]} {...props} />;\n}\n\n/** The scrolling middle; the sheet itself scrolls, so this only spaces its children. */\nexport function SheetBody({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.description)}\n </View>\n );\n}\n\nexport function SheetFooter({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.footer, style]} {...props}>\n {wrapText(children, styles.hint)}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2.5),\n minWidth: 0,\n height: theme.spacing(11),\n borderBottomWidth: 1,\n borderBottomColor: theme.colors.border,\n paddingHorizontal: theme.spacing(4),\n },\n close: { marginLeft: 'auto' },\n title: {\n flexShrink: 1,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n fontWeight: theme.fontWeight.semibold,\n },\n description: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n body: {\n gap: theme.spacing(3),\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n footer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: theme.spacing(2),\n minHeight: 34,\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.deep,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(1.5),\n },\n hint: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize['2xs'],\n lineHeight: theme.lineHeight['2xs'],\n },\n}));\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAakB,eAAelB,cAA0B;CAAEgB,MAAM;CAAOC,eAAeE;AAAU,CAAC;AAU/F,SAAgBK,MAAM,EAAER,MAAMK,cAAc,OAAOC,cAAcC,YAAwB;CACvF,MAAM,CAACE,SAASR,WAAWP,gBAAgBM,MAAMK,aAAaC,YAAY;CAC1E,OAAO,oBAAC,aAAa,UAAd;EAAuB,OAAO;GAAEN,MAAMS;GAASR;EAAQ;E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AA,CAAA;CACxC;CACAjB,MAAM;EACJQ,KAAKH,MAAMI,QAAQ,CAAC;EACpBO,mBAAmBX,MAAMI,QAAQ,CAAC;EAClCuB,iBAAiB3B,MAAMI,QAAQ,CAAC;EAACQ,mBAAA,CAAA,CAAA;CACnC;CACAf,QAAQ;EACNI,eAAe;EACf2B,UAAU;EACV1B,YAAY;EACZ2B,gBAAgB;EAChB1B,KAAKH,MAAMI,QAAQ,CAAC;EACpB0B,WAAW;EACXC,gBAAgB;EAChBC,gBAAgBhC,MAAMS,OAAO;EAC7BwB,iBAAiBjC,MAAMS,OAAOyB;EAC9BvB,mBAAmBX,MAAMI,QAAQ,CAAC;EAClCuB,iBAAiB3B,MAAMI,QAAQ,GAAG;EAACQ,mBAAA,CAAA,CAAA;CACrC;CACAd,MAAM;EACJiB,OAAOf,MAAMS,OAAO0B;EACpBlB,YAAY9D,OAAO6C,MAAMiB,WAAWC,IAAI;EACxCC,UAAUnB,MAAMmB,SAAS;EACzBE,YAAYrB,MAAMqB,WAAW;EAAMT,mBAAA,CAAA,CAAA;CACrC;AACF,EAAE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InsideSheetContext } from "../lib/insideSheet.mjs";
|
|
2
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
2
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
4
3
|
import { BackHandler } from "react-native";
|
|
4
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
5
5
|
import { useCallback, useContext, useEffect, useRef } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { BottomSheetBackdrop, BottomSheetModal, BottomSheetScrollView } from "@gorhom/bottom-sheet";
|
|
@@ -16,7 +16,7 @@ const BACKDROP_ALPHA_PERCENT = 70;
|
|
|
16
16
|
* back, clear of the safe area and lifted by the keyboard. Private: the public
|
|
17
17
|
* parts keep bottom-sheet types out of the package API.
|
|
18
18
|
*/
|
|
19
|
-
function SheetFrame({ open, onClose, children }) {
|
|
19
|
+
function SheetFrame({ open, onClose, children, scrollable = true }) {
|
|
20
20
|
const { theme } = useUnistyles();
|
|
21
21
|
const insets = useContext(SafeAreaInsetsContext);
|
|
22
22
|
const sheet = useRef(null);
|
|
@@ -67,13 +67,16 @@ function SheetFrame({ open, onClose, children }) {
|
|
|
67
67
|
presented.current = false;
|
|
68
68
|
if (openRef.current) onClose();
|
|
69
69
|
},
|
|
70
|
-
children: /* @__PURE__ */ jsx(BottomSheetScrollView, {
|
|
70
|
+
children: scrollable ? /* @__PURE__ */ jsx(BottomSheetScrollView, {
|
|
71
71
|
keyboardShouldPersistTaps: "handled",
|
|
72
72
|
contentContainerStyle: [styles.content, { paddingBottom: insets?.bottom ?? 0 }],
|
|
73
73
|
children: /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
74
74
|
value: true,
|
|
75
75
|
children
|
|
76
76
|
})
|
|
77
|
+
}) : /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
78
|
+
value: true,
|
|
79
|
+
children
|
|
77
80
|
})
|
|
78
81
|
});
|
|
79
82
|
}
|
|
@@ -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
|
|
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","scrollable","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 /** False when the content supplies its own Gorhom virtualized scroll owner. */\n scrollable?: boolean;\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 }: 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 {scrollable ? (\n <BottomSheetScrollView\n keyboardShouldPersistTaps=\"handled\"\n contentContainerStyle={[styles.content, { paddingBottom: insets?.bottom ?? 0 }]}\n >\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </BottomSheetScrollView>\n ) : (\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n )}\n </BottomSheetModal>\n );\n}\n\nconst styles = StyleSheet.create({ content: { flexGrow: 1 } });\n"],"mappings":";;;;;;;;;;;AAeA,MAAMe,yBAAyB;;;;;;;AAiB/B,SAAgBM,WAAW,EAAEJ,MAAMC,SAASC,UAAUC,aAAa,QAAyB;CAC1F,MAAM,EAAEE,UAAUT,aAAa;CAC/B,MAAMU,SAAShB,WAAWI,qBAAqB;CAC/C,MAAMa,QAAQf,OAAyB,IAAI;CAC3C,MAAMgB,UAAUhB,OAAOQ,IAAI;CAC3B,MAAMS,YAAYjB,OAAO,KAAK;CAE9BD,gBAAgB;EACdiB,QAAQE,UAAUV;EAClB,IAAIA,MAAM;GACRS,UAAUC,UAAU;GACpBH,MAAMG,SAASC,QAAQ;EACzB,OAAO,IAAIF,UAAUC,SAAS;GAG5BD,UAAUC,UAAU;GACpBH,MAAMG,SAASE,QAAQ;EACzB;CACF,GAAG,CAACZ,IAAI,CAAC;CAETT,gBAAgB;EACd,IAAI,CAACS,MAAM,OAAOa;EAClB,MAAMC,eAAerB,YAAYsB,iBAAiB,2BAA2B;GAC3Ed,QAAQ;GACR,OAAO;EACT,CAAC;EACD,aAAaa,aAAaE,OAAO;CACnC,GAAG,CAAChB,MAAMC,OAAO,CAAC;CAElB,MAAMgB,gBAAgBlC,UAAUsB,MAAMa,OAAOC,MAAMrB,sBAAsB;CACzE,MAAMsB,iBAAiB/B,aACpBgC,UACC,oBAAC,qBAAD;EACE,GAAIA;EACJ,gBAAgB;EAChB,mBAAmB;EACnB,SAAS;EACT,eAAc;EACd,OAAO,CAACA,MAAMC,OAAO,EAAEC,iBAAiBN,cAAc,CAAC;CAAE,IAG7D,CAACA,aAAa,CAChB;CAEA,OACE,oBAAC,kBAAD;EACE,KAAKV;EACL,eAAc;EACd;EACA,UAAUD,QAAQkB,OAAO;EACzB,kBAAiB;EACjB,sBAAqB;EACrB,2BAA0B;EAC1B,mBAAmBJ;EACnB,iBAAiB;GAAEG,iBAAiBlB,MAAMa,OAAOO;GAAMC,cAAcrB,MAAMqB,aAAaC;EAAG;EAC3F,sBAAsB,EAAEJ,iBAAiBlB,MAAMa,OAAOU,OAAO;EAE7D,iBAAiB;GAEfnB,UAAUC,UAAU;GACpB,IAAIF,QAAQE,SAAST,QAAQ;EAC/B;YAECE,aACC,oBAAC,uBAAD;GACE,2BAA0B;GAC1B,uBAAuB,CAAC0B,OAAOC,SAAS,EAAEC,eAAezB,QAAQ0B,UAAU,EAAE,CAAC;aAE9E,oBAAC,mBAAmB,UAApB;IAA6B;IAAO9B;GAAsC;EACrD,KAEvB,oBAAC,mBAAmB,UAApB;GAA6B;GAAOA;EAAsC;CAE5D;AAEtB;AAEA,MAAM2B,SAASlC,WAAWsC,OAAO,EAAEH,SAAS,EAAEI,UAAU,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
9
|
+
/** A sheet's only vertical scroll owner. Put headings and controls in its header/footer. */
|
|
10
|
+
export declare function SheetList<T>({ contentContainerStyle, embedded, listKey, ...props }: SheetListProps<T>): import("react").JSX.Element;
|
|
11
|
+
//#endregion
|
|
12
|
+
//# 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;;;wBAMc,UAAU,KAAK,uBAAuB,UAAkB,YAAY,SAAS,eAAe,qBAAE,IAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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, ...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
|
+
children: list
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { SheetList };
|
|
33
|
+
//# 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","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}\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, ...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}>\n {list}\n </SheetFrame>\n );\n}\n"],"mappings":";;;;;;;;;AAiBA,MAAMW,sBAAsBP,cAAcJ,mBAAmB;;AAE7D,SAAgBY,UAAa,EAAEC,uBAAuBJ,WAAW,OAAOC,SAAS,GAAGI,SAA4B;CAC9G,MAAMC,QAAQd,WAAWI,YAAY;CACrC,MAAMW,SAASf,WAAWE,qBAAqB;CAC/C,MAAMc,OACJ,oBAAC,aAAa,UAAd;EAAuB,OAAOF;YAC5B,oBAAC,qBAAD;GAEE,2BAA0B;GAC1B,GAAID;GACJ,uBAAuB,CAAC,EAAEI,eAAeF,QAAQG,UAAU,EAAE,GAAGN,qBAAqB;EAAE,GAHlFH,OAGkF;CAEpE;CAEzB,OAAOD,WACLQ,OAEA,oBAAC,YAAD;EAAY,MAAMF,MAAMK;EAAM,eAAeL,MAAMM,QAAQ,KAAK;EAAG,YAAY;YAC5EJ;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"}
|