@floegence/floe-webapp-core 0.101.47 → 0.101.50
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/dist/components/media/ImageAnnotationSurface.js +71 -69
- package/dist/components/ui/PromptCard.d.ts +3 -0
- package/dist/components/ui/PromptCard.js +131 -120
- package/dist/components/ui/promptCardPlacement.d.ts +24 -0
- package/dist/components/ui/promptCardPlacement.js +12 -0
- package/dist/styles.css +1 -1
- package/dist/ui.css +2 -1
- package/package.json +1 -1
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import { use as
|
|
2
|
-
import { createSignal as
|
|
3
|
-
import { imageAnnotationMarkup as
|
|
4
|
-
var
|
|
5
|
-
function
|
|
1
|
+
import { use as W, insert as j, createComponent as D, effect as X, setAttribute as h, setStyleProperty as b, memo as G, className as tt, template as F, delegateEvents as et } from "solid-js/web";
|
|
2
|
+
import { createSignal as J, createMemo as it, onMount as nt, onCleanup as at, For as Q, Show as V } from "solid-js";
|
|
3
|
+
import { imageAnnotationMarkup as Z, validateImageAnnotation as Y, imagePointFromClient as ot } from "./imageAnnotation.js";
|
|
4
|
+
var rt = /* @__PURE__ */ F("<div data-floe-image-annotation style=width:100%;height:100%;overscroll-behavior:contain><div style=display:grid;place-items:center><svg xmlns=http://www.w3.org/2000/svg role=img style=display:block;user-select:none;flex:none><image></image><g data-annotation-target>"), dt = /* @__PURE__ */ F("<svg><g style=pointer-events:none></svg>", !1, !0, !1), lt = /* @__PURE__ */ F("<svg><rect data-annotation-target fill=white stroke=#111827></svg>", !1, !0, !1);
|
|
5
|
+
function gt(e) {
|
|
6
6
|
let v, u;
|
|
7
|
-
const [
|
|
7
|
+
const [P, $] = J({
|
|
8
8
|
width: 1,
|
|
9
9
|
height: 1
|
|
10
|
-
}), [N,
|
|
11
|
-
let
|
|
12
|
-
const
|
|
13
|
-
|
|
10
|
+
}), [N, M] = J();
|
|
11
|
+
let k, f;
|
|
12
|
+
const L = () => N() ?? e.annotation, m = it(() => Math.min(P().width / e.width, P().height / e.height) * Math.max(1, e.zoom ?? 1)), _ = () => e.showAnnotation !== !1 && L() && Y(e, L()) ? Z(e, L(), e.marker ?? (e.activeIndex !== void 0 ? e.activeIndex + 1 : 1)) : "";
|
|
13
|
+
nt(() => {
|
|
14
14
|
let i = 0;
|
|
15
15
|
const d = () => {
|
|
16
16
|
i = 0;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
width:
|
|
17
|
+
const r = v.clientWidth, c = v.clientHeight;
|
|
18
|
+
$((s) => s.width === r && s.height === c ? s : {
|
|
19
|
+
width: r,
|
|
20
20
|
height: c
|
|
21
21
|
});
|
|
22
22
|
}, a = new ResizeObserver(() => {
|
|
23
23
|
i || (i = requestAnimationFrame(d));
|
|
24
24
|
});
|
|
25
|
-
a.observe(v), d(),
|
|
25
|
+
a.observe(v), d(), at(() => {
|
|
26
26
|
a.disconnect(), cancelAnimationFrame(i);
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
|
-
const T = (i, d = !1) =>
|
|
29
|
+
const T = (i, d = !1) => ot(e, u.getBoundingClientRect(), {
|
|
30
30
|
x: i.clientX,
|
|
31
31
|
y: i.clientY
|
|
32
|
-
}, d),
|
|
32
|
+
}, d), w = () => !!e.onChange && !e.disabled && !e.panning, B = (i) => {
|
|
33
33
|
if (f?.id === i.pointerId) {
|
|
34
34
|
v.scrollLeft = f.left + f.x - i.clientX, v.scrollTop = f.top + f.y - i.clientY;
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
const d =
|
|
38
|
-
if (!d || d.id !== i.pointerId || d.src !== e.src || !
|
|
37
|
+
const d = k;
|
|
38
|
+
if (!d || d.id !== i.pointerId || d.src !== e.src || !w()) return;
|
|
39
39
|
const a = T(i, !0);
|
|
40
40
|
if (!a) return;
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const c =
|
|
44
|
-
|
|
45
|
-
...
|
|
46
|
-
x: Math.max(0, Math.min(e.width - c,
|
|
47
|
-
y: Math.max(0, Math.min(e.height - s,
|
|
41
|
+
const r = d.original;
|
|
42
|
+
if (r && d.corner === void 0) {
|
|
43
|
+
const c = r.kind === "rectangle" ? r.width : 0, s = r.kind === "rectangle" ? r.height : 0;
|
|
44
|
+
M({
|
|
45
|
+
...r,
|
|
46
|
+
x: Math.max(0, Math.min(e.width - c, r.x + a.x - d.start.x)),
|
|
47
|
+
y: Math.max(0, Math.min(e.height - s, r.y + a.y - d.start.y))
|
|
48
48
|
});
|
|
49
49
|
} else {
|
|
50
|
-
const c =
|
|
51
|
-
x:
|
|
52
|
-
y:
|
|
50
|
+
const c = r?.kind === "rectangle" && d.corner !== void 0 ? {
|
|
51
|
+
x: r.x + (d.corner % 2 ? 0 : r.width),
|
|
52
|
+
y: r.y + (d.corner < 2 ? r.height : 0)
|
|
53
53
|
} : d.start, s = Math.abs(a.x - c.x), I = Math.abs(a.y - c.y);
|
|
54
|
-
Math.hypot(i.clientX - d.client.x, i.clientY - d.client.y) < 5 && !
|
|
54
|
+
Math.hypot(i.clientX - d.client.x, i.clientY - d.client.y) < 5 && !r ? M({
|
|
55
55
|
kind: "point",
|
|
56
56
|
...c
|
|
57
|
-
}) : s > 0 && I > 0 &&
|
|
57
|
+
}) : s > 0 && I > 0 && M({
|
|
58
58
|
kind: "rectangle",
|
|
59
59
|
x: Math.min(c.x, a.x),
|
|
60
60
|
y: Math.min(c.y, a.y),
|
|
@@ -67,13 +67,13 @@ function ct(e) {
|
|
|
67
67
|
f = void 0, u.hasPointerCapture(i.pointerId) && u.releasePointerCapture(i.pointerId);
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
const a =
|
|
70
|
+
const a = k;
|
|
71
71
|
if (!a || a.id !== i.pointerId) return;
|
|
72
72
|
d || B(i);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
const i =
|
|
73
|
+
const r = N();
|
|
74
|
+
k = void 0, M(void 0), u.hasPointerCapture(i.pointerId) && u.releasePointerCapture(i.pointerId), !d && a.src === e.src && w() && r && Y(e, r) && e.onChange?.(r);
|
|
75
|
+
}, p = () => {
|
|
76
|
+
const i = L();
|
|
77
77
|
return i?.kind === "rectangle" ? [{
|
|
78
78
|
x: i.x,
|
|
79
79
|
y: i.y
|
|
@@ -89,11 +89,11 @@ function ct(e) {
|
|
|
89
89
|
}] : [];
|
|
90
90
|
};
|
|
91
91
|
return (() => {
|
|
92
|
-
var i =
|
|
93
|
-
typeof s == "function" ?
|
|
94
|
-
if (!
|
|
92
|
+
var i = rt(), d = i.firstChild, a = d.firstChild, r = a.firstChild, c = r.nextSibling, s = v;
|
|
93
|
+
typeof s == "function" ? W(s, i) : v = i, a.$$keydown = (t) => {
|
|
94
|
+
if (!w()) return;
|
|
95
95
|
if (t.key === "Escape") {
|
|
96
|
-
|
|
96
|
+
k = void 0, M(void 0);
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
const l = {
|
|
@@ -104,15 +104,15 @@ function ct(e) {
|
|
|
104
104
|
}[t.key];
|
|
105
105
|
if (!l && t.key !== "Enter" && t.key !== " ") return;
|
|
106
106
|
t.preventDefault();
|
|
107
|
-
const
|
|
107
|
+
const o = e.annotation ?? {
|
|
108
108
|
kind: "point",
|
|
109
109
|
x: e.width / 2,
|
|
110
110
|
y: e.height / 2
|
|
111
111
|
}, n = t.shiftKey ? 10 : 1;
|
|
112
112
|
e.onChange?.({
|
|
113
|
-
...
|
|
114
|
-
x: Math.max(0, Math.min(e.width - (
|
|
115
|
-
y: Math.max(0, Math.min(e.height - (
|
|
113
|
+
...o,
|
|
114
|
+
x: Math.max(0, Math.min(e.width - (o.kind === "rectangle" ? o.width : 0), o.x + (l?.[0] ?? 0) * n)),
|
|
115
|
+
y: Math.max(0, Math.min(e.height - (o.kind === "rectangle" ? o.height : 0), o.y + (l?.[1] ?? 0) * n))
|
|
116
116
|
});
|
|
117
117
|
}, a.addEventListener("lostpointercapture", (t) => E(t, !0)), a.addEventListener("pointercancel", (t) => E(t, !0)), a.$$pointerup = (t) => E(t), a.$$pointermove = B, a.$$pointerdown = (t) => {
|
|
118
118
|
if (e.panning && t.button === 0 && !f) {
|
|
@@ -125,16 +125,16 @@ function ct(e) {
|
|
|
125
125
|
}, u.setPointerCapture(t.pointerId), t.preventDefault();
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
|
-
if (!
|
|
128
|
+
if (!w() || t.button !== 0 || k) return;
|
|
129
129
|
const l = T(t);
|
|
130
130
|
if (!l) return;
|
|
131
|
-
const
|
|
131
|
+
const o = t.target, n = o.closest("[data-annotation-index]")?.getAttribute("data-annotation-index");
|
|
132
132
|
if (n != null && Number(n) !== e.activeIndex) {
|
|
133
133
|
e.onSelect?.(Number(n)), t.preventDefault();
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
const g =
|
|
137
|
-
|
|
136
|
+
const g = o.getAttribute("data-corner");
|
|
137
|
+
k = {
|
|
138
138
|
id: t.pointerId,
|
|
139
139
|
start: l,
|
|
140
140
|
client: {
|
|
@@ -142,13 +142,13 @@ function ct(e) {
|
|
|
142
142
|
y: t.clientY
|
|
143
143
|
},
|
|
144
144
|
src: e.src,
|
|
145
|
-
...
|
|
145
|
+
...o.closest("[data-annotation-target]") ? {
|
|
146
146
|
original: e.annotation
|
|
147
147
|
} : {},
|
|
148
148
|
...g !== null ? {
|
|
149
149
|
corner: Number(g)
|
|
150
150
|
} : {}
|
|
151
|
-
}, k
|
|
151
|
+
}, M(k.original ?? {
|
|
152
152
|
kind: "point",
|
|
153
153
|
...l
|
|
154
154
|
}), u.setPointerCapture(t.pointerId), u.focus({
|
|
@@ -156,40 +156,40 @@ function ct(e) {
|
|
|
156
156
|
}), t.preventDefault();
|
|
157
157
|
};
|
|
158
158
|
var I = u;
|
|
159
|
-
return typeof I == "function" ?
|
|
159
|
+
return typeof I == "function" ? W(I, a) : u = a, j(a, D(Q, {
|
|
160
160
|
get each() {
|
|
161
161
|
return e.annotations?.slice(0, 99);
|
|
162
162
|
},
|
|
163
|
-
children: (t, l) => D(
|
|
163
|
+
children: (t, l) => D(V, {
|
|
164
164
|
get when() {
|
|
165
|
-
return
|
|
165
|
+
return G(() => e.showAnnotation !== !1 && l() !== e.activeIndex)() && Y(e, t);
|
|
166
166
|
},
|
|
167
167
|
get children() {
|
|
168
|
-
var
|
|
168
|
+
var o = dt();
|
|
169
169
|
return X((n) => {
|
|
170
|
-
var g = l(), x =
|
|
171
|
-
return g !== n.e && h(
|
|
170
|
+
var g = l(), x = Z(e, t, l() + 1), y = e.cursor ?? (e.onSelect ? "pointer" : void 0);
|
|
171
|
+
return g !== n.e && h(o, "data-annotation-index", n.e = g), x !== n.t && (o.innerHTML = n.t = x), y !== n.a && b(o, "cursor", n.a = y), n;
|
|
172
172
|
}, {
|
|
173
173
|
e: void 0,
|
|
174
174
|
t: void 0,
|
|
175
175
|
a: void 0
|
|
176
|
-
}),
|
|
176
|
+
}), o;
|
|
177
177
|
}
|
|
178
178
|
})
|
|
179
|
-
}), c),
|
|
179
|
+
}), c), j(a, D(V, {
|
|
180
180
|
get when() {
|
|
181
|
-
return
|
|
181
|
+
return G(() => !!w())() && e.showAnnotation !== !1;
|
|
182
182
|
},
|
|
183
183
|
get children() {
|
|
184
|
-
return D(
|
|
184
|
+
return D(Q, {
|
|
185
185
|
get each() {
|
|
186
|
-
return
|
|
186
|
+
return p();
|
|
187
187
|
},
|
|
188
188
|
children: (t, l) => (() => {
|
|
189
|
-
var
|
|
189
|
+
var o = lt();
|
|
190
190
|
return X((n) => {
|
|
191
|
-
var g = l(), x = t.x - 5 /
|
|
192
|
-
return g !== n.e && h(
|
|
191
|
+
var g = l(), x = t.x - 5 / m(), y = t.y - 5 / m(), C = 10 / m(), A = 10 / m(), S = 1 / m(), z = e.cursor ?? (l() === 0 || l() === 3 ? "nwse-resize" : "nesw-resize");
|
|
192
|
+
return g !== n.e && h(o, "data-corner", n.e = g), x !== n.t && h(o, "x", n.t = x), y !== n.a && h(o, "y", n.a = y), C !== n.o && h(o, "width", n.o = C), A !== n.i && h(o, "height", n.i = A), S !== n.n && h(o, "stroke-width", n.n = S), z !== n.s && b(o, "cursor", n.s = z), n;
|
|
193
193
|
}, {
|
|
194
194
|
e: void 0,
|
|
195
195
|
t: void 0,
|
|
@@ -198,13 +198,13 @@ function ct(e) {
|
|
|
198
198
|
i: void 0,
|
|
199
199
|
n: void 0,
|
|
200
200
|
s: void 0
|
|
201
|
-
}),
|
|
201
|
+
}), o;
|
|
202
202
|
})()
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
205
|
}), null), X((t) => {
|
|
206
|
-
var l = e.class,
|
|
207
|
-
return l !== t.e &&
|
|
206
|
+
var l = e.class, o = (e.zoom ?? 1) > 1 ? "auto" : "hidden", n = (e.zoom ?? 1) > 1 ? "stable" : "auto", g = `${Math.max(P().width, e.width * m())}px`, x = `${Math.max(P().height, e.height * m())}px`, y = e.width * m(), C = e.height * m(), A = `0 0 ${e.width} ${e.height}`, S = e.label, z = w() ? 0 : void 0, H = w() || e.panning ? "none" : "auto", R = e.cursor ?? (e.panning ? "grab" : w() ? "crosshair" : "default"), q = e.src, K = e.width, O = e.height, U = _();
|
|
207
|
+
return l !== t.e && tt(i, t.e = l), o !== t.t && b(i, "overflow", t.t = o), n !== t.a && b(i, "scrollbar-gutter", t.a = n), g !== t.o && b(d, "width", t.o = g), x !== t.i && b(d, "height", t.i = x), y !== t.n && h(a, "width", t.n = y), C !== t.s && h(a, "height", t.s = C), A !== t.h && h(a, "viewBox", t.h = A), S !== t.r && h(a, "aria-label", t.r = S), z !== t.d && h(a, "tabindex", t.d = z), H !== t.l && b(a, "touch-action", t.l = H), R !== t.u && b(a, "cursor", t.u = R), q !== t.c && h(r, "href", t.c = q), K !== t.w && h(r, "width", t.w = K), O !== t.m && h(r, "height", t.m = O), U !== t.f && (c.innerHTML = t.f = U), t;
|
|
208
208
|
}, {
|
|
209
209
|
e: void 0,
|
|
210
210
|
t: void 0,
|
|
@@ -219,11 +219,13 @@ function ct(e) {
|
|
|
219
219
|
l: void 0,
|
|
220
220
|
u: void 0,
|
|
221
221
|
c: void 0,
|
|
222
|
-
w: void 0
|
|
222
|
+
w: void 0,
|
|
223
|
+
m: void 0,
|
|
224
|
+
f: void 0
|
|
223
225
|
}), i;
|
|
224
226
|
})();
|
|
225
227
|
}
|
|
226
|
-
|
|
228
|
+
et(["pointerdown", "pointermove", "pointerup", "keydown"]);
|
|
227
229
|
export {
|
|
228
|
-
|
|
230
|
+
gt as ImageAnnotationSurface
|
|
229
231
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type JSX } from 'solid-js';
|
|
2
2
|
import { type SelectOption, type SelectBaseProps } from './Select';
|
|
3
|
+
import { type PromptCardRegion } from './promptCardPlacement';
|
|
3
4
|
export interface PromptCardProps {
|
|
4
5
|
open: boolean;
|
|
5
6
|
/** Viewport coordinates captured by the host at the contextual action. */
|
|
@@ -7,6 +8,8 @@ export interface PromptCardProps {
|
|
|
7
8
|
x: number;
|
|
8
9
|
y: number;
|
|
9
10
|
}> | null;
|
|
11
|
+
/** Selected content to keep visible where space permits, in viewport pixels and preferred order. */
|
|
12
|
+
avoidRegions?: readonly PromptCardRegion[];
|
|
10
13
|
viewportInsets?: Readonly<{
|
|
11
14
|
top?: number;
|
|
12
15
|
right?: number;
|