@agimon-ai/po-native-components 0.0.0-alpha.13 → 0.0.0-alpha.130

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.
Files changed (141) hide show
  1. package/LICENSE +149 -22
  2. package/dist/components/AgentAvatar.d.mts +14 -0
  3. package/dist/components/AgentAvatar.d.mts.map +1 -0
  4. package/dist/components/AgentAvatar.mjs +87 -0
  5. package/dist/components/AgentAvatar.mjs.map +1 -0
  6. package/dist/components/AnnotationSurface.d.mts +69 -0
  7. package/dist/components/AnnotationSurface.d.mts.map +1 -0
  8. package/dist/components/AnnotationSurface.mjs +426 -0
  9. package/dist/components/AnnotationSurface.mjs.map +1 -0
  10. package/dist/components/Badge.d.mts +1 -1
  11. package/dist/components/Badge.mjs +1 -1
  12. package/dist/components/Button.mjs +3 -3
  13. package/dist/components/Button.mjs.map +1 -1
  14. package/dist/components/CodeBlock.d.mts +3 -1
  15. package/dist/components/CodeBlock.d.mts.map +1 -1
  16. package/dist/components/CodeBlock.mjs +35 -47
  17. package/dist/components/CodeBlock.mjs.map +1 -1
  18. package/dist/components/CopyButton.d.mts +13 -0
  19. package/dist/components/CopyButton.d.mts.map +1 -0
  20. package/dist/components/CopyButton.mjs +43 -0
  21. package/dist/components/CopyButton.mjs.map +1 -0
  22. package/dist/components/CountBadge.d.mts +15 -0
  23. package/dist/components/CountBadge.d.mts.map +1 -0
  24. package/dist/components/CountBadge.mjs +49 -0
  25. package/dist/components/CountBadge.mjs.map +1 -0
  26. package/dist/components/Dialog.d.mts.map +1 -1
  27. package/dist/components/Dialog.mjs +9 -8
  28. package/dist/components/Dialog.mjs.map +1 -1
  29. package/dist/components/Dot.d.mts +1 -1
  30. package/dist/components/Dot.mjs +2 -2
  31. package/dist/components/DropdownMenu.d.mts +3 -1
  32. package/dist/components/DropdownMenu.d.mts.map +1 -1
  33. package/dist/components/DropdownMenu.mjs +21 -14
  34. package/dist/components/DropdownMenu.mjs.map +1 -1
  35. package/dist/components/HashlineLines.d.mts +13 -0
  36. package/dist/components/HashlineLines.d.mts.map +1 -0
  37. package/dist/components/HashlineLines.mjs +148 -0
  38. package/dist/components/HashlineLines.mjs.map +1 -0
  39. package/dist/components/HostFilter.d.mts +17 -0
  40. package/dist/components/HostFilter.d.mts.map +1 -0
  41. package/dist/components/HostFilter.mjs +66 -0
  42. package/dist/components/HostFilter.mjs.map +1 -0
  43. package/dist/components/HostTag.d.mts +7 -0
  44. package/dist/components/HostTag.d.mts.map +1 -0
  45. package/dist/components/HostTag.mjs +47 -0
  46. package/dist/components/HostTag.mjs.map +1 -0
  47. package/dist/components/InfoStrip.d.mts +9 -0
  48. package/dist/components/InfoStrip.d.mts.map +1 -0
  49. package/dist/components/InfoStrip.mjs +53 -0
  50. package/dist/components/InfoStrip.mjs.map +1 -0
  51. package/dist/components/Input.d.mts +3 -1
  52. package/dist/components/Input.d.mts.map +1 -1
  53. package/dist/components/Input.mjs +4 -3
  54. package/dist/components/Input.mjs.map +1 -1
  55. package/dist/components/Label.mjs +1 -1
  56. package/dist/components/List.d.mts.map +1 -1
  57. package/dist/components/List.mjs +38 -6
  58. package/dist/components/List.mjs.map +1 -1
  59. package/dist/components/LiveDuration.d.mts +30 -0
  60. package/dist/components/LiveDuration.d.mts.map +1 -0
  61. package/dist/components/LiveDuration.mjs +67 -0
  62. package/dist/components/LiveDuration.mjs.map +1 -0
  63. package/dist/components/Markdown.d.mts +10 -1
  64. package/dist/components/Markdown.d.mts.map +1 -1
  65. package/dist/components/Markdown.mjs +335 -26
  66. package/dist/components/Markdown.mjs.map +1 -1
  67. package/dist/components/MessageItem.d.mts +10 -15
  68. package/dist/components/MessageItem.d.mts.map +1 -1
  69. package/dist/components/MessageItem.mjs +72 -63
  70. package/dist/components/MessageItem.mjs.map +1 -1
  71. package/dist/components/NativeShellState.d.mts +30 -0
  72. package/dist/components/NativeShellState.d.mts.map +1 -0
  73. package/dist/components/NativeShellState.mjs +61 -0
  74. package/dist/components/NativeShellState.mjs.map +1 -0
  75. package/dist/components/SectionLabel.mjs +1 -1
  76. package/dist/components/Select.d.mts +33 -0
  77. package/dist/components/Select.d.mts.map +1 -0
  78. package/dist/components/Select.mjs +222 -0
  79. package/dist/components/Select.mjs.map +1 -0
  80. package/dist/components/Sheet.d.mts +9 -1
  81. package/dist/components/Sheet.d.mts.map +1 -1
  82. package/dist/components/Sheet.mjs +27 -10
  83. package/dist/components/Sheet.mjs.map +1 -1
  84. package/dist/components/SheetFrame.mjs +143 -28
  85. package/dist/components/SheetFrame.mjs.map +1 -1
  86. package/dist/components/SheetList.d.mts +14 -0
  87. package/dist/components/SheetList.d.mts.map +1 -0
  88. package/dist/components/SheetList.mjs +34 -0
  89. package/dist/components/SheetList.mjs.map +1 -0
  90. package/dist/components/ShowMore.d.mts +10 -0
  91. package/dist/components/ShowMore.d.mts.map +1 -0
  92. package/dist/components/ShowMore.mjs +44 -0
  93. package/dist/components/ShowMore.mjs.map +1 -0
  94. package/dist/components/Spinner.d.mts +1 -1
  95. package/dist/components/StatusBadge.d.mts +1 -1
  96. package/dist/components/Switch.d.mts +14 -0
  97. package/dist/components/Switch.d.mts.map +1 -0
  98. package/dist/components/Switch.mjs +37 -0
  99. package/dist/components/Switch.mjs.map +1 -0
  100. package/dist/components/SyntaxLine.d.mts +19 -0
  101. package/dist/components/SyntaxLine.d.mts.map +1 -0
  102. package/dist/components/SyntaxLine.mjs +134 -0
  103. package/dist/components/SyntaxLine.mjs.map +1 -0
  104. package/dist/components/Tabs.d.mts.map +1 -1
  105. package/dist/components/Tabs.mjs +8 -7
  106. package/dist/components/Tabs.mjs.map +1 -1
  107. package/dist/components/ToolPathLink.d.mts +10 -0
  108. package/dist/components/ToolPathLink.d.mts.map +1 -0
  109. package/dist/components/ToolPathLink.mjs +40 -0
  110. package/dist/components/ToolPathLink.mjs.map +1 -0
  111. package/dist/components/ToolResultImage.d.mts +12 -0
  112. package/dist/components/ToolResultImage.d.mts.map +1 -0
  113. package/dist/components/ToolResultImage.mjs +48 -0
  114. package/dist/components/ToolResultImage.mjs.map +1 -0
  115. package/dist/icons/iconGlyphs.d.mts +60 -0
  116. package/dist/icons/iconGlyphs.d.mts.map +1 -1
  117. package/dist/icons/iconGlyphs.mjs +60 -0
  118. package/dist/icons/iconGlyphs.mjs.map +1 -1
  119. package/dist/icons/icons.d.mts +61 -1
  120. package/dist/icons/icons.d.mts.map +1 -1
  121. package/dist/icons/icons.mjs +17 -2
  122. package/dist/icons/icons.mjs.map +1 -1
  123. package/dist/index.d.mts +20 -6
  124. package/dist/index.mjs +21 -7
  125. package/dist/lib/fonts.d.mts +3 -1
  126. package/dist/lib/fonts.d.mts.map +1 -1
  127. package/dist/lib/fonts.mjs +4 -2
  128. package/dist/lib/fonts.mjs.map +1 -1
  129. package/dist/lib/insideSheet.d.mts +10 -0
  130. package/dist/lib/insideSheet.d.mts.map +1 -0
  131. package/dist/lib/markdown.mjs +172 -23
  132. package/dist/lib/markdown.mjs.map +1 -1
  133. package/dist/lib/reading.mjs +60 -0
  134. package/dist/lib/reading.mjs.map +1 -0
  135. package/dist/lib/useControllable.mjs +14 -6
  136. package/dist/lib/useControllable.mjs.map +1 -1
  137. package/dist/lib/useReadingPage.mjs +33 -0
  138. package/dist/lib/useReadingPage.mjs.map +1 -0
  139. package/dist/shell.d.mts +6 -0
  140. package/dist/shell.mjs +7 -0
  141. package/package.json +37 -28
@@ -1,45 +1,104 @@
1
- import { InsideSheetContext } from "../lib/insideSheet.mjs";
2
- import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
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 { useCallback, useContext, useEffect, useRef } from "react";
6
- import { jsx } from "react/jsx-runtime";
7
- import { BottomSheetBackdrop, BottomSheetModal, BottomSheetScrollView } from "@gorhom/bottom-sheet";
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, 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 }) {
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 (presented.current) {
31
- presented.current = false;
32
- sheet.current?.dismiss();
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, onClose]);
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,6 +108,44 @@ 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 renderFooter = useCallback((props) => /* @__PURE__ */ jsx(BottomSheetFooter, {
113
+ ...props,
114
+ children: /* @__PURE__ */ jsx(View, {
115
+ onLayout: (event) => setFooterHeight(event.nativeEvent.layout.height),
116
+ style: {
117
+ paddingBottom: footerInset,
118
+ backgroundColor: theme.colors.rail
119
+ },
120
+ children: /* @__PURE__ */ jsx(FooterBody, { holder })
121
+ })
122
+ }), [
123
+ holder,
124
+ footerInset,
125
+ theme.colors.rail
126
+ ]);
127
+ const backgroundStyle = useMemo(() => ({
128
+ backgroundColor: theme.colors.rail,
129
+ borderRadius: theme.borderRadius.lg
130
+ }), [theme.colors.rail, theme.borderRadius.lg]);
131
+ const handleIndicatorStyle = useMemo(() => ({ backgroundColor: theme.colors.border }), [theme.colors.border]);
132
+ const onChange = useCallback((index) => {
133
+ if (index >= 0 && dismissing.current) sheet.current?.dismiss();
134
+ }, []);
135
+ const onSheetDismiss = useCallback(() => {
136
+ const reopen = dismissing.current && openRef.current;
137
+ dismissing.current = false;
138
+ presented.current = false;
139
+ dismissSheet?.(entry.current);
140
+ if (reopen) {
141
+ presented.current = true;
142
+ registerSheet(entry.current);
143
+ sheet.current?.present();
144
+ return;
145
+ }
146
+ if (openRef.current) latest.current.onClose();
147
+ latest.current.onDismiss?.();
148
+ }, []);
52
149
  return /* @__PURE__ */ jsx(BottomSheetModal, {
53
150
  ref: sheet,
54
151
  stackBehavior: "push",
@@ -58,26 +155,44 @@ function SheetFrame({ open, onClose, children }) {
58
155
  keyboardBlurBehavior: "restore",
59
156
  android_keyboardInputMode: "adjustResize",
60
157
  backdropComponent: renderBackdrop,
61
- backgroundStyle: {
62
- backgroundColor: theme.colors.rail,
63
- borderRadius: theme.borderRadius.lg
64
- },
65
- handleIndicatorStyle: { backgroundColor: theme.colors.border },
66
- onDismiss: () => {
67
- presented.current = false;
68
- if (openRef.current) onClose();
69
- },
70
- children: /* @__PURE__ */ jsx(BottomSheetScrollView, {
158
+ ...footer === void 0 ? {} : { footerComponent: renderFooter },
159
+ backgroundStyle,
160
+ handleIndicatorStyle,
161
+ onChange,
162
+ onDismiss: onSheetDismiss,
163
+ children: scrollable ? /* @__PURE__ */ jsxs(BottomSheetScrollView, {
71
164
  keyboardShouldPersistTaps: "handled",
72
- contentContainerStyle: [styles.content, { paddingBottom: insets?.bottom ?? 0 }],
73
- children: /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
165
+ contentContainerStyle: [styles.content, { paddingBottom: footer === void 0 ? insets?.bottom ?? 0 : footerHeight }],
166
+ children: [note ? /* @__PURE__ */ jsx(SheetNote, { note }) : null, /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
74
167
  value: true,
75
168
  children
76
- })
77
- })
169
+ })]
170
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [note ? /* @__PURE__ */ jsx(SheetNote, { note }) : null, /* @__PURE__ */ jsx(InsideSheetContext.Provider, {
171
+ value: true,
172
+ children
173
+ })] })
174
+ });
175
+ }
176
+ /** A gentle rose line: the person is asked something below, never told to hurry. */
177
+ function SheetNote({ note }) {
178
+ return /* @__PURE__ */ jsx(Text, {
179
+ style: styles.note,
180
+ accessibilityRole: "alert",
181
+ children: note
78
182
  });
79
183
  }
80
- const styles = StyleSheet.create({ content: { flexGrow: 1 } });
184
+ const styles = StyleSheet.create((theme) => ({
185
+ content: { flexGrow: 1 },
186
+ note: {
187
+ marginHorizontal: theme.spacing(4),
188
+ marginBottom: theme.spacing(2),
189
+ color: theme.colors.magenta,
190
+ fontFamily: fontOf(theme.fontFamily.sans),
191
+ fontSize: theme.fontSize.sm,
192
+ lineHeight: theme.lineHeight.sm,
193
+ uni__dependencies: [0]
194
+ }
195
+ }));
81
196
 
82
197
  //#endregion
83
198
  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,QA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AO,EAAEH,SAAS,EAAEI,UAAU,EAAE,EAAE,CAAC"}
1
+ {"version":3,"file":"SheetFrame.mjs","names":["dismissSheet","InsideSheetContext","OpenSheet","registerSheet","unregisterSheet","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","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","renderFooter","event","nativeEvent","layout","height","paddingBottom","rail","backgroundStyle","borderRadius","lg","handleIndicatorStyle","border","onChange","index","onSheetDismiss","reopen","top","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 { 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}\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}: 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 renderFooter = useCallback(\n (props: BottomSheetFooterProps) => (\n <BottomSheetFooter {...props}>\n <View\n onLayout={(event) => setFooterHeight(event.nativeEvent.layout.height)}\n style={{ paddingBottom: footerInset, backgroundColor: theme.colors.rail }}\n >\n <FooterBody holder={holder} />\n </View>\n </BottomSheetFooter>\n ),\n [holder, footerInset, theme.colors.rail],\n );\n const backgroundStyle = useMemo(\n () => ({ backgroundColor: theme.colors.rail, borderRadius: theme.borderRadius.lg }),\n [theme.colors.rail, 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 stackBehavior=\"push\"\n enablePanDownToClose\n topInset={insets?.top ?? 0}\n keyboardBehavior=\"interactive\"\n keyboardBlurBehavior=\"restore\"\n android_keyboardInputMode=\"adjustResize\"\n backdropComponent={renderBackdrop}\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,MAAM2B,yBAAyB;AAwB/B,SAASgB,aAAaC,SAAkC;CACtD,IAAIX,SAASW;CACb,MAAMC,4BAAY,IAAIC,IAAgB;CACtC,OAAO;EACLP,WAAWN;EACXO,MAAMO,SAAS;GACb,IAAIA,SAASd,QAAQ;GACrBA,SAASc;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,MAAMlB,SAASb,qBAAqB+B,OAAOV,WAAWU,OAAOZ,GAAG;CAChE,OAAO,oBAAC,mBAAmB,UAApB;EAA6B;YAAON;CAAoC;AACjF;;;;;;;AAQA,SAAgBmB,WAAW,EACzBvB,MACAC,SACAC,WACAC,UACAE,aAAa,MACbD,QACAE,OAAO,SACW;CAClB,MAAM,EAAEkB,UAAU5B,aAAa;CAC/B,MAAM6B,SAASxC,WAAWS,qBAAqB;CAC/C,MAAMgC,QAAQrC,OAAyB,IAAI;CAC3C,MAAMsC,UAAUtC,OAAOW,IAAI;CAC3B,MAAM4B,YAAYvC,OAAO,KAAK;CAC9B,MAAMwC,aAAaxC,OAAO,KAAK;CAC/B,MAAM,CAACyC,cAAcC,mBAAmBzC,SAAS,CAAC;CAClD,MAAM,CAAC0C,MAAMC,WAAW3C,SAAiB;CACzC,MAAM4C,SAAS7C,OAAO;EAAEiB;EAA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YAAY;CAC7B,GAAG,CAAA,CAAE;CAEL,OACE,oBAAC,kBAAD;EACE,KAAKwB;EACL,eAAc;EACd;EACA,UAAUD,QAAQ6C,OAAO;EACzB,kBAAiB;EACjB,sBAAqB;EACrB,2BAA0B;EAC1B,mBAAmBtB;EACnB,GAAK5C,WAAWmC,SAAY,CAAC,IAAI,EAAEgC,iBAAiBjB,aAAa;EAChDO;EACKG;EACZE;EACV,WAAWE;YAEV/D,aACC,qBAAC,uBAAD;GACE,2BAA0B;GAC1B,uBAAuB,CACrBmE,OAAOC,SACP,EAAEd,eAAevD,WAAWmC,SAAad,QAAQ4B,UAAU,IAAKvB,aAAa,CAAC;aAJlF,CAOGE,OAAO,oBAAC,WAAD,EAAiBA,KAAK,KAAM,MACpC,oBAAC,mBAAmB,UAApB;IAA6B;IAAO7B;GAAsC,EACrD;OAEvB,4CACG6B,OAAO,oBAAC,WAAD,EAAiBA,KAAK,KAAM,MACpC,oBAAC,mBAAmB,UAApB;GAA6B;GAAO7B;EAAsC,EAC5E;CAEc;AAEtB;;AAGA,SAASuE,UAAU,EAAE1C,QAA0B;CAC7C,OACE,oBAAC,MAAD;EAAM,OAAOwC,OAAOxC;EAAM,mBAAkB;YACzCA;CACG;AAEV;AAEA,MAAMwC,SAAS7E,WAAWgF,QAAQnD,WAAW;CAC3CiD,SAAS,EAAEG,UAAU,EAAE;CACvB5C,MAAM;EACJ6C,kBAAkBrD,MAAMsD,QAAQ,CAAC;EACjCC,cAAcvD,MAAMsD,QAAQ,CAAC;EAC7BE,OAAOxD,MAAMsB,OAAOmC;EACpBC,YAAYrF,OAAO2B,MAAM0D,WAAWC,IAAI;EACxCC,UAAU5D,MAAM4D,SAASC;EACzBC,YAAY9D,MAAM8D,WAAWD;EAAEE,mBAAA,CAAA,CAAA;CACjC;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"}
@@ -0,0 +1,19 @@
1
+ import { SyntaxSpan } from "@agimon-ai/po-web-components/text";
2
+ import { TextProps } from "react-native";
3
+ //#region src/components/SyntaxLine.d.ts
4
+ /**
5
+ * Colours `text` as lines of spans, or undefined while loading and for text with
6
+ * no grammar. Pass a whole block, not one line: a line is not a parse unit.
7
+ */
8
+ export declare function useSyntaxLines(text: string, query?: {
9
+ path?: string | undefined;
10
+ }): readonly (readonly SyntaxSpan[])[] | undefined;
11
+ export interface SyntaxLineProps extends Omit<TextProps, 'children'> {
12
+ /** The line's spans from `useSyntaxLines`, or undefined to show `text` plain. */
13
+ spans?: readonly SyntaxSpan[] | undefined;
14
+ text: string;
15
+ }
16
+ /** One line: coloured when its spans are in, the plain text until then. */
17
+ export declare function SyntaxLine({ spans, text, ...props }: SyntaxLineProps): import("react").JSX.Element;
18
+ //#endregion
19
+ //# sourceMappingURL=SyntaxLine.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyntaxLine.d.mts","names":[],"sources":["../../src/components/SyntaxLine.tsx"],"mappings":";;;;;;;wBAgBgB,eAAe,cAAc;EAAS;uBAAgC;iBAyBrE,wBAAwB,KAAK;;EAE5C,iBAAiB;EACjB;;;wBAIc,aAAa,OAAO,SAAS,SAAS,kCAAe,IAAA"}
@@ -0,0 +1,134 @@
1
+ import { detectGrammar, highlightToLines } from "@agimon-ai/po-web-components/text";
2
+ import { Text } from "react-native-unistyles/components/native/Text";
3
+ import { StyleSheet } from "react-native-unistyles";
4
+ import { useEffect, useState } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/components/SyntaxLine.tsx
8
+ /**
9
+ * Colours `text` as lines of spans, or undefined while loading and for text with
10
+ * no grammar. Pass a whole block, not one line: a line is not a parse unit.
11
+ */
12
+ function useSyntaxLines(text, query = {}) {
13
+ const grammar = detectGrammar({
14
+ path: query.path,
15
+ text
16
+ });
17
+ const signature = `${grammar ?? ""}\u0000${text}`;
18
+ const [done, setDone] = useState();
19
+ useEffect(() => {
20
+ if (grammar === void 0) return;
21
+ let live = true;
22
+ const controller = new AbortController();
23
+ highlightToLines(text, grammar, controller.signal).then((lines) => {
24
+ if (live && lines !== void 0) setDone({
25
+ signature,
26
+ lines
27
+ });
28
+ }, () => void 0);
29
+ return () => {
30
+ live = false;
31
+ controller.abort();
32
+ };
33
+ }, [
34
+ text,
35
+ grammar,
36
+ signature
37
+ ]);
38
+ return done?.signature === signature ? done.lines : void 0;
39
+ }
40
+ /** One line: coloured when its spans are in, the plain text until then. */
41
+ function SyntaxLine({ spans, text, ...props }) {
42
+ return /* @__PURE__ */ jsx(Text, {
43
+ ...props,
44
+ children: spans?.map((span, index) => /* @__PURE__ */ jsx(Text, {
45
+ style: span.token === void 0 ? void 0 : syntax[span.token],
46
+ children: span.text
47
+ }, index)) ?? text
48
+ });
49
+ }
50
+ /** The web's `PO_SYNTAX_STYLES`, on the native theme's colours. */
51
+ const syntax = StyleSheet.create((theme) => ({
52
+ comment: {
53
+ color: theme.colors.faint,
54
+ fontStyle: "italic",
55
+ uni__dependencies: [0]
56
+ },
57
+ keyword: {
58
+ color: theme.colors.magenta,
59
+ uni__dependencies: [0]
60
+ },
61
+ constant: {
62
+ color: theme.colors.violet,
63
+ uni__dependencies: [0]
64
+ },
65
+ literal: {
66
+ color: theme.colors.orange,
67
+ uni__dependencies: [0]
68
+ },
69
+ string: {
70
+ color: theme.colors.green,
71
+ uni__dependencies: [0]
72
+ },
73
+ regexp: {
74
+ color: theme.colors.teal,
75
+ uni__dependencies: [0]
76
+ },
77
+ operator: {
78
+ color: theme.colors.blue,
79
+ uni__dependencies: [0]
80
+ },
81
+ punctuation: {
82
+ color: theme.colors.dim,
83
+ uni__dependencies: [0]
84
+ },
85
+ variable: {
86
+ color: theme.colors.text,
87
+ uni__dependencies: [0]
88
+ },
89
+ property: {
90
+ color: theme.colors.cyan,
91
+ uni__dependencies: [0]
92
+ },
93
+ callable: {
94
+ color: theme.colors.blue,
95
+ uni__dependencies: [0]
96
+ },
97
+ type: {
98
+ color: theme.colors.yellow,
99
+ uni__dependencies: [0]
100
+ },
101
+ tag: {
102
+ color: theme.colors.red,
103
+ uni__dependencies: [0]
104
+ },
105
+ attribute: {
106
+ color: theme.colors.yellow,
107
+ uni__dependencies: [0]
108
+ },
109
+ meta: {
110
+ color: theme.colors.faint,
111
+ uni__dependencies: [0]
112
+ },
113
+ heading: {
114
+ color: theme.colors.hi,
115
+ fontWeight: "bold",
116
+ uni__dependencies: [0]
117
+ },
118
+ link: {
119
+ color: theme.colors.cyan,
120
+ textDecorationLine: "underline",
121
+ uni__dependencies: [0]
122
+ },
123
+ emphasis: { fontStyle: "italic" },
124
+ strong: { fontWeight: "bold" },
125
+ strikethrough: { textDecorationLine: "line-through" },
126
+ invalid: {
127
+ color: theme.colors.red,
128
+ uni__dependencies: [0]
129
+ }
130
+ }));
131
+
132
+ //#endregion
133
+ export { SyntaxLine, useSyntaxLines };
134
+ //# sourceMappingURL=SyntaxLine.mjs.map