@agimon-ai/po-native-components 0.0.0-alpha.35 → 0.0.0-alpha.37
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/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +33 -16
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +10 -4
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/HashlineLines.d.mts.map +1 -1
- package/dist/components/HashlineLines.mjs +13 -4
- package/dist/components/HashlineLines.mjs.map +1 -1
- package/dist/components/Input.mjs +2 -1
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +2 -0
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/Markdown.d.mts +3 -1
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +160 -38
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/Sheet.d.mts +3 -1
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +10 -3
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.mjs +5 -2
- 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/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- 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 +4 -4
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { READING, inlineLength, inlinePrefix } from "../lib/reading.mjs";
|
|
3
|
+
import { useReadingPage } from "../lib/useReadingPage.mjs";
|
|
4
|
+
import { ShowMore } from "./ShowMore.mjs";
|
|
2
5
|
import { CodeBlock } from "./CodeBlock.mjs";
|
|
3
6
|
import { parseMarkdown } from "../lib/markdown.mjs";
|
|
4
7
|
import { View } from "react-native-unistyles/components/native/View";
|
|
@@ -6,12 +9,13 @@ import { Text } from "react-native-unistyles/components/native/Text";
|
|
|
6
9
|
import { StyleSheet } from "react-native-unistyles";
|
|
7
10
|
import { Linking } from "react-native";
|
|
8
11
|
import { createContext, memo, useContext, useEffect, useMemo, useState } from "react";
|
|
9
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
13
|
import { ScrollView } from "react-native-unistyles/components/native/ScrollView";
|
|
11
14
|
import { Image } from "react-native-unistyles/components/native/Image";
|
|
12
15
|
|
|
13
16
|
//#region src/components/Markdown.tsx
|
|
14
17
|
/** Passed by context so the inline renderers stay module functions. */
|
|
18
|
+
const InitialPageContext = createContext(1);
|
|
15
19
|
const FileLinkContext = createContext(void 0);
|
|
16
20
|
const ImageContext = createContext(void 0);
|
|
17
21
|
const URL_OR_ANCHOR = /^(?:[a-z][a-z\d+.-]*:|\/\/|#|\?)/i;
|
|
@@ -26,12 +30,12 @@ function decoded(href) {
|
|
|
26
30
|
return;
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
|
-
function InlineCode({ text }) {
|
|
33
|
+
function InlineCode({ text, originalText = text }) {
|
|
30
34
|
const onFileLink = useContext(FileLinkContext);
|
|
31
|
-
const open =
|
|
35
|
+
const open = originalText.includes("\n") ? void 0 : onFileLink?.(originalText);
|
|
32
36
|
if (open !== void 0) return /* @__PURE__ */ jsx(Text, {
|
|
33
37
|
accessibilityRole: "link",
|
|
34
|
-
accessibilityHint: `open ${
|
|
38
|
+
accessibilityHint: `open ${originalText}`,
|
|
35
39
|
onPress: open,
|
|
36
40
|
style: [styles.code, styles.fileLink],
|
|
37
41
|
children: text
|
|
@@ -126,7 +130,10 @@ function renderInline(nodes) {
|
|
|
126
130
|
return nodes.map((node, index) => {
|
|
127
131
|
switch (node.type) {
|
|
128
132
|
case "text": return node.text;
|
|
129
|
-
case "code": return /* @__PURE__ */ jsx(InlineCode, {
|
|
133
|
+
case "code": return /* @__PURE__ */ jsx(InlineCode, {
|
|
134
|
+
text: node.text,
|
|
135
|
+
originalText: node.originalText
|
|
136
|
+
}, index);
|
|
130
137
|
case "strong": return /* @__PURE__ */ jsx(Text, {
|
|
131
138
|
style: styles.strong,
|
|
132
139
|
children: renderInline(node.children)
|
|
@@ -148,26 +155,129 @@ function renderInline(nodes) {
|
|
|
148
155
|
* column takes its widest cell and the rows line up without a table layout.
|
|
149
156
|
*/
|
|
150
157
|
function MarkdownTable({ header, rows }) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
children:
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
const initialPage = useContext(InitialPageContext);
|
|
159
|
+
const [rowPage, setRows] = useState(initialPage);
|
|
160
|
+
const [columnPage, setColumns] = useState(initialPage);
|
|
161
|
+
const [cellPage, setCells] = useState(initialPage);
|
|
162
|
+
const visibleRows = rows.slice(0, READING.rows * rowPage);
|
|
163
|
+
const visibleHeader = header.slice(0, READING.columns * columnPage);
|
|
164
|
+
const limit = READING.cell * cellPage;
|
|
165
|
+
const clipped = [visibleHeader, ...visibleRows.map((row) => row.slice(0, visibleHeader.length))].some((row) => row.some((cell) => inlineLength(cell) > limit));
|
|
166
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
167
|
+
style: styles.root,
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsx(ScrollView, {
|
|
170
|
+
horizontal: true,
|
|
171
|
+
showsHorizontalScrollIndicator: false,
|
|
172
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
173
|
+
style: styles.table,
|
|
174
|
+
children: visibleHeader.map((cell, column) => /* @__PURE__ */ jsxs(View, { children: [/* @__PURE__ */ jsxs(Text, {
|
|
175
|
+
style: [
|
|
176
|
+
styles.prose,
|
|
177
|
+
styles.cell,
|
|
178
|
+
styles.headCell
|
|
179
|
+
],
|
|
180
|
+
children: [renderInline(inlinePrefix(cell, limit)), inlineLength(cell) > limit ? "…" : ""]
|
|
181
|
+
}), visibleRows.map((row, index) => /* @__PURE__ */ jsxs(Text, {
|
|
182
|
+
style: [styles.prose, styles.cell],
|
|
183
|
+
children: [renderInline(inlinePrefix(row[column] ?? [], limit)), inlineLength(row[column] ?? []) > limit ? "…" : ""]
|
|
184
|
+
}, index))] }, column))
|
|
185
|
+
})
|
|
186
|
+
}),
|
|
187
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
188
|
+
style: styles.meta,
|
|
189
|
+
children: [
|
|
190
|
+
visibleRows.length,
|
|
191
|
+
" of ",
|
|
192
|
+
rows.length,
|
|
193
|
+
" rows · ",
|
|
194
|
+
visibleHeader.length,
|
|
195
|
+
" of ",
|
|
196
|
+
header.length,
|
|
197
|
+
" columns",
|
|
198
|
+
clipped ? ` · Cells: first ${limit} characters` : ""
|
|
199
|
+
]
|
|
200
|
+
}),
|
|
201
|
+
/* @__PURE__ */ jsxs(View, {
|
|
202
|
+
style: styles.actions,
|
|
203
|
+
children: [
|
|
204
|
+
visibleRows.length < rows.length ? /* @__PURE__ */ jsx(ShowMore, {
|
|
205
|
+
label: "Show more rows",
|
|
206
|
+
onPress: () => setRows((page) => page + 1)
|
|
207
|
+
}) : null,
|
|
208
|
+
visibleHeader.length < header.length ? /* @__PURE__ */ jsx(ShowMore, {
|
|
209
|
+
label: "Show more columns",
|
|
210
|
+
onPress: () => setColumns((page) => page + 1)
|
|
211
|
+
}) : null,
|
|
212
|
+
clipped ? /* @__PURE__ */ jsx(ShowMore, {
|
|
213
|
+
label: "Show more cell text",
|
|
214
|
+
onPress: () => setCells((page) => page + 1)
|
|
215
|
+
}) : null
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function Blocks({ blocks, quoted = false }) {
|
|
222
|
+
const initialPage = useContext(InitialPageContext);
|
|
223
|
+
const [page, setPage] = useState(initialPage);
|
|
224
|
+
const visible = blocks.slice(0, READING.parts * page);
|
|
225
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [visible.map((block, index) => /* @__PURE__ */ jsx(BoundedBlock, {
|
|
226
|
+
block,
|
|
227
|
+
first: index === 0,
|
|
228
|
+
quoted
|
|
229
|
+
}, index)), visible.length < blocks.length ? /* @__PURE__ */ jsx(ShowMore, {
|
|
230
|
+
label: "Show more",
|
|
231
|
+
summary: `${visible.length} of ${blocks.length} parts`,
|
|
232
|
+
onPress: () => setPage((value) => value + 1)
|
|
233
|
+
}) : null] });
|
|
234
|
+
}
|
|
235
|
+
function BoundedBlock({ block, ...props }) {
|
|
236
|
+
const initialPage = useContext(InitialPageContext);
|
|
237
|
+
const [page, setPage] = useState(initialPage);
|
|
238
|
+
const limit = READING.characters * page;
|
|
239
|
+
let visible = block;
|
|
240
|
+
let total = 0;
|
|
241
|
+
let shown = 0;
|
|
242
|
+
if (block.type === "heading" || block.type === "paragraph") {
|
|
243
|
+
total = inlineLength(block.children);
|
|
244
|
+
const children = inlinePrefix(block.children, limit);
|
|
245
|
+
shown = inlineLength(children);
|
|
246
|
+
visible = {
|
|
247
|
+
...block,
|
|
248
|
+
children
|
|
249
|
+
};
|
|
250
|
+
} else if (block.type === "list") {
|
|
251
|
+
total = block.items.reduce((sum, item) => sum + inlineLength(item), 0);
|
|
252
|
+
let remaining = limit;
|
|
253
|
+
const items = [];
|
|
254
|
+
for (const item of block.items.slice(0, READING.parts * page)) {
|
|
255
|
+
if (remaining <= 0) break;
|
|
256
|
+
const next = inlinePrefix(item, remaining);
|
|
257
|
+
items.push(next);
|
|
258
|
+
remaining -= inlineLength(next);
|
|
259
|
+
}
|
|
260
|
+
shown = limit - remaining;
|
|
261
|
+
visible = {
|
|
262
|
+
...block,
|
|
263
|
+
items
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const more = shown < total || block.type === "list" && visible.type === "list" && visible.items.length < block.items.length;
|
|
267
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
268
|
+
style: styles.root,
|
|
269
|
+
children: [/* @__PURE__ */ jsx(Block, {
|
|
270
|
+
block: visible,
|
|
271
|
+
...props
|
|
272
|
+
}), more ? /* @__PURE__ */ jsx(ShowMore, {
|
|
273
|
+
label: "Show more text",
|
|
274
|
+
summary: `${shown} of ${total} characters`,
|
|
275
|
+
onPress: () => setPage((value) => value + 1)
|
|
276
|
+
}) : null]
|
|
168
277
|
});
|
|
169
278
|
}
|
|
170
279
|
function Block({ block, first, quoted = false }) {
|
|
280
|
+
const initialPage = useContext(InitialPageContext);
|
|
171
281
|
const prose = [styles.prose, quoted && styles.quoted];
|
|
172
282
|
switch (block.type) {
|
|
173
283
|
case "heading": return /* @__PURE__ */ jsx(Text, {
|
|
@@ -223,7 +333,8 @@ function Block({ block, first, quoted = false }) {
|
|
|
223
333
|
});
|
|
224
334
|
case "code": return /* @__PURE__ */ jsx(CodeBlock, {
|
|
225
335
|
text: block.text,
|
|
226
|
-
language: block.language
|
|
336
|
+
language: block.language,
|
|
337
|
+
initialPage
|
|
227
338
|
});
|
|
228
339
|
case "rule": return /* @__PURE__ */ jsx(View, {
|
|
229
340
|
accessible: false,
|
|
@@ -231,11 +342,10 @@ function Block({ block, first, quoted = false }) {
|
|
|
231
342
|
});
|
|
232
343
|
case "quote": return /* @__PURE__ */ jsx(View, {
|
|
233
344
|
style: [styles.root, styles.quote],
|
|
234
|
-
children:
|
|
235
|
-
|
|
236
|
-
first: index === 0,
|
|
345
|
+
children: /* @__PURE__ */ jsx(Blocks, {
|
|
346
|
+
blocks: block.children,
|
|
237
347
|
quoted: true
|
|
238
|
-
}
|
|
348
|
+
})
|
|
239
349
|
});
|
|
240
350
|
case "table": return /* @__PURE__ */ jsx(MarkdownTable, {
|
|
241
351
|
header: block.header,
|
|
@@ -244,18 +354,19 @@ function Block({ block, first, quoted = false }) {
|
|
|
244
354
|
}
|
|
245
355
|
}
|
|
246
356
|
/** Markdown in Po's shared presentation, parsed by the package's own small parser. */
|
|
247
|
-
const Markdown = memo(function Markdown({ text, onFileLink, loadImage }) {
|
|
357
|
+
const Markdown = memo(function Markdown({ text, onFileLink, loadImage, initialPage = 1 }) {
|
|
248
358
|
const blocks = useMemo(() => parseMarkdown(text), [text]);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
359
|
+
const { generation } = useReadingPage(text);
|
|
360
|
+
return /* @__PURE__ */ jsx(InitialPageContext.Provider, {
|
|
361
|
+
value: initialPage,
|
|
362
|
+
children: /* @__PURE__ */ jsx(FileLinkContext.Provider, {
|
|
363
|
+
value: onFileLink,
|
|
364
|
+
children: /* @__PURE__ */ jsx(ImageContext.Provider, {
|
|
365
|
+
value: loadImage,
|
|
366
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
367
|
+
style: styles.root,
|
|
368
|
+
children: /* @__PURE__ */ jsx(Blocks, { blocks }, generation)
|
|
369
|
+
})
|
|
259
370
|
})
|
|
260
371
|
})
|
|
261
372
|
});
|
|
@@ -289,6 +400,17 @@ const HEADING_INK = {
|
|
|
289
400
|
6: "dim"
|
|
290
401
|
};
|
|
291
402
|
const styles = StyleSheet.create((theme) => ({
|
|
403
|
+
meta: {
|
|
404
|
+
color: theme.colors.dim,
|
|
405
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
406
|
+
fontSize: theme.fontSize.sm,
|
|
407
|
+
lineHeight: theme.lineHeight.sm,
|
|
408
|
+
uni__dependencies: [0]
|
|
409
|
+
},
|
|
410
|
+
actions: {
|
|
411
|
+
flexDirection: "row",
|
|
412
|
+
flexWrap: "wrap"
|
|
413
|
+
},
|
|
292
414
|
root: {
|
|
293
415
|
minWidth: 0,
|
|
294
416
|
gap: theme.spacing(2),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.mjs","names":["createContext","memo","ReactNode","useContext","useEffect","useMemo","useState","Linking","StyleSheet","fontOf","MarkdownBlock","MarkdownHeadingLevel","MarkdownInline","parseMarkdown","CodeBlock","FileLinkHandler","text","explicit","FileLinkContext","undefined","MarkdownImageLoader","path","Promise","url","dispose","ImageContext","URL_OR_ANCHOR","DIRECT_IMAGE","PLACEHOLDER_RATIO","decoded","href","decodeURIComponent","InlineCode","onFileLink","open","includes","styles","code","fileLink","InlineLink","children","isFile","test","openURL","catch","link","MarkdownImage","src","alt","loader","split","loaded","setLoaded","failed","ratio","setRatio","active","asset","Awaited","ReturnType","resolve","then","Error","result","current","uri","waiting","prose","imageState","nativeEvent","fit","width","height","size","source","Image","getSize","image","aspectRatio","renderInline","nodes","map","node","index","type","strong","em","MarkdownTable","header","rows","table","cell","column","headCell","row","Block","block","first","quoted","heading","level","firstHeading","parts","run","flush","length","push","root","list","items","item","marker","ordered","start","itemText","language","rule","quote","child","MarkdownProps","loadImage","Markdown","blocks","HEADING_STEP","const","HEADING_SPACE","HEADING_INK","create","theme","minWidth","gap","spacing","uni__dependencies","color","colors","fontFamily","sans","fontSize","base","lineHeight","marginTop","letterSpacing","fontWeight","semibold","hi","fontStyle","backgroundColor","deep","green","mono","textDecorationLine","blue","flexDirection","paddingLeft","dim","flexShrink","borderLeftWidth","borderLeftColor","border","borderTopWidth","borderColor","paddingHorizontal","paddingVertical","borderRightWidth","borderBottomWidth","maxHeight","borderRadius","md","borderWidth"],"sources":["../../src/components/Markdown.tsx"],"sourcesContent":["import { createContext, memo, type ReactNode, useContext, useEffect, useMemo, useState } from 'react';\nimport { Image, Linking, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { type MarkdownBlock, type MarkdownHeadingLevel, type MarkdownInline, parseMarkdown } from '../lib/markdown';\nimport { CodeBlock } from './CodeBlock';\n\n/*\n * Markdown in the web component's element styles, from the package's own\n * parser: headings, paragraphs, lists, code spans and fences, bold, italic,\n * links, images, blockquotes and tables. Web links open with Linking; a file\n * path goes to the host. Raw HTML blocks are left out, as on the web.\n */\n\n/**\n * What a piece of inline code or a relative link opens, when the host knows.\n * Returning undefined leaves it as plain code or an ordinary link. The same\n * contract as the web Markdown's handler.\n */\nexport type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;\n\n/** Passed by context so the inline renderers stay module functions. */\nconst FileLinkContext = createContext<FileLinkHandler | undefined>(undefined);\n\n/** Loads a relative image path from the host; the same contract as the web Markdown's `loadImage`. */\nexport type MarkdownImageLoader = (path: string) => Promise<{ url: string; dispose(): void }>;\n\nconst ImageContext = createContext<MarkdownImageLoader | undefined>(undefined);\n\nconst URL_OR_ANCHOR = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/|#|\\?)/i;\n/** Sources an Image may load as written; any other scheme stays its alt text. */\nconst DIRECT_IMAGE = /^(?:https?:|data:image\\/)/i;\n/** Until the image reports its size, it holds a landscape box rather than collapsing. */\nconst PLACEHOLDER_RATIO = 16 / 9;\n\nfunction decoded(href: string): string | undefined {\n try {\n return decodeURIComponent(href);\n } catch {\n return undefined;\n }\n}\n\nfunction InlineCode({ text }: { text: string }) {\n const onFileLink = useContext(FileLinkContext);\n const open = text.includes('\\n') ? undefined : onFileLink?.(text);\n if (open !== undefined) {\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={`open ${text}`}\n onPress={open}\n style={[styles.code, styles.fileLink]}\n >\n {text}\n </Text>\n );\n }\n return <Text style={styles.code}>{text}</Text>;\n}\n\nfunction InlineLink({ href, children }: { href: string; children: ReactNode }) {\n const onFileLink = useContext(FileLinkContext);\n const path = decoded(href);\n const isFile = path !== undefined && path !== '' && !URL_OR_ANCHOR.test(path);\n const open = isFile ? onFileLink?.(path, true) : undefined;\n return (\n <Text\n accessibilityRole=\"link\"\n onPress={() => {\n if (open !== undefined) open();\n else if (!isFile) Linking.openURL(href).catch(() => undefined);\n }}\n style={styles.link}\n >\n {children}\n </Text>\n );\n}\n\n/** One image: a file path through the host's loader, or a web or data address as written. */\nfunction MarkdownImage({ src, alt }: { src: string; alt: string }) {\n const loader = useContext(ImageContext);\n // An invalid encoded filename is shown as unavailable, never fetched.\n const path = URL_OR_ANCHOR.test(src) ? undefined : (decoded(src.split(/[?#]/u, 1)[0]!) ?? '');\n const [loaded, setLoaded] = useState<{ path: string; url?: string; failed?: boolean }>();\n const [ratio, setRatio] = useState(PLACEHOLDER_RATIO);\n useEffect(() => {\n if (loader === undefined || path === undefined) return;\n let active = true;\n let asset: Awaited<ReturnType<MarkdownImageLoader>> | undefined;\n void Promise.resolve()\n .then(() => {\n if (path === '') throw new Error('Invalid image path.');\n return loader(path);\n })\n .then((result) => {\n if (!active) return result.dispose();\n asset = result;\n setLoaded({ path, url: result.url });\n })\n .catch(() => {\n // The failure is shown in place, as the web image does.\n if (active) setLoaded({ path, failed: true });\n });\n return () => {\n active = false;\n asset?.dispose();\n };\n }, [path, loader]);\n const current = loaded?.path === path ? loaded : undefined;\n const uri = path === undefined ? (DIRECT_IMAGE.test(src) ? src : undefined) : current?.url;\n if (uri === undefined || current?.failed) {\n const waiting = path !== undefined && loader !== undefined && current === undefined;\n return (\n <Text style={[styles.prose, styles.imageState]} accessibilityRole={waiting ? 'text' : 'alert'}>\n {alt || path || 'Image'} ({waiting ? 'loading\\u2026' : 'unavailable'})\n </Text>\n );\n }\n return (\n <Image\n source={{ uri }}\n accessibilityLabel={alt || 'Image'}\n accessibilityIgnoresInvertColors\n resizeMode=\"contain\"\n onLoad={({ nativeEvent }) => {\n const fit = (width: number, height: number) => {\n if (width > 0 && height > 0) setRatio(width / height);\n };\n // iOS and Android report the size with the event; react-native-web does not, so it asks.\n const size = (nativeEvent as { source?: { width: number; height: number } } | undefined)?.source;\n if (size !== undefined) fit(size.width, size.height);\n else Image.getSize(uri, fit, () => undefined);\n }}\n onError={() => setLoaded({ path: path ?? src, failed: true })}\n style={[styles.image, { aspectRatio: ratio }]}\n />\n );\n}\nfunction renderInline(nodes: readonly MarkdownInline[]): ReactNode[] {\n return nodes.map((node, index) => {\n switch (node.type) {\n case 'text':\n return node.text;\n case 'code':\n return <InlineCode key={index} text={node.text} />;\n case 'strong':\n return (\n <Text key={index} style={styles.strong}>\n {renderInline(node.children)}\n </Text>\n );\n case 'em':\n return (\n <Text key={index} style={styles.em}>\n {renderInline(node.children)}\n </Text>\n );\n case 'link':\n return (\n <InlineLink key={index} href={node.href}>\n {renderInline(node.children)}\n </InlineLink>\n );\n case 'image':\n // Inside a heading or list item an image keeps to its alt text; paragraphs draw it.\n return node.alt;\n }\n });\n}\n\n/**\n * A table read column by column: every cell keeps to one line inside the sideways scroll, so each\n * column takes its widest cell and the rows line up without a table layout.\n */\nfunction MarkdownTable({ header, rows }: { header: MarkdownInline[][]; rows: MarkdownInline[][][] }) {\n return (\n <ScrollView horizontal showsHorizontalScrollIndicator={false}>\n <View style={styles.table}>\n {header.map((cell, column) => (\n <View key={column}>\n <Text style={[styles.prose, styles.cell, styles.headCell]}>{renderInline(cell)}</Text>\n {rows.map((row, index) => (\n <Text key={index} style={[styles.prose, styles.cell]}>\n {renderInline(row[column] ?? [])}\n </Text>\n ))}\n </View>\n ))}\n </View>\n </ScrollView>\n );\n}\n\nfunction Block({ block, first, quoted = false }: { block: MarkdownBlock; first: boolean; quoted?: boolean }) {\n const prose = [styles.prose, quoted && styles.quoted];\n switch (block.type) {\n case 'heading':\n return (\n <Text\n accessibilityRole=\"header\"\n style={[...prose, styles.heading(block.level), first && styles.firstHeading, quoted && styles.quoted]}\n >\n {renderInline(block.children)}\n </Text>\n );\n case 'paragraph': {\n // An image breaks the paragraph's text into runs, since an Image cannot sit inside Text.\n const parts: ReactNode[] = [];\n let run: MarkdownInline[] = [];\n const flush = () => {\n if (run.length > 0)\n parts.push(\n <Text key={parts.length} style={prose}>\n {renderInline(run)}\n </Text>,\n );\n run = [];\n };\n for (const node of block.children) {\n if (node.type !== 'image') {\n run.push(node);\n continue;\n }\n flush();\n parts.push(<MarkdownImage key={parts.length} src={node.src} alt={node.alt} />);\n }\n flush();\n return parts.length === 1 ? parts[0] : <View style={styles.root}>{parts}</View>;\n }\n case 'list':\n return (\n <View accessibilityRole=\"list\" style={styles.list}>\n {block.items.map((item, index) => (\n <View key={index} style={styles.item}>\n <Text style={[...prose, styles.marker]}>{block.ordered ? `${block.start + index}.` : '\\u2022'}</Text>\n <Text style={[...prose, styles.itemText]}>{renderInline(item)}</Text>\n </View>\n ))}\n </View>\n );\n case 'code':\n return <CodeBlock text={block.text} language={block.language} />;\n case 'rule':\n return <View accessible={false} style={styles.rule} />;\n case 'quote':\n return (\n <View style={[styles.root, styles.quote]}>\n {block.children.map((child, index) => (\n <Block key={index} block={child} first={index === 0} quoted />\n ))}\n </View>\n );\n case 'table':\n return <MarkdownTable header={block.header} rows={block.rows} />;\n }\n}\n\nexport interface MarkdownProps {\n text: string;\n onFileLink?: FileLinkHandler;\n /** Loads relative image paths; without it they show as unavailable. */\n loadImage?: MarkdownImageLoader;\n}\n\n/** Markdown in Po's shared presentation, parsed by the package's own small parser. */\nexport const Markdown = memo(function Markdown({ text, onFileLink, loadImage }: MarkdownProps) {\n const blocks = useMemo(() => parseMarkdown(text), [text]);\n return (\n <FileLinkContext.Provider value={onFileLink}>\n <ImageContext.Provider value={loadImage}>\n <View style={styles.root}>\n {blocks.map((block, index) => (\n <Block key={index} block={block} first={index === 0} />\n ))}\n </View>\n </ImageContext.Provider>\n </FileLinkContext.Provider>\n );\n});\n\n/**\n * Headings step up from the prose and never shrink below it; h4 to h6 keep\n * the prose size and lean on weight, fading from `hi` to `dim`.\n */\nconst HEADING_STEP = { 1: '2xl', 2: 'xl', 3: 'lg', 4: 'base', 5: 'base', 6: 'base' } as const;\nconst HEADING_SPACE = { 1: 2, 2: 2, 3: 1, 4: 0, 5: 0, 6: 0 } as const;\nconst HEADING_INK = { 1: 'hi', 2: 'hi', 3: 'hi', 4: 'hi', 5: 'text', 6: 'dim' } as const;\n\nconst styles = StyleSheet.create((theme) => ({\n root: { minWidth: 0, gap: theme.spacing(2) },\n prose: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n heading: (level: MarkdownHeadingLevel) => ({\n marginTop: theme.spacing(HEADING_SPACE[level]),\n fontSize: theme.fontSize[HEADING_STEP[level]],\n lineHeight: theme.lineHeight[HEADING_STEP[level]],\n letterSpacing: theme.letterSpacing[HEADING_STEP[level]],\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors[HEADING_INK[level]],\n }),\n firstHeading: { marginTop: 0 },\n strong: { fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n em: { fontStyle: 'italic' },\n code: {\n backgroundColor: theme.colors.deep,\n color: theme.colors.green,\n fontFamily: fontOf(theme.fontFamily.mono),\n },\n fileLink: { textDecorationLine: 'underline' },\n link: { color: theme.colors.blue, textDecorationLine: 'underline' },\n list: { gap: theme.spacing(0.5) },\n item: { flexDirection: 'row', gap: theme.spacing(2), paddingLeft: theme.spacing(1) },\n marker: { minWidth: theme.spacing(3), color: theme.colors.dim },\n itemText: { flexShrink: 1 },\n rule: { height: 1, backgroundColor: theme.colors['border-soft'] },\n // The web blockquote: a rule at the left and quieter text.\n quote: { borderLeftWidth: 2, borderLeftColor: theme.colors.border, paddingLeft: theme.spacing(3) },\n quoted: { color: theme.colors.dim },\n // The web table: bordered cells, the header on the deep surface.\n table: {\n flexDirection: 'row',\n borderTopWidth: 1,\n borderLeftWidth: 1,\n borderColor: theme.colors.border,\n },\n cell: {\n paddingHorizontal: theme.spacing(2),\n paddingVertical: theme.spacing(1),\n borderRightWidth: 1,\n borderBottomWidth: 1,\n borderColor: theme.colors.border,\n },\n headCell: { backgroundColor: theme.colors.deep, fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n // The web image's frame: at most 480 tall, a soft border and rounded corners.\n image: {\n width: '100%',\n maxHeight: 480,\n borderRadius: theme.borderRadius.md,\n borderWidth: 1,\n borderColor: theme.colors.border,\n },\n imageState: { color: theme.colors.dim },\n}));\n"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAMkB,kBAAkBlB,cAA2CmB,MAAS;AAK5E,MAAMM,eAAezB,cAA+CmB,MAAS;AAE7E,MAAMO,gBAAgB;;AAEtB,MAAMC,eAAe;;AAErB,MAAMC,oBAAoB,KAAK;AAE/B,SAASC,QAAQC,MAAkC;CACjD,IAAI;EACF,OAAOC,mBAAmBD,IAAI;CAChC,QAAQ;EACN;CACF;AACF;AAEA,SAASE,WAAW,EAAEhB,QAA0B;CAC9C,MAAMiB,aAAa9B,WAAWe,eAAe;CAC7C,MAAMgB,OAAOlB,KAAKmB,SAAS,IAAI,IAAIhB,SAAYc,aAAajB,IAAI;CAChE,IAAIkB,SAASf,QACX,OACE,oBAAC,MAAD;EACE,mBAAkB;EAClB,mBAAmB,QAAQH;EAC3B,SAASkB;EACT,OAAO,CAACE,OAAOC,MAAMD,OAAOE,QAAQ;YAEnCtB;CACG;CAGV,OAAO,oBAAC,MAAD;EAAM,OAAOoB,OAAOC;YAAOrB;CAAW;AAC/C;AAEA,SAASuB,WAAW,EAAET,MAAMU,YAAmD;CAC7E,MAAMP,aAAa9B,WAAWe,eAAe;CAC7C,MAAMG,OAAOQ,QAAQC,IAAI;CACzB,MA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OAAOwB;EAAQL,aAAazB,MAAMG,QAAQ,CAAC;EAACC,mBAAA,CAAA,CAAA;CAAC;CACjGlC,QAAQ;EAAEmC,OAAOL,MAAMM,OAAOoB;EAAGtB,mBAAA,CAAA,CAAA;CAAC;CAElC1C,OAAO;EACL8D,eAAe;EACfO,gBAAgB;EAChBH,iBAAiB;EACjBI,aAAahC,MAAMM,OAAOwB;EAAM1B,mBAAA,CAAA,CAAA;CAClC;CACAzC,MAAM;EACJsE,mBAAmBjC,MAAMG,QAAQ,CAAC;EAClC+B,iBAAiBlC,MAAMG,QAAQ,CAAC;EAChCgC,kBAAkB;EAClBC,mBAAmB;EACnBJ,aAAahC,MAAMM,OAAOwB;EAAM1B,mBAAA,CAAA,CAAA;CAClC;CACAvC,UAAU;EAAEqD,iBAAiBlB,MAAMM,OAAOa;EAAML,YAAYd,MAAMc,WAAWC;EAAUV,OAAOL,MAAMM,OAAOU;EAAEZ,mBAAA,CAAA,CAAA;CAAC;CAE9GvD,OAAO;EACLN,OAAO;EACP8F,WAAW;EACXC,cAActC,MAAMsC,aAAaC;EACjCC,aAAa;EACbR,aAAahC,MAAMM,OAAOwB;EAAM1B,mBAAA,CAAA,CAAA;CAClC;CACAhE,YAAY;EAAEiE,OAAOL,MAAMM,OAAOoB;EAAGtB,mBAAA,CAAA,CAAA;CAAC;AACxC,EAAE"}
|
|
1
|
+
{"version":3,"file":"Markdown.mjs","names":["createContext","memo","ReactNode","useContext","useEffect","useMemo","useState","Linking","StyleSheet","fontOf","MarkdownBlock","MarkdownHeadingLevel","MarkdownInline","parseMarkdown","READING","inlineLength","inlinePrefix","useReadingPage","CodeBlock","ShowMore","FileLinkHandler","text","explicit","InitialPageContext","FileLinkContext","undefined","MarkdownImageLoader","path","Promise","url","dispose","ImageContext","URL_OR_ANCHOR","DIRECT_IMAGE","PLACEHOLDER_RATIO","decoded","href","decodeURIComponent","InlineCode","originalText","onFileLink","open","includes","styles","code","fileLink","InlineLink","children","isFile","test","openURL","catch","link","MarkdownImage","src","alt","loader","split","loaded","setLoaded","failed","ratio","setRatio","active","asset","Awaited","ReturnType","resolve","then","Error","result","current","uri","waiting","prose","imageState","nativeEvent","fit","width","height","size","source","Image","getSize","image","aspectRatio","renderInline","nodes","map","node","index","type","strong","em","MarkdownTable","header","rows","initialPage","rowPage","setRows","columnPage","setColumns","cellPage","setCells","visibleRows","slice","visibleHeader","columns","limit","cell","clipped","row","length","some","root","table","column","headCell","meta","actions","page","Blocks","blocks","quoted","setPage","visible","parts","block","value","BoundedBlock","props","first","characters","total","shown","items","reduce","sum","item","remaining","next","push","more","Block","heading","level","firstHeading","run","flush","list","marker","ordered","start","itemText","language","rule","quote","MarkdownProps","loadImage","Markdown","generation","HEADING_STEP","const","HEADING_SPACE","HEADING_INK","create","theme","color","colors","dim","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies","flexDirection","flexWrap","minWidth","gap","spacing","base","marginTop","letterSpacing","fontWeight","semibold","hi","fontStyle","backgroundColor","deep","green","mono","textDecorationLine","blue","paddingLeft","flexShrink","borderLeftWidth","borderLeftColor","border","borderTopWidth","borderColor","paddingHorizontal","paddingVertical","borderRightWidth","borderBottomWidth","maxHeight","borderRadius","md","borderWidth"],"sources":["../../src/components/Markdown.tsx"],"sourcesContent":["import { createContext, memo, type ReactNode, useContext, useEffect, useMemo, useState } from 'react';\nimport { Image, Linking, ScrollView, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { type MarkdownBlock, type MarkdownHeadingLevel, type MarkdownInline, parseMarkdown } from '../lib/markdown';\nimport { READING, inlineLength, inlinePrefix } from '../lib/reading';\nimport { useReadingPage } from '../lib/useReadingPage';\nimport { CodeBlock } from './CodeBlock';\nimport { ShowMore } from './ShowMore';\n\n/*\n * Markdown in the web component's element styles, from the package's own\n * parser: headings, paragraphs, lists, code spans and fences, bold, italic,\n * links, images, blockquotes and tables. Web links open with Linking; a file\n * path goes to the host. Raw HTML blocks are left out, as on the web.\n */\n\n/**\n * What a piece of inline code or a relative link opens, when the host knows.\n * Returning undefined leaves it as plain code or an ordinary link. The same\n * contract as the web Markdown's handler.\n */\nexport type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;\n\n/** Passed by context so the inline renderers stay module functions. */\nconst InitialPageContext = createContext(1);\n\nconst FileLinkContext = createContext<FileLinkHandler | undefined>(undefined);\n\n/** Loads a relative image path from the host; the same contract as the web Markdown's `loadImage`. */\nexport type MarkdownImageLoader = (path: string) => Promise<{ url: string; dispose(): void }>;\n\nconst ImageContext = createContext<MarkdownImageLoader | undefined>(undefined);\n\nconst URL_OR_ANCHOR = /^(?:[a-z][a-z\\d+.-]*:|\\/\\/|#|\\?)/i;\n/** Sources an Image may load as written; any other scheme stays its alt text. */\nconst DIRECT_IMAGE = /^(?:https?:|data:image\\/)/i;\n/** Until the image reports its size, it holds a landscape box rather than collapsing. */\nconst PLACEHOLDER_RATIO = 16 / 9;\n\nfunction decoded(href: string): string | undefined {\n try {\n return decodeURIComponent(href);\n } catch {\n return undefined;\n }\n}\n\nfunction InlineCode({ text, originalText = text }: { text: string; originalText?: string }) {\n const onFileLink = useContext(FileLinkContext);\n const open = originalText.includes('\\n') ? undefined : onFileLink?.(originalText);\n if (open !== undefined) {\n return (\n <Text\n accessibilityRole=\"link\"\n accessibilityHint={`open ${originalText}`}\n onPress={open}\n style={[styles.code, styles.fileLink]}\n >\n {text}\n </Text>\n );\n }\n return <Text style={styles.code}>{text}</Text>;\n}\n\nfunction InlineLink({ href, children }: { href: string; children: ReactNode }) {\n const onFileLink = useContext(FileLinkContext);\n const path = decoded(href);\n const isFile = path !== undefined && path !== '' && !URL_OR_ANCHOR.test(path);\n const open = isFile ? onFileLink?.(path, true) : undefined;\n return (\n <Text\n accessibilityRole=\"link\"\n onPress={() => {\n if (open !== undefined) open();\n else if (!isFile) Linking.openURL(href).catch(() => undefined);\n }}\n style={styles.link}\n >\n {children}\n </Text>\n );\n}\n\n/** One image: a file path through the host's loader, or a web or data address as written. */\nfunction MarkdownImage({ src, alt }: { src: string; alt: string }) {\n const loader = useContext(ImageContext);\n // An invalid encoded filename is shown as unavailable, never fetched.\n const path = URL_OR_ANCHOR.test(src) ? undefined : (decoded(src.split(/[?#]/u, 1)[0]!) ?? '');\n const [loaded, setLoaded] = useState<{ path: string; url?: string; failed?: boolean }>();\n const [ratio, setRatio] = useState(PLACEHOLDER_RATIO);\n useEffect(() => {\n if (loader === undefined || path === undefined) return;\n let active = true;\n let asset: Awaited<ReturnType<MarkdownImageLoader>> | undefined;\n void Promise.resolve()\n .then(() => {\n if (path === '') throw new Error('Invalid image path.');\n return loader(path);\n })\n .then((result) => {\n if (!active) return result.dispose();\n asset = result;\n setLoaded({ path, url: result.url });\n })\n .catch(() => {\n // The failure is shown in place, as the web image does.\n if (active) setLoaded({ path, failed: true });\n });\n return () => {\n active = false;\n asset?.dispose();\n };\n }, [path, loader]);\n const current = loaded?.path === path ? loaded : undefined;\n const uri = path === undefined ? (DIRECT_IMAGE.test(src) ? src : undefined) : current?.url;\n if (uri === undefined || current?.failed) {\n const waiting = path !== undefined && loader !== undefined && current === undefined;\n return (\n <Text style={[styles.prose, styles.imageState]} accessibilityRole={waiting ? 'text' : 'alert'}>\n {alt || path || 'Image'} ({waiting ? 'loading\\u2026' : 'unavailable'})\n </Text>\n );\n }\n return (\n <Image\n source={{ uri }}\n accessibilityLabel={alt || 'Image'}\n accessibilityIgnoresInvertColors\n resizeMode=\"contain\"\n onLoad={({ nativeEvent }) => {\n const fit = (width: number, height: number) => {\n if (width > 0 && height > 0) setRatio(width / height);\n };\n // iOS and Android report the size with the event; react-native-web does not, so it asks.\n const size = (nativeEvent as { source?: { width: number; height: number } } | undefined)?.source;\n if (size !== undefined) fit(size.width, size.height);\n else Image.getSize(uri, fit, () => undefined);\n }}\n onError={() => setLoaded({ path: path ?? src, failed: true })}\n style={[styles.image, { aspectRatio: ratio }]}\n />\n );\n}\nfunction renderInline(nodes: readonly MarkdownInline[]): ReactNode[] {\n return nodes.map((node, index) => {\n switch (node.type) {\n case 'text':\n return node.text;\n case 'code':\n return <InlineCode key={index} text={node.text} originalText={node.originalText} />;\n case 'strong':\n return (\n <Text key={index} style={styles.strong}>\n {renderInline(node.children)}\n </Text>\n );\n case 'em':\n return (\n <Text key={index} style={styles.em}>\n {renderInline(node.children)}\n </Text>\n );\n case 'link':\n return (\n <InlineLink key={index} href={node.href}>\n {renderInline(node.children)}\n </InlineLink>\n );\n case 'image':\n // Inside a heading or list item an image keeps to its alt text; paragraphs draw it.\n return node.alt;\n }\n });\n}\n\n/**\n * A table read column by column: every cell keeps to one line inside the sideways scroll, so each\n * column takes its widest cell and the rows line up without a table layout.\n */\nfunction MarkdownTable({ header, rows }: { header: MarkdownInline[][]; rows: MarkdownInline[][][] }) {\n const initialPage = useContext(InitialPageContext);\n const [rowPage, setRows] = useState(initialPage);\n const [columnPage, setColumns] = useState(initialPage);\n const [cellPage, setCells] = useState(initialPage);\n const visibleRows = rows.slice(0, READING.rows * rowPage);\n const visibleHeader = header.slice(0, READING.columns * columnPage);\n const limit = READING.cell * cellPage;\n const clipped = [visibleHeader, ...visibleRows.map((row) => row.slice(0, visibleHeader.length))].some((row) =>\n row.some((cell) => inlineLength(cell) > limit),\n );\n return (\n <View style={styles.root}>\n <ScrollView horizontal showsHorizontalScrollIndicator={false}>\n <View style={styles.table}>\n {visibleHeader.map((cell, column) => (\n <View key={column}>\n <Text style={[styles.prose, styles.cell, styles.headCell]}>\n {renderInline(inlinePrefix(cell, limit))}\n {inlineLength(cell) > limit ? '…' : ''}\n </Text>\n {visibleRows.map((row, index) => (\n <Text key={index} style={[styles.prose, styles.cell]}>\n {renderInline(inlinePrefix(row[column] ?? [], limit))}\n {inlineLength(row[column] ?? []) > limit ? '…' : ''}\n </Text>\n ))}\n </View>\n ))}\n </View>\n </ScrollView>\n <Text style={styles.meta}>\n {visibleRows.length} of {rows.length} rows · {visibleHeader.length} of {header.length} columns\n {clipped ? ` · Cells: first ${limit} characters` : ''}\n </Text>\n <View style={styles.actions}>\n {visibleRows.length < rows.length ? (\n <ShowMore label=\"Show more rows\" onPress={() => setRows((page) => page + 1)} />\n ) : null}\n {visibleHeader.length < header.length ? (\n <ShowMore label=\"Show more columns\" onPress={() => setColumns((page) => page + 1)} />\n ) : null}\n {clipped ? <ShowMore label=\"Show more cell text\" onPress={() => setCells((page) => page + 1)} /> : null}\n </View>\n </View>\n );\n}\n\nfunction Blocks({ blocks, quoted = false }: { blocks: MarkdownBlock[]; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const [page, setPage] = useState(initialPage);\n const visible = blocks.slice(0, READING.parts * page);\n return (\n <>\n {visible.map((block, index) => (\n <BoundedBlock key={index} block={block} first={index === 0} quoted={quoted} />\n ))}\n {visible.length < blocks.length ? (\n <ShowMore\n label=\"Show more\"\n summary={`${visible.length} of ${blocks.length} parts`}\n onPress={() => setPage((value) => value + 1)}\n />\n ) : null}\n </>\n );\n}\n\nfunction BoundedBlock({ block, ...props }: { block: MarkdownBlock; first: boolean; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const [page, setPage] = useState(initialPage);\n const limit = READING.characters * page;\n let visible = block;\n let total = 0;\n let shown = 0;\n if (block.type === 'heading' || block.type === 'paragraph') {\n total = inlineLength(block.children);\n const children = inlinePrefix(block.children, limit);\n shown = inlineLength(children);\n visible = { ...block, children };\n } else if (block.type === 'list') {\n total = block.items.reduce((sum, item) => sum + inlineLength(item), 0);\n let remaining = limit;\n const items = [];\n for (const item of block.items.slice(0, READING.parts * page)) {\n if (remaining <= 0) break;\n const next = inlinePrefix(item, remaining);\n items.push(next);\n remaining -= inlineLength(next);\n }\n shown = limit - remaining;\n visible = { ...block, items };\n }\n const more =\n shown < total || (block.type === 'list' && visible.type === 'list' && visible.items.length < block.items.length);\n return (\n <View style={styles.root}>\n <Block block={visible} {...props} />\n {more ? (\n <ShowMore\n label=\"Show more text\"\n summary={`${shown} of ${total} characters`}\n onPress={() => setPage((value) => value + 1)}\n />\n ) : null}\n </View>\n );\n}\n\nfunction Block({ block, first, quoted = false }: { block: MarkdownBlock; first: boolean; quoted?: boolean }) {\n const initialPage = useContext(InitialPageContext);\n const prose = [styles.prose, quoted && styles.quoted];\n switch (block.type) {\n case 'heading':\n return (\n <Text\n accessibilityRole=\"header\"\n style={[...prose, styles.heading(block.level), first && styles.firstHeading, quoted && styles.quoted]}\n >\n {renderInline(block.children)}\n </Text>\n );\n case 'paragraph': {\n // An image breaks the paragraph's text into runs, since an Image cannot sit inside Text.\n const parts: ReactNode[] = [];\n let run: MarkdownInline[] = [];\n const flush = () => {\n if (run.length > 0)\n parts.push(\n <Text key={parts.length} style={prose}>\n {renderInline(run)}\n </Text>,\n );\n run = [];\n };\n for (const node of block.children) {\n if (node.type !== 'image') {\n run.push(node);\n continue;\n }\n flush();\n parts.push(<MarkdownImage key={parts.length} src={node.src} alt={node.alt} />);\n }\n flush();\n return parts.length === 1 ? parts[0] : <View style={styles.root}>{parts}</View>;\n }\n case 'list':\n return (\n <View accessibilityRole=\"list\" style={styles.list}>\n {block.items.map((item, index) => (\n <View key={index} style={styles.item}>\n <Text style={[...prose, styles.marker]}>{block.ordered ? `${block.start + index}.` : '\\u2022'}</Text>\n <Text style={[...prose, styles.itemText]}>{renderInline(item)}</Text>\n </View>\n ))}\n </View>\n );\n case 'code':\n return <CodeBlock text={block.text} language={block.language} initialPage={initialPage} />;\n case 'rule':\n return <View accessible={false} style={styles.rule} />;\n case 'quote':\n return (\n <View style={[styles.root, styles.quote]}>\n <Blocks blocks={block.children} quoted />\n </View>\n );\n case 'table':\n return <MarkdownTable header={block.header} rows={block.rows} />;\n }\n}\n\nexport interface MarkdownProps {\n text: string;\n onFileLink?: FileLinkHandler;\n /** Loads relative image paths; without it they show as unavailable. */\n loadImage?: MarkdownImageLoader;\n /** Initial reveal pages for a restored reading position. Defaults to one. */\n initialPage?: number;\n}\n\n/** Markdown in Po's shared presentation, parsed by the package's own small parser. */\nexport const Markdown = memo(function Markdown({ text, onFileLink, loadImage, initialPage = 1 }: MarkdownProps) {\n const blocks = useMemo(() => parseMarkdown(text), [text]);\n const { generation } = useReadingPage(text);\n return (\n <InitialPageContext.Provider value={initialPage}>\n <FileLinkContext.Provider value={onFileLink}>\n <ImageContext.Provider value={loadImage}>\n <View style={styles.root}>\n <Blocks key={generation} blocks={blocks} />\n </View>\n </ImageContext.Provider>\n </FileLinkContext.Provider>\n </InitialPageContext.Provider>\n );\n});\n\n/**\n * Headings step up from the prose and never shrink below it; h4 to h6 keep\n * the prose size and lean on weight, fading from `hi` to `dim`.\n */\nconst HEADING_STEP = { 1: '2xl', 2: 'xl', 3: 'lg', 4: 'base', 5: 'base', 6: 'base' } as const;\nconst HEADING_SPACE = { 1: 2, 2: 2, 3: 1, 4: 0, 5: 0, 6: 0 } as const;\nconst HEADING_INK = { 1: 'hi', 2: 'hi', 3: 'hi', 4: 'hi', 5: 'text', 6: 'dim' } as const;\n\nconst styles = StyleSheet.create((theme) => ({\n meta: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n actions: { flexDirection: 'row', flexWrap: 'wrap' },\n root: { minWidth: 0, gap: theme.spacing(2) },\n prose: {\n color: theme.colors.text,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n },\n heading: (level: MarkdownHeadingLevel) => ({\n marginTop: theme.spacing(HEADING_SPACE[level]),\n fontSize: theme.fontSize[HEADING_STEP[level]],\n lineHeight: theme.lineHeight[HEADING_STEP[level]],\n letterSpacing: theme.letterSpacing[HEADING_STEP[level]],\n fontWeight: theme.fontWeight.semibold,\n color: theme.colors[HEADING_INK[level]],\n }),\n firstHeading: { marginTop: 0 },\n strong: { fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n em: { fontStyle: 'italic' },\n code: {\n backgroundColor: theme.colors.deep,\n color: theme.colors.green,\n fontFamily: fontOf(theme.fontFamily.mono),\n },\n fileLink: { textDecorationLine: 'underline' },\n link: { color: theme.colors.blue, textDecorationLine: 'underline' },\n list: { gap: theme.spacing(0.5) },\n item: { flexDirection: 'row', gap: theme.spacing(2), paddingLeft: theme.spacing(1) },\n marker: { minWidth: theme.spacing(3), color: theme.colors.dim },\n itemText: { flexShrink: 1 },\n rule: { height: 1, backgroundColor: theme.colors['border-soft'] },\n // The web blockquote: a rule at the left and quieter text.\n quote: { borderLeftWidth: 2, borderLeftColor: theme.colors.border, paddingLeft: theme.spacing(3) },\n quoted: { color: theme.colors.dim },\n // The web table: bordered cells, the header on the deep surface.\n table: {\n flexDirection: 'row',\n borderTopWidth: 1,\n borderLeftWidth: 1,\n borderColor: theme.colors.border,\n },\n cell: {\n paddingHorizontal: theme.spacing(2),\n paddingVertical: theme.spacing(1),\n borderRightWidth: 1,\n borderBottomWidth: 1,\n borderColor: theme.colors.border,\n },\n headCell: { backgroundColor: theme.colors.deep, fontWeight: theme.fontWeight.semibold, color: theme.colors.hi },\n // The web image's frame: at most 480 tall, a soft border and rounded corners.\n image: {\n width: '100%',\n maxHeight: 480,\n borderRadius: theme.borderRadius.md,\n borderWidth: 1,\n borderColor: theme.colors.border,\n },\n imageState: { color: theme.colors.dim },\n}));\n"],"mappings":";;;;;;;;;;;;;;;;;AA0BA,MAAMuB,qBAAqBvB,cAAc,CAAC;AAE1C,MAAMwB,kBAAkBxB,cAA2CyB,MAAS;AAK5E,MAAMM,eAAe/B,cAA+CyB,MAAS;AAE7E,MAAMO,gBAAgB;;AAEtB,MAAMC,eAAe;;AAErB,MAAMC,oBAAoB,KAAK;AAE/B,SAASC,QAAQC,MAAkC;CACjD,IAAI;EACF,OAAOC,mBAAmBD,IAAI;CAChC,QAAQ;EACN;CACF;AACF;AAEA,SAASE,WAAW,EAAEjB,MAAMkB,eAAelB,QAAiD;CAC1F,MAAMmB,aAAarC,WAAWqB,eAAe;CAC7C,MAAMiB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AAE5E,QAAQ;EAAG6G,iBAAiBtB,MAAME,OAAO;EAAcO,mBAAA,CAAA,CAAA;CAAC;CAEhEnB,OAAO;EAAEwC,iBAAiB;EAAGC,iBAAiB/B,MAAME,OAAO8B;EAAQJ,aAAa5B,MAAMc,QAAQ,CAAC;EAACL,mBAAA,CAAA,CAAA;CAAC;CACjGpD,QAAQ;EAAE4C,OAAOD,MAAME,OAAOC;EAAGM,mBAAA,CAAA,CAAA;CAAC;CAElC5D,OAAO;EACL6D,eAAe;EACfuB,gBAAgB;EAChBH,iBAAiB;EACjBI,aAAalC,MAAME,OAAO8B;EAAMvB,mBAAA,CAAA,CAAA;CAClC;CACAlE,MAAM;EACJ4F,mBAAmBnC,MAAMc,QAAQ,CAAC;EAClCsB,iBAAiBpC,MAAMc,QAAQ,CAAC;EAChCuB,kBAAkB;EAClBC,mBAAmB;EACnBJ,aAAalC,MAAME,OAAO8B;EAAMvB,mBAAA,CAAA,CAAA;CAClC;CACA1D,UAAU;EAAEuE,iBAAiBtB,MAAME,OAAOqB;EAAML,YAAYlB,MAAMkB,WAAWC;EAAUlB,OAAOD,MAAME,OAAOkB;EAAEX,mBAAA,CAAA,CAAA;CAAC;CAE9G3F,OAAO;EACLN,OAAO;EACP+H,WAAW;EACXC,cAAcxC,MAAMwC,aAAaC;EACjCC,aAAa;EACbR,aAAalC,MAAME,OAAO8B;EAAMvB,mBAAA,CAAA,CAAA;CAClC;CACApG,YAAY;EAAE4F,OAAOD,MAAME,OAAOC;EAAGM,mBAAA,CAAA,CAAA;CAAC;AACxC,EAAE"}
|
|
@@ -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"}
|
|
@@ -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'],\n lineHeight: theme.lineHeight['2xs'],\n },\n}));\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAMkB,eAAelB,cAA0B;CAAEgB,MAAM;CAAOC,eAAeE;AAAU,CAAC;AAUxF,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;EAAIM;CAAgC;AACpG;;AAGA,SAAgBG,aAAa,EAAEC,SAAS,GAAGC,SAAsB;CAC/D,MAAM,EAAEX,YAAYf,WAAWgB,YAAY;C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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;EAAIM;CAAgC;AACpG;;AAGA,SAAgBG,aAAa,EAAEC,SAAS,GAAGC,SAAsB;CAC/D,MAAM,EAAEX,YAAYf,WAAWgB,YAAY;CAC3C,OACE,oBAAC,QAAD;EACE,UAAUW,UAAU;GAClBF,UAAUE,KAAK;GACfZ,QAAQ,IAAI;EACd;EACA,GAAIW;CAAM;AAGhB;;AAGA,SAAgBE,WAAW,EAAEH,SAAS,GAAGC,SAAsB;CAC7D,MAAM,EAAEX,YAAYf,WAAWgB,YAAY;CAC3C,OACE,oBAAC,QAAD;EACE,UAAUW,UAAU;GAClBF,UAAUE,KAAK;GACfZ,QAAQ,KAAK;EACf;EACA,GAAIW;CAAM;AAGhB;;AASA,SAAgBK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Q,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"}
|
|
@@ -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;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";
|
|
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
|