@agimon-ai/po-native-components 0.0.0-alpha.7 → 0.0.0-alpha.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +149 -22
- package/dist/components/AgentAvatar.d.mts +14 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +87 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/AnnotationSurface.d.mts +69 -0
- package/dist/components/AnnotationSurface.d.mts.map +1 -0
- package/dist/components/AnnotationSurface.mjs +426 -0
- package/dist/components/AnnotationSurface.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +1 -1
- package/dist/components/Button.mjs +2 -2
- package/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +35 -47
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +43 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/Dialog.mjs +3 -3
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +2 -2
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +12 -6
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +148 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/HostFilter.d.mts +17 -0
- package/dist/components/HostFilter.d.mts.map +1 -0
- package/dist/components/HostFilter.mjs +66 -0
- package/dist/components/HostFilter.mjs.map +1 -0
- package/dist/components/HostTag.d.mts +7 -0
- package/dist/components/HostTag.d.mts.map +1 -0
- package/dist/components/HostTag.mjs +47 -0
- package/dist/components/HostTag.mjs.map +1 -0
- package/dist/components/InfoStrip.d.mts +9 -0
- package/dist/components/InfoStrip.d.mts.map +1 -0
- package/dist/components/InfoStrip.mjs +53 -0
- package/dist/components/InfoStrip.mjs.map +1 -0
- package/dist/components/Input.mjs +3 -2
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +38 -6
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/LiveDuration.d.mts +30 -0
- package/dist/components/LiveDuration.d.mts.map +1 -0
- package/dist/components/LiveDuration.mjs +67 -0
- package/dist/components/LiveDuration.mjs.map +1 -0
- package/dist/components/Markdown.d.mts +10 -1
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +330 -27
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +8 -8
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +71 -55
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/Sheet.d.mts +7 -1
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +19 -4
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.d.mts +13 -0
- package/dist/components/SheetFrame.d.mts.map +1 -0
- package/dist/components/SheetFrame.mjs +113 -16
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/SheetList.d.mts +14 -0
- package/dist/components/SheetList.d.mts.map +1 -0
- package/dist/components/SheetList.mjs +34 -0
- package/dist/components/SheetList.mjs.map +1 -0
- package/dist/components/ShowMore.d.mts +10 -0
- package/dist/components/ShowMore.d.mts.map +1 -0
- package/dist/components/ShowMore.mjs +44 -0
- package/dist/components/ShowMore.mjs.map +1 -0
- package/dist/components/Spinner.d.mts +1 -1
- package/dist/components/StatusBadge.d.mts +1 -1
- package/dist/components/SyntaxLine.d.mts +19 -0
- package/dist/components/SyntaxLine.d.mts.map +1 -0
- package/dist/components/SyntaxLine.mjs +134 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.mjs +2 -2
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +40 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/icons/iconGlyphs.d.mts +56 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +56 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +57 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +15 -1
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +17 -4
- package/dist/index.mjs +18 -5
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/markdown.mjs +172 -23
- package/dist/lib/markdown.mjs.map +1 -1
- package/dist/lib/reading.mjs +60 -0
- package/dist/lib/reading.mjs.map +1 -0
- package/dist/lib/useReadingPage.mjs +33 -0
- package/dist/lib/useReadingPage.mjs.map +1 -0
- package/package.json +18 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HostTag.mjs","names":["StyleSheet","fontOf","agentInitials","Badge","HostTag","label","styles","tag","initials","create","theme","maxWidth","flexShrink","fontFamily","sans","fontSize","xs","color","colors","dim","uni__dependencies","sm","lineHeight"],"sources":["../../src/components/HostTag.tsx"],"sourcesContent":["import { Text } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { agentInitials } from './AgentAvatar';\nimport { Badge } from './Badge';\n\n/** A computer's display label, never an authority or connection indicator. */\nexport function HostTag({ label }: { label: string }) {\n return (\n <Badge accessibilityLabel={`Computer: ${label}`} style={styles.tag}>\n <Text style={styles.initials}>{agentInitials(label)}</Text>\n <Text style={styles.label} numberOfLines={1}>\n {label}\n </Text>\n </Badge>\n );\n}\nconst styles = StyleSheet.create((theme) => ({\n tag: { maxWidth: '100%', flexShrink: 1 },\n initials: { fontFamily: fontOf(theme.fontFamily.sans), fontSize: theme.fontSize.xs, color: theme.colors.dim },\n label: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n flexShrink: 1,\n },\n}));\n"],"mappings":";;;;;;;;;AAQA,SAAgBI,QAAQ,EAAEC,SAA4B;CACpD,OACE,qBAAC,OAAD;EAAO,oBAAoB,aAAaA;EAAS,OAAOC,OAAOC;YAA/D,CACE,oBAAC,MAAD;GAAM,OAAOD,OAAOE;aAAWN,cAAcG,KAAK;EAAQ,IAC1D,oBAAC,MAAD;GAAM,OAAOC,OAAOD;GAAO,eAAe;aACvCA;EACG,EACD;;AAEX;AACA,MAAMC,SAASN,WAAWS,QAAQC,WAAW;CAC3CH,KAAK;EAAEI,UAAU;EAAQC,YAAY;CAAE;CACvCJ,UAAU;EAAEK,YAAYZ,OAAOS,MAAMG,WAAWC,IAAI;EAAGC,UAAUL,MAAMK,SAASC;EAAIC,OAAOP,MAAMQ,OAAOC;EAAGC,mBAAA,CAAA,CAAA;CAAC;CAC5Gf,OAAO;EACLQ,YAAYZ,OAAOS,MAAMG,WAAWC,IAAI;EACxCC,UAAUL,MAAMK,SAASM;EACzBC,YAAYZ,MAAMY,WAAWD;EAC7BJ,OAAOP,MAAMQ,OAAOC;EACpBP,YAAY;EAACQ,mBAAA,CAAA,CAAA;CACf;AACF,EAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/components/InfoStrip.d.ts
|
|
2
|
+
/** A quiet explanation with an optional text action, without live activity. */
|
|
3
|
+
export declare function InfoStrip({ message, actionLabel, onAction }: {
|
|
4
|
+
message: string;
|
|
5
|
+
actionLabel?: string;
|
|
6
|
+
onAction?: () => void;
|
|
7
|
+
}): import("react").JSX.Element;
|
|
8
|
+
//#endregion
|
|
9
|
+
//# sourceMappingURL=InfoStrip.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoStrip.d.mts","names":[],"sources":["../../src/components/InfoStrip.tsx"],"mappings":";;wBASgB,YACd,SACA,aACA;EAEA;EACA;EACA;oBACD,IAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { Button } from "./Button.mjs";
|
|
3
|
+
import { AlertIcon } from "../icons/icons.mjs";
|
|
4
|
+
import { Panel } from "./Panel.mjs";
|
|
5
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
6
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/components/InfoStrip.tsx
|
|
10
|
+
/** A quiet explanation with an optional text action, without live activity. */
|
|
11
|
+
function InfoStrip({ message, actionLabel, onAction }) {
|
|
12
|
+
return /* @__PURE__ */ jsxs(Panel, {
|
|
13
|
+
style: styles.strip,
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsx(AlertIcon, {
|
|
16
|
+
size: 16,
|
|
17
|
+
color: "dim"
|
|
18
|
+
}),
|
|
19
|
+
/* @__PURE__ */ jsx(Text, {
|
|
20
|
+
style: styles.text,
|
|
21
|
+
children: message
|
|
22
|
+
}),
|
|
23
|
+
onAction && actionLabel ? /* @__PURE__ */ jsx(Button, {
|
|
24
|
+
variant: "ghost",
|
|
25
|
+
style: styles.action,
|
|
26
|
+
onPress: onAction,
|
|
27
|
+
children: actionLabel
|
|
28
|
+
}) : null
|
|
29
|
+
]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const styles = StyleSheet.create((theme) => ({
|
|
33
|
+
strip: {
|
|
34
|
+
flexDirection: "row",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
gap: theme.spacing(2),
|
|
37
|
+
padding: theme.spacing(3),
|
|
38
|
+
uni__dependencies: [0]
|
|
39
|
+
},
|
|
40
|
+
text: {
|
|
41
|
+
flex: 1,
|
|
42
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
43
|
+
fontSize: theme.fontSize.sm,
|
|
44
|
+
lineHeight: theme.lineHeight.sm,
|
|
45
|
+
color: theme.colors.dim,
|
|
46
|
+
uni__dependencies: [0]
|
|
47
|
+
},
|
|
48
|
+
action: { minHeight: 44 }
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { InfoStrip };
|
|
53
|
+
//# sourceMappingURL=InfoStrip.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoStrip.mjs","names":["StyleSheet","AlertIcon","fontOf","Button","Panel","InfoStrip","message","actionLabel","onAction","styles","strip","text","action","create","theme","flexDirection","alignItems","gap","spacing","padding","uni__dependencies","flex","fontFamily","sans","fontSize","sm","lineHeight","color","colors","dim","minHeight"],"sources":["../../src/components/InfoStrip.tsx"],"sourcesContent":["import { Text } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { AlertIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\nimport { Panel } from './Panel';\n\n/** A quiet explanation with an optional text action, without live activity. */\nexport function InfoStrip({\n message,\n actionLabel,\n onAction,\n}: {\n message: string;\n actionLabel?: string;\n onAction?: () => void;\n}) {\n return (\n <Panel style={styles.strip}>\n <AlertIcon size={16} color=\"dim\" />\n <Text style={styles.text}>{message}</Text>\n {onAction && actionLabel ? (\n <Button variant=\"ghost\" style={styles.action} onPress={onAction}>\n {actionLabel}\n </Button>\n ) : null}\n </Panel>\n );\n}\nconst styles = StyleSheet.create((theme) => ({\n strip: { flexDirection: 'row', alignItems: 'center', gap: theme.spacing(2), padding: theme.spacing(3) },\n text: {\n flex: 1,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.dim,\n },\n action: { minHeight: 44 },\n}));\n"],"mappings":";;;;;;;;;;AASA,SAAgBK,UAAU,EACxBC,SACAC,aACAC,YAKC;CACD,OACE,qBAAC,OAAD;EAAO,OAAOC,OAAOC;YAArB;GACE,oBAAC,WAAD;IAAW,MAAM;IAAI,OAAM;GAAK;GAChC,oBAAC,MAAD;IAAM,OAAOD,OAAOE;cAAOL;GAAc;GACxCE,YAAYD,cACX,oBAAC,QAAD;IAAQ,SAAQ;IAAQ,OAAOE,OAAOG;IAAQ,SAASJ;cACpDD;GACK,KACN;EACC;;AAEX;AACA,MAAME,SAAST,WAAWa,QAAQC,WAAW;CAC3CJ,OAAO;EAAEK,eAAe;EAAOC,YAAY;EAAUC,KAAKH,MAAMI,QAAQ,CAAC;EAAGC,SAASL,MAAMI,QAAQ,CAAC;EAACE,mBAAA,CAAA,CAAA;CAAC;CACtGT,MAAM;EACJU,MAAM;EACNC,YAAYpB,OAAOY,MAAMQ,WAAWC,IAAI;EACxCC,UAAUV,MAAMU,SAASC;EACzBC,YAAYZ,MAAMY,WAAWD;EAC7BE,OAAOb,MAAMc,OAAOC;EAAGT,mBAAA,CAAA,CAAA;CACzB;CACAR,QAAQ,EAAEkB,WAAW,GAAG;AAC1B,EAAE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
2
|
import { useInsideSheet } from "../lib/insideSheet.mjs";
|
|
3
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
4
3
|
import { StyleSheet, useUnistyles, withUnistyles } from "react-native-unistyles";
|
|
4
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
5
5
|
import { useState } from "react";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import { BottomSheetTextInput } from "@gorhom/bottom-sheet";
|
|
@@ -17,7 +17,7 @@ const ThemedSheetTextInput = withUnistyles(BottomSheetTextInput);
|
|
|
17
17
|
* red edge when invalid. Inside a Sheet it becomes the sheet's own input.
|
|
18
18
|
*/
|
|
19
19
|
function Input({ variant = "default", size = "md", invalid = false, disabled = false, style, onFocus, onBlur, accessibilityState, ...props }) {
|
|
20
|
-
const { theme } = useUnistyles();
|
|
20
|
+
const { theme, rt } = useUnistyles();
|
|
21
21
|
const [focused, setFocused] = useState(false);
|
|
22
22
|
const Field = useInsideSheet() ? ThemedSheetTextInput : TextInput;
|
|
23
23
|
const _styles = styles;
|
|
@@ -28,6 +28,7 @@ function Input({ variant = "default", size = "md", invalid = false, disabled = f
|
|
|
28
28
|
});
|
|
29
29
|
return /* @__PURE__ */ jsx(Field, {
|
|
30
30
|
autoCorrect: false,
|
|
31
|
+
keyboardAppearance: rt.themeName === "dark" ? "dark" : "light",
|
|
31
32
|
spellCheck: false,
|
|
32
33
|
placeholderTextColor: theme.colors.faint,
|
|
33
34
|
selectionColor: theme.colors.green,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.mjs","names":["withAlpha","BottomSheetTextInput","useState","TextInputProps","StyleSheet","useUnistyles","withUnistyles","fontOf","useInsideSheet","FieldVariant","FieldSize","FOCUS_EDGE_ALPHA_PERCENT","DISABLED_OPACITY","ThemedSheetTextInput","InputProps","Omit","variant","size","invalid","disabled","Input","style","onFocus","onBlur","accessibilityState","props","theme","focused","setFocused","Field","TextInput","_styles","styles","useVariants","undefined","colors","faint","green","event","field","borderColor","create","minWidth","minHeight","color","hi","fontFamily","sans","variants","default","borderRadius","DEFAULT","borderWidth","border","backgroundColor","deep","bare","padding","xs","paddingHorizontal","spacing","paddingVertical","fontSize","sm","md","base","lg","compoundVariants","uni__dependencies","red","opacity"],"sources":["../../src/components/Input.tsx"],"sourcesContent":["import { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport { BottomSheetTextInput } from '@gorhom/bottom-sheet';\nimport { useState } from 'react';\nimport { TextInput, type TextInputProps } from 'react-native';\nimport { StyleSheet, useUnistyles, withUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { useInsideSheet } from '../lib/insideSheet';\n\nexport type FieldVariant = 'default' | 'bare';\nexport type FieldSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `focus:border-po-green/60`. */\nconst FOCUS_EDGE_ALPHA_PERCENT = 60;\nconst DISABLED_OPACITY = 0.5;\n\nconst ThemedSheetTextInput = withUnistyles(BottomSheetTextInput);\nexport interface InputProps extends Omit<TextInputProps, 'editable'> {\n variant?: FieldVariant;\n /** The same rungs Button names, so a field and the button beside it line up. */\n size?: FieldSize;\n /** The value is wrong: red edge and red text, as `aria-invalid` on the web. */\n invalid?: boolean;\n disabled?: boolean;\n}\n\n/**\n * The one text field: deep well, quiet border, jade edge and cursor on focus,\n * red edge when invalid. Inside a Sheet it becomes the sheet's own input.\n */\nexport function Input({\n variant = 'default',\n size = 'md',\n invalid = false,\n disabled = false,\n style,\n onFocus,\n onBlur,\n accessibilityState,\n ...props\n}: InputProps) {\n const { theme } = useUnistyles();\n const [focused, setFocused] = useState(false);\n // Inside a Sheet the field must be the sheet's own input, so the sheet rises with the keyboard.\n const Field = useInsideSheet() ? ThemedSheetTextInput : TextInput;\n // Unistyles reserves a variant named `default` as the fallback for an unset variant.\n styles.useVariants({ variant: variant === 'bare' ? 'bare' : undefined, size });\n return (\n <Field\n autoCorrect={false}\n spellCheck={false}\n placeholderTextColor={theme.colors.faint}\n selectionColor={theme.colors.green}\n cursorColor={theme.colors.green}\n editable={!disabled}\n accessibilityState={{ ...accessibilityState, disabled }}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onBlur={(event) => {\n setFocused(false);\n onBlur?.(event);\n }}\n style={[\n styles.field,\n // Alpha mixes are computed in render from useUnistyles(), not in StyleSheet.create: on web Unistyles hands\n // the stylesheet CSS variables, which withAlpha cannot read.\n focused && variant === 'default' && { borderColor: withAlpha(theme.colors.green, FOCUS_EDGE_ALPHA_PERCENT) },\n invalid && styles.invalid,\n disabled && styles.disabled,\n style,\n ]}\n {...props}\n />\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n field: {\n minWidth: 0,\n minHeight: 44,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n variants: {\n variant: {\n default: {\n borderRadius: theme.borderRadius.DEFAULT,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: theme.colors.deep,\n },\n /** No well: a composer or a search that draws its own surface keeps the type and drops the box. */\n bare: { borderWidth: 0, backgroundColor: 'transparent', padding: 0 },\n },\n size: {\n xs: {\n paddingHorizontal: theme.spacing(1.5),\n paddingVertical: theme.spacing(0.5),\n fontSize: theme.fontSize.sm,\n },\n sm: {\n paddingHorizontal: theme.spacing(2),\n paddingVertical: theme.spacing(1),\n fontSize: theme.fontSize.sm,\n },\n md: {\n paddingHorizontal: theme.spacing(2.5),\n paddingVertical: theme.spacing(1.5),\n fontSize: theme.fontSize.base,\n },\n lg: {\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n fontSize: theme.fontSize.base,\n },\n },\n },\n compoundVariants: [{ variant: 'bare', styles: { padding: 0, paddingHorizontal: 0, paddingVertical: 0 } }],\n },\n invalid: { borderColor: theme.colors['edge-red'], color: theme.colors.red },\n disabled: { opacity: DISABLED_OPACITY },\n}));\n"],"mappings":";;;;;;;;;;;AAaA,MAAMW,2BAA2B;AACjC,MAAMC,mBAAmB;AAEzB,MAAMC,uBAAuBP,cAAcL,oBAAoB;;;;;AAc/D,SAAgBmB,MAAM,EACpBJ,UAAU,WACVC,OAAO,MACPC,UAAU,OACVC,WAAW,OACXE,OACAC,SACAC,QACAC,oBACA,GAAGC,SACU;CACb,MAAM,EAAEC,
|
|
1
|
+
{"version":3,"file":"Input.mjs","names":["withAlpha","BottomSheetTextInput","useState","TextInputProps","StyleSheet","useUnistyles","withUnistyles","fontOf","useInsideSheet","FieldVariant","FieldSize","FOCUS_EDGE_ALPHA_PERCENT","DISABLED_OPACITY","ThemedSheetTextInput","InputProps","Omit","variant","size","invalid","disabled","Input","style","onFocus","onBlur","accessibilityState","props","theme","rt","focused","setFocused","Field","TextInput","_styles","styles","useVariants","undefined","themeName","colors","faint","green","event","field","borderColor","create","minWidth","minHeight","color","hi","fontFamily","sans","variants","default","borderRadius","DEFAULT","borderWidth","border","backgroundColor","deep","bare","padding","xs","paddingHorizontal","spacing","paddingVertical","fontSize","sm","md","base","lg","compoundVariants","uni__dependencies","red","opacity"],"sources":["../../src/components/Input.tsx"],"sourcesContent":["import { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport { BottomSheetTextInput } from '@gorhom/bottom-sheet';\nimport { useState } from 'react';\nimport { TextInput, type TextInputProps } from 'react-native';\nimport { StyleSheet, useUnistyles, withUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { useInsideSheet } from '../lib/insideSheet';\n\nexport type FieldVariant = 'default' | 'bare';\nexport type FieldSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `focus:border-po-green/60`. */\nconst FOCUS_EDGE_ALPHA_PERCENT = 60;\nconst DISABLED_OPACITY = 0.5;\n\nconst ThemedSheetTextInput = withUnistyles(BottomSheetTextInput);\nexport interface InputProps extends Omit<TextInputProps, 'editable'> {\n variant?: FieldVariant;\n /** The same rungs Button names, so a field and the button beside it line up. */\n size?: FieldSize;\n /** The value is wrong: red edge and red text, as `aria-invalid` on the web. */\n invalid?: boolean;\n disabled?: boolean;\n}\n\n/**\n * The one text field: deep well, quiet border, jade edge and cursor on focus,\n * red edge when invalid. Inside a Sheet it becomes the sheet's own input.\n */\nexport function Input({\n variant = 'default',\n size = 'md',\n invalid = false,\n disabled = false,\n style,\n onFocus,\n onBlur,\n accessibilityState,\n ...props\n}: InputProps) {\n const { theme, rt } = useUnistyles();\n const [focused, setFocused] = useState(false);\n // Inside a Sheet the field must be the sheet's own input, so the sheet rises with the keyboard.\n const Field = useInsideSheet() ? ThemedSheetTextInput : TextInput;\n // Unistyles reserves a variant named `default` as the fallback for an unset variant.\n styles.useVariants({ variant: variant === 'bare' ? 'bare' : undefined, size });\n return (\n <Field\n autoCorrect={false}\n // iOS draws the keyboard light by default, a bright slab under a dark screen.\n keyboardAppearance={rt.themeName === 'dark' ? 'dark' : 'light'}\n spellCheck={false}\n placeholderTextColor={theme.colors.faint}\n selectionColor={theme.colors.green}\n cursorColor={theme.colors.green}\n editable={!disabled}\n accessibilityState={{ ...accessibilityState, disabled }}\n onFocus={(event) => {\n setFocused(true);\n onFocus?.(event);\n }}\n onBlur={(event) => {\n setFocused(false);\n onBlur?.(event);\n }}\n style={[\n styles.field,\n // Alpha mixes are computed in render from useUnistyles(), not in StyleSheet.create: on web Unistyles hands\n // the stylesheet CSS variables, which withAlpha cannot read.\n focused && variant === 'default' && { borderColor: withAlpha(theme.colors.green, FOCUS_EDGE_ALPHA_PERCENT) },\n invalid && styles.invalid,\n disabled && styles.disabled,\n style,\n ]}\n {...props}\n />\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n field: {\n minWidth: 0,\n minHeight: 44,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n variants: {\n variant: {\n default: {\n borderRadius: theme.borderRadius.DEFAULT,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: theme.colors.deep,\n },\n /** No well: a composer or a search that draws its own surface keeps the type and drops the box. */\n bare: { borderWidth: 0, backgroundColor: 'transparent', padding: 0 },\n },\n size: {\n xs: {\n paddingHorizontal: theme.spacing(1.5),\n paddingVertical: theme.spacing(0.5),\n fontSize: theme.fontSize.sm,\n },\n sm: {\n paddingHorizontal: theme.spacing(2),\n paddingVertical: theme.spacing(1),\n fontSize: theme.fontSize.sm,\n },\n md: {\n paddingHorizontal: theme.spacing(2.5),\n paddingVertical: theme.spacing(1.5),\n fontSize: theme.fontSize.base,\n },\n lg: {\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n fontSize: theme.fontSize.base,\n },\n },\n },\n compoundVariants: [{ variant: 'bare', styles: { padding: 0, paddingHorizontal: 0, paddingVertical: 0 } }],\n },\n invalid: { borderColor: theme.colors['edge-red'], color: theme.colors.red },\n disabled: { opacity: DISABLED_OPACITY },\n}));\n"],"mappings":";;;;;;;;;;;AAaA,MAAMW,2BAA2B;AACjC,MAAMC,mBAAmB;AAEzB,MAAMC,uBAAuBP,cAAcL,oBAAoB;;;;;AAc/D,SAAgBmB,MAAM,EACpBJ,UAAU,WACVC,OAAO,MACPC,UAAU,OACVC,WAAW,OACXE,OACAC,SACAC,QACAC,oBACA,GAAGC,SACU;CACb,MAAM,EAAEC,OAAOC,OAAOtB,aAAa;CACnC,MAAM,CAACuB,SAASC,cAAc3B,SAAS,KAAK;CAE5C,MAAM4B,QAAQtB,eAAe,IAAIK,uBAAuBkB;CACxD,MAAAC,UAAAC;CAAA;EAAA,MAAAA,SAAAD,QAAAE,YACmB;GAAElB,SAASA,YAAY,SAAS,SAASmB;GAAWlB;EAAK,CAAC;EAC7E,OACE,oBAAC,OAAD;GACE,aAAa;GAEb,oBAAoBU,GAAGS,cAAc,SAAS,SAAS;GACvD,YAAY;GACZ,sBAAsBV,MAAMW,OAAOC;GACnC,gBAAgBZ,MAAMW,OAAOE;GAC7B,aAAab,MAAMW,OAAOE;GAC1B,UAAU,CAACpB;GACX,oBAAoB;IAAE,GAAGK;IAAoBL;GAAS;GACtD,UAAUqB,UAAU;IAClBX,WAAW,IAAI;IACfP,UAAUkB,KAAK;GACjB;GACA,SAASA,UAAU;IACjBX,WAAW,KAAK;IAChBN,SAASiB,KAAK;GAChB;GACA,OAAO;IACLP,OAAOQ;IAGPb,WAAWZ,YAAY,aAAa,EAAE0B,aAAa1C,UAAU0B,MAAMW,OAAOE,OAAO5B,wBAAwB,EAAE;IAC3GO,WAA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AA,CAAA,CAAA;CAAC;CAC1EnD,UAAU,EAAEqD,SAAS5D,iBAAiB;AACxC,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/Label.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.d.mts","names":[],"sources":["../../src/components/List.tsx"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"List.d.mts","names":[],"sources":["../../src/components/List.tsx"],"mappings":";;;iBA+BiB,UAAU;EACzB,eAAe;EACf,aAAa,MAAM,GAAG,kBAAkB;;EAExC,eAAe,MAAM,GAAG;;;;;EAKxB;;EAEA;;EAEA,QAAQ;EACR,SAAS;EACT,SAAS;EACT;EACA;;EAEA,QAAQ,UAAU;;EAElB;;wBAOc,KAAK,KACnB,MACA,YACA,cACA,eACA,YACA,OACA,QACA,QACA,cACA,oBACA,OACA,kBACC,UAAU,qBAAE,IAAA;iBAkDE;EACf,OAAO;;EAEP,cAAc;;EAEd,UAAU;;EAEV,WAAW;;EAEX;EACA;EACA;;EAEA;EACA;EACA,QAAQ,UAAU;;;wBAIJ,UACd,OACA,aACA,SACA,UACA,UACA,UACA,SACA,YACA,oBACA,SACC,+BAAY,IAAA"}
|
package/dist/components/List.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { Button } from "./Button.mjs";
|
|
3
|
+
import { ChevronDownIcon, ChevronRightIcon } from "../icons/icons.mjs";
|
|
3
4
|
import { View } from "react-native-unistyles/components/native/View";
|
|
5
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
4
6
|
import { StyleSheet } from "react-native-unistyles";
|
|
5
7
|
import { Platform } from "react-native";
|
|
6
|
-
import {
|
|
8
|
+
import { useCallback, useRef, useState } from "react";
|
|
7
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
9
11
|
import { FlashList } from "@shopify/flash-list";
|
|
@@ -13,29 +15,51 @@ const MIN_ROW_HEIGHT = 44;
|
|
|
13
15
|
const DISABLED_OPACITY = .4;
|
|
14
16
|
/** How close to the bottom a reader must be for a new row to keep the list pinned, as a fraction of the visible height. */
|
|
15
17
|
const PIN_THRESHOLD = .1;
|
|
18
|
+
/** How far above the bottom, in visible heights, a chat reader must scroll before the jump-to-latest button shows. */
|
|
19
|
+
const JUMP_THRESHOLD = 1;
|
|
16
20
|
function Separator() {
|
|
17
21
|
return /* @__PURE__ */ jsx(View, { style: styles.separator });
|
|
18
22
|
}
|
|
19
23
|
function List({ data, renderItem, keyExtractor, startAtBottom = false, separators = true, empty, header, footer, onEndReached, accessibilityLabel, style, contentPadding }) {
|
|
20
|
-
|
|
24
|
+
const renderRow = useCallback(({ item, index }) => renderItem(item, index), [renderItem]);
|
|
25
|
+
const listRef = useRef(null);
|
|
26
|
+
const [awayFromBottom, setAwayFromBottom] = useState(false);
|
|
27
|
+
const onScroll = useCallback(({ nativeEvent }) => {
|
|
28
|
+
const { contentOffset, contentSize, layoutMeasurement } = nativeEvent;
|
|
29
|
+
const distance = contentSize.height - layoutMeasurement.height - contentOffset.y;
|
|
30
|
+
setAwayFromBottom(distance > layoutMeasurement.height * JUMP_THRESHOLD);
|
|
31
|
+
}, []);
|
|
32
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
21
33
|
style: [styles.frame, style],
|
|
22
34
|
accessibilityLabel,
|
|
23
|
-
children: /* @__PURE__ */ jsx(FlashList, {
|
|
35
|
+
children: [/* @__PURE__ */ jsx(FlashList, {
|
|
36
|
+
ref: listRef,
|
|
37
|
+
onScroll: startAtBottom ? onScroll : void 0,
|
|
38
|
+
scrollEventThrottle: startAtBottom ? 100 : void 0,
|
|
24
39
|
data,
|
|
25
|
-
renderItem:
|
|
40
|
+
renderItem: renderRow,
|
|
26
41
|
keyExtractor,
|
|
27
42
|
ItemSeparatorComponent: separators ? Separator : null,
|
|
28
43
|
ListEmptyComponent: empty === void 0 ? null : /* @__PURE__ */ jsx(Fragment, { children: empty }),
|
|
29
44
|
ListHeaderComponent: header === void 0 ? null : /* @__PURE__ */ jsx(Fragment, { children: header }),
|
|
30
45
|
ListFooterComponent: footer === void 0 ? null : /* @__PURE__ */ jsx(Fragment, { children: footer }),
|
|
31
46
|
onEndReached,
|
|
47
|
+
keyboardDismissMode: Platform.OS === "ios" ? "interactive" : "on-drag",
|
|
48
|
+
keyboardShouldPersistTaps: startAtBottom ? "never" : "handled",
|
|
32
49
|
contentInsetAdjustmentBehavior: "automatic",
|
|
33
50
|
contentContainerStyle: contentPadding === void 0 ? void 0 : { padding: contentPadding },
|
|
34
51
|
maintainVisibleContentPosition: startAtBottom ? {
|
|
35
52
|
startRenderingFromBottom: true,
|
|
36
53
|
autoscrollToBottomThreshold: PIN_THRESHOLD
|
|
37
54
|
} : void 0
|
|
38
|
-
})
|
|
55
|
+
}), startAtBottom && awayFromBottom ? /* @__PURE__ */ jsx(Button, {
|
|
56
|
+
variant: "subtle",
|
|
57
|
+
size: "icon-md",
|
|
58
|
+
accessibilityLabel: "Jump to latest",
|
|
59
|
+
onPress: () => listRef.current?.scrollToEnd({ animated: true }),
|
|
60
|
+
style: styles.jump,
|
|
61
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 18 })
|
|
62
|
+
}) : null]
|
|
39
63
|
});
|
|
40
64
|
}
|
|
41
65
|
/** One list row: 44pt tall, optional leading and trailing slots, pressable when it navigates. */
|
|
@@ -99,6 +123,14 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
99
123
|
flex: 1,
|
|
100
124
|
minHeight: 0
|
|
101
125
|
},
|
|
126
|
+
jump: {
|
|
127
|
+
position: "absolute",
|
|
128
|
+
bottom: theme.spacing(3),
|
|
129
|
+
alignSelf: "center",
|
|
130
|
+
borderRadius: theme.borderRadius.full,
|
|
131
|
+
borderColor: theme.colors.border,
|
|
132
|
+
uni__dependencies: [0]
|
|
133
|
+
},
|
|
102
134
|
separator: {
|
|
103
135
|
height: StyleSheet.hairlineWidth,
|
|
104
136
|
marginLeft: theme.spacing(4),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.mjs","names":["FlashList","ReactElement","ReactNode","Platform","StyleProp","ViewStyle","StyleSheet","ChevronRightIcon","fontOf","MIN_ROW_HEIGHT","DISABLED_OPACITY","PIN_THRESHOLD","ListProps","data","T","renderItem","item","index","keyExtractor","startAtBottom","separators","empty","header","footer","onEndReached","accessibilityLabel","style","contentPadding","Separator","styles","separator","List","frame","undefined","padding","startRenderingFromBottom","autoscrollToBottomThreshold","ListRowProps","title","description","leading","trailing","selected","disabled","onPress","disclosure","ListRow","chevron","OS","content","text","titleSelected","row","pressed","create","theme","flex","minHeight","height","hairlineWidth","marginLeft","spacing","backgroundColor","colors","uni__dependencies","flexDirection","alignItems","gap","paddingHorizontal","paddingVertical","panel","opacity","minWidth","color","hi","fontFamily","sans","fontSize","base","lineHeight","fontWeight","medium","green","semibold","faint","sm"],"sources":["../../src/components/List.tsx"],"sourcesContent":["import { FlashList } from '@shopify/flash-list';\nimport type { ReactElement, ReactNode } from 'react';\nimport { Platform, Pressable, type StyleProp, Text, View, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { ChevronRightIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\n\n/*\n * A virtualised list on FlashList: sessions, devices, a transcript. Rows\n * recycle, separators are hairlines, and a chat list can start at the bottom\n * and stay pinned there as rows arrive. The public props are this package's\n * own, so FlashList's types never reach a caller.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst DISABLED_OPACITY = 0.4;\n/** How close to the bottom a reader must be for a new row to keep the list pinned, as a fraction of the visible height. */\nconst PIN_THRESHOLD = 0.1;\n\nexport interface ListProps<T> {\n data: readonly T[];\n renderItem: (item: T, index: number) => ReactElement | null;\n /** A stable key per row; FlashList recycles views by it. */\n keyExtractor: (item: T, index: number) => string;\n /**\n * A chat list: render from the bottom and keep the newest row in view as\n * rows arrive, while the reader is near the bottom.\n */\n startAtBottom?: boolean;\n /** Hairline separators between rows. On by default. */\n separators?: boolean;\n /** Shown when `data` is empty. */\n empty?: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n onEndReached?: () => void;\n accessibilityLabel?: string;\n /** The list's frame; give it a height or a flex parent, since a virtualised list needs bounds. */\n style?: StyleProp<ViewStyle>;\n /** Padding around the rows. */\n contentPadding?: number;\n}\n\nfunction Separator() {\n return <View style={styles.separator} />;\n}\n\nexport function List<T>({\n data,\n renderItem,\n keyExtractor,\n startAtBottom = false,\n separators = true,\n empty,\n header,\n footer,\n onEndReached,\n accessibilityLabel,\n style,\n contentPadding,\n}: ListProps<T>) {\n return (\n <View style={[styles.frame, style]} accessibilityLabel={accessibilityLabel}>\n <FlashList\n data={data}\n renderItem={({ item, index }) => renderItem(item, index)}\n keyExtractor={keyExtractor}\n ItemSeparatorComponent={separators ? Separator : null}\n ListEmptyComponent={empty === undefined ? null : <>{empty}</>}\n ListHeaderComponent={header === undefined ? null : <>{header}</>}\n ListFooterComponent={footer === undefined ? null : <>{footer}</>}\n onEndReached={onEndReached}\n // Lets UIKit inset the rows under a translucent or large-title header instead of drawing beneath it.\n contentInsetAdjustmentBehavior=\"automatic\"\n contentContainerStyle={contentPadding === undefined ? undefined : { padding: contentPadding }}\n maintainVisibleContentPosition={\n startAtBottom ? { startRenderingFromBottom: true, autoscrollToBottomThreshold: PIN_THRESHOLD } : undefined\n }\n />\n </View>\n );\n}\n\nexport interface ListRowProps {\n title: ReactNode;\n /** A second, quieter line under the title. */\n description?: ReactNode;\n /** Before the text: a Dot, an icon. */\n leading?: ReactNode;\n /** After the text: a Badge, a ghost button, a count. */\n trailing?: ReactNode;\n /** Selected rows sit on a green tint. */\n selected?: boolean;\n disabled?: boolean;\n onPress?: () => void;\n /** The iOS disclosure chevron. Defaults to on for a pressable row on iOS, where rows that navigate wear one. */\n disclosure?: boolean;\n accessibilityLabel?: string;\n style?: StyleProp<ViewStyle>;\n}\n\n/** One list row: 44pt tall, optional leading and trailing slots, pressable when it navigates. */\nexport function ListRow({\n title,\n description,\n leading,\n trailing,\n selected = false,\n disabled = false,\n onPress,\n disclosure,\n accessibilityLabel,\n style,\n}: ListRowProps) {\n const chevron = disclosure ?? (onPress !== undefined && Platform.OS === 'ios');\n const content = (\n <>\n {leading}\n <View style={styles.text}>\n {typeof title === 'string' ? (\n <Text numberOfLines={1} style={[styles.title, selected && styles.titleSelected]}>\n {title}\n </Text>\n ) : (\n title\n )}\n {typeof description === 'string' ? (\n <Text numberOfLines={2} style={styles.description}>\n {description}\n </Text>\n ) : (\n description\n )}\n </View>\n {trailing}\n {chevron ? <ChevronRightIcon size={14} color=\"faint\" /> : null}\n </>\n );\n if (onPress === undefined) {\n return (\n <View\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n style={[styles.row, selected && styles.selected, disabled && styles.disabled, style]}\n >\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n disabled={disabled}\n onPress={onPress}\n style={({ pressed }) => [\n styles.row,\n selected && styles.selected,\n pressed && styles.pressed,\n disabled && styles.disabled,\n style,\n ]}\n >\n {content}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { flex: 1, minHeight: 0 },\n separator: {\n height: StyleSheet.hairlineWidth,\n marginLeft: theme.spacing(4),\n backgroundColor: theme.colors['border-soft'],\n },\n row: {\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(2),\n },\n selected: { backgroundColor: theme.colors['tint-green'] },\n pressed: { backgroundColor: theme.colors.panel },\n disabled: { opacity: DISABLED_OPACITY },\n text: { flex: 1, minWidth: 0, gap: theme.spacing(0.5) },\n title: {\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.medium,\n },\n titleSelected: { color: theme.colors.green, fontWeight: theme.fontWeight.semibold },\n description: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;AAeA,MAAMS,iBAAiB;AACvB,MAAMC,mBAAmB;;AAEzB,MAAMC,gBAAgB;AA0BtB,SAASiB,YAAY;CACnB,OAAO,oBAAC,MAAD,EAAM,OAAOC,OAAOC,UAAU;AACvC;AAEA,SAAgBC,KAAQ,EACtBlB,MACAE,YACAG,cACAC,gBAAgB,OAChBC,aAAa,MACbC,OACAC,QACAC,QACAC,cACAC,oBACAC,OACAC,kBACe;CACf,OACE,oBAAC,MAAD;EAAM,OAAO,CAACE,OAAOG,OAAON,KAAK;EAAuBD;YACtD,oBAAC,WAAD;GACQZ;GACN,aAAa,EAAEG,MAAMC,YAAYF,WAAWC,MAAMC,KAAK;GACzCC;GACd,wBAAwBE,aAAaQ,YAAY;GACjD,oBAAoBP,UAAUY,SAAY,OAAO,0CAAGZ,MAAM;GAC1D,qBAAqBC,WAAWW,SAAY,OAAO,0CAAGX,OAAO;GAC7D,qBAAqBC,WAAWU,SAAY,OAAO,0CAAGV,OAAO;GAC/CC;GAEd,gCAA+B;GAC/B,uBAAuBG,mBAAmBM,SAAYA,SAAY,EAAEC,SAASP,eAAe;GAC5F,gCACER,gBAAgB;IAAEgB,0BAA0B;IAAMC,6BAA6BzB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EACHa,eAAe;EACfC,YAAY;EACZC,KAAKZ,MAAMM,QAAQ,CAAC;EACpBJ,WAAWhD;EACX2D,mBAAmBb,MAAMM,QAAQ,CAAC;EAClCQ,iBAAiBd,MAAMM,QAAQ,CAAC;EAACG,mBAAA,CAAA,CAAA;CACnC;CACAtB,UAAU;EAAEoB,iBAAiBP,MAAMQ,OAAO;EAAaC,mBAAA,CAAA,CAAA;CAAC;CACxDX,SAAS;EAAES,iBAAiBP,MAAMQ,OAAOO;EAAKN,mBAAA,CAAA,CAAA;CAAC;CAC/CrB,UAAU,EAAE4B,SAAS7D,iBAAiB;CACtCwC,MAAM;EAAEM,MAAM;EAAGgB,UAAU;EAAGL,KAAKZ,MAAMM,QAAQ,EAAG;EAACG,mBAAA,CAAA,CAAA;CAAC;CACtD1B,OAAO;EACLmC,OAAOlB,MAAMQ,OAAOW;EACpBC,YAAYnE,OAAO+C,MAAMoB,WAAWC,IAAI;EACxCC,UAAUtB,MAAMsB,SAASC;EACzBC,YAAYxB,MAAMwB,WAAWD;EAC7BE,YAAYzB,MAAMyB,WAAWC;EAAMjB,mBAAA,CAAA,CAAA;CACrC;CACAb,eAAe;EAAEsB,OAAOlB,MAAMQ,OAAOmB;EAAOF,YAAYzB,MAAMyB,WAAWG;EAAQnB,mBAAA,CAAA,CAAA;CAAC;CAClFzB,aAAa;EACXkC,OAAOlB,MAAMQ,OAAOqB;EACpBT,YAAYnE,OAAO+C,MAAMoB,WAAWC,IAAI;EACxCC,UAAUtB,MAAMsB,SAASQ;EACzBN,YAAYxB,MAAMwB,WAAWM;EAAErB,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"List.mjs","names":["FlashList","FlashListRef","ReactElement","ReactNode","useCallback","useRef","useState","NativeScrollEvent","NativeSyntheticEvent","Platform","StyleProp","ViewStyle","StyleSheet","ChevronDownIcon","ChevronRightIcon","fontOf","Button","MIN_ROW_HEIGHT","DISABLED_OPACITY","PIN_THRESHOLD","JUMP_THRESHOLD","ListProps","data","T","renderItem","item","index","keyExtractor","startAtBottom","separators","empty","header","footer","onEndReached","accessibilityLabel","style","contentPadding","Separator","styles","separator","List","renderRow","listRef","awayFromBottom","setAwayFromBottom","onScroll","nativeEvent","contentOffset","contentSize","layoutMeasurement","distance","height","y","frame","undefined","OS","padding","startRenderingFromBottom","autoscrollToBottomThreshold","current","scrollToEnd","animated","jump","ListRowProps","title","description","leading","trailing","selected","disabled","onPress","disclosure","ListRow","chevron","content","text","titleSelected","row","pressed","create","theme","flex","minHeight","position","bottom","spacing","alignSelf","borderRadius","full","borderColor","colors","border","uni__dependencies","hairlineWidth","marginLeft","backgroundColor","flexDirection","alignItems","gap","paddingHorizontal","paddingVertical","panel","opacity","minWidth","color","hi","fontFamily","sans","fontSize","base","lineHeight","fontWeight","medium","green","semibold","faint","sm"],"sources":["../../src/components/List.tsx"],"sourcesContent":["import { FlashList, type FlashListRef } from '@shopify/flash-list';\nimport { type ReactElement, type ReactNode, useCallback, useRef, useState } from 'react';\nimport {\n type NativeScrollEvent,\n type NativeSyntheticEvent,\n Platform,\n Pressable,\n type StyleProp,\n Text,\n View,\n type ViewStyle,\n} from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { ChevronDownIcon, ChevronRightIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\n/*\n * A virtualised list on FlashList: sessions, devices, a transcript. Rows\n * recycle, separators are hairlines, and a chat list can start at the bottom\n * and stay pinned there as rows arrive. The public props are this package's\n * own, so FlashList's types never reach a caller.\n */\n\nconst MIN_ROW_HEIGHT = 44;\nconst DISABLED_OPACITY = 0.4;\n/** How close to the bottom a reader must be for a new row to keep the list pinned, as a fraction of the visible height. */\nconst PIN_THRESHOLD = 0.1;\n/** How far above the bottom, in visible heights, a chat reader must scroll before the jump-to-latest button shows. */\nconst JUMP_THRESHOLD = 1;\n\nexport interface ListProps<T> {\n data: readonly T[];\n renderItem: (item: T, index: number) => ReactElement | null;\n /** A stable key per row; FlashList recycles views by it. */\n keyExtractor: (item: T, index: number) => string;\n /**\n * A chat list: render from the bottom and keep the newest row in view as\n * rows arrive, while the reader is near the bottom.\n */\n startAtBottom?: boolean;\n /** Hairline separators between rows. On by default. */\n separators?: boolean;\n /** Shown when `data` is empty. */\n empty?: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n onEndReached?: () => void;\n accessibilityLabel?: string;\n /** The list's frame; give it a height or a flex parent, since a virtualised list needs bounds. */\n style?: StyleProp<ViewStyle>;\n /** Padding around the rows. */\n contentPadding?: number;\n}\n\nfunction Separator() {\n return <View style={styles.separator} />;\n}\n\nexport function List<T>({\n data,\n renderItem,\n keyExtractor,\n startAtBottom = false,\n separators = true,\n empty,\n header,\n footer,\n onEndReached,\n accessibilityLabel,\n style,\n contentPadding,\n}: ListProps<T>) {\n const renderRow = useCallback(({ item, index }: { item: T; index: number }) => renderItem(item, index), [renderItem]);\n const listRef = useRef<FlashListRef<T>>(null);\n const [awayFromBottom, setAwayFromBottom] = useState(false);\n const onScroll = useCallback(({ nativeEvent }: NativeSyntheticEvent<NativeScrollEvent>) => {\n const { contentOffset, contentSize, layoutMeasurement } = nativeEvent;\n const distance = contentSize.height - layoutMeasurement.height - contentOffset.y;\n setAwayFromBottom(distance > layoutMeasurement.height * JUMP_THRESHOLD);\n }, []);\n return (\n <View style={[styles.frame, style]} accessibilityLabel={accessibilityLabel}>\n <FlashList\n ref={listRef}\n onScroll={startAtBottom ? onScroll : undefined}\n scrollEventThrottle={startAtBottom ? 100 : undefined}\n data={data}\n renderItem={renderRow}\n keyExtractor={keyExtractor}\n ItemSeparatorComponent={separators ? Separator : null}\n ListEmptyComponent={empty === undefined ? null : <>{empty}</>}\n ListHeaderComponent={header === undefined ? null : <>{header}</>}\n ListFooterComponent={footer === undefined ? null : <>{footer}</>}\n onEndReached={onEndReached}\n // Dragging the rows pulls the keyboard down with the finger, as in Messages.\n keyboardDismissMode={Platform.OS === 'ios' ? 'interactive' : 'on-drag'}\n // A chat's rows are mostly pressable (long-press bubbles, tool groups), so any tap there hides the keyboard\n // first, as in Messages; other lists let a tap on a row land.\n keyboardShouldPersistTaps={startAtBottom ? 'never' : 'handled'}\n // Lets UIKit inset the rows under a translucent or large-title header instead of drawing beneath it.\n contentInsetAdjustmentBehavior=\"automatic\"\n contentContainerStyle={contentPadding === undefined ? undefined : { padding: contentPadding }}\n maintainVisibleContentPosition={\n startAtBottom ? { startRenderingFromBottom: true, autoscrollToBottomThreshold: PIN_THRESHOLD } : undefined\n }\n />\n {startAtBottom && awayFromBottom ? (\n <Button\n variant=\"subtle\"\n size=\"icon-md\"\n accessibilityLabel=\"Jump to latest\"\n onPress={() => listRef.current?.scrollToEnd({ animated: true })}\n style={styles.jump}\n >\n <ChevronDownIcon size={18} />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport interface ListRowProps {\n title: ReactNode;\n /** A second, quieter line under the title. */\n description?: ReactNode;\n /** Before the text: a Dot, an icon. */\n leading?: ReactNode;\n /** After the text: a Badge, a ghost button, a count. */\n trailing?: ReactNode;\n /** Selected rows sit on a green tint. */\n selected?: boolean;\n disabled?: boolean;\n onPress?: () => void;\n /** The iOS disclosure chevron. Defaults to on for a pressable row on iOS, where rows that navigate wear one. */\n disclosure?: boolean;\n accessibilityLabel?: string;\n style?: StyleProp<ViewStyle>;\n}\n\n/** One list row: 44pt tall, optional leading and trailing slots, pressable when it navigates. */\nexport function ListRow({\n title,\n description,\n leading,\n trailing,\n selected = false,\n disabled = false,\n onPress,\n disclosure,\n accessibilityLabel,\n style,\n}: ListRowProps) {\n const chevron = disclosure ?? (onPress !== undefined && Platform.OS === 'ios');\n const content = (\n <>\n {leading}\n <View style={styles.text}>\n {typeof title === 'string' ? (\n <Text numberOfLines={1} style={[styles.title, selected && styles.titleSelected]}>\n {title}\n </Text>\n ) : (\n title\n )}\n {typeof description === 'string' ? (\n <Text numberOfLines={2} style={styles.description}>\n {description}\n </Text>\n ) : (\n description\n )}\n </View>\n {trailing}\n {chevron ? <ChevronRightIcon size={14} color=\"faint\" /> : null}\n </>\n );\n if (onPress === undefined) {\n return (\n <View\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n style={[styles.row, selected && styles.selected, disabled && styles.disabled, style]}\n >\n {content}\n </View>\n );\n }\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={accessibilityLabel}\n accessibilityState={{ selected, disabled }}\n disabled={disabled}\n onPress={onPress}\n style={({ pressed }) => [\n styles.row,\n selected && styles.selected,\n pressed && styles.pressed,\n disabled && styles.disabled,\n style,\n ]}\n >\n {content}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { flex: 1, minHeight: 0 },\n jump: {\n position: 'absolute',\n bottom: theme.spacing(3),\n alignSelf: 'center',\n borderRadius: theme.borderRadius.full,\n borderColor: theme.colors.border,\n },\n separator: {\n height: StyleSheet.hairlineWidth,\n marginLeft: theme.spacing(4),\n backgroundColor: theme.colors['border-soft'],\n },\n row: {\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(2),\n },\n selected: { backgroundColor: theme.colors['tint-green'] },\n pressed: { backgroundColor: theme.colors.panel },\n disabled: { opacity: DISABLED_OPACITY },\n text: { flex: 1, minWidth: 0, gap: theme.spacing(0.5) },\n title: {\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.base,\n lineHeight: theme.lineHeight.base,\n fontWeight: theme.fontWeight.medium,\n },\n titleSelected: { color: theme.colors.green, fontWeight: theme.fontWeight.semibold },\n description: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;;;AAwBA,MAAMiB,iBAAiB;AACvB,MAAMC,m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A,CAAA;CAAC;CAClF3B,aAAa;EACXuC,OAAOxB,MAAMU,OAAOyB;EACpBT,YAAY3F,OAAOiE,MAAM0B,WAAWC,IAAI;EACxCC,UAAU5B,MAAM4B,SAASQ;EACzBN,YAAY9B,MAAM8B,WAAWM;EAAExB,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StyleProp, TextStyle } from "react-native";
|
|
2
|
+
//#region src/components/LiveDuration.d.ts
|
|
3
|
+
/** What a custom clock shows at `now`, and how long until it changes; no `nextMs` freezes it. */
|
|
4
|
+
export interface LiveDurationReading {
|
|
5
|
+
text: string;
|
|
6
|
+
nextMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export type LiveDurationProps = {
|
|
9
|
+
style?: StyleProp<TextStyle>;
|
|
10
|
+
} & ({
|
|
11
|
+
/** The copy before the elapsed time, such as "running". */
|
|
12
|
+
label: string;
|
|
13
|
+
/** Epoch milliseconds the clock counts from. */
|
|
14
|
+
since: number;
|
|
15
|
+
clock?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
/** A custom format; keep it stable (useCallback), since a new function restarts the clock. */
|
|
18
|
+
clock: (now: number) => LiveDurationReading;
|
|
19
|
+
label?: undefined;
|
|
20
|
+
since?: undefined;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* "running · 12m" that ages by itself, or any `clock` format. Each change writes a shared value the UI thread
|
|
24
|
+
* draws, so a list of running work re-renders nothing to keep its clocks current. It sleeps while the app is in
|
|
25
|
+
* the background and catches up on return. Read-only and not focusable: it sits inside a row whose own label
|
|
26
|
+
* speaks for it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function LiveDuration({ label, since, clock, style }: LiveDurationProps): import("react").JSX.Element;
|
|
29
|
+
//#endregion
|
|
30
|
+
//# sourceMappingURL=LiveDuration.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveDuration.d.mts","names":[],"sources":["../../src/components/LiveDuration.tsx"],"mappings":";;;iBASiB;EACf;EACA;;YAGU;EACV,QAAQ,UAAU;;;EAId;;EAEA;EACA;;;EAIA,QAAQ,gBAAgB;EACxB;EACA;;;;;;;;wBAUU,eAAe,OAAO,OAAO,OAAO,SAAS,oCAAiB,IAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { clockRefreshMs, clockText } from "@agimon-ai/po-web-components/text";
|
|
2
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
3
|
+
import { AppState } from "react-native";
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { TextInput } from "react-native-unistyles/components/native/TextInput";
|
|
7
|
+
import Animated, { useAnimatedProps, useSharedValue } from "react-native-reanimated";
|
|
8
|
+
|
|
9
|
+
//#region src/components/LiveDuration.tsx
|
|
10
|
+
const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);
|
|
11
|
+
/**
|
|
12
|
+
* "running · 12m" that ages by itself, or any `clock` format. Each change writes a shared value the UI thread
|
|
13
|
+
* draws, so a list of running work re-renders nothing to keep its clocks current. It sleeps while the app is in
|
|
14
|
+
* the background and catches up on return. Read-only and not focusable: it sits inside a row whose own label
|
|
15
|
+
* speaks for it.
|
|
16
|
+
*/
|
|
17
|
+
function LiveDuration({ label, since, clock, style }) {
|
|
18
|
+
const read = (now) => clock ? clock(now) : {
|
|
19
|
+
text: clockText({
|
|
20
|
+
label,
|
|
21
|
+
since
|
|
22
|
+
}, now),
|
|
23
|
+
nextMs: clockRefreshMs(since, now)
|
|
24
|
+
};
|
|
25
|
+
const [initial] = useState(() => read(Date.now()).text);
|
|
26
|
+
const text = useSharedValue(initial);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
let timer;
|
|
29
|
+
const tick = () => {
|
|
30
|
+
clearTimeout(timer);
|
|
31
|
+
timer = void 0;
|
|
32
|
+
if (AppState.currentState !== "active") return;
|
|
33
|
+
const reading = read(Date.now());
|
|
34
|
+
text.value = reading.text;
|
|
35
|
+
if (reading.nextMs !== void 0) timer = setTimeout(tick, Math.max(1, reading.nextMs));
|
|
36
|
+
};
|
|
37
|
+
const subscription = AppState.addEventListener("change", tick);
|
|
38
|
+
tick();
|
|
39
|
+
return () => {
|
|
40
|
+
clearTimeout(timer);
|
|
41
|
+
subscription.remove();
|
|
42
|
+
};
|
|
43
|
+
}, [
|
|
44
|
+
label,
|
|
45
|
+
since,
|
|
46
|
+
clock,
|
|
47
|
+
text
|
|
48
|
+
]);
|
|
49
|
+
const animatedProps = useAnimatedProps(() => ({ text: text.value }));
|
|
50
|
+
return /* @__PURE__ */ jsx(AnimatedTextInput, {
|
|
51
|
+
editable: false,
|
|
52
|
+
focusable: false,
|
|
53
|
+
pointerEvents: "none",
|
|
54
|
+
underlineColorAndroid: "transparent",
|
|
55
|
+
defaultValue: initial,
|
|
56
|
+
animatedProps,
|
|
57
|
+
style: [styles.text, style]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
const styles = StyleSheet.create({ text: {
|
|
61
|
+
padding: 0,
|
|
62
|
+
margin: 0
|
|
63
|
+
} });
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
export { LiveDuration };
|
|
67
|
+
//# sourceMappingURL=LiveDuration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LiveDuration.mjs","names":["clockRefreshMs","clockText","useEffect","useState","AppState","StyleProp","TextInputProps","TextStyle","Animated","useAnimatedProps","useSharedValue","StyleSheet","AnimatedTextInput","createAnimatedComponent","TextInput","LiveDurationReading","text","nextMs","LiveDurationProps","style","label","since","clock","now","LiveDuration","read","initial","Date","timer","ReturnType","setTimeout","tick","clearTimeout","undefined","currentState","reading","value","Math","max","subscription","addEventListener","remove","animatedProps","styles","create","padding","margin"],"sources":["../../src/components/LiveDuration.tsx"],"sourcesContent":["import { clockRefreshMs, clockText } from '@agimon-ai/po-web-components/text';\nimport { useEffect, useState } from 'react';\nimport { AppState, type StyleProp, TextInput, type TextInputProps, type TextStyle } from 'react-native';\nimport Animated, { useAnimatedProps, useSharedValue } from 'react-native-reanimated';\nimport { StyleSheet } from 'react-native-unistyles';\n\nconst AnimatedTextInput = Animated.createAnimatedComponent(TextInput);\n\n/** What a custom clock shows at `now`, and how long until it changes; no `nextMs` freezes it. */\nexport interface LiveDurationReading {\n text: string;\n nextMs?: number;\n}\n\nexport type LiveDurationProps = {\n style?: StyleProp<TextStyle>;\n} & (\n | {\n /** The copy before the elapsed time, such as \"running\". */\n label: string;\n /** Epoch milliseconds the clock counts from. */\n since: number;\n clock?: undefined;\n }\n | {\n /** A custom format; keep it stable (useCallback), since a new function restarts the clock. */\n clock: (now: number) => LiveDurationReading;\n label?: undefined;\n since?: undefined;\n }\n);\n\n/**\n * \"running · 12m\" that ages by itself, or any `clock` format. Each change writes a shared value the UI thread\n * draws, so a list of running work re-renders nothing to keep its clocks current. It sleeps while the app is in\n * the background and catches up on return. Read-only and not focusable: it sits inside a row whose own label\n * speaks for it.\n */\nexport function LiveDuration({ label, since, clock, style }: LiveDurationProps) {\n const read = (now: number): LiveDurationReading =>\n clock ? clock(now) : { text: clockText({ label, since }, now), nextMs: clockRefreshMs(since, now) };\n // The first paint's text; the effect below keeps it current from then on.\n const [initial] = useState(() => read(Date.now()).text);\n const text = useSharedValue(initial);\n useEffect(() => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n const tick = (): void => {\n clearTimeout(timer);\n timer = undefined;\n if (AppState.currentState !== 'active') return;\n const reading = read(Date.now());\n text.value = reading.text;\n if (reading.nextMs !== undefined) timer = setTimeout(tick, Math.max(1, reading.nextMs));\n };\n const subscription = AppState.addEventListener('change', tick);\n tick();\n return () => {\n clearTimeout(timer);\n subscription.remove();\n };\n // read is rebuilt each render from exactly these inputs.\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [label, since, clock, text]);\n const animatedProps = useAnimatedProps(() => ({ text: text.value }) as TextInputProps);\n return (\n <AnimatedTextInput\n editable={false}\n focusable={false}\n pointerEvents=\"none\"\n underlineColorAndroid=\"transparent\"\n defaultValue={initial}\n animatedProps={animatedProps}\n style={[styles.text, style]}\n />\n );\n}\n\nconst styles = StyleSheet.create({\n // A TextInput pads itself on Android; a status line sits flush like the Text beside it.\n text: { padding: 0, margin: 0 },\n});\n"],"mappings":";;;;;;;;;AAMA,MAAMY,oBAAoBJ,SAASK,wBAAwBC,SAAS;;;;;;;AAgCpE,SAAgBU,aAAa,EAAEJ,OAAOC,OAAOC,OAAOH,SAA4B;CAC9E,MAAMM,QAAQF,QACZD,QAAQA,MAAMC,GAAG,IAAI;EAAEP,MAAMf,UAAU;GAAEmB;GAAOC;EAAM,GAAGE,GAAG;EAAGN,QAAQjB,eAAeqB,OAAOE,GAAG;CAAE;CAEpG,MAAM,CAACG,WAAWvB,eAAesB,KAAKE,KAAKJ,IAAI,CAAC,CAAC,CAACP,IAAI;CACtD,MAAMA,OAAON,eAAegB,OAAO;CACnCxB,gBAAgB;EACd,IAAI0B;EACJ,MAAMG,aAAmB;GACvBC,aAAaJ,KAAK;GAClBA,QAAQK;GACR,IAAI7B,SAAS8B,iBAAiB,UAAU;GACxC,MAAMC,UAAUV,KAAKE,KAAKJ,IAAI,CAAC;GAC/BP,KAAKoB,QAAQD,QAAQnB;GACrB,IAAImB,QAAQlB,WAAWgB,QAAWL,QAAQE,WAAWC,MAAMM,KAAKC,IAAI,GAAGH,QAAQlB,MAAM,CAAC;EACxF;EACA,MAAMsB,eAAenC,SAASoC,iBAAiB,UAAUT,IAAI;EAC7DA,KAAK;EACL,aAAa;GACXC,aAAaJ,KAAK;GAClBW,aAAaE,OAAO;EACtB;CAGF,GAAG;EAACrB;EAAOC;EAAOC;EAAON;CAAI,CAAC;CAC9B,MAAM0B,gBAAgBjC,wBAAwB,EAAEO,MAAMA,KAAKoB,MAAM,EAAoB;CACrF,OACE,oBAAC,mBAAD;EACE,UAAU;EACV,WAAW;EACX,eAAc;EACd,uBAAsB;EACtB,cAAcV;EACCgB;EACf,OAAO,CAACC,OAAO3B,MAAMG,KAAK;CAAE;AAGlC;AAEA,MAAMwB,SAAShC,WAAWiC,OAAO,EAE/B5B,MAAM;CAAE6B,SAAS;CAAGC,QAAQ;AAAE,EAChC,CAAC"}
|
|
@@ -5,11 +5,20 @@
|
|
|
5
5
|
* contract as the web Markdown's handler.
|
|
6
6
|
*/
|
|
7
7
|
export type FileLinkHandler = (text: string, explicit?: boolean) => (() => void) | undefined;
|
|
8
|
+
/** Loads a relative image path from the host; the same contract as the web Markdown's `loadImage`. */
|
|
9
|
+
export type MarkdownImageLoader = (path: string) => Promise<{
|
|
10
|
+
url: string;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}>;
|
|
8
13
|
export interface MarkdownProps {
|
|
9
14
|
text: string;
|
|
10
15
|
onFileLink?: FileLinkHandler;
|
|
16
|
+
/** Loads relative image paths; without it they show as unavailable. */
|
|
17
|
+
loadImage?: MarkdownImageLoader;
|
|
18
|
+
/** Initial reveal pages for a restored reading position. Defaults to one. */
|
|
19
|
+
initialPage?: number;
|
|
11
20
|
}
|
|
12
21
|
/** Markdown in Po's shared presentation, parsed by the package's own small parser. */
|
|
13
|
-
export declare
|
|
22
|
+
export declare const Markdown: import("react").MemoExoticComponent<({ text, onFileLink, loadImage, initialPage }: MarkdownProps) => import("react").JSX.Element>;
|
|
14
23
|
//#endregion
|
|
15
24
|
//# sourceMappingURL=Markdown.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../src/components/Markdown.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"Markdown.d.mts","names":[],"sources":["../../src/components/Markdown.tsx"],"mappings":";;;;;;YAuBY,mBAAmB,cAAc;;YAQjC,uBAAuB,iBAAiB;EAAU;EAAa;;iBAmU1D;EACf;EACA,aAAa;;EAEb,YAAY;;EAEZ;;;qBAIW,0BAAQ,uBAAA,MAAA,YAAA,WAAA,eAA4E,kCAAa,IAAA"}
|