@agimon-ai/po-native-components 0.0.0-alpha.21 → 0.0.0-alpha.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -149
- package/README.md +9 -51
- package/dist/components/AgentAvatar.d.mts +19 -0
- package/dist/components/AgentAvatar.d.mts.map +1 -0
- package/dist/components/AgentAvatar.mjs +88 -0
- package/dist/components/AgentAvatar.mjs.map +1 -0
- package/dist/components/AnnotationSurface.d.mts +69 -0
- package/dist/components/AnnotationSurface.d.mts.map +1 -0
- package/dist/components/AnnotationSurface.mjs +431 -0
- package/dist/components/AnnotationSurface.mjs.map +1 -0
- package/dist/components/Badge.d.mts +1 -1
- package/dist/components/Badge.mjs +1 -1
- package/dist/components/Button.mjs +3 -3
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/CodeBlock.d.mts +3 -1
- package/dist/components/CodeBlock.d.mts.map +1 -1
- package/dist/components/CodeBlock.mjs +42 -47
- package/dist/components/CodeBlock.mjs.map +1 -1
- package/dist/components/ComputerRow.d.mts +15 -0
- package/dist/components/ComputerRow.d.mts.map +1 -0
- package/dist/components/ComputerRow.mjs +107 -0
- package/dist/components/ComputerRow.mjs.map +1 -0
- package/dist/components/CopyButton.d.mts +13 -0
- package/dist/components/CopyButton.d.mts.map +1 -0
- package/dist/components/CopyButton.mjs +49 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/CountBadge.d.mts +15 -0
- package/dist/components/CountBadge.d.mts.map +1 -0
- package/dist/components/CountBadge.mjs +49 -0
- package/dist/components/CountBadge.mjs.map +1 -0
- package/dist/components/CtaCard.d.mts +19 -0
- package/dist/components/CtaCard.d.mts.map +1 -0
- package/dist/components/CtaCard.mjs +92 -0
- package/dist/components/CtaCard.mjs.map +1 -0
- package/dist/components/Dialog.d.mts +2 -2
- package/dist/components/Dialog.d.mts.map +1 -1
- package/dist/components/Dialog.mjs +16 -10
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +2 -2
- package/dist/components/DropdownMenu.d.mts +3 -1
- package/dist/components/DropdownMenu.d.mts.map +1 -1
- package/dist/components/DropdownMenu.mjs +21 -14
- package/dist/components/DropdownMenu.mjs.map +1 -1
- package/dist/components/EmptyState.d.mts +31 -3
- package/dist/components/EmptyState.d.mts.map +1 -1
- package/dist/components/EmptyState.mjs +303 -29
- package/dist/components/EmptyState.mjs.map +1 -1
- package/dist/components/FileList.d.mts +48 -0
- package/dist/components/FileList.d.mts.map +1 -0
- package/dist/components/FileList.mjs +737 -0
- package/dist/components/FileList.mjs.map +1 -0
- package/dist/components/FilePreview.d.mts +33 -0
- package/dist/components/FilePreview.d.mts.map +1 -0
- package/dist/components/FilePreview.mjs +102 -0
- package/dist/components/FilePreview.mjs.map +1 -0
- package/dist/components/FileViewer.d.mts +57 -0
- package/dist/components/FileViewer.d.mts.map +1 -0
- package/dist/components/FileViewer.mjs +345 -0
- package/dist/components/FileViewer.mjs.map +1 -0
- package/dist/components/HashlineLines.d.mts +13 -0
- package/dist/components/HashlineLines.d.mts.map +1 -0
- package/dist/components/HashlineLines.mjs +153 -0
- package/dist/components/HashlineLines.mjs.map +1 -0
- package/dist/components/HostFilter.d.mts +17 -0
- package/dist/components/HostFilter.d.mts.map +1 -0
- package/dist/components/HostFilter.mjs +68 -0
- package/dist/components/HostFilter.mjs.map +1 -0
- package/dist/components/HostTag.d.mts +7 -0
- package/dist/components/HostTag.d.mts.map +1 -0
- package/dist/components/HostTag.mjs +48 -0
- package/dist/components/HostTag.mjs.map +1 -0
- package/dist/components/InfoStrip.d.mts +9 -0
- package/dist/components/InfoStrip.d.mts.map +1 -0
- package/dist/components/InfoStrip.mjs +53 -0
- package/dist/components/InfoStrip.mjs.map +1 -0
- package/dist/components/Input.d.mts +3 -1
- package/dist/components/Input.d.mts.map +1 -1
- package/dist/components/Input.mjs +4 -3
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Label.mjs +1 -1
- package/dist/components/LinkText.d.mts +13 -0
- package/dist/components/LinkText.d.mts.map +1 -0
- package/dist/components/LinkText.mjs +32 -0
- package/dist/components/LinkText.mjs.map +1 -0
- package/dist/components/List.d.mts.map +1 -1
- package/dist/components/List.mjs +50 -11
- package/dist/components/List.mjs.map +1 -1
- package/dist/components/LiveDuration.d.mts +30 -0
- package/dist/components/LiveDuration.d.mts.map +1 -0
- package/dist/components/LiveDuration.mjs +67 -0
- package/dist/components/LiveDuration.mjs.map +1 -0
- package/dist/components/LoadingState.d.mts +17 -0
- package/dist/components/LoadingState.d.mts.map +1 -0
- package/dist/components/LoadingState.mjs +90 -0
- package/dist/components/LoadingState.mjs.map +1 -0
- package/dist/components/Markdown.d.mts +24 -2
- package/dist/components/Markdown.d.mts.map +1 -1
- package/dist/components/Markdown.mjs +356 -27
- package/dist/components/Markdown.mjs.map +1 -1
- package/dist/components/MessageItem.d.mts +10 -15
- package/dist/components/MessageItem.d.mts.map +1 -1
- package/dist/components/MessageItem.mjs +94 -68
- package/dist/components/MessageItem.mjs.map +1 -1
- package/dist/components/NativeShellState.d.mts +30 -0
- package/dist/components/NativeShellState.d.mts.map +1 -0
- package/dist/components/NativeShellState.mjs +61 -0
- package/dist/components/NativeShellState.mjs.map +1 -0
- package/dist/components/RailItem.d.mts +13 -0
- package/dist/components/RailItem.d.mts.map +1 -0
- package/dist/components/RailItem.mjs +61 -0
- package/dist/components/RailItem.mjs.map +1 -0
- package/dist/components/ReferenceChip.d.mts +18 -0
- package/dist/components/ReferenceChip.d.mts.map +1 -0
- package/dist/components/ReferenceChip.mjs +38 -0
- package/dist/components/ReferenceChip.mjs.map +1 -0
- package/dist/components/SectionLabel.mjs +1 -1
- package/dist/components/SeekBar.d.mts +17 -0
- package/dist/components/SeekBar.d.mts.map +1 -0
- package/dist/components/SeekBar.mjs +97 -0
- package/dist/components/SeekBar.mjs.map +1 -0
- package/dist/components/Select.d.mts +39 -0
- package/dist/components/Select.d.mts.map +1 -0
- package/dist/components/Select.mjs +288 -0
- package/dist/components/Select.mjs.map +1 -0
- package/dist/components/Sheet.d.mts +17 -2
- package/dist/components/Sheet.d.mts.map +1 -1
- package/dist/components/Sheet.mjs +34 -11
- package/dist/components/Sheet.mjs.map +1 -1
- package/dist/components/SheetFrame.mjs +149 -28
- package/dist/components/SheetFrame.mjs.map +1 -1
- package/dist/components/SheetList.d.mts +14 -0
- package/dist/components/SheetList.d.mts.map +1 -0
- package/dist/components/SheetList.mjs +34 -0
- package/dist/components/SheetList.mjs.map +1 -0
- package/dist/components/ShowMore.d.mts +10 -0
- package/dist/components/ShowMore.d.mts.map +1 -0
- package/dist/components/ShowMore.mjs +44 -0
- package/dist/components/ShowMore.mjs.map +1 -0
- package/dist/components/Spinner.d.mts +1 -1
- package/dist/components/StatusBadge.d.mts +1 -1
- package/dist/components/Switch.d.mts +14 -0
- package/dist/components/Switch.d.mts.map +1 -0
- package/dist/components/Switch.mjs +37 -0
- package/dist/components/Switch.mjs.map +1 -0
- package/dist/components/SyntaxLine.d.mts +19 -0
- package/dist/components/SyntaxLine.d.mts.map +1 -0
- package/dist/components/SyntaxLine.mjs +134 -0
- package/dist/components/SyntaxLine.mjs.map +1 -0
- package/dist/components/Tabs.d.mts.map +1 -1
- package/dist/components/Tabs.mjs +8 -7
- package/dist/components/Tabs.mjs.map +1 -1
- package/dist/components/ToolPathLink.d.mts +10 -0
- package/dist/components/ToolPathLink.d.mts.map +1 -0
- package/dist/components/ToolPathLink.mjs +42 -0
- package/dist/components/ToolPathLink.mjs.map +1 -0
- package/dist/components/ToolResultImage.d.mts +21 -0
- package/dist/components/ToolResultImage.d.mts.map +1 -0
- package/dist/components/ToolResultImage.mjs +60 -0
- package/dist/components/ToolResultImage.mjs.map +1 -0
- package/dist/icons/IconColorContext.d.mts +2 -1
- package/dist/icons/IconColorContext.d.mts.map +1 -1
- package/dist/icons/IconColorContext.mjs.map +1 -1
- package/dist/icons/iconGlyphs.d.mts +132 -0
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +132 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +133 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +35 -2
- package/dist/icons/icons.mjs.map +1 -1
- package/dist/index.d.mts +31 -7
- package/dist/index.mjs +36 -12
- package/dist/lib/fileKindLabel.mjs +17 -0
- package/dist/lib/fileKindLabel.mjs.map +1 -0
- package/dist/lib/fonts.d.mts +3 -1
- package/dist/lib/fonts.d.mts.map +1 -1
- package/dist/lib/fonts.mjs +4 -2
- package/dist/lib/fonts.mjs.map +1 -1
- package/dist/lib/insideSheet.d.mts +10 -0
- package/dist/lib/insideSheet.d.mts.map +1 -0
- package/dist/lib/markdown.mjs +310 -23
- package/dist/lib/markdown.mjs.map +1 -1
- package/dist/lib/reading.mjs +60 -0
- package/dist/lib/reading.mjs.map +1 -0
- package/dist/lib/useControllable.mjs +14 -6
- package/dist/lib/useControllable.mjs.map +1 -1
- package/dist/lib/useReadingPage.mjs +33 -0
- package/dist/lib/useReadingPage.mjs.map +1 -0
- package/dist/po-runtime-identity.json +1 -0
- package/dist/shell.d.mts +6 -0
- package/dist/shell.mjs +7 -0
- package/locales/vi.json +112 -0
- package/locales/zh-CN.json +112 -0
- package/package.json +43 -30
|
@@ -5,10 +5,11 @@ import { CloseIcon } from "../icons/icons.mjs";
|
|
|
5
5
|
import { useControllable } from "../lib/useControllable.mjs";
|
|
6
6
|
import { SheetFrame } from "./SheetFrame.mjs";
|
|
7
7
|
import { View } from "react-native-unistyles/components/native/View";
|
|
8
|
-
import { StyleSheet } from "react-native-unistyles";
|
|
9
8
|
import { Text } from "react-native-unistyles/components/native/Text";
|
|
10
|
-
import {
|
|
9
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
10
|
+
import { createContext, useCallback, useContext, useMemo } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { useT } from "@agimon-ai/po-core/native";
|
|
12
13
|
|
|
13
14
|
//#region src/components/Sheet.tsx
|
|
14
15
|
const SheetContext = createContext({
|
|
@@ -17,11 +18,12 @@ const SheetContext = createContext({
|
|
|
17
18
|
});
|
|
18
19
|
function Sheet({ open, defaultOpen = false, onOpenChange, children }) {
|
|
19
20
|
const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);
|
|
21
|
+
const value = useMemo(() => ({
|
|
22
|
+
open: current,
|
|
23
|
+
setOpen
|
|
24
|
+
}), [current, setOpen]);
|
|
20
25
|
return /* @__PURE__ */ jsx(SheetContext.Provider, {
|
|
21
|
-
value
|
|
22
|
-
open: current,
|
|
23
|
-
setOpen
|
|
24
|
-
},
|
|
26
|
+
value,
|
|
25
27
|
children
|
|
26
28
|
});
|
|
27
29
|
}
|
|
@@ -48,15 +50,36 @@ function SheetClose({ onPress, ...props }) {
|
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
/** The sheet surface. Fields inside it switch to the sheet's own input so the keyboard lifts the sheet. */
|
|
51
|
-
function SheetContent({ children }) {
|
|
53
|
+
function SheetContent({ children, scrollable = true, footer, keep, onDismiss, snapPoints, backdrop, background }) {
|
|
52
54
|
const { open, setOpen } = useContext(SheetContext);
|
|
55
|
+
const value = useMemo(() => ({
|
|
56
|
+
open,
|
|
57
|
+
setOpen
|
|
58
|
+
}), [open, setOpen]);
|
|
59
|
+
const close = useCallback(() => setOpen(false), [setOpen]);
|
|
60
|
+
const pinned = useMemo(() => footer === void 0 ? void 0 : /* @__PURE__ */ jsx(SheetContext.Provider, {
|
|
61
|
+
value,
|
|
62
|
+
children: footer
|
|
63
|
+
}), [footer, value]);
|
|
53
64
|
return /* @__PURE__ */ jsx(SheetFrame, {
|
|
54
65
|
open,
|
|
55
|
-
onClose:
|
|
56
|
-
|
|
66
|
+
onClose: close,
|
|
67
|
+
scrollable,
|
|
68
|
+
keep,
|
|
69
|
+
onDismiss,
|
|
70
|
+
snapPoints,
|
|
71
|
+
backdrop,
|
|
72
|
+
background,
|
|
73
|
+
...pinned === void 0 ? {} : { footer: pinned },
|
|
74
|
+
children: /* @__PURE__ */ jsx(SheetContext.Provider, {
|
|
75
|
+
value,
|
|
76
|
+
children
|
|
77
|
+
})
|
|
57
78
|
});
|
|
58
79
|
}
|
|
59
|
-
function SheetHeader({ dismissible = true, closeLabel
|
|
80
|
+
function SheetHeader({ dismissible = true, closeLabel: closeLabelProp, style, children, ...props }) {
|
|
81
|
+
const t = useT();
|
|
82
|
+
const closeLabel = closeLabelProp ?? t("nativeComponents.dialog.close", "close");
|
|
60
83
|
const { setOpen } = useContext(SheetContext);
|
|
61
84
|
return /* @__PURE__ */ jsxs(View, {
|
|
62
85
|
style: [styles.header, style],
|
|
@@ -162,5 +185,5 @@ const styles = StyleSheet.create((theme) => ({
|
|
|
162
185
|
}));
|
|
163
186
|
|
|
164
187
|
//#endregion
|
|
165
|
-
export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
|
188
|
+
export { Sheet, SheetBody, SheetClose, SheetContent, SheetContext, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger };
|
|
166
189
|
//# sourceMappingURL=Sheet.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.mjs","names":["createContext","ReactNode","useContext","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","CloseIcon","fontOf","useControllable","wrapText","Button","ButtonProps","SheetFrame","SheetState","open","setOpen","SheetContext","undefined","SheetProps","defaultOpen","onOpenChange","children","Sheet","current","SheetTrigger","onPress","props","event","SheetClose","SheetContentProps","SheetContent","SheetPartProps","Omit","style","SheetHeaderProps","dismissible","closeLabel","SheetHeader","styles","header","close","SheetTitle","title","SheetDescription","description","SheetBody","body","SheetFooter","footer","hint","create","theme","flexDirection","alignItems","gap","spacing","minWidth","height","borderBottomWidth","borderBottomColor","colors","border","paddingHorizontal","uni__dependencies","marginLeft","flexShrink","color","hi","fontFamily","sans","fontSize","lg","lineHeight","fontWeight","semibold","dim","sm","lineHeightRelaxed","paddingVertical","flexWrap","justifyContent","minHeight","borderTopWidth","borderTopColor","backgroundColor","deep","faint"],"sources":["../../src/components/Sheet.tsx"],"sourcesContent":["import { createContext, type ReactNode, useContext } from 'react';\nimport { type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { CloseIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button, type ButtonProps } from './Button';\nimport { SheetFrame } from './SheetFrame';\n\n/*\n * The web Sheet as a bottom sheet: the native shape for a detail view or a\n * short form over what the reader was looking at. `side` and `width` are\n * dropped; a phone sheet rises from the bottom edge and takes the width.\n */\n\ninterface SheetState {\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nconst SheetContext = createContext<SheetState>({ open: false, setOpen: () => undefined });\n\nexport interface SheetProps {\n /** Controlled mode; pair with onOpenChange. Omit it and the sheet keeps its own state. */\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\nexport function Sheet({ open, defaultOpen = false, onOpenChange, children }: SheetProps) {\n const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);\n return <SheetContext.Provider value={{ open: current, setOpen }}>{children}</SheetContext.Provider>;\n}\n\n/** A Button that opens the enclosing sheet. */\nexport function SheetTrigger({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(true);\n }}\n {...props}\n />\n );\n}\n\n/** A Button that closes the enclosing sheet. */\nexport function SheetClose({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(false);\n }}\n {...props}\n />\n );\n}\n\nexport interface SheetContentProps {\n children?: ReactNode;\n}\n\n/** The sheet surface. Fields inside it switch to the sheet's own input so the keyboard lifts the sheet. */\nexport function SheetContent({ children }: SheetContentProps) {\n const { open, setOpen } = useContext(SheetContext);\n return (\n <SheetFrame open={open} onClose={() => setOpen(false)}>\n {children}\n </SheetFrame>\n );\n}\n\nexport interface SheetPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\nexport interface SheetHeaderProps extends SheetPartProps {\n /** Show the close control at the right of the strip. On by default: a sheet is dismissed, not answered. */\n dismissible?: boolean;\n /** What the close control announces. */\n closeLabel?: string;\n}\n\nexport function SheetHeader({ dismissible = true, closeLabel = 'close', style, children, ...props }: SheetHeaderProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <View style={[styles.header, style]} {...props}>\n {children}\n {dismissible ? (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n accessibilityLabel={closeLabel}\n onPress={() => setOpen(false)}\n style={styles.close}\n >\n <CloseIcon size={12} color=\"faint\" />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport function SheetTitle({ style, ...props }: TextProps) {\n return <Text accessibilityRole=\"header\" numberOfLines={1} style={[styles.title, style]} {...props} />;\n}\n\nexport function SheetDescription({ style, ...props }: TextProps) {\n return <Text style={[styles.description, style]} {...props} />;\n}\n\n/** The scrolling middle; the sheet itself scrolls, so this only spaces its children. */\nexport function SheetBody({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.description)}\n </View>\n );\n}\n\nexport function SheetFooter({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.footer, style]} {...props}>\n {wrapText(children, styles.hint)}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2.5),\n minWidth: 0,\n height: theme.spacing(11),\n borderBottomWidth: 1,\n borderBottomColor: theme.colors.border,\n paddingHorizontal: theme.spacing(4),\n },\n close: { marginLeft: 'auto' },\n title: {\n flexShrink: 1,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n fontWeight: theme.fontWeight.semibold,\n },\n description: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n body: {\n gap: theme.spacing(3),\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n footer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: theme.spacing(2),\n minHeight: 34,\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.deep,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(1.5),\n },\n hint: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize['2xs'],\n lineHeight: theme.lineHeight['2xs'],\n },\n}));\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAMkB,eAAelB,cAA0B;CAAEgB,MAAM;CAAOC,eAAeE;AAAU,CAAC;AAUxF,SAAgBK,MAAM,EAAER,MAAMK,cAAc,OAAOC,cAAcC,YAAwB;CACvF,MAAM,CAACE,SAASR,WAAWP,gBAAgBM,MAAMK,aAAaC,YAAY;CAC1E,OAAO,oBAAC,aAAa,UAAd;EAAuB,OAAO;GAAEN,MAAMS;GAASR;EAAQ;EAAIM;CAAgC;AACpG;;AAGA,SAAgBG,aAAa,EAAEC,SAAS,GAAGC,SAAsB;CAC/D,MAAM,EAAEX,YAAYf,WAAWgB,YAAY;CAC3C,OACE,oBAAC,QAAD;EACE,UAAUW,UAAU;GAClBF,UAAUE,KAAK;GACfZ,QAAQ,IAAI;EACd;EACA,GAAIW;CAAM;AAGhB;;A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gBAAgBhC,MAAMS,OAAO;EAC7BwB,iBAAiBjC,MAAMS,OAAOyB;EAC9BvB,mBAAmBX,MAAMI,QAAQ,CAAC;EAClCuB,iBAAiB3B,MAAMI,QAAQ,GAAG;EAACQ,mBAAA,CAAA,CAAA;CACrC;CACAd,MAAM;EACJiB,OAAOf,MAAMS,OAAO0B;EACpBlB,YAAY7D,OAAO4C,MAAMiB,WAAWC,IAAI;EACxCC,UAAUnB,MAAMmB,SAAS;EACzBE,YAAYrB,MAAMqB,WAAW;EAAMT,mBAAA,CAAA,CAAA;CACrC;AACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"Sheet.mjs","names":["useT","NativeColorToken","createContext","ReactNode","useCallback","useContext","useMemo","StyleProp","TextProps","ViewProps","ViewStyle","StyleSheet","CloseIcon","fontOf","useControllable","wrapText","Button","ButtonProps","SheetFrame","SheetState","open","setOpen","SheetContext","undefined","SheetProps","defaultOpen","onOpenChange","children","Sheet","current","value","SheetTrigger","onPress","props","event","SheetClose","SheetContentProps","footer","scrollable","keep","onDismiss","snapPoints","backdrop","background","SheetContent","close","pinned","SheetPartProps","Omit","style","SheetHeaderProps","dismissible","closeLabel","SheetHeader","closeLabelProp","t","styles","header","SheetTitle","title","SheetDescription","description","SheetBody","body","SheetFooter","hint","create","theme","flexDirection","alignItems","gap","spacing","minWidth","height","borderBottomWidth","borderBottomColor","colors","border","paddingHorizontal","uni__dependencies","marginLeft","flexShrink","color","hi","fontFamily","sans","fontSize","lg","lineHeight","fontWeight","semibold","dim","sm","lineHeightRelaxed","paddingVertical","flexWrap","justifyContent","minHeight","borderTopWidth","borderTopColor","backgroundColor","deep","faint"],"sources":["../../src/components/Sheet.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport type { NativeColorToken } from '@agimon-ai/po-web-components/nativeTheme';\nimport { createContext, type ReactNode, useCallback, useContext, useMemo } from 'react';\nimport { type StyleProp, Text, type TextProps, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { CloseIcon } from '../icons/icons';\nimport { fontOf } from '../lib/fonts';\nimport { useControllable } from '../lib/useControllable';\nimport { wrapText } from '../lib/wrapText';\nimport { Button, type ButtonProps } from './Button';\nimport { SheetFrame } from './SheetFrame';\n\n/*\n * The web Sheet as a bottom sheet: the native shape for a detail view or a\n * short form over what the reader was looking at. `side` and `width` are\n * dropped; a phone sheet rises from the bottom edge and takes the width.\n */\n\ninterface SheetState {\n open: boolean;\n setOpen: (open: boolean) => void;\n}\n\nexport const SheetContext = createContext<SheetState>({ open: false, setOpen: () => undefined });\n\nexport interface SheetProps {\n /** Controlled mode; pair with onOpenChange. Omit it and the sheet keeps its own state. */\n open?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n children?: ReactNode;\n}\n\nexport function Sheet({ open, defaultOpen = false, onOpenChange, children }: SheetProps) {\n const [current, setOpen] = useControllable(open, defaultOpen, onOpenChange);\n const value = useMemo(() => ({ open: current, setOpen }), [current, setOpen]);\n return <SheetContext.Provider value={value}>{children}</SheetContext.Provider>;\n}\n\n/** A Button that opens the enclosing sheet. */\nexport function SheetTrigger({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(true);\n }}\n {...props}\n />\n );\n}\n\n/** A Button that closes the enclosing sheet. */\nexport function SheetClose({ onPress, ...props }: ButtonProps) {\n const { setOpen } = useContext(SheetContext);\n return (\n <Button\n onPress={(event) => {\n onPress?.(event);\n setOpen(false);\n }}\n {...props}\n />\n );\n}\n\nexport interface SheetContentProps {\n children?: ReactNode;\n /** Pinned actions outside the scrolling body. The footer carries the bottom safe area. */\n footer?: ReactNode;\n /** False when an embedded SheetList owns vertical scrolling. */\n scrollable?: boolean;\n /** The sheet holds unsaved work: a prompt arriving in the conversation leaves it open with a note. */\n keep?: boolean;\n /** Runs after the native modal is dismissed, including a caller-initiated close. */\n onDismiss?: () => void;\n /** Fixed heights such as `['58%']`; given, the sheet stops sizing itself to its content. */\n snapPoints?: (string | number)[];\n /** The dimmed overlay that closes the sheet on tap. Off leaves what is behind visible and usable. */\n backdrop?: boolean;\n /** The sheet and footer surface colour. */\n background?: NativeColorToken;\n}\n\n/** The sheet surface. Fields inside it switch to the sheet's own input so the keyboard lifts the sheet. */\nexport function SheetContent({\n children,\n scrollable = true,\n footer,\n keep,\n onDismiss,\n snapPoints,\n backdrop,\n background,\n}: SheetContentProps) {\n const { open, setOpen } = useContext(SheetContext);\n const value = useMemo(() => ({ open, setOpen }), [open, setOpen]);\n const close = useCallback(() => setOpen(false), [setOpen]);\n const pinned = useMemo(\n () => (footer === undefined ? undefined : <SheetContext.Provider value={value}>{footer}</SheetContext.Provider>),\n [footer, value],\n );\n return (\n <SheetFrame\n open={open}\n onClose={close}\n scrollable={scrollable}\n keep={keep}\n onDismiss={onDismiss}\n snapPoints={snapPoints}\n backdrop={backdrop}\n background={background}\n {...(pinned === undefined ? {} : { footer: pinned })}\n >\n <SheetContext.Provider value={value}>{children}</SheetContext.Provider>\n </SheetFrame>\n );\n}\n\nexport interface SheetPartProps extends Omit<ViewProps, 'children' | 'style'> {\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\nexport interface SheetHeaderProps extends SheetPartProps {\n /** Show the close control at the right of the strip. On by default: a sheet is dismissed, not answered. */\n dismissible?: boolean;\n /** What the close control announces. */\n closeLabel?: string;\n}\n\nexport function SheetHeader({\n dismissible = true,\n closeLabel: closeLabelProp,\n style,\n children,\n ...props\n}: SheetHeaderProps) {\n const t = useT();\n const closeLabel = closeLabelProp ?? t('nativeComponents.dialog.close', 'close');\n const { setOpen } = useContext(SheetContext);\n return (\n <View style={[styles.header, style]} {...props}>\n {children}\n {dismissible ? (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n accessibilityLabel={closeLabel}\n onPress={() => setOpen(false)}\n style={styles.close}\n >\n <CloseIcon size={12} color=\"faint\" />\n </Button>\n ) : null}\n </View>\n );\n}\n\nexport function SheetTitle({ style, ...props }: TextProps) {\n return <Text accessibilityRole=\"header\" numberOfLines={1} style={[styles.title, style]} {...props} />;\n}\n\nexport function SheetDescription({ style, ...props }: TextProps) {\n return <Text style={[styles.description, style]} {...props} />;\n}\n\n/** The scrolling middle; the sheet itself scrolls, so this only spaces its children. */\nexport function SheetBody({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.body, style]} {...props}>\n {wrapText(children, styles.description)}\n </View>\n );\n}\n\nexport function SheetFooter({ style, children, ...props }: SheetPartProps) {\n return (\n <View style={[styles.footer, style]} {...props}>\n {wrapText(children, styles.hint)}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(2.5),\n minWidth: 0,\n height: theme.spacing(11),\n borderBottomWidth: 1,\n borderBottomColor: theme.colors.border,\n paddingHorizontal: theme.spacing(4),\n },\n close: { marginLeft: 'auto' },\n title: {\n flexShrink: 1,\n color: theme.colors.hi,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.lg,\n lineHeight: theme.lineHeight.lg,\n fontWeight: theme.fontWeight.semibold,\n },\n description: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n body: {\n gap: theme.spacing(3),\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(3),\n },\n footer: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: theme.spacing(2),\n minHeight: 34,\n borderTopWidth: 1,\n borderTopColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.deep,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(1.5),\n },\n hint: {\n color: theme.colors.faint,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize['2xs'],\n lineHeight: theme.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AAMI,QAAQ,CAAC;EAClCuB,iBAAiB3B,MAAMI,QAAQ,GAAG;EAACQ,mBAAA,CAAA,CAAA;CACrC;CACAd,MAAM;EACJiB,OAAOf,MAAMS,OAAO0B;EACpBlB,YAAYvE,OAAOsD,MAAMiB,WAAWC,IAAI;EACxCC,UAAUnB,MAAMmB,SAAS;EACzBE,YAAYrB,MAAMqB,WAAW;EAAMT,mBAAA,CAAA,CAAA;CACrC;AACF,EAAE"}
|
|
@@ -1,45 +1,104 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
3
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
3
4
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
4
|
-
import { BackHandler } from "react-native";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { BackHandler, Keyboard } from "react-native";
|
|
6
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
7
|
+
import { useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
8
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { InsideSheetContext, dismissSheet, registerSheet, unregisterSheet } from "@agimon-ai/po-native-components/shell";
|
|
10
|
+
import { BottomSheetBackdrop, BottomSheetFooter, BottomSheetModal, BottomSheetScrollView } from "@gorhom/bottom-sheet";
|
|
8
11
|
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
9
12
|
|
|
10
13
|
//#region src/components/SheetFrame.tsx
|
|
11
14
|
/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */
|
|
12
15
|
const BACKDROP_ALPHA_PERCENT = 70;
|
|
16
|
+
function footerHolder(initial) {
|
|
17
|
+
let footer = initial;
|
|
18
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
19
|
+
return {
|
|
20
|
+
get: () => footer,
|
|
21
|
+
set: (next) => {
|
|
22
|
+
if (next === footer) return;
|
|
23
|
+
footer = next;
|
|
24
|
+
for (const listener of listeners) listener();
|
|
25
|
+
},
|
|
26
|
+
subscribe: (listener) => {
|
|
27
|
+
listeners.add(listener);
|
|
28
|
+
return () => listeners.delete(listener);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function FooterBody({ holder }) {
|
|
33
|
+
const footer = useSyncExternalStore(holder.subscribe, holder.get);
|
|
34
|
+
return /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
35
|
+
value: true,
|
|
36
|
+
children: footer
|
|
37
|
+
});
|
|
38
|
+
}
|
|
13
39
|
/**
|
|
14
40
|
* The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized
|
|
15
41
|
* to its content, closed by dragging down, tapping the backdrop or Android
|
|
16
42
|
* back, clear of the safe area and lifted by the keyboard. Private: the public
|
|
17
43
|
* parts keep bottom-sheet types out of the package API.
|
|
18
44
|
*/
|
|
19
|
-
function SheetFrame({ open, onClose, children }) {
|
|
45
|
+
function SheetFrame({ open, onClose, onDismiss, children, scrollable = true, footer, keep = false, snapPoints, backdrop = true, background = "rail" }) {
|
|
20
46
|
const { theme } = useUnistyles();
|
|
21
47
|
const insets = useContext(SafeAreaInsetsContext);
|
|
22
48
|
const sheet = useRef(null);
|
|
23
49
|
const openRef = useRef(open);
|
|
24
50
|
const presented = useRef(false);
|
|
51
|
+
const dismissing = useRef(false);
|
|
52
|
+
const [footerHeight, setFooterHeight] = useState(0);
|
|
53
|
+
const [note, setNote] = useState();
|
|
54
|
+
const latest = useRef({
|
|
55
|
+
keep,
|
|
56
|
+
onClose,
|
|
57
|
+
onDismiss
|
|
58
|
+
});
|
|
59
|
+
latest.current = {
|
|
60
|
+
keep,
|
|
61
|
+
onClose,
|
|
62
|
+
onDismiss
|
|
63
|
+
};
|
|
64
|
+
const entry = useRef({
|
|
65
|
+
keep: () => latest.current.keep,
|
|
66
|
+
close: () => latest.current.onClose(),
|
|
67
|
+
setNote
|
|
68
|
+
});
|
|
69
|
+
const footers = useRef(void 0);
|
|
70
|
+
footers.current ??= footerHolder(footer);
|
|
71
|
+
const holder = footers.current;
|
|
72
|
+
useLayoutEffect(() => holder.set(footer), [holder, footer]);
|
|
25
73
|
useEffect(() => {
|
|
26
74
|
openRef.current = open;
|
|
27
|
-
if (open) {
|
|
75
|
+
if (open && !dismissing.current) {
|
|
28
76
|
presented.current = true;
|
|
77
|
+
registerSheet(entry.current);
|
|
78
|
+
Keyboard.dismiss();
|
|
29
79
|
sheet.current?.present();
|
|
30
|
-
} else if (
|
|
31
|
-
|
|
32
|
-
|
|
80
|
+
} else if (!open) {
|
|
81
|
+
unregisterSheet(entry.current);
|
|
82
|
+
setNote(void 0);
|
|
83
|
+
if (presented.current && !dismissing.current) {
|
|
84
|
+
dismissing.current = true;
|
|
85
|
+
sheet.current?.dismiss();
|
|
86
|
+
}
|
|
33
87
|
}
|
|
34
88
|
}, [open]);
|
|
89
|
+
useEffect(() => () => {
|
|
90
|
+
openRef.current = false;
|
|
91
|
+
unregisterSheet(entry.current);
|
|
92
|
+
dismissSheet?.(entry.current);
|
|
93
|
+
}, []);
|
|
35
94
|
useEffect(() => {
|
|
36
95
|
if (!open) return void 0;
|
|
37
96
|
const subscription = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
38
|
-
onClose();
|
|
97
|
+
latest.current.onClose();
|
|
39
98
|
return true;
|
|
40
99
|
});
|
|
41
100
|
return () => subscription.remove();
|
|
42
|
-
}, [open
|
|
101
|
+
}, [open]);
|
|
43
102
|
const backdropColor = withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT);
|
|
44
103
|
const renderBackdrop = useCallback((props) => /* @__PURE__ */ jsx(BottomSheetBackdrop, {
|
|
45
104
|
...props,
|
|
@@ -49,35 +108,97 @@ function SheetFrame({ open, onClose, children }) {
|
|
|
49
108
|
pressBehavior: "close",
|
|
50
109
|
style: [props.style, { backgroundColor: backdropColor }]
|
|
51
110
|
}), [backdropColor]);
|
|
111
|
+
const footerInset = insets?.bottom ?? 0;
|
|
112
|
+
const surface = theme.colors[background];
|
|
113
|
+
const renderFooter = useCallback((props) => /* @__PURE__ */ jsx(BottomSheetFooter, {
|
|
114
|
+
...props,
|
|
115
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
116
|
+
onLayout: (event) => setFooterHeight(event.nativeEvent.layout.height),
|
|
117
|
+
style: {
|
|
118
|
+
paddingBottom: footerInset,
|
|
119
|
+
backgroundColor: surface
|
|
120
|
+
},
|
|
121
|
+
children: /* @__PURE__ */ jsx(FooterBody, { holder })
|
|
122
|
+
})
|
|
123
|
+
}), [
|
|
124
|
+
holder,
|
|
125
|
+
footerInset,
|
|
126
|
+
surface
|
|
127
|
+
]);
|
|
128
|
+
const backgroundStyle = useMemo(() => ({
|
|
129
|
+
backgroundColor: surface,
|
|
130
|
+
borderRadius: theme.borderRadius.lg
|
|
131
|
+
}), [surface, theme.borderRadius.lg]);
|
|
132
|
+
const handleIndicatorStyle = useMemo(() => ({ backgroundColor: theme.colors.border }), [theme.colors.border]);
|
|
133
|
+
const onChange = useCallback((index) => {
|
|
134
|
+
if (index >= 0 && dismissing.current) sheet.current?.dismiss();
|
|
135
|
+
}, []);
|
|
136
|
+
const onSheetDismiss = useCallback(() => {
|
|
137
|
+
const reopen = dismissing.current && openRef.current;
|
|
138
|
+
dismissing.current = false;
|
|
139
|
+
presented.current = false;
|
|
140
|
+
dismissSheet?.(entry.current);
|
|
141
|
+
if (reopen) {
|
|
142
|
+
presented.current = true;
|
|
143
|
+
registerSheet(entry.current);
|
|
144
|
+
sheet.current?.present();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (openRef.current) latest.current.onClose();
|
|
148
|
+
latest.current.onDismiss?.();
|
|
149
|
+
}, []);
|
|
52
150
|
return /* @__PURE__ */ jsx(BottomSheetModal, {
|
|
53
151
|
ref: sheet,
|
|
152
|
+
accessible: false,
|
|
54
153
|
stackBehavior: "push",
|
|
55
154
|
enablePanDownToClose: true,
|
|
56
155
|
topInset: insets?.top ?? 0,
|
|
57
156
|
keyboardBehavior: "interactive",
|
|
58
157
|
keyboardBlurBehavior: "restore",
|
|
59
158
|
android_keyboardInputMode: "adjustResize",
|
|
60
|
-
backdropComponent: renderBackdrop,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
159
|
+
...backdrop ? { backdropComponent: renderBackdrop } : {},
|
|
160
|
+
...snapPoints === void 0 ? {} : {
|
|
161
|
+
snapPoints,
|
|
162
|
+
enableDynamicSizing: false
|
|
64
163
|
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
children: /* @__PURE__ */
|
|
164
|
+
...footer === void 0 ? {} : { footerComponent: renderFooter },
|
|
165
|
+
backgroundStyle,
|
|
166
|
+
handleIndicatorStyle,
|
|
167
|
+
onChange,
|
|
168
|
+
onDismiss: onSheetDismiss,
|
|
169
|
+
children: scrollable ? /* @__PURE__ */ jsxs(BottomSheetScrollView, {
|
|
71
170
|
keyboardShouldPersistTaps: "handled",
|
|
72
|
-
contentContainerStyle: [styles.content, { paddingBottom: insets?.bottom ?? 0 }],
|
|
73
|
-
children: /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
171
|
+
contentContainerStyle: [styles.content, { paddingBottom: footer === void 0 ? insets?.bottom ?? 0 : footerHeight }],
|
|
172
|
+
children: [note ? /* @__PURE__ */ jsx(SheetNote, { note }) : null, /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
74
173
|
value: true,
|
|
75
174
|
children
|
|
76
|
-
})
|
|
77
|
-
})
|
|
175
|
+
})]
|
|
176
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [note ? /* @__PURE__ */ jsx(SheetNote, { note }) : null, /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
|
|
177
|
+
value: true,
|
|
178
|
+
children
|
|
179
|
+
})] })
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/** A gentle rose line: the person is asked something below, never told to hurry. */
|
|
183
|
+
function SheetNote({ note }) {
|
|
184
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
185
|
+
style: styles.note,
|
|
186
|
+
accessibilityRole: "alert",
|
|
187
|
+
children: note
|
|
78
188
|
});
|
|
79
189
|
}
|
|
80
|
-
const styles = StyleSheet.create(
|
|
190
|
+
const styles = StyleSheet.create((theme) => ({
|
|
191
|
+
content: { flexGrow: 1 },
|
|
192
|
+
note: {
|
|
193
|
+
marginHorizontal: theme.spacing(4),
|
|
194
|
+
marginBottom: theme.spacing(2),
|
|
195
|
+
color: theme.colors.magenta,
|
|
196
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
197
|
+
fontSize: theme.fontSize.sm,
|
|
198
|
+
lineHeight: theme.lineHeight.sm,
|
|
199
|
+
uni__dependencies: [0]
|
|
200
|
+
}
|
|
201
|
+
}));
|
|
81
202
|
|
|
82
203
|
//#endregion
|
|
83
204
|
export { SheetFrame };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SheetFrame.mjs","names":["withAlpha","BottomSheetBackdrop","BottomSheetBackdropProps","BottomSheetModal","BottomSheetScrollView","ReactNode","useCallback","useContext","useEffect","useRef","BackHandler","SafeAreaInsetsContext","StyleSheet","useUnistyles","InsideSheetContext","BACKDROP_ALPHA_PERCENT","SheetFrameProps","open","onClose","children","SheetFrame","theme","insets","sheet","openRef","presented","current","present","dismiss","undefined","subscription","addEventListener","remove","backdropColor","colors","deep","renderBackdrop","props","style","backgroundColor","top","rail","borderRadius","lg","border","styles","content","paddingBottom","bottom","create","flexGrow"],"sources":["../../src/components/SheetFrame.tsx"],"sourcesContent":["import { withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport {\n BottomSheetBackdrop,\n type BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport { type ReactNode, useCallback, useContext, useEffect, useRef } from 'react';\nimport { BackHandler } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { InsideSheetContext } from '../lib/insideSheet';\n\n/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n\nexport interface SheetFrameProps {\n open: boolean;\n /** The sheet asked to close: a drag down, a backdrop tap or Android back. */\n onClose: () => void;\n children?: ReactNode;\n}\n\n/**\n * The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized\n * to its content, closed by dragging down, tapping the backdrop or Android\n * back, clear of the safe area and lifted by the keyboard. Private: the public\n * parts keep bottom-sheet types out of the package API.\n */\nexport function SheetFrame({ open, onClose, children }: SheetFrameProps) {\n const { theme } = useUnistyles();\n const insets = useContext(SafeAreaInsetsContext);\n const sheet = useRef<BottomSheetModal>(null);\n const openRef = useRef(open);\n const presented = useRef(false);\n\n useEffect(() => {\n openRef.current = open;\n if (open) {\n presented.current = true;\n sheet.current?.present();\n } else if (presented.current) {\n // Only a presented sheet is dismissed. Dismissing one that never opened leaves bottom-sheet's\n // modal stuck in its dismissing status, and the next present() then never draws.\n presented.current = false;\n sheet.current?.dismiss();\n }\n }, [open]);\n\n useEffect(() => {\n if (!open) return undefined;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n onClose();\n return true;\n });\n return () => subscription.remove();\n }, [open, onClose]);\n\n const backdropColor = withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT);\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={1}\n pressBehavior=\"close\"\n style={[props.style, { backgroundColor: backdropColor }]}\n />\n ),\n [backdropColor],\n );\n\n return (\n <BottomSheetModal\n ref={sheet}\n stackBehavior=\"push\"\n enablePanDownToClose\n topInset={insets?.top ?? 0}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n android_keyboardInputMode=\"adjustResize\"\n backdropComponent={renderBackdrop}\n backgroundStyle={{ backgroundColor: theme.colors.rail, borderRadius: theme.borderRadius.lg }}\n handleIndicatorStyle={{ backgroundColor: theme.colors.border }}\n // A sheet the caller closed is already shut; only a close the sheet started is reported.\n onDismiss={() => {\n // Already shut, so the close the parent answers with must not dismiss it a second time.\n presented.current = false;\n if (openRef.current) onClose();\n }}\n >\n <BottomSheetScrollView\n keyboardShouldPersistTaps=\"handled\"\n contentContainerStyle={[styles.content, { paddingBottom: insets?.bottom ?? 0 }]}\n >\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </BottomSheetScrollView>\n </BottomSheetModal>\n );\n}\n\nconst styles = StyleSheet.create({ content: { flexGrow: 1 } });\n"],"mappings":";;;;;;;;;;;AAeA,MAAMe,yBAAyB;;;;;;;AAe/B,SAAgBK,WAAW,EAAEH,MAAMC,SAASC,YAA6B;CACvE,MAAM,EAAEE,UAAUR,aAAa;CAC/B,MAAMS,SAASf,WAAWI,qBAAqB;CAC/C,MAAMY,QAAQd,OAAyB,IAAI;CAC3C,MAAMe,UAAUf,OAAOQ,IAAI;CAC3B,MAAMQ,YAAYhB,OAAO,KAAK;CAE9BD,gBAAgB;EACdgB,QAAQE,UAAUT;EAClB,IAAIA,MAAM;GACRQ,UAAUC,UAAU;GACpBH,MAAMG,SAASC,QAAQ;EACzB,OAAO,IAAIF,UAAUC,SAAS;GAG5BD,UAAUC,UAAU;GACpBH,MAAMG,SAASE,QAAQ;EACzB;CACF,GAAG,CAACX,IAAI,CAAC;CAETT,gBAAgB;EACd,IAAI,CAACS,MAAM,OAAOY;EAClB,MAAMC,eAAepB,YAAYqB,iBAAiB,2BAA2B;GAC3Eb,QAAQ;GACR,OAAO;EACT,CAAC;EACD,aAAaY,aAAaE,OAAO;CACnC,GAAG,CAACf,MAAMC,OAAO,CAAC;CAElB,MAAMe,gBAAgBjC,UAAUqB,MAAMa,OAAOC,MAAMpB,sBAAsB;CACzE,MAAMqB,iBAAiB9B,aACpB+B,UACC,oBAAC,qBAAD;EACE,GAAIA;EACJ,gBAAgB;EAChB,mBAAmB;EACnB,SAAS;EACT,eAAc;EACd,OAAO,CAACA,MAAMC,OAAO,EAAEC,iBAAiBN,cAAc,CAAC;CAAE,IAG7D,CAACA,aAAa,CAChB;CAEA,OACE,oBAAC,kBAAD;EACE,KAAKV;EACL,eAAc;EACd;EACA,UAAUD,QAAQkB,OAAO;EACzB,kBAAiB;EACjB,sBAAqB;EACrB,2BAA0B;EAC1B,mBAAmBJ;EACnB,iBAAiB;GAAEG,iBAAiBlB,MAAMa,OAAOO;GAAMC,cAAcrB,MAAMqB,aAAaC;EAAG;EAC3F,sBAAsB,EAAEJ,iBAAiBlB,MAAMa,OAAOU,OAAO;EAE7D,iBAAiB;GAEfnB,UAAUC,UAAU;GACpB,IAAIF,QAAQE,SAASR,QAAQ;EAC/B;YAEA,oBAAC,uBAAD;GACE,2BAA0B;GAC1B,uBAAuB,CAAC2B,OAAOC,SAAS,EAAEC,eAAezB,QAAQ0B,UAAU,EAAE,CAAC;aAE9E,oBAAC,mBAAmB,UAApB;IAA6B;IAAO7B;GAAsC;EACrD;CACP;AAEtB;AAEA,MAAM0B,SAASjC,WAAWqC,OAAO,EAAEH,SAAS,EAAEI,UAAU,EAAE,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"SheetFrame.mjs","names":["dismissSheet","InsideSheetContext","OpenSheet","registerSheet","unregisterSheet","NativeColorToken","withAlpha","BottomSheetBackdrop","BottomSheetBackdropProps","BottomSheetModal","BottomSheetFooter","BottomSheetFooterProps","BottomSheetScrollView","ReactNode","useCallback","useContext","useEffect","useLayoutEffect","useMemo","useRef","useState","useSyncExternalStore","BackHandler","Keyboard","SafeAreaInsetsContext","StyleSheet","useUnistyles","fontOf","BACKDROP_ALPHA_PERCENT","SheetFrameProps","open","onClose","onDismiss","children","footer","scrollable","keep","snapPoints","backdrop","background","sheetsYielded","yieldSheets","FooterHolder","get","set","subscribe","listener","footerHolder","initial","listeners","Set","next","add","delete","FooterBody","holder","SheetFrame","theme","insets","sheet","openRef","presented","dismissing","footerHeight","setFooterHeight","note","setNote","latest","current","entry","close","footers","undefined","dismiss","present","subscription","addEventListener","remove","backdropColor","colors","deep","renderBackdrop","props","style","backgroundColor","footerInset","bottom","surface","renderFooter","event","nativeEvent","layout","height","paddingBottom","backgroundStyle","borderRadius","lg","handleIndicatorStyle","border","onChange","index","onSheetDismiss","reopen","top","backdropComponent","enableDynamicSizing","footerComponent","styles","content","SheetNote","create","flexGrow","marginHorizontal","spacing","marginBottom","color","magenta","fontFamily","sans","fontSize","sm","lineHeight","uni__dependencies"],"sources":["../../src/components/SheetFrame.tsx"],"sourcesContent":["import {\n dismissSheet,\n InsideSheetContext,\n type OpenSheet,\n registerSheet,\n unregisterSheet,\n} from '@agimon-ai/po-native-components/shell';\nimport { type NativeColorToken, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport {\n BottomSheetBackdrop,\n type BottomSheetBackdropProps,\n BottomSheetModal,\n BottomSheetFooter,\n type BottomSheetFooterProps,\n BottomSheetScrollView,\n} from '@gorhom/bottom-sheet';\nimport {\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n useSyncExternalStore,\n} from 'react';\nimport { BackHandler, Keyboard, Text, View } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\n\n/** `bg-po-deep/70`, the overlay every web sheet and dialog draws. */\nconst BACKDROP_ALPHA_PERCENT = 70;\n\nexport interface SheetFrameProps {\n open: boolean;\n /** The sheet asked to close: a drag down, a backdrop tap or Android back. */\n onClose: () => void;\n onDismiss?: () => void;\n children?: ReactNode;\n footer?: ReactNode;\n /** False when the content supplies its own Gorhom virtualized scroll owner. */\n scrollable?: boolean;\n /** The sheet holds work not yet saved, so a prompt arriving leaves it open with a note instead of closing it. */\n keep?: boolean;\n /** Fixed heights such as `['58%']`; given, the sheet stops sizing itself to its content. */\n snapPoints?: (string | number)[];\n /** The dimmed overlay that closes the sheet on tap. Off leaves what is behind visible and usable. */\n backdrop?: boolean;\n /** The sheet and footer surface colour. */\n background?: NativeColorToken;\n}\n\nexport { sheetsYielded, yieldSheets } from '@agimon-ai/po-native-components/shell';\n\n/** The latest footer, read by a footer component whose identity never changes while the sheet lives. */\ninterface FooterHolder {\n get: () => ReactNode;\n set: (footer: ReactNode) => void;\n subscribe: (listener: () => void) => () => void;\n}\n\nfunction footerHolder(initial: ReactNode): FooterHolder {\n let footer = initial;\n const listeners = new Set<() => void>();\n return {\n get: () => footer,\n set: (next) => {\n if (next === footer) return;\n footer = next;\n for (const listener of listeners) listener();\n },\n subscribe: (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\nfunction FooterBody({ holder }: { holder: FooterHolder }) {\n const footer = useSyncExternalStore(holder.subscribe, holder.get);\n return <InsideSheetContext.Provider value>{footer}</InsideSheetContext.Provider>;\n}\n\n/**\n * The bottom sheet both Sheet and DropdownMenu sit in: a drag handle, sized\n * to its content, closed by dragging down, tapping the backdrop or Android\n * back, clear of the safe area and lifted by the keyboard. Private: the public\n * parts keep bottom-sheet types out of the package API.\n */\nexport function SheetFrame({\n open,\n onClose,\n onDismiss,\n children,\n scrollable = true,\n footer,\n keep = false,\n snapPoints,\n backdrop = true,\n background = 'rail',\n}: SheetFrameProps) {\n const { theme } = useUnistyles();\n const insets = useContext(SafeAreaInsetsContext);\n const sheet = useRef<BottomSheetModal>(null);\n const openRef = useRef(open);\n const presented = useRef(false);\n const dismissing = useRef(false);\n const [footerHeight, setFooterHeight] = useState(0);\n const [note, setNote] = useState<string>();\n const latest = useRef({ keep, onClose, onDismiss });\n latest.current = { keep, onClose, onDismiss };\n const entry = useRef<OpenSheet>({\n keep: () => latest.current.keep,\n close: () => latest.current.onClose(),\n setNote,\n });\n // Gorhom takes the footer as a component; a new one each render would remount its fields mid-typing.\n const footers = useRef<FooterHolder>(undefined);\n footers.current ??= footerHolder(footer);\n const holder = footers.current;\n useLayoutEffect(() => holder.set(footer), [holder, footer]);\n\n useEffect(() => {\n openRef.current = open;\n if (open && !dismissing.current) {\n presented.current = true;\n registerSheet(entry.current);\n // The keyboard of the field behind would cover the sheet; a field inside it focuses after this.\n Keyboard.dismiss();\n sheet.current?.present();\n } else if (!open) {\n unregisterSheet(entry.current);\n setNote(undefined);\n if (presented.current && !dismissing.current) {\n // A new open waits for native dismissal, otherwise its callback closes the new request.\n dismissing.current = true;\n sheet.current?.dismiss();\n }\n }\n }, [open]);\n\n useEffect(\n () => () => {\n openRef.current = false;\n unregisterSheet(entry.current);\n dismissSheet?.(entry.current);\n },\n [],\n );\n\n useEffect(() => {\n if (!open) return undefined;\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n latest.current.onClose();\n return true;\n });\n return () => subscription.remove();\n }, [open]);\n\n const backdropColor = withAlpha(theme.colors.deep, BACKDROP_ALPHA_PERCENT);\n const renderBackdrop = useCallback(\n (props: BottomSheetBackdropProps) => (\n <BottomSheetBackdrop\n {...props}\n appearsOnIndex={0}\n disappearsOnIndex={-1}\n opacity={1}\n pressBehavior=\"close\"\n style={[props.style, { backgroundColor: backdropColor }]}\n />\n ),\n [backdropColor],\n );\n\n const footerInset = insets?.bottom ?? 0;\n const surface = theme.colors[background];\n const renderFooter = useCallback(\n (props: BottomSheetFooterProps) => (\n <BottomSheetFooter {...props}>\n <View\n onLayout={(event) => setFooterHeight(event.nativeEvent.layout.height)}\n style={{ paddingBottom: footerInset, backgroundColor: surface }}\n >\n <FooterBody holder={holder} />\n </View>\n </BottomSheetFooter>\n ),\n [holder, footerInset, surface],\n );\n const backgroundStyle = useMemo(\n () => ({ backgroundColor: surface, borderRadius: theme.borderRadius.lg }),\n [surface, theme.borderRadius.lg],\n );\n const handleIndicatorStyle = useMemo(() => ({ backgroundColor: theme.colors.border }), [theme.colors.border]);\n const onChange = useCallback((index: number) => {\n // present() mounts on the next frame, so an earlier dismiss() may have had nothing to close.\n if (index >= 0 && dismissing.current) sheet.current?.dismiss();\n }, []);\n // A sheet the caller closed is already shut; only a close the sheet started is reported.\n const onSheetDismiss = useCallback(() => {\n const reopen = dismissing.current && openRef.current;\n dismissing.current = false;\n presented.current = false;\n dismissSheet?.(entry.current);\n if (reopen) {\n presented.current = true;\n registerSheet(entry.current);\n sheet.current?.present();\n return;\n }\n if (openRef.current) latest.current.onClose();\n latest.current.onDismiss?.();\n }, []);\n\n return (\n <BottomSheetModal\n ref={sheet}\n // The library marks the whole sheet as one accessible element, which hides its fields and buttons on iOS.\n accessible={false}\n stackBehavior=\"push\"\n enablePanDownToClose\n topInset={insets?.top ?? 0}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n android_keyboardInputMode=\"adjustResize\"\n {...(backdrop ? { backdropComponent: renderBackdrop } : {})}\n {...(snapPoints === undefined ? {} : { snapPoints, enableDynamicSizing: false })}\n {...(footer === undefined ? {} : { footerComponent: renderFooter })}\n backgroundStyle={backgroundStyle}\n handleIndicatorStyle={handleIndicatorStyle}\n onChange={onChange}\n onDismiss={onSheetDismiss}\n >\n {scrollable ? (\n <BottomSheetScrollView\n keyboardShouldPersistTaps=\"handled\"\n contentContainerStyle={[\n styles.content,\n { paddingBottom: footer === undefined ? (insets?.bottom ?? 0) : footerHeight },\n ]}\n >\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </BottomSheetScrollView>\n ) : (\n <>\n {note ? <SheetNote note={note} /> : null}\n <InsideSheetContext.Provider value>{children}</InsideSheetContext.Provider>\n </>\n )}\n </BottomSheetModal>\n );\n}\n\n/** A gentle rose line: the person is asked something below, never told to hurry. */\nfunction SheetNote({ note }: { note: string }) {\n return (\n <Text style={styles.note} accessibilityRole=\"alert\">\n {note}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n content: { flexGrow: 1 },\n note: {\n marginHorizontal: theme.spacing(4),\n marginBottom: theme.spacing(2),\n color: theme.colors.magenta,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n },\n}));\n"],"mappings":";;;;;;;;;;;;;;AAkCA,MAAM4B,yBAAyB;AA8B/B,SAASmB,aAAaC,SAAkC;CACtD,IAAId,SAASc;CACb,MAAMC,4BAAY,IAAIC,IAAgB;CACtC,OAAO;EACLP,WAAWT;EACXU,MAAMO,SAAS;GACb,IAAIA,SAASjB,QAAQ;GACrBA,SAASiB;GACT,KAAK,MAAML,YAAYG,WAAWH,SAAS;EAC7C;EACAD,YAAYC,aAAa;GACvBG,UAAUG,IAAIN,QAAQ;GACtB,aAAaG,UAAUI,OAAOP,QAAQ;EACxC;CACF;AACF;AAEA,SAASQ,WAAW,EAAEC,UAAoC;CACxD,MAAMrB,SAASb,qBAAqBkC,OAAOV,WAAWU,OAAOZ,GAAG;CAChE,OAAO,oBAAC,mBAAmB,UAApB;EAA6B;YAAOT;CAAoC;AACjF;;;;;;;AAQA,SAAgBsB,WAAW,EACzB1B,MACAC,SACAC,WACAC,UACAE,aAAa,MACbD,QACAE,OAAO,OACPC,YACAC,WAAW,MACXC,aAAa,UACK;CAClB,MAAM,EAAEkB,UAAU/B,aAAa;CAC/B,MAAMgC,SAAS3C,WAAWS,qBAAqB;CAC/C,MAAMmC,QAAQxC,OAAyB,IAAI;CAC3C,MAAMyC,UAAUzC,OAAOW,IAAI;CAC3B,MAAM+B,YAAY1C,OAAO,KAAK;CAC9B,MAAM2C,aAAa3C,OAAO,KAAK;CAC/B,MAAM,CAAC4C,cAAcC,mBAAmB5C,SAAS,CAAC;CAClD,MAAM,CAAC6C,MAAMC,WAAW9C,SAAiB;CACzC,MAAM+C,S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jC;AACF,EAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FlatListProps } from "react-native";
|
|
2
|
+
//#region src/components/SheetList.d.ts
|
|
3
|
+
export interface SheetListProps<T> extends FlatListProps<T> {
|
|
4
|
+
/** Use inside a persistent SheetContent with scrollable={false}. */
|
|
5
|
+
embedded?: boolean;
|
|
6
|
+
/** Reset the list without replacing its modal owner. */
|
|
7
|
+
listKey?: string;
|
|
8
|
+
/** The sheet holds unsaved work: a prompt arriving in the conversation leaves it open with a note. */
|
|
9
|
+
keep?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** A sheet's only vertical scroll owner. Put headings and controls in its header/footer. */
|
|
12
|
+
export declare function SheetList<T>({ contentContainerStyle, embedded, listKey, keep, ...props }: SheetListProps<T>): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=SheetList.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetList.d.mts","names":[],"sources":["../../src/components/SheetList.tsx"],"mappings":";;iBASiB,eAAe,WAAW,cAAc;;EAEvD;;EAEA;;EAEA;;;wBAMc,UAAU,KAAK,uBAAuB,UAAkB,SAAS,SAAS,SAAS,eAAe,qBAAE,IAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SheetFrame } from "./SheetFrame.mjs";
|
|
2
|
+
import { SheetContext } from "./Sheet.mjs";
|
|
3
|
+
import { withUnistyles } from "react-native-unistyles";
|
|
4
|
+
import { useContext } from "react";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { BottomSheetFlatList } from "@gorhom/bottom-sheet";
|
|
7
|
+
import { SafeAreaInsetsContext } from "react-native-safe-area-context";
|
|
8
|
+
|
|
9
|
+
//#region src/components/SheetList.tsx
|
|
10
|
+
const ThemedSheetFlatList = withUnistyles(BottomSheetFlatList);
|
|
11
|
+
/** A sheet's only vertical scroll owner. Put headings and controls in its header/footer. */
|
|
12
|
+
function SheetList({ contentContainerStyle, embedded = false, listKey, keep, ...props }) {
|
|
13
|
+
const state = useContext(SheetContext);
|
|
14
|
+
const insets = useContext(SafeAreaInsetsContext);
|
|
15
|
+
const list = /* @__PURE__ */ jsx(SheetContext.Provider, {
|
|
16
|
+
value: state,
|
|
17
|
+
children: /* @__PURE__ */ jsx(ThemedSheetFlatList, {
|
|
18
|
+
keyboardShouldPersistTaps: "handled",
|
|
19
|
+
...props,
|
|
20
|
+
contentContainerStyle: [{ paddingBottom: insets?.bottom ?? 0 }, contentContainerStyle]
|
|
21
|
+
}, listKey)
|
|
22
|
+
});
|
|
23
|
+
return embedded ? list : /* @__PURE__ */ jsx(SheetFrame, {
|
|
24
|
+
open: state.open,
|
|
25
|
+
onClose: () => state.setOpen(false),
|
|
26
|
+
scrollable: false,
|
|
27
|
+
keep,
|
|
28
|
+
children: list
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { SheetList };
|
|
34
|
+
//# sourceMappingURL=SheetList.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SheetList.mjs","names":["BottomSheetFlatList","useContext","FlatListProps","SafeAreaInsetsContext","withUnistyles","SheetContext","SheetFrame","SheetListProps","T","embedded","listKey","keep","ThemedSheetFlatList","SheetList","contentContainerStyle","props","state","insets","list","paddingBottom","bottom","open","setOpen"],"sources":["../../src/components/SheetList.tsx"],"sourcesContent":["import { BottomSheetFlatList } from '@gorhom/bottom-sheet';\nimport { useContext } from 'react';\nimport type { FlatListProps } from 'react-native';\nimport { SafeAreaInsetsContext } from 'react-native-safe-area-context';\nimport { withUnistyles } from 'react-native-unistyles';\n\nimport { SheetContext } from './Sheet';\nimport { SheetFrame } from './SheetFrame';\n\nexport interface SheetListProps<T> extends FlatListProps<T> {\n /** Use inside a persistent SheetContent with scrollable={false}. */\n embedded?: boolean;\n /** Reset the list without replacing its modal owner. */\n listKey?: string;\n /** The sheet holds unsaved work: a prompt arriving in the conversation leaves it open with a note. */\n keep?: boolean;\n}\n\n// Gorhom normalizes scroll styles internally; resolve Unistyles before that boundary.\nconst ThemedSheetFlatList = withUnistyles(BottomSheetFlatList) as typeof BottomSheetFlatList;\n/** A sheet's only vertical scroll owner. Put headings and controls in its header/footer. */\nexport function SheetList<T>({ contentContainerStyle, embedded = false, listKey, keep, ...props }: SheetListProps<T>) {\n const state = useContext(SheetContext);\n const insets = useContext(SafeAreaInsetsContext);\n const list = (\n <SheetContext.Provider value={state}>\n <ThemedSheetFlatList<T>\n key={listKey}\n keyboardShouldPersistTaps=\"handled\"\n {...props}\n contentContainerStyle={[{ paddingBottom: insets?.bottom ?? 0 }, contentContainerStyle]}\n />\n </SheetContext.Provider>\n );\n return embedded ? (\n list\n ) : (\n <SheetFrame open={state.open} onClose={() => state.setOpen(false)} scrollable={false} keep={keep}>\n {list}\n </SheetFrame>\n );\n}\n"],"mappings":";;;;;;;;;AAmBA,MAAMY,sBAAsBR,cAAcJ,mBAAmB;;AAE7D,SAAgBa,UAAa,EAAEC,uBAAuBL,WAAW,OAAOC,SAASC,MAAM,GAAGI,SAA4B;CACpH,MAAMC,QAAQf,WAAWI,YAAY;CACrC,MAAMY,SAAShB,WAAWE,qBAAqB;CAC/C,MAAMe,OACJ,oBAAC,aAAa,UAAd;EAAuB,OAAOF;YAC5B,oBAAC,qBAAD;GAEE,2BAA0B;GAC1B,GAAID;GACJ,uBAAuB,CAAC,EAAEI,eAAeF,QAAQG,UAAU,EAAE,GAAGN,qBAAqB;EAAE,GAHlFJ,OAGkF;CAEpE;CAEzB,OAAOD,WACLS,OAEA,oBAAC,YAAD;EAAY,MAAMF,MAAMK;EAAM,eAAeL,MAAMM,QAAQ,KAAK;EAAG,YAAY;EAAaX;YACzFO;CACS;AAEhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/ShowMore.d.ts
|
|
2
|
+
export interface ShowMoreProps {
|
|
3
|
+
label: string;
|
|
4
|
+
summary?: string;
|
|
5
|
+
onPress: () => void;
|
|
6
|
+
}
|
|
7
|
+
/** A bounded preview's explicit next part. The caller keeps the complete source. */
|
|
8
|
+
export declare function ShowMore({ label, summary, onPress }: ShowMoreProps): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
//# sourceMappingURL=ShowMore.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowMore.d.mts","names":[],"sources":["../../src/components/ShowMore.tsx"],"mappings":";iBAMiB;EACf;EACA;EACA;;;wBAIc,WAAW,OAAO,SAAS,WAAW,gCAAa,IAAA"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { Button } from "./Button.mjs";
|
|
3
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
4
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
5
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/ShowMore.tsx
|
|
9
|
+
/** A bounded preview's explicit next part. The caller keeps the complete source. */
|
|
10
|
+
function ShowMore({ label, summary, onPress }) {
|
|
11
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
12
|
+
style: styles.reveal,
|
|
13
|
+
children: [summary ? /* @__PURE__ */ jsx(Text, {
|
|
14
|
+
style: styles.summary,
|
|
15
|
+
children: summary
|
|
16
|
+
}) : null, /* @__PURE__ */ jsx(Button, {
|
|
17
|
+
variant: "ghost",
|
|
18
|
+
onPress,
|
|
19
|
+
style: styles.button,
|
|
20
|
+
children: label
|
|
21
|
+
})]
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const styles = StyleSheet.create((theme) => ({
|
|
25
|
+
reveal: {
|
|
26
|
+
gap: theme.spacing(1),
|
|
27
|
+
uni__dependencies: [0]
|
|
28
|
+
},
|
|
29
|
+
summary: {
|
|
30
|
+
color: theme.colors.dim,
|
|
31
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
32
|
+
fontSize: theme.fontSize.sm,
|
|
33
|
+
lineHeight: theme.lineHeightRelaxed.sm,
|
|
34
|
+
uni__dependencies: [0]
|
|
35
|
+
},
|
|
36
|
+
button: {
|
|
37
|
+
alignSelf: "flex-start",
|
|
38
|
+
minHeight: 44
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ShowMore };
|
|
44
|
+
//# sourceMappingURL=ShowMore.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShowMore.mjs","names":["StyleSheet","fontOf","Button","ShowMoreProps","label","summary","onPress","ShowMore","styles","reveal","button","create","theme","gap","spacing","uni__dependencies","color","colors","dim","fontFamily","sans","fontSize","sm","lineHeight","lineHeightRelaxed","alignSelf","minHeight"],"sources":["../../src/components/ShowMore.tsx"],"sourcesContent":["import { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { Button } from './Button';\n\nexport interface ShowMoreProps {\n label: string;\n summary?: string;\n onPress: () => void;\n}\n\n/** A bounded preview's explicit next part. The caller keeps the complete source. */\nexport function ShowMore({ label, summary, onPress }: ShowMoreProps) {\n return (\n <View style={styles.reveal}>\n {summary ? <Text style={styles.summary}>{summary}</Text> : null}\n <Button variant=\"ghost\" onPress={onPress} style={styles.button}>\n {label}\n </Button>\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n reveal: { gap: theme.spacing(1) },\n summary: {\n color: theme.colors.dim,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeightRelaxed.sm,\n },\n button: { alignSelf: 'flex-start', minHeight: 44 },\n}));\n"],"mappings":";;;;;;;;;AAaA,SAAgBO,SAAS,EAAEH,OAAOC,SAASC,WAA0B;CACnE,OACE,qBAAC,MAAD;EAAM,OAAOE,OAAOC;YAApB,CACGJ,UAAU,oBAAC,MAAD;GAAM,OAAOG,OAAOH;aAAUA;EAAc,KAAI,MAC3D,oBAAC,QAAD;GAAQ,SAAQ;GAAiBC;GAAS,OAAOE,OAAOE;aACrDN;EACK,EACJ;;AAEV;AAEA,MAAMI,SAASR,WAAWW,QAAQC,WAAW;CAC3CH,QAAQ;EAAEI,KAAKD,MAAME,QAAQ,CAAC;EAACC,mBAAA,CAAA,CAAA;CAAC;CAChCV,SAAS;EACPW,OAAOJ,MAAMK,OAAOC;EACpBC,YAAYlB,OAAOW,MAAMO,WAAWC,IAAI;EACxCC,UAAUT,MAAMS,SAASC;EACzBC,YAAYX,MAAMY,kBAAkBF;EAAEP,mBAAA,CAAA,CAAA;CACxC;CACAL,QAAQ;EAAEe,WAAW;EAAcC,WAAW;CAAG;AACnD,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NativeColorToken } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { NativeColorToken } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
//#region src/components/Spinner.d.ts
|
|
4
4
|
export interface SpinnerProps {
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NativeColorToken, StatusTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleProp, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { NativeColorToken, StatusTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/components/StatusBadge.d.ts
|
|
5
5
|
type StatusTone$1 = StatusTone;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
//#region src/components/Switch.d.ts
|
|
3
|
+
export interface SwitchProps {
|
|
4
|
+
value: boolean;
|
|
5
|
+
onValueChange: (value: boolean) => void;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
/** What the switch turns on, such as "Resize large images". */
|
|
8
|
+
accessibilityLabel?: string;
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
}
|
|
11
|
+
/** The web Switch as the platform's own: jade track when on, a selection tick on each change. */
|
|
12
|
+
export declare function Switch({ value, onValueChange, disabled, accessibilityLabel, style }: SwitchProps): import("react").JSX.Element;
|
|
13
|
+
//#endregion
|
|
14
|
+
//# sourceMappingURL=Switch.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.d.mts","names":[],"sources":["../../src/components/Switch.tsx"],"mappings":";;iBAiBiB;EACf;EACA,gBAAgB;EAChB;;EAEA;EACA,QAAQ,UAAU;;;wBAIJ,SAAS,OAAO,eAAe,UAAkB,oBAAoB,SAAS,8BAAW,IAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { selectionTick } from "../lib/haptics.mjs";
|
|
2
|
+
import { withUnistyles } from "react-native-unistyles";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Switch } from "react-native-unistyles/components/native/Switch";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Switch.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Theme colours reach the platform switch through withUnistyles, so it follows theme changes. The thumb
|
|
9
|
+
* is `on-selected` (near white in both schemes, as the platform thumb is), never a surface colour that
|
|
10
|
+
* would go dark in dark mode. `activeThumbColor` only reaches react-native-web, whose own default is teal.
|
|
11
|
+
*/
|
|
12
|
+
const ThemedSwitch = withUnistyles(Switch, (theme) => ({
|
|
13
|
+
trackColor: {
|
|
14
|
+
true: theme.colors.green,
|
|
15
|
+
false: theme.colors.border
|
|
16
|
+
},
|
|
17
|
+
ios_backgroundColor: theme.colors.border,
|
|
18
|
+
thumbColor: theme.colors["on-selected"],
|
|
19
|
+
activeThumbColor: theme.colors["on-selected"]
|
|
20
|
+
}));
|
|
21
|
+
/** The web Switch as the platform's own: jade track when on, a selection tick on each change. */
|
|
22
|
+
function Switch$1({ value, onValueChange, disabled = false, accessibilityLabel, style }) {
|
|
23
|
+
return /* @__PURE__ */ jsx(ThemedSwitch, {
|
|
24
|
+
value,
|
|
25
|
+
disabled,
|
|
26
|
+
accessibilityLabel,
|
|
27
|
+
onValueChange: (next) => {
|
|
28
|
+
selectionTick();
|
|
29
|
+
onValueChange(next);
|
|
30
|
+
},
|
|
31
|
+
style
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Switch$1 as Switch };
|
|
37
|
+
//# sourceMappingURL=Switch.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Switch.mjs","names":["StyleProp","ViewStyle","withUnistyles","selectionTick","ThemedSwitch","RNSwitch","theme","trackColor","true","colors","green","false","border","ios_backgroundColor","thumbColor","activeThumbColor","SwitchProps","value","onValueChange","disabled","accessibilityLabel","style","Switch","next","RNSwitch","Switch"],"sources":["../../src/components/Switch.tsx"],"sourcesContent":["import { Switch as RNSwitch, type StyleProp, type ViewStyle } from 'react-native';\nimport { withUnistyles } from 'react-native-unistyles';\n\nimport { selectionTick } from '../lib/haptics';\n\n/**\n * Theme colours reach the platform switch through withUnistyles, so it follows theme changes. The thumb\n * is `on-selected` (near white in both schemes, as the platform thumb is), never a surface colour that\n * would go dark in dark mode. `activeThumbColor` only reaches react-native-web, whose own default is teal.\n */\nconst ThemedSwitch = withUnistyles(RNSwitch, (theme) => ({\n trackColor: { true: theme.colors.green, false: theme.colors.border },\n ios_backgroundColor: theme.colors.border,\n thumbColor: theme.colors['on-selected'],\n activeThumbColor: theme.colors['on-selected'],\n}));\n\nexport interface SwitchProps {\n value: boolean;\n onValueChange: (value: boolean) => void;\n disabled?: boolean;\n /** What the switch turns on, such as \"Resize large images\". */\n accessibilityLabel?: string;\n style?: StyleProp<ViewStyle>;\n}\n\n/** The web Switch as the platform's own: jade track when on, a selection tick on each change. */\nexport function Switch({ value, onValueChange, disabled = false, accessibilityLabel, style }: SwitchProps) {\n return (\n <ThemedSwitch\n value={value}\n disabled={disabled}\n accessibilityLabel={accessibilityLabel}\n onValueChange={(next) => {\n selectionTick();\n onValueChange(next);\n }}\n style={style}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAMI,eAAeF,cAAcG,SAAWC,WAAW;CACvDC,YAAY;EAAEC,MAAMF,MAAMG,OAAOC;EAAOC,OAAOL,MAAMG,OAAOG;CAAO;CACnEC,qBAAqBP,MAAMG,OAAOG;CAClCE,YAAYR,MAAMG,OAAO;CACzBM,kBAAkBT,MAAMG,OAAO;AACjC,EAAE;;AAYF,SAAgBa,SAAO,EAAEL,OAAOC,eAAeC,WAAW,OAAOC,oBAAoBC,SAAsB;CACzG,OACE,oBAAC,cAAD;EACSJ;EACGE;EACUC;EACpB,gBAAgBG,SAAS;GACvBpB,cAAc;GACde,cAAcK,IAAI;EACpB;EACOF;CAAM;AAGnB"}
|