@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
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
+
import { selectionTick } from "../lib/haptics.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 { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
9
|
+
import { useT } from "@agimon-ai/po-core/native";
|
|
10
|
+
|
|
11
|
+
//#region src/components/AnnotationSurface.tsx
|
|
12
|
+
const clamp = (value) => Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0;
|
|
13
|
+
const MAX_POINTS = 128;
|
|
14
|
+
function Stroke({ points, width, height, highlight = false }) {
|
|
15
|
+
const thickness = highlight ? 16 : 3;
|
|
16
|
+
const bounded = points.slice(0, MAX_POINTS);
|
|
17
|
+
return bounded.map((point, index) => {
|
|
18
|
+
const previous = bounded[index - 1];
|
|
19
|
+
if (!previous || ![
|
|
20
|
+
point.x,
|
|
21
|
+
point.y,
|
|
22
|
+
previous.x,
|
|
23
|
+
previous.y
|
|
24
|
+
].every(Number.isFinite)) return null;
|
|
25
|
+
const x = clamp(previous.x) * width;
|
|
26
|
+
const y = clamp(previous.y) * height;
|
|
27
|
+
const dx = clamp(point.x) * width - x;
|
|
28
|
+
const dy = clamp(point.y) * height - y;
|
|
29
|
+
const length = Math.hypot(dx, dy);
|
|
30
|
+
return /* @__PURE__ */ jsx(View, { style: [
|
|
31
|
+
styles.segment,
|
|
32
|
+
highlight && styles.highlight,
|
|
33
|
+
{
|
|
34
|
+
left: x + dx / 2 - length / 2,
|
|
35
|
+
top: y + dy / 2 - thickness / 2,
|
|
36
|
+
width: length,
|
|
37
|
+
transform: [{ rotate: `${Math.atan2(dy, dx)}rad` }]
|
|
38
|
+
}
|
|
39
|
+
] }, index);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Tap to pin a note on whatever it wraps. Each pin is its own 44pt button, so a
|
|
44
|
+
* screen reader can reach every note; the surface's own element sits behind the
|
|
45
|
+
* content, so text and controls inside stay readable, and activating it places a
|
|
46
|
+
* note at its centre.
|
|
47
|
+
*/
|
|
48
|
+
function AnnotationSurface({ children, marks, selectedId, onPlace, onDraw, onSelectMark, accessibilityLabel, zoomable = false, onViewportChange, navigation = false, viewport: controlledViewport, drawingHighlight = false, style }) {
|
|
49
|
+
const t = useT();
|
|
50
|
+
const [size, setSize] = useState({
|
|
51
|
+
width: 0,
|
|
52
|
+
height: 0
|
|
53
|
+
});
|
|
54
|
+
const [viewport, setViewport] = useState({
|
|
55
|
+
scale: 1,
|
|
56
|
+
x: 0,
|
|
57
|
+
y: 0
|
|
58
|
+
});
|
|
59
|
+
const transform = useRef(viewport);
|
|
60
|
+
const pinch = useRef(null);
|
|
61
|
+
const suppressTap = useRef(false);
|
|
62
|
+
const pressedPoint = useRef(void 0);
|
|
63
|
+
const navigating = useRef(false);
|
|
64
|
+
const reportViewport = (next, dimensions = size) => {
|
|
65
|
+
onViewportChange?.({
|
|
66
|
+
...dimensions,
|
|
67
|
+
zoom: next.scale,
|
|
68
|
+
originX: dimensions.width * (1 - next.scale) / 2 + next.x,
|
|
69
|
+
originY: dimensions.height * (1 - next.scale) / 2 + next.y
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const boundViewport = (request, dimensions = size) => {
|
|
73
|
+
const scale = zoomable && Number.isFinite(request.zoom) ? Math.max(1, Math.min(4, request.zoom)) : 1;
|
|
74
|
+
const maxX = dimensions.width * (scale - 1) / 2;
|
|
75
|
+
const maxY = dimensions.height * (scale - 1) / 2;
|
|
76
|
+
return {
|
|
77
|
+
scale,
|
|
78
|
+
x: Math.max(-maxX, Math.min(maxX, (Number.isFinite(request.originX) ? request.originX : 0) + maxX)),
|
|
79
|
+
y: Math.max(-maxY, Math.min(maxY, (Number.isFinite(request.originY) ? request.originY : 0) + maxY))
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const resetViewport = (dimensions = size) => {
|
|
83
|
+
pinch.current = null;
|
|
84
|
+
transform.current = boundViewport(controlledViewport ?? {
|
|
85
|
+
zoom: 1,
|
|
86
|
+
originX: 0,
|
|
87
|
+
originY: 0
|
|
88
|
+
}, dimensions);
|
|
89
|
+
setViewport(transform.current);
|
|
90
|
+
reportViewport(transform.current, dimensions);
|
|
91
|
+
};
|
|
92
|
+
useLayoutEffect(() => {
|
|
93
|
+
const next = boundViewport(controlledViewport ?? {
|
|
94
|
+
zoom: 1,
|
|
95
|
+
originX: 0,
|
|
96
|
+
originY: 0
|
|
97
|
+
});
|
|
98
|
+
if (next.scale !== transform.current.scale || Math.abs(next.x - transform.current.x) > 1e-6 || Math.abs(next.y - transform.current.y) > 1e-6) resetViewport();
|
|
99
|
+
}, [
|
|
100
|
+
zoomable,
|
|
101
|
+
controlledViewport?.zoom,
|
|
102
|
+
controlledViewport?.originX,
|
|
103
|
+
controlledViewport?.originY
|
|
104
|
+
]);
|
|
105
|
+
useLayoutEffect(() => {
|
|
106
|
+
reportViewport(transform.current);
|
|
107
|
+
}, [size, onViewportChange]);
|
|
108
|
+
const sourcePoint = (x, y) => {
|
|
109
|
+
const current = transform.current;
|
|
110
|
+
return {
|
|
111
|
+
x: clamp((x - size.width / 2 - current.x) / current.scale / size.width + .5),
|
|
112
|
+
y: clamp((y - size.height / 2 - current.y) / current.scale / size.height + .5)
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
const moveViewport = (event) => {
|
|
116
|
+
const { touches } = event.nativeEvent;
|
|
117
|
+
const [first, second] = touches;
|
|
118
|
+
const count = touches.length;
|
|
119
|
+
if (!zoomable || !first || count !== 2 && !(navigation && count === 1) || size.width <= 0 || size.height <= 0) {
|
|
120
|
+
pinch.current = null;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
cancel();
|
|
124
|
+
suppressTap.current = true;
|
|
125
|
+
const x = second ? (first.pageX + second.pageX) / 2 : first.pageX;
|
|
126
|
+
const y = second ? (first.pageY + second.pageY) / 2 : first.pageY;
|
|
127
|
+
const distance = second ? Math.hypot(first.pageX - second.pageX, first.pageY - second.pageY) : 1;
|
|
128
|
+
if (![
|
|
129
|
+
x,
|
|
130
|
+
y,
|
|
131
|
+
distance
|
|
132
|
+
].every(Number.isFinite) || distance <= 0) {
|
|
133
|
+
pinch.current = null;
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!pinch.current || pinch.current.count !== count) {
|
|
137
|
+
const focalX = Number.isFinite(first.locationX) ? first.locationX + x - first.pageX : x;
|
|
138
|
+
const focalY = Number.isFinite(first.locationY) ? first.locationY + y - first.pageY : y;
|
|
139
|
+
pinch.current = {
|
|
140
|
+
count,
|
|
141
|
+
focalX,
|
|
142
|
+
focalY,
|
|
143
|
+
x,
|
|
144
|
+
y,
|
|
145
|
+
distance,
|
|
146
|
+
scale: transform.current.scale,
|
|
147
|
+
offsetX: transform.current.x,
|
|
148
|
+
offsetY: transform.current.y
|
|
149
|
+
};
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const start = pinch.current;
|
|
153
|
+
const scale = Math.max(1, Math.min(4, start.scale * distance / start.distance));
|
|
154
|
+
const ratio = scale / start.scale;
|
|
155
|
+
const maxX = size.width * (scale - 1) / 2;
|
|
156
|
+
const maxY = size.height * (scale - 1) / 2;
|
|
157
|
+
transform.current = {
|
|
158
|
+
scale,
|
|
159
|
+
x: Math.max(-maxX, Math.min(maxX, start.offsetX * ratio + (start.focalX - size.width / 2) * (1 - ratio) + x - start.x)),
|
|
160
|
+
y: Math.max(-maxY, Math.min(maxY, start.offsetY * ratio + (start.focalY - size.height / 2) * (1 - ratio) + y - start.y))
|
|
161
|
+
};
|
|
162
|
+
reportViewport(transform.current);
|
|
163
|
+
setViewport(transform.current);
|
|
164
|
+
};
|
|
165
|
+
const [live, setLive] = useState([]);
|
|
166
|
+
const stroke = useRef(null);
|
|
167
|
+
const draw = useRef(onDraw);
|
|
168
|
+
draw.current = onDraw;
|
|
169
|
+
const drawing = onDraw !== void 0;
|
|
170
|
+
const cancel = () => {
|
|
171
|
+
stroke.current = null;
|
|
172
|
+
pressedPoint.current = void 0;
|
|
173
|
+
setLive([]);
|
|
174
|
+
};
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
stroke.current = null;
|
|
177
|
+
setLive([]);
|
|
178
|
+
return () => {
|
|
179
|
+
stroke.current = null;
|
|
180
|
+
};
|
|
181
|
+
}, [
|
|
182
|
+
drawing,
|
|
183
|
+
navigation,
|
|
184
|
+
drawingHighlight,
|
|
185
|
+
controlledViewport?.zoom,
|
|
186
|
+
controlledViewport?.originX,
|
|
187
|
+
controlledViewport?.originY
|
|
188
|
+
]);
|
|
189
|
+
const append = (event) => {
|
|
190
|
+
if (!stroke.current || !draw.current) return cancel();
|
|
191
|
+
const { locationX, locationY, touches } = event.nativeEvent;
|
|
192
|
+
if (touches.length > 1 || ![
|
|
193
|
+
locationX,
|
|
194
|
+
locationY,
|
|
195
|
+
size.width,
|
|
196
|
+
size.height
|
|
197
|
+
].every(Number.isFinite) || size.width <= 0 || size.height <= 0) return cancel();
|
|
198
|
+
const point = sourcePoint(locationX, locationY);
|
|
199
|
+
const last = stroke.current[stroke.current.length - 1];
|
|
200
|
+
if (last?.x === point.x && last.y === point.y) return;
|
|
201
|
+
if (stroke.current.length < MAX_POINTS) stroke.current.push(point);
|
|
202
|
+
else stroke.current[127] = point;
|
|
203
|
+
setLive([...stroke.current]);
|
|
204
|
+
};
|
|
205
|
+
const place = (event) => {
|
|
206
|
+
if (!onPlace || onDraw || navigation || suppressTap.current) return;
|
|
207
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
208
|
+
const point = size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY) ? sourcePoint(locationX, locationY) : pressedPoint.current ?? {
|
|
209
|
+
x: .5,
|
|
210
|
+
y: .5
|
|
211
|
+
};
|
|
212
|
+
pressedPoint.current = void 0;
|
|
213
|
+
selectionTick();
|
|
214
|
+
onPlace(point);
|
|
215
|
+
};
|
|
216
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
217
|
+
style: [
|
|
218
|
+
styles.frame,
|
|
219
|
+
zoomable && { overflow: "hidden" },
|
|
220
|
+
style
|
|
221
|
+
],
|
|
222
|
+
onStartShouldSetResponderCapture: (event) => zoomable && (navigation || event.nativeEvent.touches.length > 1),
|
|
223
|
+
onMoveShouldSetResponderCapture: (event) => zoomable && (navigation || event.nativeEvent.touches.length > 1),
|
|
224
|
+
onResponderGrant: zoomable ? (event) => {
|
|
225
|
+
cancel();
|
|
226
|
+
navigating.current = true;
|
|
227
|
+
suppressTap.current = true;
|
|
228
|
+
moveViewport(event);
|
|
229
|
+
} : void 0,
|
|
230
|
+
onResponderStart: zoomable ? (event) => {
|
|
231
|
+
cancel();
|
|
232
|
+
moveViewport(event);
|
|
233
|
+
} : void 0,
|
|
234
|
+
onResponderEnd: zoomable ? (event) => {
|
|
235
|
+
cancel();
|
|
236
|
+
moveViewport(event);
|
|
237
|
+
} : void 0,
|
|
238
|
+
onResponderMove: zoomable ? moveViewport : void 0,
|
|
239
|
+
onResponderRelease: zoomable ? () => {
|
|
240
|
+
navigating.current = false;
|
|
241
|
+
pinch.current = null;
|
|
242
|
+
} : void 0,
|
|
243
|
+
onResponderTerminationRequest: () => true,
|
|
244
|
+
onResponderTerminate: zoomable ? () => {
|
|
245
|
+
navigating.current = false;
|
|
246
|
+
pinch.current = null;
|
|
247
|
+
cancel();
|
|
248
|
+
} : void 0,
|
|
249
|
+
onLayout: (event) => {
|
|
250
|
+
cancel();
|
|
251
|
+
const { width, height } = event.nativeEvent.layout;
|
|
252
|
+
const dimensions = {
|
|
253
|
+
width: Number.isFinite(width) ? Math.max(0, width) : 0,
|
|
254
|
+
height: Number.isFinite(height) ? Math.max(0, height) : 0
|
|
255
|
+
};
|
|
256
|
+
resetViewport(dimensions);
|
|
257
|
+
setSize(dimensions);
|
|
258
|
+
},
|
|
259
|
+
children: [
|
|
260
|
+
/* @__PURE__ */ jsx(View, {
|
|
261
|
+
pointerEvents: "none",
|
|
262
|
+
style: styles.overlay,
|
|
263
|
+
accessible: true,
|
|
264
|
+
accessibilityRole: onPlace && !onDraw ? "button" : "image",
|
|
265
|
+
accessibilityLabel,
|
|
266
|
+
accessibilityHint: onPlace && !onDraw ? t("nativeComponents.annotation.placeHint", "Double tap to add a note here. Use the Note on whole image action to mark the whole image.") : void 0,
|
|
267
|
+
accessibilityActions: onPlace ? [...onDraw ? [] : [{ name: "activate" }], {
|
|
268
|
+
name: "noteWholeImage",
|
|
269
|
+
label: t("nativeComponents.annotation.noteWholeImage", "Note on whole image")
|
|
270
|
+
}] : void 0,
|
|
271
|
+
onAccessibilityAction: (event) => {
|
|
272
|
+
const { actionName } = event.nativeEvent;
|
|
273
|
+
if (actionName === "noteWholeImage" || actionName === "activate" && !onDraw) onPlace?.({
|
|
274
|
+
x: .5,
|
|
275
|
+
y: .5
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ jsx(Pressable, {
|
|
280
|
+
accessible: false,
|
|
281
|
+
disabled: !onPlace || !!onDraw || navigation,
|
|
282
|
+
onPressIn: (event) => {
|
|
283
|
+
pressedPoint.current = void 0;
|
|
284
|
+
if (navigating.current) return;
|
|
285
|
+
suppressTap.current = false;
|
|
286
|
+
const { locationX, locationY } = event.nativeEvent;
|
|
287
|
+
if (size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY)) pressedPoint.current = sourcePoint(locationX, locationY);
|
|
288
|
+
},
|
|
289
|
+
onPress: place,
|
|
290
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
291
|
+
pointerEvents: zoomable && viewport.scale > 1 ? "none" : "auto",
|
|
292
|
+
style: zoomable ? { transform: [
|
|
293
|
+
{ translateX: viewport.x },
|
|
294
|
+
{ translateY: viewport.y },
|
|
295
|
+
{ scale: viewport.scale }
|
|
296
|
+
] } : void 0,
|
|
297
|
+
children: [children, /* @__PURE__ */ jsxs(View, {
|
|
298
|
+
pointerEvents: "none",
|
|
299
|
+
accessible: false,
|
|
300
|
+
style: styles.overlay,
|
|
301
|
+
children: [marks.map((mark) => mark.points && /* @__PURE__ */ jsx(Stroke, {
|
|
302
|
+
points: mark.points,
|
|
303
|
+
width: size.width,
|
|
304
|
+
height: size.height,
|
|
305
|
+
highlight: mark.highlight
|
|
306
|
+
}, mark.id)), onDraw && /* @__PURE__ */ jsx(Stroke, {
|
|
307
|
+
points: live,
|
|
308
|
+
width: size.width,
|
|
309
|
+
height: size.height,
|
|
310
|
+
highlight: drawingHighlight
|
|
311
|
+
})]
|
|
312
|
+
})]
|
|
313
|
+
})
|
|
314
|
+
}),
|
|
315
|
+
onDraw && !navigation && /* @__PURE__ */ jsx(View, {
|
|
316
|
+
accessible: false,
|
|
317
|
+
collapsable: false,
|
|
318
|
+
style: styles.overlay,
|
|
319
|
+
onStartShouldSetResponder: () => true,
|
|
320
|
+
onResponderGrant: (event) => {
|
|
321
|
+
stroke.current = [];
|
|
322
|
+
append(event);
|
|
323
|
+
},
|
|
324
|
+
onResponderStart: (event) => {
|
|
325
|
+
if (event.nativeEvent.touches.length > 1) cancel();
|
|
326
|
+
},
|
|
327
|
+
onResponderMove: append,
|
|
328
|
+
onResponderRelease: (event) => {
|
|
329
|
+
append(event);
|
|
330
|
+
const points = stroke.current;
|
|
331
|
+
cancel();
|
|
332
|
+
if (points && points.length >= 2 && points.some((point) => point.x !== points[0].x || point.y !== points[0].y)) draw.current?.(points);
|
|
333
|
+
},
|
|
334
|
+
onResponderTerminationRequest: () => true,
|
|
335
|
+
onResponderTerminate: cancel
|
|
336
|
+
}),
|
|
337
|
+
marks.map((mark) => {
|
|
338
|
+
const selected = mark.id === selectedId;
|
|
339
|
+
return /* @__PURE__ */ jsx(Pressable, {
|
|
340
|
+
accessibilityRole: "button",
|
|
341
|
+
accessibilityLabel: mark.description ? t("nativeComponents.annotation.markDescribed", "Note {label}: {description}", {
|
|
342
|
+
label: mark.label,
|
|
343
|
+
description: mark.description
|
|
344
|
+
}) : t("nativeComponents.annotation.mark", "Note {label}", { label: mark.label }),
|
|
345
|
+
accessibilityState: { selected },
|
|
346
|
+
onPress: () => onSelectMark?.(mark.id),
|
|
347
|
+
style: [styles.hit, zoomable ? {
|
|
348
|
+
left: size.width / 2 + (clamp(mark.x) - .5) * size.width * viewport.scale + viewport.x,
|
|
349
|
+
top: size.height / 2 + (clamp(mark.y) - .5) * size.height * viewport.scale + viewport.y
|
|
350
|
+
} : {
|
|
351
|
+
left: `${clamp(mark.x) * 100}%`,
|
|
352
|
+
top: `${clamp(mark.y) * 100}%`
|
|
353
|
+
}],
|
|
354
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
355
|
+
style: [styles.pin, selected && styles.pinSelected],
|
|
356
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
357
|
+
style: [styles.label, selected && styles.labelSelected],
|
|
358
|
+
children: mark.label
|
|
359
|
+
})
|
|
360
|
+
})
|
|
361
|
+
}, mark.id);
|
|
362
|
+
})
|
|
363
|
+
]
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
const HIT = 44;
|
|
367
|
+
const PIN = 28;
|
|
368
|
+
const styles = StyleSheet.create((theme) => ({
|
|
369
|
+
frame: {
|
|
370
|
+
position: "relative",
|
|
371
|
+
alignSelf: "stretch"
|
|
372
|
+
},
|
|
373
|
+
overlay: {
|
|
374
|
+
position: "absolute",
|
|
375
|
+
top: 0,
|
|
376
|
+
right: 0,
|
|
377
|
+
bottom: 0,
|
|
378
|
+
left: 0
|
|
379
|
+
},
|
|
380
|
+
segment: {
|
|
381
|
+
position: "absolute",
|
|
382
|
+
height: 3,
|
|
383
|
+
borderRadius: 1.5,
|
|
384
|
+
backgroundColor: theme.colors.magenta,
|
|
385
|
+
uni__dependencies: [0]
|
|
386
|
+
},
|
|
387
|
+
highlight: {
|
|
388
|
+
height: 16,
|
|
389
|
+
borderRadius: 8,
|
|
390
|
+
opacity: .3
|
|
391
|
+
},
|
|
392
|
+
hit: {
|
|
393
|
+
position: "absolute",
|
|
394
|
+
width: HIT,
|
|
395
|
+
height: HIT,
|
|
396
|
+
marginLeft: -22,
|
|
397
|
+
marginTop: -22,
|
|
398
|
+
alignItems: "center",
|
|
399
|
+
justifyContent: "center"
|
|
400
|
+
},
|
|
401
|
+
pin: {
|
|
402
|
+
width: PIN,
|
|
403
|
+
height: PIN,
|
|
404
|
+
borderRadius: PIN / 2,
|
|
405
|
+
alignItems: "center",
|
|
406
|
+
justifyContent: "center",
|
|
407
|
+
borderWidth: 2,
|
|
408
|
+
borderColor: theme.colors.magenta,
|
|
409
|
+
backgroundColor: theme.colors.bg,
|
|
410
|
+
uni__dependencies: [0]
|
|
411
|
+
},
|
|
412
|
+
pinSelected: {
|
|
413
|
+
backgroundColor: theme.colors.magenta,
|
|
414
|
+
uni__dependencies: [0]
|
|
415
|
+
},
|
|
416
|
+
label: {
|
|
417
|
+
color: theme.colors.magenta,
|
|
418
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
419
|
+
fontSize: theme.fontSize.sm,
|
|
420
|
+
fontWeight: theme.fontWeight.semibold,
|
|
421
|
+
uni__dependencies: [0]
|
|
422
|
+
},
|
|
423
|
+
labelSelected: {
|
|
424
|
+
color: theme.colors.bg,
|
|
425
|
+
uni__dependencies: [0]
|
|
426
|
+
}
|
|
427
|
+
}));
|
|
428
|
+
|
|
429
|
+
//#endregion
|
|
430
|
+
export { AnnotationSurface };
|
|
431
|
+
//# sourceMappingURL=AnnotationSurface.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationSurface.mjs","names":["useT","ReactNode","useEffect","useLayoutEffect","useRef","useState","GestureResponderEvent","StyleProp","ViewStyle","StyleSheet","fontOf","selectionTick","AnnotationMark","id","x","y","label","description","points","highlight","AnnotationSurfaceProps","children","marks","selectedId","onPlace","point","onDraw","onSelectMark","accessibilityLabel","zoomable","navigation","viewport","zoom","originX","originY","drawingHighlight","onViewportChange","width","height","style","clamp","value","Number","isFinite","Math","min","max","MAX_POINTS","Point","Stroke","thickness","bounded","slice","map","index","previous","every","dx","dy","length","hypot","styles","segment","left","top","transform","rotate","atan2","AnnotationSurface","controlledViewport","t","size","setSize","setViewport","scale","pinch","count","focalX","focalY","distance","offsetX","offsetY","suppressTap","pressedPoint","undefined","navigating","reportViewport","next","dimensions","boundViewport","request","NonNullable","maxX","maxY","resetViewport","current","abs","sourcePoint","moveViewport","event","touches","nativeEvent","first","second","cancel","pageX","pageY","locationX","locationY","start","ratio","live","setLive","stroke","draw","drawing","append","last","push","place","known","frame","overflow","layout","overlay","name","actionName","translateX","translateY","mark","some","selected","hit","pin","pinSelected","labelSelected","HIT","PIN","create","theme","position","alignSelf","right","bottom","borderRadius","backgroundColor","colors","magenta","uni__dependencies","opacity","marginLeft","marginTop","alignItems","justifyContent","borderWidth","borderColor","bg","color","fontFamily","sans","fontSize","sm","fontWeight","semibold"],"sources":["../../src/components/AnnotationSurface.tsx"],"sourcesContent":["import { useT } from '@agimon-ai/po-core/native';\nimport { type ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport { type GestureResponderEvent, Pressable, type StyleProp, Text, View, type ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { selectionTick } from '../lib/haptics';\n\n/** One note pinned to the content, with an optional stroke, in fractions (0 to 1) of the surface's width and height. */\nexport interface AnnotationMark {\n id: string;\n x: number;\n y: number;\n /** The short text drawn on the pin, such as \"1\". */\n label: string;\n /** What a screen reader announces for the pin, such as the note text. */\n description?: string;\n /** Optional normalized freehand stroke. At most 128 finite points are rendered. */\n points?: readonly { x: number; y: number }[];\n /** A translucent, thick rose stroke over the content. */\n highlight?: boolean;\n}\n\nexport interface AnnotationSurfaceProps {\n /** The content being marked up: an image, a page, a block of text. */\n children: ReactNode;\n marks: readonly AnnotationMark[];\n selectedId?: string;\n /** A tap places a note there. Without onPlace or onDraw the surface is read-only. */\n onPlace?: (point: { x: number; y: number }) => void;\n /** Enables drawing instead of tap placement. Receives 2 to 128 finite [0,1] points only on a completed stroke. */\n onDraw?: (points: { x: number; y: number }[]) => void;\n onSelectMark?: (id: string) => void;\n /** What the content is, such as \"hero.png\". */\n accessibilityLabel: string;\n /** Image surfaces can pinch and move with two fingers on both native platforms. */\n zoomable?: boolean;\n /** Explicit one-finger pan instead of placing or drawing marks. */\n navigation?: boolean;\n /** Controlled transform. Origins are unscaled RN layout positions, not raster pixels. */\n viewport?: { zoom: number; originX: number; originY: number };\n /** Render the in-progress stroke as a highlight. */\n drawingHighlight?: boolean;\n /** Viewport dimensions and source-layout-to-viewport transform, all in RN layout units, not raster pixels. */\n onViewportChange?: (viewport: {\n width: number;\n height: number;\n zoom: number;\n originX: number;\n originY: number;\n }) => void;\n style?: StyleProp<ViewStyle>;\n}\n\nconst clamp = (value: number) => (Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : 0);\nconst MAX_POINTS = 128;\ntype Point = { x: number; y: number };\n\nfunction Stroke({\n points,\n width,\n height,\n highlight = false,\n}: {\n points: readonly Point[];\n width: number;\n height: number;\n highlight?: boolean;\n}) {\n const thickness = highlight ? 16 : 3;\n // Slice before processing so even externally supplied strokes have bounded work.\n const bounded = points.slice(0, MAX_POINTS);\n return bounded.map((point, index) => {\n const previous = bounded[index - 1];\n if (!previous || ![point.x, point.y, previous.x, previous.y].every(Number.isFinite)) return null;\n const x = clamp(previous.x) * width;\n const y = clamp(previous.y) * height;\n const dx = clamp(point.x) * width - x;\n const dy = clamp(point.y) * height - y;\n const length = Math.hypot(dx, dy);\n return (\n <View\n key={index}\n style={[\n styles.segment,\n highlight && styles.highlight,\n {\n left: x + dx / 2 - length / 2,\n top: y + dy / 2 - thickness / 2,\n width: length,\n transform: [{ rotate: `${Math.atan2(dy, dx)}rad` }],\n },\n ]}\n />\n );\n });\n}\n\n/**\n * Tap to pin a note on whatever it wraps. Each pin is its own 44pt button, so a\n * screen reader can reach every note; the surface's own element sits behind the\n * content, so text and controls inside stay readable, and activating it places a\n * note at its centre.\n */\nexport function AnnotationSurface({\n children,\n marks,\n selectedId,\n onPlace,\n onDraw,\n onSelectMark,\n accessibilityLabel,\n zoomable = false,\n onViewportChange,\n navigation = false,\n viewport: controlledViewport,\n drawingHighlight = false,\n style,\n}: AnnotationSurfaceProps) {\n const t = useT();\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [viewport, setViewport] = useState({ scale: 1, x: 0, y: 0 });\n const transform = useRef(viewport);\n const pinch = useRef<{\n count: number;\n focalX: number;\n focalY: number;\n distance: number;\n x: number;\n y: number;\n scale: number;\n offsetX: number;\n offsetY: number;\n } | null>(null);\n const suppressTap = useRef(false);\n const pressedPoint = useRef<Point | undefined>(undefined);\n const navigating = useRef(false);\n const reportViewport = (next: typeof viewport, dimensions = size) => {\n onViewportChange?.({\n ...dimensions,\n zoom: next.scale,\n originX: (dimensions.width * (1 - next.scale)) / 2 + next.x,\n originY: (dimensions.height * (1 - next.scale)) / 2 + next.y,\n });\n };\n const boundViewport = (request: NonNullable<AnnotationSurfaceProps['viewport']>, dimensions = size) => {\n const scale = zoomable && Number.isFinite(request.zoom) ? Math.max(1, Math.min(4, request.zoom)) : 1;\n const maxX = (dimensions.width * (scale - 1)) / 2;\n const maxY = (dimensions.height * (scale - 1)) / 2;\n return {\n scale,\n x: Math.max(-maxX, Math.min(maxX, (Number.isFinite(request.originX) ? request.originX : 0) + maxX)),\n y: Math.max(-maxY, Math.min(maxY, (Number.isFinite(request.originY) ? request.originY : 0) + maxY)),\n };\n };\n const resetViewport = (dimensions = size) => {\n pinch.current = null;\n transform.current = boundViewport(controlledViewport ?? { zoom: 1, originX: 0, originY: 0 }, dimensions);\n setViewport(transform.current);\n reportViewport(transform.current, dimensions);\n };\n // Layout effects publish programmatic zoom/Fit/focus before a parent's capture effect.\n useLayoutEffect(() => {\n const next = boundViewport(controlledViewport ?? { zoom: 1, originX: 0, originY: 0 });\n // A controlled parent's gesture echo is not a new navigation command.\n if (\n next.scale !== transform.current.scale ||\n Math.abs(next.x - transform.current.x) > 1e-6 ||\n Math.abs(next.y - transform.current.y) > 1e-6\n )\n resetViewport();\n }, [zoomable, controlledViewport?.zoom, controlledViewport?.originX, controlledViewport?.originY]);\n useLayoutEffect(() => {\n reportViewport(transform.current);\n }, [size, onViewportChange]);\n const sourcePoint = (x: number, y: number) => {\n const current = transform.current;\n return {\n x: clamp((x - size.width / 2 - current.x) / current.scale / size.width + 0.5),\n y: clamp((y - size.height / 2 - current.y) / current.scale / size.height + 0.5),\n };\n };\n const moveViewport = (event: GestureResponderEvent) => {\n const { touches } = event.nativeEvent;\n const [first, second] = touches;\n const count = touches.length;\n if (!zoomable || !first || (count !== 2 && !(navigation && count === 1)) || size.width <= 0 || size.height <= 0) {\n pinch.current = null;\n return;\n }\n cancel();\n suppressTap.current = true;\n const x = second ? (first.pageX + second.pageX) / 2 : first.pageX;\n const y = second ? (first.pageY + second.pageY) / 2 : first.pageY;\n const distance = second ? Math.hypot(first.pageX - second.pageX, first.pageY - second.pageY) : 1;\n if (![x, y, distance].every(Number.isFinite) || distance <= 0) {\n pinch.current = null;\n return;\n }\n if (!pinch.current || pinch.current.count !== count) {\n // Touch locations are frame-local; page positions are used only for movement deltas.\n const focalX = Number.isFinite(first.locationX) ? first.locationX + x - first.pageX : x;\n const focalY = Number.isFinite(first.locationY) ? first.locationY + y - first.pageY : y;\n pinch.current = {\n count,\n focalX,\n focalY,\n x,\n y,\n distance,\n scale: transform.current.scale,\n offsetX: transform.current.x,\n offsetY: transform.current.y,\n };\n return;\n }\n const start = pinch.current;\n const scale = Math.max(1, Math.min(4, (start.scale * distance) / start.distance));\n const ratio = scale / start.scale;\n const maxX = (size.width * (scale - 1)) / 2;\n const maxY = (size.height * (scale - 1)) / 2;\n transform.current = {\n scale,\n x: Math.max(\n -maxX,\n Math.min(maxX, start.offsetX * ratio + (start.focalX - size.width / 2) * (1 - ratio) + x - start.x),\n ),\n y: Math.max(\n -maxY,\n Math.min(maxY, start.offsetY * ratio + (start.focalY - size.height / 2) * (1 - ratio) + y - start.y),\n ),\n };\n // Publish synchronously so capture can reject a gesture even before React renders it.\n reportViewport(transform.current);\n setViewport(transform.current);\n };\n const [live, setLive] = useState<readonly Point[]>([]);\n const stroke = useRef<Point[] | null>(null);\n // Callers pass inline callbacks, so a new identity is not a new tool: only switching drawing off or on cancels.\n const draw = useRef(onDraw);\n draw.current = onDraw;\n const drawing = onDraw !== undefined;\n const cancel = () => {\n stroke.current = null;\n pressedPoint.current = undefined;\n setLive([]);\n };\n useEffect(() => {\n stroke.current = null;\n setLive([]);\n return () => {\n stroke.current = null;\n };\n }, [\n drawing,\n navigation,\n drawingHighlight,\n controlledViewport?.zoom,\n controlledViewport?.originX,\n controlledViewport?.originY,\n ]);\n const append = (event: GestureResponderEvent) => {\n if (!stroke.current || !draw.current) return cancel();\n const { locationX, locationY, touches } = event.nativeEvent;\n if (\n touches.length > 1 ||\n ![locationX, locationY, size.width, size.height].every(Number.isFinite) ||\n size.width <= 0 ||\n size.height <= 0\n )\n return cancel();\n const point = sourcePoint(locationX, locationY);\n const last = stroke.current[stroke.current.length - 1];\n if (last?.x === point.x && last.y === point.y) return;\n // Keep the start and a bounded prefix; update the last point once full.\n if (stroke.current.length < MAX_POINTS) stroke.current.push(point);\n else stroke.current[MAX_POINTS - 1] = point;\n setLive([...stroke.current]);\n };\n const place = (event: GestureResponderEvent) => {\n if (!onPlace || onDraw || navigation || suppressTap.current) return;\n const { locationX, locationY } = event.nativeEvent;\n const known = size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY);\n const point = known ? sourcePoint(locationX, locationY) : (pressedPoint.current ?? { x: 0.5, y: 0.5 });\n pressedPoint.current = undefined;\n selectionTick();\n onPlace(point);\n };\n return (\n <View\n style={[styles.frame, zoomable && { overflow: 'hidden' }, style]}\n onStartShouldSetResponderCapture={(event) => zoomable && (navigation || event.nativeEvent.touches.length > 1)}\n onMoveShouldSetResponderCapture={(event) => zoomable && (navigation || event.nativeEvent.touches.length > 1)}\n onResponderGrant={\n zoomable\n ? (event) => {\n cancel();\n navigating.current = true;\n suppressTap.current = true;\n moveViewport(event);\n }\n : undefined\n }\n onResponderStart={\n zoomable\n ? (event) => {\n cancel();\n moveViewport(event);\n }\n : undefined\n }\n onResponderEnd={\n zoomable\n ? (event) => {\n cancel();\n moveViewport(event);\n }\n : undefined\n }\n onResponderMove={zoomable ? moveViewport : undefined}\n onResponderRelease={\n zoomable\n ? () => {\n navigating.current = false;\n pinch.current = null;\n }\n : undefined\n }\n onResponderTerminationRequest={() => true}\n onResponderTerminate={\n zoomable\n ? () => {\n navigating.current = false;\n pinch.current = null;\n cancel();\n }\n : undefined\n }\n onLayout={(event) => {\n cancel();\n const { width, height } = event.nativeEvent.layout;\n const dimensions = {\n width: Number.isFinite(width) ? Math.max(0, width) : 0,\n height: Number.isFinite(height) ? Math.max(0, height) : 0,\n };\n resetViewport(dimensions);\n setSize(dimensions);\n }}\n >\n <View\n pointerEvents=\"none\"\n style={styles.overlay}\n accessible\n accessibilityRole={onPlace && !onDraw ? 'button' : 'image'}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={\n onPlace && !onDraw\n ? t(\n 'nativeComponents.annotation.placeHint',\n 'Double tap to add a note here. Use the Note on whole image action to mark the whole image.',\n )\n : undefined\n }\n accessibilityActions={\n onPlace\n ? [\n ...(onDraw ? [] : [{ name: 'activate' }]),\n {\n name: 'noteWholeImage',\n label: t('nativeComponents.annotation.noteWholeImage', 'Note on whole image'),\n },\n ]\n : undefined\n }\n onAccessibilityAction={(event) => {\n const { actionName } = event.nativeEvent;\n if (actionName === 'noteWholeImage' || (actionName === 'activate' && !onDraw)) onPlace?.({ x: 0.5, y: 0.5 });\n }}\n />\n <Pressable\n accessible={false}\n disabled={!onPlace || !!onDraw || navigation}\n onPressIn={(event) => {\n pressedPoint.current = undefined;\n if (navigating.current) return;\n suppressTap.current = false;\n // react-native-web onPress is a MouseEvent; its responder start retains the native location.\n const { locationX, locationY } = event.nativeEvent;\n if (size.width > 0 && size.height > 0 && Number.isFinite(locationX) && Number.isFinite(locationY))\n pressedPoint.current = sourcePoint(locationX, locationY);\n }}\n onPress={place}\n >\n {/* Zoomed content is only a picture, so every touch maps through the frame. At 1x it keeps its own controls, such as PDF page buttons. */}\n <View\n pointerEvents={zoomable && viewport.scale > 1 ? 'none' : 'auto'}\n style={\n zoomable\n ? { transform: [{ translateX: viewport.x }, { translateY: viewport.y }, { scale: viewport.scale }] }\n : undefined\n }\n >\n {children}\n <View pointerEvents=\"none\" accessible={false} style={styles.overlay}>\n {marks.map(\n (mark) =>\n mark.points && (\n <Stroke\n key={mark.id}\n points={mark.points}\n width={size.width}\n height={size.height}\n highlight={mark.highlight}\n />\n ),\n )}\n {onDraw && <Stroke points={live} width={size.width} height={size.height} highlight={drawingHighlight} />}\n </View>\n </View>\n </Pressable>\n {onDraw && !navigation && (\n <View\n accessible={false}\n // Only JS responder props, which Fabric may flatten out of the native tree; keep it hit-testable.\n collapsable={false}\n style={styles.overlay}\n onStartShouldSetResponder={() => true}\n onResponderGrant={(event) => {\n stroke.current = [];\n append(event);\n }}\n onResponderStart={(event) => {\n if (event.nativeEvent.touches.length > 1) cancel();\n }}\n onResponderMove={append}\n onResponderRelease={(event) => {\n append(event);\n const points = stroke.current;\n cancel();\n if (\n points &&\n points.length >= 2 &&\n points.some((point) => point.x !== points[0].x || point.y !== points[0].y)\n ) {\n draw.current?.(points);\n }\n }}\n onResponderTerminationRequest={() => true}\n onResponderTerminate={cancel}\n />\n )}\n {marks.map((mark) => {\n const selected = mark.id === selectedId;\n return (\n <Pressable\n key={mark.id}\n accessibilityRole=\"button\"\n accessibilityLabel={\n mark.description\n ? t('nativeComponents.annotation.markDescribed', 'Note {label}: {description}', {\n label: mark.label,\n description: mark.description,\n })\n : t('nativeComponents.annotation.mark', 'Note {label}', { label: mark.label })\n }\n accessibilityState={{ selected }}\n onPress={() => onSelectMark?.(mark.id)}\n style={[\n styles.hit,\n zoomable\n ? {\n left: size.width / 2 + (clamp(mark.x) - 0.5) * size.width * viewport.scale + viewport.x,\n top: size.height / 2 + (clamp(mark.y) - 0.5) * size.height * viewport.scale + viewport.y,\n }\n : { left: `${clamp(mark.x) * 100}%`, top: `${clamp(mark.y) * 100}%` },\n ]}\n >\n <View style={[styles.pin, selected && styles.pinSelected]}>\n <Text style={[styles.label, selected && styles.labelSelected]}>{mark.label}</Text>\n </View>\n </Pressable>\n );\n })}\n </View>\n );\n}\n\nconst HIT = 44;\nconst PIN = 28;\n\nconst styles = StyleSheet.create((theme) => ({\n frame: { position: 'relative', alignSelf: 'stretch' },\n overlay: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 },\n segment: { position: 'absolute', height: 3, borderRadius: 1.5, backgroundColor: theme.colors.magenta },\n highlight: { height: 16, borderRadius: 8, opacity: 0.3 },\n hit: {\n position: 'absolute',\n width: HIT,\n height: HIT,\n marginLeft: -HIT / 2,\n marginTop: -HIT / 2,\n alignItems: 'center',\n justifyContent: 'center',\n },\n pin: {\n width: PIN,\n height: PIN,\n borderRadius: PIN / 2,\n alignItems: 'center',\n justifyContent: 'center',\n borderWidth: 2,\n borderColor: theme.colors.magenta,\n backgroundColor: theme.colors.bg,\n },\n pinSelected: { backgroundColor: theme.colors.magenta },\n label: {\n color: theme.colors.magenta,\n fontFamily: fontOf(theme.fontFamily.sans),\n fontSize: theme.fontSize.sm,\n fontWeight: theme.fontWeight.semibold,\n },\n labelSelected: { color: theme.colors.bg },\n}));\n"],"mappings":";;;;;;;;;;;AAsDA,MAAMwC,SAASC,UAAmBC,OAAOC,SAASF,KAAK,IAAIG,KAAKC,IAAI,GAAGD,KAAKE,IAAI,GAAGL,KAAK,CAAC,IAAI;AAC7F,MAAMM,aAAa;AAGnB,SAASE,OAAO,EACd/B,QACAmB,OACAC,QACAnB,YAAY,SAMX;CACD,MAAM+B,YAAY/B,YAAY,KAAK;CAEnC,MAAMgC,UAAUjC,OAAOkC,MAAM,GAAGL,UAAU;CAC1C,OAAOI,QAAQE,KAAK5B,OAAO6B,UAAU;EACnC,MAAMC,WAAWJ,QAAQG,QAAQ;EACjC,IAAI,CAACC,YAAY,CAAC;GAAC9B,MAAMX;GA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AAK;EACHQ,UAAU;EACVvG,OAAOmG;EACPlG,QAAQkG;EACRc,YAAY;EACZC,WAAW;EACXC,YAAY;EACZC,gBAAgB;CAClB;CACApB,KAAK;EACHhG,OAAOoG;EACPnG,QAAQmG;EACRO,cAAcP,MAAM;EACpBe,YAAY;EACZC,gBAAgB;EAChBC,aAAa;EACbC,aAAahB,MAAMO,OAAOC;EAC1BF,iBAAiBN,MAAMO,OAAOU;EAAER,mBAAA,CAAA,CAAA;CAClC;CACAd,aAAa;EAAEW,iBAAiBN,MAAMO,OAAOC;EAAOC,mBAAA,CAAA,CAAA;CAAC;CACrDpI,OAAO;EACL6I,OAAOlB,MAAMO,OAAOC;EACpBW,YAAYpJ,OAAOiI,MAAMmB,WAAWC,IAAI;EACxCC,UAAUrB,MAAMqB,SAASC;EACzBC,YAAYvB,MAAMuB,WAAWC;EAAQf,mBAAA,CAAA,CAAA;CACvC;CACAb,eAAe;EAAEsB,OAAOlB,MAAMO,OAAOU;EAAER,mBAAA,CAAA,CAAA;CAAC;AAC1C,EAAE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChipTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
2
1
|
import { StyleProp, ViewProps, ViewStyle } from "react-native";
|
|
2
|
+
import { ChipTone } from "@agimon-ai/po-web-components/nativeTheme";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
4
|
//#region src/components/Badge.d.ts
|
|
5
5
|
export type BadgeTone = ChipTone;
|
|
@@ -2,12 +2,12 @@ import { fontOf } from "../lib/fonts.mjs";
|
|
|
2
2
|
import { CHIP_INK } from "../lib/tone.mjs";
|
|
3
3
|
import { wrapText } from "../lib/wrapText.mjs";
|
|
4
4
|
import { View } from "react-native-unistyles/components/native/View";
|
|
5
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
6
5
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
6
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
|
|
9
9
|
//#region src/components/Badge.tsx
|
|
10
|
-
/** `border-
|
|
10
|
+
/** `border-po-<accent>/40`. */
|
|
11
11
|
const EDGE_ALPHA_PERCENT = 40;
|
|
12
12
|
/** An outlined chip in one of the accent tones. */
|
|
13
13
|
function Badge({ tone = "neutral", size = "sm", children, style, ...props }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.mjs","names":["ChipTone","withAlpha","ReactNode","StyleProp","ViewProps","ViewStyle","StyleSheet","useUnistyles","fontOf","CHIP_INK","wrapText","BadgeTone","BadgeSize","EDGE_ALPHA_PERCENT","BadgeProps","Omit","tone","size","children","style","Badge","props","theme","_styles","styles","useVariants","edge","undefined","borderColor","colors","badge","label","create","ink","color","flexDirection","alignItems","alignSelf","gap","spacing","borderRadius","DEFAULT","borderWidth","border","variants","xs","paddingHorizontal","paddingVertical","sm","md","lg","uni__dependencies","fontFamily","sans","neutral","blue","green","yellow","red","magenta","violet","cyan","orange","teal","fontSize","lineHeight","fontWeight","semibold","base"],"sources":["../../src/components/Badge.tsx"],"sourcesContent":["import { type ChipTone, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { CHIP_INK } from '../lib/tone';\nimport { wrapText } from '../lib/wrapText';\n\nexport type BadgeTone = ChipTone;\nexport type BadgeSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `border-
|
|
1
|
+
{"version":3,"file":"Badge.mjs","names":["ChipTone","withAlpha","ReactNode","StyleProp","ViewProps","ViewStyle","StyleSheet","useUnistyles","fontOf","CHIP_INK","wrapText","BadgeTone","BadgeSize","EDGE_ALPHA_PERCENT","BadgeProps","Omit","tone","size","children","style","Badge","props","theme","_styles","styles","useVariants","edge","undefined","borderColor","colors","badge","label","create","ink","color","flexDirection","alignItems","alignSelf","gap","spacing","borderRadius","DEFAULT","borderWidth","border","variants","xs","paddingHorizontal","paddingVertical","sm","md","lg","uni__dependencies","fontFamily","sans","neutral","blue","green","yellow","red","magenta","violet","cyan","orange","teal","fontSize","lineHeight","fontWeight","semibold","base"],"sources":["../../src/components/Badge.tsx"],"sourcesContent":["import { type ChipTone, withAlpha } from '@agimon-ai/po-web-components/nativeTheme';\nimport type { ReactNode } from 'react';\nimport { type StyleProp, View, type ViewProps, type ViewStyle } from 'react-native';\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport { fontOf } from '../lib/fonts';\nimport { CHIP_INK } from '../lib/tone';\nimport { wrapText } from '../lib/wrapText';\n\nexport type BadgeTone = ChipTone;\nexport type BadgeSize = 'xs' | 'sm' | 'md' | 'lg';\n\n/** `border-po-<accent>/40`. */\nconst EDGE_ALPHA_PERCENT = 40;\n\nexport interface BadgeProps extends Omit<ViewProps, 'children' | 'style'> {\n tone?: BadgeTone;\n /** The same rungs Button names, so a chip can sit beside a button of any size. */\n size?: BadgeSize;\n children?: ReactNode;\n style?: StyleProp<ViewStyle>;\n}\n\n/** An outlined chip in one of the accent tones. */\nexport function Badge({ tone = 'neutral', size = 'sm', children, style, ...props }: BadgeProps) {\n const { theme } = useUnistyles();\n styles.useVariants({ tone, size });\n // Alpha mixes are computed in render from useUnistyles(), not in StyleSheet.create: on web Unistyles hands\n // the stylesheet CSS variables, which withAlpha cannot read.\n const edge =\n tone === 'neutral' ? undefined : { borderColor: withAlpha(theme.colors[CHIP_INK[tone]], EDGE_ALPHA_PERCENT) };\n return (\n <View style={[styles.badge, edge, style]} {...props}>\n {wrapText(children, styles.label)}\n </View>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const ink = (tone: ChipTone) => ({ color: theme.colors[CHIP_INK[tone]] });\n return {\n badge: {\n flexDirection: 'row',\n alignItems: 'center',\n alignSelf: 'flex-start',\n gap: theme.spacing(1.5),\n borderRadius: theme.borderRadius.DEFAULT,\n borderWidth: 1,\n borderColor: theme.colors.border,\n variants: {\n size: {\n xs: { paddingHorizontal: theme.spacing(1.5), paddingVertical: 1 },\n sm: { paddingHorizontal: theme.spacing(2), paddingVertical: theme.spacing(0.5) },\n md: { paddingHorizontal: theme.spacing(2.5), paddingVertical: theme.spacing(1) },\n lg: { paddingHorizontal: theme.spacing(3), paddingVertical: theme.spacing(1.5) },\n },\n },\n },\n label: {\n fontFamily: fontOf(theme.fontFamily.sans),\n variants: {\n tone: {\n neutral: ink('neutral'),\n blue: ink('blue'),\n green: ink('green'),\n yellow: ink('yellow'),\n red: ink('red'),\n magenta: ink('magenta'),\n violet: ink('violet'),\n cyan: ink('cyan'),\n orange: ink('orange'),\n teal: ink('teal'),\n },\n size: {\n xs: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm, fontWeight: theme.fontWeight.semibold },\n sm: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n md: { fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.sm },\n lg: { fontSize: theme.fontSize.base, lineHeight: theme.lineHeight.base },\n },\n },\n },\n };\n});\n"],"mappings":";;;;;;;;;;AAaA,MAAMa,qBAAqB;;AAW3B,SAAgBO,MAAM,EAAEJ,OAAO,WAAWC,OAAO,MAAMC,UAAUC,OAAO,GAAGE,SAAqB;CAC9F,MAAM,EAAEC,UAAUf,aAAa;CAAE,MAAAgB,UAAAC;CAAA;EAAA,MAAAA,SAAAD,QAAAE,YACd;GAAET;GAAMC;EAAK,CAAC;EAGjC,MAAMS,OACJV,SAAS,YAAYW,SAAY,EAAEC,aAAa3B,UAAUqB,MAAMO,OAAOpB,SAASO,QAAQH,kBAAkB,EAAE;EAC9G,OACE,oBAAC,MAAD;GAAM,OAAO;IAACW,OAAOM;IAAOJ;IAAMP;GAAK;GAAG,GAAIE;aAC3CX,SAASQ,UAAUM,OAAOO,KAAK;EAC5B;CACN;AACJ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AM4C,WAAWC;KAAS;KAC1GnB,IAAI;MAAEgB,UAAU1C,MAAM0C,SAAShB;MAAIiB,YAAY3C,MAAM2C,WAAWjB;KAAG;KACnEC,IAAI;MAAEe,UAAU1C,MAAM0C,SAAShB;MAAIiB,YAAY3C,MAAM2C,WAAWjB;KAAG;KACnEE,IAAI;MAAEc,UAAU1C,MAAM0C,SAASI;MAAMH,YAAY3C,MAAM2C,WAAWG;KAAK;IACzE;GACF;GAACjB,mBAAA,CAAA,GAAA,CAAA;EACH;CACF;AACF,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { fontOf } from "../lib/fonts.mjs";
|
|
2
|
-
import { wrapText } from "../lib/wrapText.mjs";
|
|
3
|
-
import { IconColorContext } from "../icons/IconColorContext.mjs";
|
|
4
2
|
import { impactLight } from "../lib/haptics.mjs";
|
|
3
|
+
import { wrapText } from "../lib/wrapText.mjs";
|
|
5
4
|
import { Spinner } from "./Spinner.mjs";
|
|
6
|
-
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
7
5
|
import { StyleSheet, useUnistyles } from "react-native-unistyles";
|
|
6
|
+
import { withAlpha } from "@agimon-ai/po-web-components/nativeTheme";
|
|
8
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
8
|
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
9
|
+
import { IconColorContext } from "@agimon-ai/po-native-components/shell";
|
|
10
10
|
|
|
11
11
|
//#region src/components/Button.tsx
|
|
12
12
|
/** Apple's and Google's minimum tap target; a smaller visual box makes up the rest with hitSlop. */
|
|
@@ -14,7 +14,7 @@ const MIN_TAP_TARGET = 44;
|
|
|
14
14
|
const DISABLED_OPACITY = .4;
|
|
15
15
|
const PRESSED_FILL_OPACITY = .85;
|
|
16
16
|
const RIPPLE_ALPHA_PERCENT = 20;
|
|
17
|
-
/** `hover:border-
|
|
17
|
+
/** `hover:border-po-green/50`. */
|
|
18
18
|
const PRESSED_EDGE_ALPHA_PERCENT = 50;
|
|
19
19
|
/** The visual height of each size, from which hitSlop pads the tap target to 44pt. */
|
|
20
20
|
const SIZE_HEIGHT = {
|