@agimon-ai/po-native-components 0.0.0-alpha.3 → 0.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +149 -22
- package/dist/components/AgentAvatar.d.mts +14 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +87 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +2 -2
- package/dist/components/Badge.mjs.map +1 -1
- package/dist/components/Button.mjs +2 -2
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +5 -34
- 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 +5 -5
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +3 -3
- package/dist/components/Dot.mjs.map +1 -1
- package/dist/components/DropdownMenu.mjs +1 -1
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +137 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/Input.mjs +2 -2
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/List.mjs +1 -1
- package/dist/components/Markdown.d.mts +8 -1
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +199 -18
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +2 -1
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +20 -24
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/Sheet.mjs +1 -1
- package/dist/components/SheetFrame.mjs +2 -2
- package/dist/components/SheetFrame.mjs.map +1 -1
- 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 +132 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.mjs +1 -1
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +40 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/icons/iconGlyphs.d.mts +90 -54
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +36 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +37 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +10 -1
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +9 -4
- package/dist/index.mjs +9 -4
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/markdown.mjs +101 -5
- package/dist/lib/markdown.mjs.map +1 -1
- package/package.json +23 -20
|
@@ -4,19 +4,19 @@ import { Button } from "./Button.mjs";
|
|
|
4
4
|
import { CloseIcon } from "../icons/icons.mjs";
|
|
5
5
|
import { useControllable } from "../lib/useControllable.mjs";
|
|
6
6
|
import { View } from "react-native-unistyles/components/native/View";
|
|
7
|
-
import {
|
|
7
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
8
8
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
9
9
|
import { Easing, Modal, Platform } from "react-native";
|
|
10
|
-
import {
|
|
10
|
+
import { Animated } from "react-native-unistyles/components/native/Animated";
|
|
11
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
11
12
|
import { createContext, useContext, useEffect, useRef } from "react";
|
|
12
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
14
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
14
|
-
import { Animated } from "react-native-unistyles/components/native/Animated";
|
|
15
15
|
|
|
16
16
|
//#region src/components/Dialog.tsx
|
|
17
|
-
/** `bg-
|
|
17
|
+
/** `bg-po-deep/70`. */
|
|
18
18
|
const BACKDROP_ALPHA_PERCENT = 70;
|
|
19
|
-
/** `animate-
|
|
19
|
+
/** `animate-po-pop` starts the card slightly small and grows it into place. */
|
|
20
20
|
const POP_FROM_SCALE = .96;
|
|
21
21
|
/** `max-w-[calc(100vw-24px)]`: 12pt clear of each screen edge. */
|
|
22
22
|
const SCREEN_MARGIN = 12;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.mjs","names":["withAlpha","createContext","ReactNode","useContext","useEffect","useRef","Easing","Modal","Platform","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","useUnistyles","CloseIcon","fontOf","useControllable","wrapText","Button","ButtonProps","BACKDROP_ALPHA_PERCENT","POP_FROM_SCALE","SCREEN_MARGIN","DialogWidth","DialogState","open","setOpen","DialogContext","undefined","DialogProps","defaultOpen","onOpenChange","children","Dialog","current","DialogTrigger","onPress","props","event","DialogClose","DialogContentProps","width","style","closeLabel","DialogContent","theme","progress","Animated","Value","x1","y1","x2","y2","motion","easing","setValue","timing","toValue","duration","pop","bezier","useNativeDriver","OS","start","_styles","styles","useVariants","root","backdrop","backgroundColor","colors","deep","card","opacity","transform","scale","interpolate","inputRange","outputRange","DialogPartProps","Omit","DialogHeaderProps","dismissible","DialogHeader","header","DialogTitle","title","DialogDescription","description","DialogBody","body","DialogFooterVariant","DialogFooterProps","variant","DialogFooter","_styles2","footer","hint","create","flex","alignItems","justifyContent","padding","position","top","right","bottom","left","maxHeight","overflow","borderRadius","lg","borderWidth","borderColor","border","panel","variants","sm","maxWidth","md","uni__dependencies","flexDirection","gap","spacing","minWidth","borderBottomWidth","borderBottomColor","flexShrink","color","hi","fontFamily","sans","fontSize","xl","lineHeight","letterSpacing","fontWeight","semibold","dim","lineHeightRelaxed","plain","bar","flexWrap","minHeight","borderTopWidth","borderTopColor","paddingHorizontal","paddingVertical","faint"],"sources":["../../src/components/Dialog.tsx"],"sourcesContent":["import { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport { createContext, type ReactNode, useContext, useEffect, useRef } from 'react';\nimport {\n Animated,\n Easing,\n Modal,\n Platform,\n Pressable,\n type StyleProp,\n Text,\n type TextProps,\n View,\n type ViewProps,\n type ViewStyle,\n} from 'react-native';\nimport { StyleSheet, useUnistyles } 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';\n\n/*\n * The web Dialog as a centred card in an RN Modal: the native shape for a\n * question that blocks, such as a destructive confirmation. Android back and\n * a backdrop tap close it, as Escape and an outside click do on the web.\n */\n\n/** `bg-doom-deep/70`. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n/** `animate-doom-pop` starts the card slightly small and grows it into place. */\nconst POP_FROM_SCALE = 0.96;\n/** `max-w-[calc(100vw-24px)]`: 12pt clear of each screen edge. */\nconst SCREEN_MARGIN = 12;\n\nexport type DialogWidth = 'sm' | 'md' | 'lg';\n\ninterface DialogState {\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nconst DialogContext = createContext<DialogState>({ open: false, setOpen: () => undefined });\n\nexport interface DialogProps {\n /** Controlled mode; pair with onOpenChange. Omit it and the dialog keeps its own state. */\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\nexport function Dialog({ open, defaultOpen = false, onOpenChange, children }: DialogProps) {\n const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);\n return <DialogContext.Provider value={{ open: current, setOpen }}>{children}</DialogContext.Provider>;\n}\n\n/** A Button that opens the enclosing dialog. */\nexport function DialogTrigger({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(DialogContext);\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 dialog. */\nexport function DialogClose({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(DialogContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(false);\n }}\n {...props}\n />\n );\n}\n\nexport interface DialogContentProps {\n /** Width preset; `style` may still override. */\n width?: DialogWidth;\n /** Applied to the card, after the preset. */\n style?: StyleProp<ViewStyle>;\n /** What the backdrop announces as its close action. */\n closeLabel?: string;\n children?: ReactNode;\n}\n\nexport function DialogContent({ width = 'md', style, closeLabel = 'close', children }: DialogContentProps) {\n const { open, setOpen } = useContext(DialogContext);\n const { theme } = useUnistyles();\n const progress = useRef(new Animated.Value(0)).current;\n const [x1, y1, x2, y2] = theme.motion.easing;\n useEffect(() => {\n if (!open) return;\n progress.setValue(0);\n Animated.timing(progress, {\n toValue: 1,\n duration: theme.motion.pop,\n easing: Easing.bezier(x1, y1, x2, y2),\n useNativeDriver: Platform.OS !== 'web',\n }).start();\n }, [open, progress, theme.motion.pop, x1, y1, x2, y2]);\n styles.useVariants({ width });\n return (\n <Modal visible={open} transparent animationType=\"fade\" statusBarTranslucent onRequestClose={() => setOpen(false)}>\n <View style={styles.root}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={closeLabel}\n onPress={() => setOpen(false)}\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 style={[styles.backdrop, { backgroundColor: withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT) }]}\n />\n <Animated.View\n accessibilityViewIsModal\n style={[\n styles.card,\n style,\n {\n opacity: progress,\n transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [POP_FROM_SCALE, 1] }) }],\n },\n ]}\n >\n {children}\n </Animated.View>\n </View>\n </Modal>\n );\n}\n\nexport interface DialogPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\nexport interface DialogHeaderProps extends DialogPartProps {\n /**\n * Show the close control at the right of the strip. Off by default, as on\n * the web: Android back and a backdrop tap already close every dialog.\n */\n dismissible?: boolean;\n /** What the close control announces. */\n closeLabel?: string;\n}\n\nexport function DialogHeader({\n dismissible = false,\n closeLabel = 'close',\n style,\n children,\n ...props\n}: DialogHeaderProps) {\n const { setOpen } = useContext(DialogContext);\n return (\n <View style={[styles.header, style]} {...props}>\n {children}\n {dismissible ? (\n <Button variant=\"ghost\" size=\"icon\" accessibilityLabel={closeLabel} onPress={() => setOpen(false)}>\n <CloseIcon size={12} color=\"faint\" />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport function DialogTitle({ style, ...props }: TextProps) {\n return <Text accessibilityRole=\"header\" style={[styles.title, style]} {...props} />;\n}\n\nexport function DialogDescription({ style, ...props }: TextProps) {\n return <Text style={[styles.description, style]} {...props} />;\n}\n\nexport function DialogBody({ style, children, ...props }: DialogPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.description)}\n </View>\n );\n}\n\nexport type DialogFooterVariant = 'plain' | 'bar';\n\nexport interface DialogFooterProps extends DialogPartProps {\n /** `plain`: buttons alone, inside the body's padding. `bar`: the recessed full-width strip with a hint at the left. */\n variant?: DialogFooterVariant;\n}\n\nexport function DialogFooter({ variant = 'plain', style, children, ...props }: DialogFooterProps) {\n styles.useVariants({ footer: variant });\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 root: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: SCREEN_MARGIN },\n backdrop: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 },\n card: {\n width: '100%',\n maxHeight: '100%',\n overflow: 'hidden',\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: theme.colors.panel,\n variants: {\n width: {\n sm: { maxWidth: 360 },\n md: { maxWidth: 480 },\n lg: { maxWidth: 620 },\n },\n },\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: theme.spacing(3),\n minWidth: 0,\n borderBottomWidth: 1,\n borderBottomColor: theme.colors.border,\n padding: theme.spacing(3),\n },\n title: {\n flexShrink: 1,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.xl,\n lineHeight: theme.lineHeight.xl,\n letterSpacing: theme.letterSpacing.xl,\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: { gap: theme.spacing(3), padding: theme.spacing(3) },\n footer: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2),\n variants: {\n footer: {\n plain: { justifyContent: 'flex-end' },\n bar: {\n flexWrap: 'wrap',\n justifyContent: 'space-between',\n minHeight: 34,\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.deep,\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n },\n },\n },\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":";;;;;;;;;;;;;;;;;AA8BA,MAAMqB,yBAAyB;;AAE/B,MAAMC,iBAAi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GAAG;GACpC;EACF,EACF;EAACH,mBAAA,CAAA,GAAA,CAAA;CACH;CACAvB,MAAM;EACJ+B,OAAOnF,MAAMyB,OAAO8E;EACpBlB,YAAYnH,OAAO8B,MAAMqF,WAAWC,IAAI;EACxCC,UAAUvF,MAAMuF,SAAS;EACzBE,YAAYzF,MAAMyF,WAAW;EAAMd,mBAAA,CAAA,CAAA;CACrC;AACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"Dialog.mjs","names":["withAlpha","createContext","ReactNode","useContext","useEffect","useRef","Easing","Modal","Platform","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","useUnistyles","CloseIcon","fontOf","useControllable","wrapText","Button","ButtonProps","BACKDROP_ALPHA_PERCENT","POP_FROM_SCALE","SCREEN_MARGIN","DialogWidth","DialogState","open","setOpen","DialogContext","undefined","DialogProps","defaultOpen","onOpenChange","children","Dialog","current","DialogTrigger","onPress","props","event","DialogClose","DialogContentProps","width","style","closeLabel","DialogContent","theme","progress","Animated","Value","x1","y1","x2","y2","motion","easing","setValue","timing","toValue","duration","pop","bezier","useNativeDriver","OS","start","_styles","styles","useVariants","root","backdrop","backgroundColor","colors","deep","card","opacity","transform","scale","interpolate","inputRange","outputRange","DialogPartProps","Omit","DialogHeaderProps","dismissible","DialogHeader","header","DialogTitle","title","DialogDescription","description","DialogBody","body","DialogFooterVariant","DialogFooterProps","variant","DialogFooter","_styles2","footer","hint","create","flex","alignItems","justifyContent","padding","position","top","right","bottom","left","maxHeight","overflow","borderRadius","lg","borderWidth","borderColor","border","panel","variants","sm","maxWidth","md","uni__dependencies","flexDirection","gap","spacing","minWidth","borderBottomWidth","borderBottomColor","flexShrink","color","hi","fontFamily","sans","fontSize","xl","lineHeight","letterSpacing","fontWeight","semibold","dim","lineHeightRelaxed","plain","bar","flexWrap","minHeight","borderTopWidth","borderTopColor","paddingHorizontal","paddingVertical","faint"],"sources":["../../src/components/Dialog.tsx"],"sourcesContent":["import { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport { createContext, type ReactNode, useContext, useEffect, useRef } from 'react';\nimport {\n Animated,\n Easing,\n Modal,\n Platform,\n Pressable,\n type StyleProp,\n Text,\n type TextProps,\n View,\n type ViewProps,\n type ViewStyle,\n} from 'react-native';\nimport { StyleSheet, useUnistyles } 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';\n\n/*\n * The web Dialog as a centred card in an RN Modal: the native shape for a\n * question that blocks, such as a destructive confirmation. Android back and\n * a backdrop tap close it, as Escape and an outside click do on the web.\n */\n\n/** `bg-po-deep/70`. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n/** `animate-po-pop` starts the card slightly small and grows it into place. */\nconst POP_FROM_SCALE = 0.96;\n/** `max-w-[calc(100vw-24px)]`: 12pt clear of each screen edge. */\nconst SCREEN_MARGIN = 12;\n\nexport type DialogWidth = 'sm' | 'md' | 'lg';\n\ninterface DialogState {\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nconst DialogContext = createContext<DialogState>({ open: false, setOpen: () => undefined });\n\nexport interface DialogProps {\n /** Controlled mode; pair with onOpenChange. Omit it and the dialog keeps its own state. */\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\nexport function Dialog({ open, defaultOpen = false, onOpenChange, children }: DialogProps) {\n const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);\n return <DialogContext.Provider value={{ open: current, setOpen }}>{children}</DialogContext.Provider>;\n}\n\n/** A Button that opens the enclosing dialog. */\nexport function DialogTrigger({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(DialogContext);\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 dialog. */\nexport function DialogClose({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(DialogContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(false);\n }}\n {...props}\n />\n );\n}\n\nexport interface DialogContentProps {\n /** Width preset; `style` may still override. */\n width?: DialogWidth;\n /** Applied to the card, after the preset. */\n style?: StyleProp<ViewStyle>;\n /** What the backdrop announces as its close action. */\n closeLabel?: string;\n children?: ReactNode;\n}\n\nexport function DialogContent({ width = 'md', style, closeLabel = 'close', children }: DialogContentProps) {\n const { open, setOpen } = useContext(DialogContext);\n const { theme } = useUnistyles();\n const progress = useRef(new Animated.Value(0)).current;\n const [x1, y1, x2, y2] = theme.motion.easing;\n useEffect(() => {\n if (!open) return;\n progress.setValue(0);\n Animated.timing(progress, {\n toValue: 1,\n duration: theme.motion.pop,\n easing: Easing.bezier(x1, y1, x2, y2),\n useNativeDriver: Platform.OS !== 'web',\n }).start();\n }, [open, progress, theme.motion.pop, x1, y1, x2, y2]);\n styles.useVariants({ width });\n return (\n <Modal visible={open} transparent animationType=\"fade\" statusBarTranslucent onRequestClose={() => setOpen(false)}>\n <View style={styles.root}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel={closeLabel}\n onPress={() => setOpen(false)}\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 style={[styles.backdrop, { backgroundColor: withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT) }]}\n />\n <Animated.View\n accessibilityViewIsModal\n style={[\n styles.card,\n style,\n {\n opacity: progress,\n transform: [{ scale: progress.interpolate({ inputRange: [0, 1], outputRange: [POP_FROM_SCALE, 1] }) }],\n },\n ]}\n >\n {children}\n </Animated.View>\n </View>\n </Modal>\n );\n}\n\nexport interface DialogPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\nexport interface DialogHeaderProps extends DialogPartProps {\n /**\n * Show the close control at the right of the strip. Off by default, as on\n * the web: Android back and a backdrop tap already close every dialog.\n */\n dismissible?: boolean;\n /** What the close control announces. */\n closeLabel?: string;\n}\n\nexport function DialogHeader({\n dismissible = false,\n closeLabel = 'close',\n style,\n children,\n ...props\n}: DialogHeaderProps) {\n const { setOpen } = useContext(DialogContext);\n return (\n <View style={[styles.header, style]} {...props}>\n {children}\n {dismissible ? (\n <Button variant=\"ghost\" size=\"icon\" accessibilityLabel={closeLabel} onPress={() => setOpen(false)}>\n <CloseIcon size={12} color=\"faint\" />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport function DialogTitle({ style, ...props }: TextProps) {\n return <Text accessibilityRole=\"header\" style={[styles.title, style]} {...props} />;\n}\n\nexport function DialogDescription({ style, ...props }: TextProps) {\n return <Text style={[styles.description, style]} {...props} />;\n}\n\nexport function DialogBody({ style, children, ...props }: DialogPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.description)}\n </View>\n );\n}\n\nexport type DialogFooterVariant = 'plain' | 'bar';\n\nexport interface DialogFooterProps extends DialogPartProps {\n /** `plain`: buttons alone, inside the body's padding. `bar`: the recessed full-width strip with a hint at the left. */\n variant?: DialogFooterVariant;\n}\n\nexport function DialogFooter({ variant = 'plain', style, children, ...props }: DialogFooterProps) {\n styles.useVariants({ footer: variant });\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 root: { flex: 1, alignItems: 'center', justifyContent: 'center', padding: SCREEN_MARGIN },\n backdrop: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 },\n card: {\n width: '100%',\n maxHeight: '100%',\n overflow: 'hidden',\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors.border,\n backgroundColor: theme.colors.panel,\n variants: {\n width: {\n sm: { maxWidth: 360 },\n md: { maxWidth: 480 },\n lg: { maxWidth: 620 },\n },\n },\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: theme.spacing(3),\n minWidth: 0,\n borderBottomWidth: 1,\n borderBottomColor: theme.colors.border,\n padding: theme.spacing(3),\n },\n title: {\n flexShrink: 1,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.xl,\n lineHeight: theme.lineHeight.xl,\n letterSpacing: theme.letterSpacing.xl,\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: { gap: theme.spacing(3), padding: theme.spacing(3) },\n footer: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2),\n variants: {\n footer: {\n plain: { justifyContent: 'flex-end' },\n bar: {\n flexWrap: 'wrap',\n justifyContent: 'space-between',\n minHeight: 34,\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.deep,\n paddingHorizontal: theme.spacing(3),\n paddingVertical: theme.spacing(1.5),\n },\n },\n },\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":";;;;;;;;;;;;;;;;;AA8BA,MAAMqB,yBAAyB;;AAE/B,MAAMC,iBAAiB;;AAEvB,MAAMC,gBAAgB;AAStB,MAAMK,gBAAgB3B,cAA2B;CAAEyB,MAAM;CAAOC,eAAeE;AAAU,CAAC;AAU1F,SAAgBK,OAAO,EAAER,MAAMK,cAAc,OAAOC,cAAcC,YAAyB;CACzF,MAAM,CAACE,SAASR,WAAWV,gBAAgBS,MAAMK,aAAaC,YAAY;CAC1E,OAAO,oBAAC,cAAc,UAAf;EAAwB,OAAO;GAAEN,MAAMS;GAASR;EAAQ;EAAIM;CAAiC;AACtG;;AAGA,SAAgBG,cAAc,EAAEC,SAAS,GAAGC,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Style } from "react-native";
|
|
2
|
+
import { DotTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
//#region src/components/Dot.d.ts
|
|
4
4
|
type DotTone$1 = DotTone;
|
|
5
5
|
export type DotSize = 'xs' | 'sm' | 'md' | 'lg';
|
package/dist/components/Dot.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
2
|
+
import { Animated } from "react-native-unistyles/components/native/Animated";
|
|
3
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
4
|
import { useEffect, useRef } from "react";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import { Animated } from "react-native-unistyles/components/native/Animated";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Dot.tsx
|
|
8
|
-
/** `bg-
|
|
8
|
+
/** `bg-po-faint/40`: a thing that exists but is not live. */
|
|
9
9
|
const MUTED_ALPHA_PERCENT = 40;
|
|
10
10
|
/** Tailwind's `animate-pulse`: a 2s cycle down to half opacity and back. */
|
|
11
11
|
const PULSE_HALF_CYCLE_MS = 1e3;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dot.mjs","names":["DotTone","Tone","withAlpha","useEffect","useRef","StyleProp","ViewStyle","StyleSheet","useUnistyles","DotSize","MUTED_ALPHA_PERCENT","PULSE_HALF_CYCLE_MS","PULSE_LOW_OPACITY","DotProps","tone","size","pulse","style","Dot","theme","_styles","styles","useVariants","opacity","Animated","Value","current","setValue","undefined","loop","sequence","timing","toValue","duration","useNativeDriver","start","stop","dot","backgroundColor","colors","faint","create","flexShrink","borderRadius","full","variants","neutral","muted","blue","green","yellow","red","magenta","violet","cyan","orange","teal","xs","width","spacing","height","sm","md","lg","uni__dependencies"],"sources":["../../src/components/Dot.tsx"],"sourcesContent":["import { type DotTone as Tone, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useEffect, useRef } from 'react';\nimport { Animated, type StyleProp, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nexport type DotTone = Tone;\nexport type DotSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `bg-
|
|
1
|
+
{"version":3,"file":"Dot.mjs","names":["DotTone","Tone","withAlpha","useEffect","useRef","StyleProp","ViewStyle","StyleSheet","useUnistyles","DotSize","MUTED_ALPHA_PERCENT","PULSE_HALF_CYCLE_MS","PULSE_LOW_OPACITY","DotProps","tone","size","pulse","style","Dot","theme","_styles","styles","useVariants","opacity","Animated","Value","current","setValue","undefined","loop","sequence","timing","toValue","duration","useNativeDriver","start","stop","dot","backgroundColor","colors","faint","create","flexShrink","borderRadius","full","variants","neutral","muted","blue","green","yellow","red","magenta","violet","cyan","orange","teal","xs","width","spacing","height","sm","md","lg","uni__dependencies"],"sources":["../../src/components/Dot.tsx"],"sourcesContent":["import { type DotTone as Tone, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport { useEffect, useRef } from 'react';\nimport { Animated, type StyleProp, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nexport type DotTone = Tone;\nexport type DotSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `bg-po-faint/40`: a thing that exists but is not live. */\nconst MUTED_ALPHA_PERCENT = 40;\n/** Tailwind's `animate-pulse`: a 2s cycle down to half opacity and back. */\nconst PULSE_HALF_CYCLE_MS = 1000;\nconst PULSE_LOW_OPACITY = 0.5;\n\nexport interface DotProps {\n tone?: DotTone;\n size?: DotSize;\n /** Something is live: the dot breathes. */\n pulse?: boolean;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The status dot: a colour and, while something is live, a pulse. Hidden from screen readers. */\nexport function Dot({ tone = 'neutral', size = 'sm', pulse = false, style }: DotProps) {\n const { theme } = useUnistyles();\n styles.useVariants({ tone, size });\n const opacity = useRef(new Animated.Value(1)).current;\n useEffect(() => {\n if (!pulse) {\n opacity.setValue(1);\n return undefined;\n }\n const loop = Animated.loop(\n Animated.sequence([\n Animated.timing(opacity, { toValue: PULSE_LOW_OPACITY, duration: PULSE_HALF_CYCLE_MS, useNativeDriver: true }),\n Animated.timing(opacity, { toValue: 1, duration: PULSE_HALF_CYCLE_MS, useNativeDriver: true }),\n ]),\n );\n loop.start();\n return () => loop.stop();\n }, [pulse, opacity]);\n return (\n <Animated.View\n accessible={false}\n importantForAccessibility=\"no-hide-descendants\"\n accessibilityElementsHidden\n style={[\n styles.dot,\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 tone === 'muted' && { backgroundColor: withAlpha(theme.colors.faint, MUTED_ALPHA_PERCENT) },\n { opacity },\n style,\n ]}\n />\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n dot: {\n flexShrink: 0,\n borderRadius: theme.borderRadius.full,\n variants: {\n tone: {\n neutral: { backgroundColor: theme.colors.faint },\n muted: {},\n blue: { backgroundColor: theme.colors.blue },\n green: { backgroundColor: theme.colors.green },\n yellow: { backgroundColor: theme.colors.yellow },\n red: { backgroundColor: theme.colors.red },\n magenta: { backgroundColor: theme.colors.magenta },\n violet: { backgroundColor: theme.colors.violet },\n cyan: { backgroundColor: theme.colors.cyan },\n orange: { backgroundColor: theme.colors.orange },\n teal: { backgroundColor: theme.colors.teal },\n },\n size: {\n xs: { width: theme.spacing(1), height: theme.spacing(1) },\n sm: { width: theme.spacing(1.5), height: theme.spacing(1.5) },\n md: { width: theme.spacing(2), height: theme.spacing(2) },\n lg: { width: theme.spacing(2.5), height: theme.spacing(2.5) },\n },\n },\n },\n}));\n"],"mappings":";;;;;;;;AASA,MAAMU,sBAAsB;;AAE5B,MAAMC,sBAAsB;AAC5B,MAAMC,oBAAoB;;AAW1B,SAAgBM,IAAI,EAAEJ,OAAO,WAAWC,OAAO,MAAMC,QAAQ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AOY,IAAI;GACzCC,SAAS,EAAEd,iBAAiBnB,MAAMoB,OAAOa,QAAQ;GACjDC,QAAQ,EAAEf,iBAAiBnB,MAAMoB,OAAOc,OAAO;GAC/CC,MAAM,EAAEhB,iBAAiBnB,MAAMoB,OAAOe,KAAK;GAC3CC,QAAQ,EAAEjB,iBAAiBnB,MAAMoB,OAAOgB,OAAO;GAC/CC,MAAM,EAAElB,iBAAiBnB,MAAMoB,OAAOiB,KAAK;EAC7C;EACAzC,MAAM;GACJ0C,IAAI;IAAEC,OAAOvC,MAAMwC,QAAQ,CAAC;IAAGC,QAAQzC,MAAMwC,QAAQ,CAAC;GAAE;GACxDE,IAAI;IAAEH,OAAOvC,MAAMwC,QAAQ,GAAG;IAAGC,QAAQzC,MAAMwC,QAAQ,GAAG;GAAE;GAC5DG,IAAI;IAAEJ,OAAOvC,MAAMwC,QAAQ,CAAC;IAAGC,QAAQzC,MAAMwC,QAAQ,CAAC;GAAE;GACxDI,IAAI;IAAEL,OAAOvC,MAAMwC,QAAQ,GAAG;IAAGC,QAAQzC,MAAMwC,QAAQ,GAAG;GAAE;EAC9D;CACF;CAACK,mBAAA,CAAA,GAAA,CAAA;AACH,EACF,EAAE"}
|
|
@@ -6,8 +6,8 @@ import { CheckIcon } from "../icons/icons.mjs";
|
|
|
6
6
|
import { useControllable } from "../lib/useControllable.mjs";
|
|
7
7
|
import { SheetFrame } from "./SheetFrame.mjs";
|
|
8
8
|
import { View } from "react-native-unistyles/components/native/View";
|
|
9
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
10
9
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
10
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
11
11
|
import { createContext, useContext } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PresentedLine } from "@agimon-ai/po-web-components/text";
|
|
2
|
+
import { ViewProps } from "react-native";
|
|
3
|
+
//#region src/components/HashlineLines.d.ts
|
|
4
|
+
export interface HashlineLinesProps extends Omit<ViewProps, 'children'> {
|
|
5
|
+
lines: readonly PresentedLine[];
|
|
6
|
+
/** Width of the line-number column, in characters, from `hashlineBody`. */
|
|
7
|
+
gutter: number;
|
|
8
|
+
/** The file a body of bare anchored lines came from, for highlighting. */
|
|
9
|
+
path?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare function HashlineLines({ lines, gutter, path, style, ...props }: HashlineLinesProps): import("react").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=HashlineLines.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HashlineLines.d.mts","names":[],"sources":["../../src/components/HashlineLines.tsx"],"mappings":";;;iBA0BiB,2BAA2B,KAAK;EAC/C,gBAAgB;;EAEhB;;EAEA;;wBAsCc,gBAAgB,OAAO,QAAQ,MAAM,UAAU,SAAS,qCAAkB,IAAA"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { SyntaxLine } from "./SyntaxLine.mjs";
|
|
3
|
+
import { detectGrammar, hashlineGroups, hashlineGroupsKey, highlightToLines } from "@agimon-ai/po-web-components/text";
|
|
4
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
5
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
6
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
//#region src/components/HashlineLines.tsx
|
|
11
|
+
const NO_SPANS = /* @__PURE__ */ new Map();
|
|
12
|
+
/** Spans per presented-line index, kept with the body they belong to, as the web's hook. */
|
|
13
|
+
function useHashlineSpans(lines, path) {
|
|
14
|
+
const groups = useMemo(() => hashlineGroups(lines, path), [lines, path]);
|
|
15
|
+
const key = hashlineGroupsKey(groups);
|
|
16
|
+
const [done, setDone] = useState();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
let live = true;
|
|
19
|
+
const next = /* @__PURE__ */ new Map();
|
|
20
|
+
const work = groups.map(async (group) => {
|
|
21
|
+
const grammar = detectGrammar({
|
|
22
|
+
path: group.path,
|
|
23
|
+
text: group.text
|
|
24
|
+
});
|
|
25
|
+
if (grammar === void 0) return;
|
|
26
|
+
const highlighted = await highlightToLines(group.text, grammar);
|
|
27
|
+
if (highlighted === void 0) return;
|
|
28
|
+
for (const [offset, index] of group.indices.entries()) {
|
|
29
|
+
const line = highlighted[offset];
|
|
30
|
+
if (line !== void 0) next.set(index, line);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
Promise.allSettled(work).then(() => {
|
|
34
|
+
if (live && next.size > 0) setDone({
|
|
35
|
+
key,
|
|
36
|
+
spans: next
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return () => {
|
|
40
|
+
live = false;
|
|
41
|
+
};
|
|
42
|
+
}, [key]);
|
|
43
|
+
return done?.key === key ? done.spans : NO_SPANS;
|
|
44
|
+
}
|
|
45
|
+
function HashlineLines({ lines, gutter, path, style, ...props }) {
|
|
46
|
+
const spans = useHashlineSpans(lines, path);
|
|
47
|
+
return /* @__PURE__ */ jsx(View, {
|
|
48
|
+
style,
|
|
49
|
+
...props,
|
|
50
|
+
children: lines.map((line, index) => {
|
|
51
|
+
if (line.type === "file") return /* @__PURE__ */ jsx(Text, {
|
|
52
|
+
numberOfLines: 1,
|
|
53
|
+
style: [
|
|
54
|
+
styles.mono,
|
|
55
|
+
styles.faint,
|
|
56
|
+
index > 0 && styles.fileGap
|
|
57
|
+
],
|
|
58
|
+
children: line.path
|
|
59
|
+
}, index);
|
|
60
|
+
if (line.type === "plain") return /* @__PURE__ */ jsx(Text, {
|
|
61
|
+
selectable: true,
|
|
62
|
+
style: [styles.mono, styles.dim],
|
|
63
|
+
children: line.text
|
|
64
|
+
}, index);
|
|
65
|
+
const { value } = line;
|
|
66
|
+
const match = value.marker === "match";
|
|
67
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
68
|
+
style: styles.row,
|
|
69
|
+
children: [
|
|
70
|
+
value.marker !== void 0 ? /* @__PURE__ */ jsx(Text, {
|
|
71
|
+
style: [styles.mono, match ? styles.marker : styles.faint],
|
|
72
|
+
children: match ? ">>" : " "
|
|
73
|
+
}) : null,
|
|
74
|
+
/* @__PURE__ */ jsx(Text, {
|
|
75
|
+
style: [styles.mono, styles.faint],
|
|
76
|
+
children: String(value.line).padStart(gutter)
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ jsx(SyntaxLine, {
|
|
79
|
+
selectable: true,
|
|
80
|
+
spans: spans.get(index),
|
|
81
|
+
text: value.content,
|
|
82
|
+
style: [
|
|
83
|
+
styles.mono,
|
|
84
|
+
styles.content,
|
|
85
|
+
match ? styles.hi : styles.text
|
|
86
|
+
]
|
|
87
|
+
})
|
|
88
|
+
]
|
|
89
|
+
}, index);
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
const styles = StyleSheet.create((theme) => ({
|
|
94
|
+
row: {
|
|
95
|
+
flexDirection: "row",
|
|
96
|
+
gap: theme.spacing(2),
|
|
97
|
+
uni__dependencies: [0]
|
|
98
|
+
},
|
|
99
|
+
fileGap: {
|
|
100
|
+
marginTop: theme.spacing(1),
|
|
101
|
+
uni__dependencies: [0]
|
|
102
|
+
},
|
|
103
|
+
mono: {
|
|
104
|
+
fontFamily: fontOf(theme.fontFamily.mono),
|
|
105
|
+
fontSize: theme.fontSize.sm,
|
|
106
|
+
lineHeight: theme.lineHeightRelaxed.sm,
|
|
107
|
+
uni__dependencies: [0]
|
|
108
|
+
},
|
|
109
|
+
content: {
|
|
110
|
+
flex: 1,
|
|
111
|
+
minWidth: 0
|
|
112
|
+
},
|
|
113
|
+
marker: {
|
|
114
|
+
color: theme.colors.blue,
|
|
115
|
+
uni__dependencies: [0]
|
|
116
|
+
},
|
|
117
|
+
faint: {
|
|
118
|
+
color: theme.colors.faint,
|
|
119
|
+
uni__dependencies: [0]
|
|
120
|
+
},
|
|
121
|
+
dim: {
|
|
122
|
+
color: theme.colors.dim,
|
|
123
|
+
uni__dependencies: [0]
|
|
124
|
+
},
|
|
125
|
+
text: {
|
|
126
|
+
color: theme.colors.text,
|
|
127
|
+
uni__dependencies: [0]
|
|
128
|
+
},
|
|
129
|
+
hi: {
|
|
130
|
+
color: theme.colors.hi,
|
|
131
|
+
uni__dependencies: [0]
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
|
|
135
|
+
//#endregion
|
|
136
|
+
export { HashlineLines };
|
|
137
|
+
//# sourceMappingURL=HashlineLines.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HashlineLines.mjs","names":["detectGrammar","hashlineGroups","hashlineGroupsKey","highlightToLines","PresentedLine","SyntaxSpan","useEffect","useMemo","useState","ViewProps","StyleSheet","fontOf","SyntaxLine","HashlineLinesProps","Omit","lines","gutter","path","NO_SPANS","ReadonlyMap","Map","useHashlineSpans","groups","key","done","setDone","spans","live","next","work","map","group","grammar","text","undefined","highlighted","offset","index","indices","entries","line","set","Promise","allSettled","then","size","HashlineLines","style","props","type","styles","mono","faint","fileGap","dim","value","match","marker","row","String","padStart","get","content","hi","create","theme","flexDirection","gap","spacing","uni__dependencies","marginTop","fontFamily","fontSize","sm","lineHeight","lineHeightRelaxed","flex","minWidth","color","colors","blue"],"sources":["../../src/components/HashlineLines.tsx"],"sourcesContent":["import {\n detectGrammar,\n hashlineGroups,\n hashlineGroupsKey,\n highlightToLines,\n type PresentedLine,\n type SyntaxSpan,\n} from '@agimon-ai/po-web-components/text';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Text, View, type ViewProps } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { SyntaxLine } from './SyntaxLine';\n\n/*\n * The anchored body shared by hashline results, as the web's HashlineLines: a\n * file heading per group, a right-aligned line-number gutter, and a `>>`\n * marker on grep matches. Mono type makes a padded number the gutter, so the\n * column needs no measuring.\n *\n * The anchored lines are coloured with the web's grammars and palette when the\n * body names a file, or when `path` names one. Colour arrives late and never\n * blocks the text: an unhighlighted body is the same body without the colours.\n */\n\nexport interface HashlineLinesProps extends Omit<ViewProps, 'children'> {\n lines: readonly PresentedLine[];\n /** Width of the line-number column, in characters, from `hashlineBody`. */\n gutter: number;\n /** The file a body of bare anchored lines came from, for highlighting. */\n path?: string | undefined;\n}\n\nconst NO_SPANS: ReadonlyMap<number, readonly SyntaxSpan[]> = new Map();\n\n/** Spans per presented-line index, kept with the body they belong to, as the web's hook. */\nfunction useHashlineSpans(lines: readonly PresentedLine[], path: string | undefined) {\n const groups = useMemo(() => hashlineGroups(lines, path), [lines, path]);\n const key = hashlineGroupsKey(groups);\n const [done, setDone] = useState<{ key: string; spans: ReadonlyMap<number, readonly SyntaxSpan[]> }>();\n\n useEffect(() => {\n let live = true;\n const next = new Map<number, readonly SyntaxSpan[]>();\n const work = groups.map(async (group) => {\n const grammar = detectGrammar({ path: group.path, text: group.text });\n if (grammar === undefined) return;\n const highlighted = await highlightToLines(group.text, grammar);\n if (highlighted === undefined) return;\n for (const [offset, index] of group.indices.entries()) {\n const line = highlighted[offset];\n if (line !== undefined) next.set(index, line);\n }\n });\n // A grammar that fails to load leaves its run plain: colour is decoration.\n void Promise.allSettled(work).then(() => {\n if (live && next.size > 0) setDone({ key, spans: next });\n });\n return () => {\n live = false;\n };\n // The groups are rebuilt with the lines; their key is what actually changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n\n return done?.key === key ? done.spans : NO_SPANS;\n}\n\nexport function HashlineLines({ lines, gutter, path, style, ...props }: HashlineLinesProps) {\n const spans = useHashlineSpans(lines, path);\n return (\n <View style={style} {...props}>\n {lines.map((line, index) => {\n if (line.type === 'file') {\n return (\n <Text key={index} numberOfLines={1} style={[styles.mono, styles.faint, index > 0 && styles.fileGap]}>\n {line.path}\n </Text>\n );\n }\n if (line.type === 'plain') {\n return (\n <Text key={index} selectable style={[styles.mono, styles.dim]}>\n {line.text}\n </Text>\n );\n }\n const { value } = line;\n const match = value.marker === 'match';\n return (\n <View key={index} style={styles.row}>\n {value.marker !== undefined ? (\n <Text style={[styles.mono, match ? styles.marker : styles.faint]}>{match ? '>>' : ' '}</Text>\n ) : null}\n <Text style={[styles.mono, styles.faint]}>{String(value.line).padStart(gutter)}</Text>\n <SyntaxLine\n selectable\n spans={spans.get(index)}\n text={value.content}\n style={[styles.mono, styles.content, match ? styles.hi : styles.text]}\n />\n </View>\n );\n })}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n row: { flexDirection: 'row', gap: theme.spacing(2) },\n fileGap: { marginTop: theme.spacing(1) },\n mono: {\n fontFamily: fontOf(theme.fontFamily.mono),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n content: { flex: 1, minWidth: 0 },\n marker: { color: theme.colors.blue },\n faint: { color: theme.colors.faint },\n dim: { color: theme.colors.dim },\n text: { color: theme.colors.text },\n hi: { color: theme.colors.hi },\n}));\n"],"mappings":";;;;;;;;;;AAkCA,MAAMkB,2BAAuD,IAAIE,IAAI;;AAGrE,SAASC,iBAAiBN,OAAiCE,MAA0B;CACnF,MAAMK,SAASf,cAAcN,eAAec,OAAOE,IAAI,GAAG,CAACF,OAAOE,IAAI,CAAC;CACvE,MAAMM,MAAMrB,kBAAkBoB,MAAM;CACpC,MAAM,CAACE,MAAMC,WAAWjB,SAA6E;CAErGF,gBAAgB;EACd,IAAIqB,OAAO;EACX,MAAMC,uBAAO,IAAIR,IAAmC;EACpD,MAAMS,OAAOP,OAAOQ,IAAI,OAAOC,UAAU;GACvC,MAAMC,UAAUhC,cAAc;IAAEiB,MAAMc,MAAMd;IAAMgB,MAAMF,MAAME;GAAK,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A;CAAC;AAC/B,EAAE"}
|
|
@@ -1,14 +1,14 @@
|
|
|
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";
|
|
8
8
|
import { TextInput } from "react-native-unistyles/components/native/TextInput";
|
|
9
9
|
|
|
10
10
|
//#region src/components/Input.tsx
|
|
11
|
-
/** `focus:border-
|
|
11
|
+
/** `focus:border-po-green/60`. */
|
|
12
12
|
const FOCUS_EDGE_ALPHA_PERCENT = 60;
|
|
13
13
|
const DISABLED_OPACITY = .5;
|
|
14
14
|
const ThemedSheetTextInput = withUnistyles(BottomSheetTextInput);
|
|
@@ -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-
|
|
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,UAAUrB,aAAa;CAC/B,MAAM,CAACsB,SAASC,cAAc1B,SAAS,KAAK;CAE5C,MAAM2B,QAAQrB,eAAe,IAAIK,uBAAuBiB;CACxD,MAAAC,UAAAC;CAAA;EAAA,MAAAA,SAAAD,QAAAE,YACmB;GAAEjB,SAASA,YAAY,SAAS,SAASkB;GAAWjB;EAAK,CAAC;EAC7E,OACE,oBAAC,OAAD;GACE,aAAa;GACb,YAAY;GACZ,sBAAsBS,MAAMS,OAAOC;GACnC,gBAAgBV,MAAMS,OAAOE;GAC7B,aAAaX,MAAMS,OAAOE;GAC1B,UAAU,CAAClB;GACX,oBAAoB;IAAE,GAAGK;IAAoBL;GAAS;GACtD,UAAUmB,UAAU;IAClBV,WAAW,IAAI;IACfN,UAAUgB,KAAK;GACjB;GACA,SAASA,UAAU;IACjBV,W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mB;IAAGE,iBAAiB;GAAE;EAAE,CAAC;EAACO,mBAAA,CAAA,GAAA,CAAA;CAC3G;CACAlD,SAAS;EAAEsB,aAAad,MAAMS,OAAO;EAAaS,OAAOlB,MAAMS,OAAOkC;EAAGD,mBAAA,CAAA,CAAA;CAAC;CAC1EjD,UAAU,EAAEmD,SAAS1D,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
|
package/dist/components/List.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
2
|
import { ChevronRightIcon } from "../icons/icons.mjs";
|
|
3
3
|
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
4
5
|
import { StyleSheet } from "react-native-unistyles";
|
|
5
6
|
import { Platform } from "react-native";
|
|
6
|
-
import { Text } from "react-native-unistyles/components/native/Text";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
9
9
|
import { FlashList } from "@shopify/flash-list";
|
|
@@ -5,11 +5,18 @@
|
|
|
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;
|
|
11
18
|
}
|
|
12
19
|
/** Markdown in Po's shared presentation, parsed by the package's own small parser. */
|
|
13
|
-
export declare function Markdown({ text, onFileLink }: MarkdownProps): import("react").JSX.Element;
|
|
20
|
+
export declare function Markdown({ text, onFileLink, loadImage }: MarkdownProps): import("react").JSX.Element;
|
|
14
21
|
//#endregion
|
|
15
22
|
//# 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":";;;;;;YAoBY,mBAAmB,cAAc;;YAMjC,uBAAuB,iBAAiB;EAAU;EAAa;;iBA0O1D;EACf;EACA,aAAa;;EAEb,YAAY;;;wBAIE,WAAW,MAAM,YAAY,aAAa,gCAAa,IAAA"}
|