@agimon-ai/po-native-components 0.0.0-alpha.2 → 0.0.0-alpha.200
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 +1 -2
- 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 +2 -2
- package/dist/components/Badge.mjs.map +1 -1
- package/dist/components/Button.mjs +4 -4
- 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 +18 -12
- package/dist/components/Dialog.mjs.map +1 -1
- package/dist/components/Dot.d.mts +1 -1
- package/dist/components/Dot.mjs +3 -3
- package/dist/components/Dot.mjs.map +1 -1
- package/dist/components/DropdownMenu.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 +46 -0
- package/dist/components/FileList.d.mts.map +1 -0
- package/dist/components/FileList.mjs +727 -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 +335 -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 +5 -4
- 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/SegmentedControl.d.mts.map +1 -1
- package/dist/components/SegmentedControl.mjs.map +1 -1
- 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 +150 -29
- 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 +206 -54
- package/dist/icons/iconGlyphs.d.mts.map +1 -1
- package/dist/icons/iconGlyphs.mjs +152 -0
- package/dist/icons/iconGlyphs.mjs.map +1 -1
- package/dist/icons/icons.d.mts +153 -1
- package/dist/icons/icons.d.mts.map +1 -1
- package/dist/icons/icons.mjs +40 -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/package.json +41 -31
package/LICENSE
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2026
|
|
4
|
-
Copyright (c) 2026 pulseaiclub
|
|
3
|
+
Copyright (c) 2026 Agimon Pty Ltd
|
|
5
4
|
|
|
6
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Po native components
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
code the web library's look and API (`@agimon-ai/po-web-components`) built on native parts: the
|
|
5
|
-
platform activity indicator, Pressable with an Android ripple and 44pt tap targets, SF Symbols on
|
|
6
|
-
iOS and Material icons elsewhere, and a small haptics policy.
|
|
3
|
+
Shared React Native components for the Po app and native plugins. Use them instead of rebuilding buttons, forms, lists, sheets, dialogs, transcript items, or file views in each plugin. They share Po's semantic palette with the web library while using native controls, accessibility roles, touch targets, and platform icons.
|
|
7
4
|
|
|
8
5
|
## Use
|
|
9
6
|
|
|
10
|
-
Mount `PoNativeProvider` once
|
|
11
|
-
handler root and the bottom sheet host that sheets, dialogs and menus need. Register Po's native
|
|
12
|
-
themes with Unistyles (`NATIVE_THEMES` from `@agimon-ai/po-web-components/nativeTheme`) before this
|
|
13
|
-
package is imported.
|
|
7
|
+
Register the native Unistyles themes from `@agimon-ai/po-web-components/nativeTheme` before importing this package. Mount `PoNativeProvider` once inside the app's `SafeAreaProvider`; it supplies the gesture root and bottom-sheet host.
|
|
14
8
|
|
|
15
9
|
```tsx
|
|
16
10
|
import { Button, PoNativeProvider } from '@agimon-ai/po-native-components';
|
|
@@ -22,50 +16,14 @@ import { Button, PoNativeProvider } from '@agimon-ai/po-native-components';
|
|
|
22
16
|
</PoNativeProvider>;
|
|
23
17
|
```
|
|
24
18
|
|
|
25
|
-
|
|
26
|
-
contract, so it only ever grows: props and exports are added, never removed or renamed.
|
|
19
|
+
Discover actual exports and props in [`src/exports/index.ts`](src/exports/index.ts) and colocated component stories. Web props are not automatically native contracts: for example, there is no DOM `asChild`, and sheets use native bottom-sheet behavior.
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
Plugins import this package through the native host-module allowlist. That shared API is additive: do not remove or rename existing exports or props.
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
| ----------------------------------------------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
32
|
-
| `Button` | Button (9 variants, 7 sizes) | Pressed state for hover, Android ripple, hitSlop to 44pt, light haptic on primary, danger and success |
|
|
33
|
-
| `Label`, `Input`, `Textarea` | Label, Input, Textarea | Placeholder in `faint`, jade cursor, autocorrect off, focus edge at 60% green |
|
|
34
|
-
| `Spinner` | Spinner | `ActivityIndicator` in a theme token; a labelled spinner is a live progress indicator |
|
|
35
|
-
| `Badge`, `StatusBadge`, `STATUS_EDGE`, `Dot` | Same | Accent edges at 40% alpha; `Dot` pulses with RN `Animated` |
|
|
36
|
-
| `EmptyState`, `SectionLabel`, `Panel`, `PanelHeader`, `PanelBody` | Same | Headings carry the header role |
|
|
37
|
-
| `List`, `ListRow` | None (the web uses card buttons) | FlashList; hairline separators, iOS disclosure chevron, selected rows on a green tint, `startAtBottom` for a chat list |
|
|
38
|
-
| `Sheet` and its parts | Sheet (`side` and `width` dropped) | `BottomSheetModal`: drag handle, sized to content, drag down, backdrop tap or Android back closes; fields inside switch to the sheet's own input |
|
|
39
|
-
| `Dialog` and its parts | Dialog (`width`, footer `plain` or `bar`) | RN `Modal` with an `Animated` pop; centred card; Android back and a backdrop tap close it |
|
|
40
|
-
| `DropdownMenu` and its parts | DropdownMenu (no submenus yet) | An action list in a bottom sheet; selection haptic; destructive items in red |
|
|
41
|
-
| `Tabs` and its parts, `TabBadge` | Tabs | Horizontal `ScrollView`; tab roles; active tab on a green tint; selection haptic |
|
|
42
|
-
| `SegmentedControl` | Select (task status) | segmented-control through `withUnistyles`; native on iOS, the library's fallback elsewhere |
|
|
43
|
-
| `CodeBlock` | CodeBlock (`text`, `language`) | Horizontal scroll, selectable mono text, expo-clipboard copy; no colouring or mermaid yet |
|
|
44
|
-
| `Markdown` | Markdown (`text`, `onFileLink`) | The package's own parser; links open with `Linking`; no tables, images or blockquotes yet |
|
|
45
|
-
| `MessageItem` and its parts, `toolTone`, `STATUS_LABEL` | MessageItem | The header is one Pressable that expands the item; edge from `STATUS_EDGE`; outcome as a `StatusBadge` |
|
|
46
|
-
| Icons (`CheckIcon` ... `CloseIcon`, 14) | icons.ts, same names | SF Symbols on iOS, MaterialIcons on Android and web |
|
|
47
|
-
| `PoNativeProvider` | None | `GestureHandlerRootView` and `BottomSheetModalProvider` |
|
|
48
|
-
| `fontOf`, `impactLight`, `selectionTick` | None | Per-platform font family; the haptics policy |
|
|
23
|
+
## Build and stories
|
|
49
24
|
|
|
50
|
-
`
|
|
51
|
-
alpha mixes are computed in render because Unistyles hands stylesheets CSS variables on web.
|
|
25
|
+
`tsdown` emits unbundled ESM with bare dependencies external, so Metro uses the app's single React, Unistyles, and native-library instances. The build applies the Unistyles Babel rewrite before publication.
|
|
52
26
|
|
|
53
|
-
|
|
27
|
+
Component stories are titled `Native/Components/<Name>`. Preview them through the repository's style-system tooling and preserve their identities through implementation. The story-only theme setup in `src/unistyles.ts` is not exported.
|
|
54
28
|
|
|
55
|
-
|
|
56
|
-
external, so each native library resolves from the app's single copy. The Unistyles Babel rewrite
|
|
57
|
-
runs at build time through `unistylesBabel` from `@agimon-ai/po-build/tsdown`.
|
|
58
|
-
|
|
59
|
-
## Stories
|
|
60
|
-
|
|
61
|
-
Each component has a colocated `*.stories.tsx` titled `Native/Components/<Name>`, rendered from the
|
|
62
|
-
repository root:
|
|
63
|
-
|
|
64
|
-
```sh
|
|
65
|
-
pnpm exec style-system get-ui-component -c 'Native/Components/Button' -a packages/core/po-native-components -s Playground
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
`src/unistyles.ts` registers the themes for story renders only and is never exported. Story renders
|
|
69
|
-
run on react-native-web, so they cannot show SF Symbols, haptics or native ripples; check those on
|
|
70
|
-
a device. The SegmentedControl story does not render: style-system's bundler cannot parse the Flow
|
|
71
|
-
source segmented-control ships for its non-iOS fallback.
|
|
29
|
+
React Native Web previews do not verify SF Symbols, haptics, ripples, native sheets, or device accessibility behavior. Check those on the target platform. A rendered story is not human approval.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/components/AgentAvatar.d.ts
|
|
2
|
+
/** How an agent is doing, as the avatar's corner dot shows it. */
|
|
3
|
+
export type AgentState = 'running' | 'waiting' | 'done' | 'failed';
|
|
4
|
+
/** One letter for a first name, two for a hyphenated agent name (`po-developer` is PD). */
|
|
5
|
+
export declare function agentInitials(name: string): string;
|
|
6
|
+
declare const TINTS: readonly ["green", "teal", "blue", "cyan", "yellow", "violet"];
|
|
7
|
+
export type Tint = (typeof TINTS)[number];
|
|
8
|
+
/** The tint an avatar seed always reads as, so surfaces outside React Native can paint the same face. */
|
|
9
|
+
export declare function tintFor(seed: string): Tint;
|
|
10
|
+
/** An agent's face: its initials on a tint fixed by `seed`, with its state as a corner dot. */
|
|
11
|
+
export declare function AgentAvatar({ name, seed, state, size }: {
|
|
12
|
+
name: string;
|
|
13
|
+
seed?: string;
|
|
14
|
+
state?: AgentState;
|
|
15
|
+
size?: 'sm' | 'md';
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
//#endregion
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=AgentAvatar.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentAvatar.d.mts","names":[],"sources":["../../src/components/AgentAvatar.tsx"],"mappings":";;YAQY;;wBAGI,cAAc;cAUxB;YACM,eAAe;;wBAGX,QAAQ,eAAe;;wBAgBvB,cACd,MACA,MACA,OACA;EAEA;EACA;EACA,QAAQ;EACR;oBACD,IAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { Dot } from "./Dot.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/AgentAvatar.tsx
|
|
9
|
+
/** One letter for a first name, two for a hyphenated agent name (`po-developer` is PD). */
|
|
10
|
+
function agentInitials(name) {
|
|
11
|
+
return name.split(/[-_.\s]+/u).filter(Boolean).slice(0, 2).map((part) => part.charAt(0).toUpperCase()).join("");
|
|
12
|
+
}
|
|
13
|
+
const TINTS = [
|
|
14
|
+
"green",
|
|
15
|
+
"teal",
|
|
16
|
+
"blue",
|
|
17
|
+
"cyan",
|
|
18
|
+
"yellow",
|
|
19
|
+
"violet"
|
|
20
|
+
];
|
|
21
|
+
/** The tint an avatar seed always reads as, so surfaces outside React Native can paint the same face. */
|
|
22
|
+
function tintFor(seed) {
|
|
23
|
+
let hash = 0;
|
|
24
|
+
for (const char of seed) hash = (hash * 31 + char.charCodeAt(0)) % 997;
|
|
25
|
+
return TINTS[hash % TINTS.length] ?? "green";
|
|
26
|
+
}
|
|
27
|
+
const RING = 2;
|
|
28
|
+
const STATE_DOT = {
|
|
29
|
+
running: "green",
|
|
30
|
+
waiting: "yellow",
|
|
31
|
+
done: "neutral",
|
|
32
|
+
failed: "red"
|
|
33
|
+
};
|
|
34
|
+
/** An agent's face: its initials on a tint fixed by `seed`, with its state as a corner dot. */
|
|
35
|
+
function AgentAvatar({ name, seed = name, state, size = "md" }) {
|
|
36
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
37
|
+
accessible: true,
|
|
38
|
+
accessibilityRole: "image",
|
|
39
|
+
accessibilityLabel: state ? `${name}, ${state}` : name,
|
|
40
|
+
testID: "agent-avatar",
|
|
41
|
+
style: styles.frame,
|
|
42
|
+
children: [/* @__PURE__ */ jsx(View, {
|
|
43
|
+
style: styles.face(tintFor(seed), size === "sm" ? 24 : 32),
|
|
44
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
45
|
+
style: styles.initials,
|
|
46
|
+
children: agentInitials(name)
|
|
47
|
+
})
|
|
48
|
+
}), state ? /* @__PURE__ */ jsx(Dot, {
|
|
49
|
+
tone: STATE_DOT[state],
|
|
50
|
+
size: "md",
|
|
51
|
+
pulse: state === "running",
|
|
52
|
+
style: styles.dot
|
|
53
|
+
}) : null]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const styles = StyleSheet.create((theme) => ({
|
|
57
|
+
frame: { flexShrink: 0 },
|
|
58
|
+
face: (tint, side) => ({
|
|
59
|
+
width: side,
|
|
60
|
+
height: side,
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
justifyContent: "center",
|
|
63
|
+
borderRadius: theme.borderRadius.full,
|
|
64
|
+
backgroundColor: theme.colors[`tint-${tint}`],
|
|
65
|
+
uni__dependencies: [0]
|
|
66
|
+
}),
|
|
67
|
+
initials: {
|
|
68
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
69
|
+
fontSize: theme.fontSize.sm,
|
|
70
|
+
lineHeight: theme.lineHeight.sm,
|
|
71
|
+
color: theme.colors.hi,
|
|
72
|
+
uni__dependencies: [0]
|
|
73
|
+
},
|
|
74
|
+
dot: {
|
|
75
|
+
position: "absolute",
|
|
76
|
+
right: -4,
|
|
77
|
+
bottom: -4,
|
|
78
|
+
width: theme.spacing(2) + 4,
|
|
79
|
+
height: theme.spacing(2) + 4,
|
|
80
|
+
borderWidth: RING,
|
|
81
|
+
borderColor: theme.colors.panel,
|
|
82
|
+
uni__dependencies: [0]
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { AgentAvatar, agentInitials, tintFor };
|
|
88
|
+
//# sourceMappingURL=AgentAvatar.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentAvatar.mjs","names":["DotTone","StyleSheet","fontOf","Dot","AgentState","agentInitials","name","split","filter","Boolean","slice","map","part","charAt","toUpperCase","join","TINTS","const","Tint","tintFor","seed","hash","char","charCodeAt","length","RING","STATE_DOT","Readonly","Record","running","waiting","done","failed","AgentAvatar","state","size","styles","frame","face","initials","dot","create","theme","flexShrink","tint","side","width","height","alignItems","justifyContent","borderRadius","full","backgroundColor","colors","uni__dependencies","fontFamily","sans","fontSize","sm","lineHeight","color","hi","position","right","bottom","spacing","borderWidth","borderColor","panel"],"sources":["../../src/components/AgentAvatar.tsx"],"sourcesContent":["import type { DotTone } from '@agimon-ai/po-web-components/nativeTheme';\nimport { Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { Dot } from './Dot';\n\n/** How an agent is doing, as the avatar's corner dot shows it. */\nexport type AgentState = 'running' | 'waiting' | 'done' | 'failed';\n\n/** One letter for a first name, two for a hyphenated agent name (`po-developer` is PD). */\nexport function agentInitials(name: string): string {\n return name\n .split(/[-_.\\s]+/u)\n .filter(Boolean)\n .slice(0, 2)\n .map((part) => part.charAt(0).toUpperCase())\n .join('');\n}\n\n// ponytail: mirrors po-web-components AgentAvatar's tint hash; keep the two in step so a seed reads the same tint.\nconst TINTS = ['green', 'teal', 'blue', 'cyan', 'yellow', 'violet'] as const;\nexport type Tint = (typeof TINTS)[number];\n\n/** The tint an avatar seed always reads as, so surfaces outside React Native can paint the same face. */\nexport function tintFor(seed: string): Tint {\n let hash = 0;\n for (const char of seed) hash = (hash * 31 + char.charCodeAt(0)) % 997;\n return TINTS[hash % TINTS.length] ?? 'green';\n}\n\nconst RING = 2;\n\nconst STATE_DOT: Readonly<Record<AgentState, DotTone>> = {\n running: 'green',\n waiting: 'yellow',\n done: 'neutral',\n failed: 'red',\n};\n\n/** An agent's face: its initials on a tint fixed by `seed`, with its state as a corner dot. */\nexport function AgentAvatar({\n name,\n seed = name,\n state,\n size = 'md',\n}: {\n name: string;\n seed?: string;\n state?: AgentState;\n size?: 'sm' | 'md';\n}) {\n return (\n <View\n accessible\n accessibilityRole=\"image\"\n accessibilityLabel={state ? `${name}, ${state}` : name}\n testID=\"agent-avatar\"\n style={styles.frame}\n >\n <View style={styles.face(tintFor(seed), size === 'sm' ? 24 : 32)}>\n <Text style={styles.initials}>{agentInitials(name)}</Text>\n </View>\n {state ? <Dot tone={STATE_DOT[state]} size=\"md\" pulse={state === 'running'} style={styles.dot} /> : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { flexShrink: 0 },\n // `size-6` and `size-8`.\n face: (tint: Tint, side: number) => ({\n width: side,\n height: side,\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: theme.borderRadius.full,\n backgroundColor: theme.colors[`tint-${tint}`],\n }),\n initials: {\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n lineHeight: theme.lineHeight.sm,\n color: theme.colors.hi,\n },\n // `-right-0.5 -bottom-0.5 ring-2 ring-po-panel`: a ring sits outside the dot, a border inside, so the box grows by it.\n dot: {\n position: 'absolute',\n right: -2 - RING,\n bottom: -2 - RING,\n width: theme.spacing(2) + 2 * RING,\n height: theme.spacing(2) + 2 * RING,\n borderWidth: RING,\n borderColor: theme.colors.panel,\n },\n}));\n"],"mappings":";;;;;;;;;AAWA,SAAgBK,cAAcC,MAAsB;CAClD,OAAOA,KACJC,MAAM,WAAW,CAAC,CAClBC,OAAOC,OAAO,CAAC,CACfC,MAAM,GAAG,CAAC,CAAC,CACXC,KAAKC,SAASA,KAAKC,OAAO,CAAC,CAAC,CAACC,YAAY,CAAC,CAAC,CAC3CC,KAAK,EAAE;AACZ;AAGA,MAAMC,QAAQ;CAAC;CAAS;CAAQ;CAAQ;CAAQ;CAAU;AAAQ;;AAIlE,SAAgBG,QAAQC,MAAoB;CAC1C,IAAIC,OAAO;CACX,KAAK,MAAMC,QAAQF,MAAMC,QAAQA,OAAO,KAAKC,KAAKC,WAAW,CAAC,KAAK;CACnE,OAAOP,MAAMK,OAAOL,MAAMQ,WAAW;AACvC;AAEA,MAAMC,OAAO;AAEb,MAAMC,YAAmD;CACvDG,SAAS;CACTC,SAAS;CACTC,MAAM;CACNC,QAAQ;AACV;;AAGA,SAAgBC,YAAY,EAC1B3B,MACAc,OAAOd,MACP4B,OACAC,OAAO,QAMN;CACD,OACE,qBAAC,MAAD;EACE;EACA,mBAAkB;EAClB,oBAAoBD,QAAQ,GAAG5B,KAAI,IAAK4B,UAAU5B;EAClD,QAAO;EACP,OAAO8B,OAAOC;YALhB,CAOE,oBAAC,MAAD;GAAM,OAAOD,OAAOE,KAAKnB,QAAQC,IAAI,GAAGe,SAAS,OAAO,KAAK,EAAE;aAC7D,oBAAC,MAAD;IAAM,OAAOC,OAAOG;cAAWlC,cAAcC,IAAI;GAAQ;EACrD,IACL4B,QAAQ,oBAAC,KAAD;GAAK,MAAMR,UAAUQ;GAAQ,MAAK;GAAK,OAAOA,UAAU;GAAW,OAAOE,OAAOI;EAAI,KAAM,IAChG;;AAEV;AAEA,MAAMJ,SAASnC,WAAWwC,QAAQC,WAAW;CAC3CL,OAAO,EAAEM,YAAY,EAAE;CAEvBL,OAAOM,MAAYC,UAAkB;EACnCC,OAAOD;EACPE,QAAQF;EACRG,YAAY;EACZC,gBAAgB;EAChBC,cAAcR,MAAMQ,aAAaC;EACjCC,iBAAiBV,MAAMW,OAAO,QAAQT;EAAOU,mBAAA,CAAA,CAAA;CAC/C;CACAf,UAAU;EACRgB,YAAYrD,OAAOwC,MAAMa,WAAWC,IAAI;EACxCC,UAAUf,MAAMe,SAASC;EACzBC,YAAYjB,MAAMiB,WAAWD;EAC7BE,OAAOlB,MAAMW,OAAOQ;EAAEP,mBAAA,CAAA,CAAA;CACxB;CAEAd,KAAK;EACHsB,UAAU;EACVC,OAAO;EACPC,QAAQ;EACRlB,OAAOJ,MAAMuB,QAAQ,CAAC,IAAI;EAC1BlB,QAAQL,MAAMuB,QAAQ,CAAC,IAAI;EAC3BC,aAAazC;EACb0C,aAAazB,MAAMW,OAAOe;EAAKd,mBAAA,CAAA,CAAA;CACjC;AACF,EAAE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/components/AnnotationSurface.d.ts
|
|
4
|
+
/** One note pinned to the content, with an optional stroke, in fractions (0 to 1) of the surface's width and height. */
|
|
5
|
+
export interface AnnotationMark {
|
|
6
|
+
id: string;
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
/** The short text drawn on the pin, such as "1". */
|
|
10
|
+
label: string;
|
|
11
|
+
/** What a screen reader announces for the pin, such as the note text. */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Optional normalized freehand stroke. At most 128 finite points are rendered. */
|
|
14
|
+
points?: readonly {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}[];
|
|
18
|
+
/** A translucent, thick rose stroke over the content. */
|
|
19
|
+
highlight?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface AnnotationSurfaceProps {
|
|
22
|
+
/** The content being marked up: an image, a page, a block of text. */
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
marks: readonly AnnotationMark[];
|
|
25
|
+
selectedId?: string;
|
|
26
|
+
/** A tap places a note there. Without onPlace or onDraw the surface is read-only. */
|
|
27
|
+
onPlace?: (point: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}) => void;
|
|
31
|
+
/** Enables drawing instead of tap placement. Receives 2 to 128 finite [0,1] points only on a completed stroke. */
|
|
32
|
+
onDraw?: (points: {
|
|
33
|
+
x: number;
|
|
34
|
+
y: number;
|
|
35
|
+
}[]) => void;
|
|
36
|
+
onSelectMark?: (id: string) => void;
|
|
37
|
+
/** What the content is, such as "hero.png". */
|
|
38
|
+
accessibilityLabel: string;
|
|
39
|
+
/** Image surfaces can pinch and move with two fingers on both native platforms. */
|
|
40
|
+
zoomable?: boolean;
|
|
41
|
+
/** Explicit one-finger pan instead of placing or drawing marks. */
|
|
42
|
+
navigation?: boolean;
|
|
43
|
+
/** Controlled transform. Origins are unscaled RN layout positions, not raster pixels. */
|
|
44
|
+
viewport?: {
|
|
45
|
+
zoom: number;
|
|
46
|
+
originX: number;
|
|
47
|
+
originY: number;
|
|
48
|
+
};
|
|
49
|
+
/** Render the in-progress stroke as a highlight. */
|
|
50
|
+
drawingHighlight?: boolean;
|
|
51
|
+
/** Viewport dimensions and source-layout-to-viewport transform, all in RN layout units, not raster pixels. */
|
|
52
|
+
onViewportChange?: (viewport: {
|
|
53
|
+
width: number;
|
|
54
|
+
height: number;
|
|
55
|
+
zoom: number;
|
|
56
|
+
originX: number;
|
|
57
|
+
originY: number;
|
|
58
|
+
}) => void;
|
|
59
|
+
style?: StyleProp<ViewStyle>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Tap to pin a note on whatever it wraps. Each pin is its own 44pt button, so a
|
|
63
|
+
* screen reader can reach every note; the surface's own element sits behind the
|
|
64
|
+
* content, so text and controls inside stay readable, and activating it places a
|
|
65
|
+
* note at its centre.
|
|
66
|
+
*/
|
|
67
|
+
export declare function AnnotationSurface({ children, marks, selectedId, onPlace, onDraw, onSelectMark, accessibilityLabel, zoomable, onViewportChange, navigation, viewport: controlledViewport, drawingHighlight, style }: AnnotationSurfaceProps): import("react").JSX.Element;
|
|
68
|
+
//#endregion
|
|
69
|
+
//# sourceMappingURL=AnnotationSurface.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationSurface.d.mts","names":[],"sources":["../../src/components/AnnotationSurface.tsx"],"mappings":";;;;iBASiB;EACf;EACA;EACA;;EAEA;;EAEA;;EAEA;IAAoB;IAAW;;;EAE/B;;iBAGe;;EAEf,UAAU;EACV,gBAAgB;EAChB;;EAEA,WAAW;IAAS;IAAW;;;EAE/B,UAAU;IAAU;IAAW;;EAC/B,gBAAgB;;EAEhB;;EAEA;;EAEA;;EAEA;IAAa;IAAc;IAAiB;;;EAE5C;;EAEA,oBAAoB;IAClB;IACA;IACA;IACA;IACA;;EAEF,QAAQ,UAAU;;;;;;;;wBAqDJ,oBACd,UACA,OACA,YACA,SACA,QACA,cACA,oBACA,UACA,kBACA,YACA,UAAU,oBACV,kBACA,SACC,yCAAsB,IAAA"}
|