laif-ds 0.2.87 → 0.2.89
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/CHANGELOG.md +15 -0
- package/dist/_virtual/index3.js +5 -5
- package/dist/_virtual/index4.js +5 -5
- package/dist/_virtual/index5.js +4 -4
- package/dist/_virtual/index6.js +2 -2
- package/dist/_virtual/index7.js +2 -2
- package/dist/agent-docs/adoption-report.json +19 -23
- package/dist/agent-docs/components/Button.md +3 -0
- package/dist/agent-docs/components/FilePreviewer.md +2 -1
- package/dist/agent-docs/manifest.json +10 -9
- package/dist/components/design-tokens.js +12 -1
- package/dist/components/ui/button.js +29 -22
- package/dist/components/ui/file-previewer.js +38 -42
- package/dist/components/ui/zoomable-image.js +213 -0
- package/dist/index.d.ts +1 -0
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/node_modules/eventemitter3/index2.js +1 -1
- package/dist/node_modules/hast-util-to-jsx-runtime/lib/index.js +1 -1
- package/dist/node_modules/recharts/es6/util/Events.js +1 -1
- package/dist/node_modules/style-to-object/cjs/index.js +1 -1
- package/dist/node_modules/unified/lib/index.js +1 -1
- package/dist/styles.v3.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as N, jsx as m } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as y, useState as P, useEffect as E } from "react";
|
|
4
|
+
import { Button as X } from "./button.js";
|
|
5
|
+
import { Icon as Y } from "./icon.js";
|
|
6
|
+
import { cn as L } from "../../lib/utils.js";
|
|
7
|
+
const i = 1, A = 5, T = 1.25, S = (r, s, l) => Math.min(l, Math.max(s, r)), j = (r, s) => Math.hypot(r.x - s.x, r.y - s.y), J = (r, s) => ({
|
|
8
|
+
x: (r.x + s.x) / 2,
|
|
9
|
+
y: (r.y + s.y) / 2
|
|
10
|
+
});
|
|
11
|
+
function v(r, s, l) {
|
|
12
|
+
const p = S(s, i, A);
|
|
13
|
+
if (p === r.scale) return r;
|
|
14
|
+
if (p <= i) return { scale: i, x: 0, y: 0 };
|
|
15
|
+
const d = p / r.scale;
|
|
16
|
+
return {
|
|
17
|
+
scale: p,
|
|
18
|
+
x: l.x - (l.x - r.x) * d,
|
|
19
|
+
y: l.y - (l.y - r.y) * d
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function re({
|
|
23
|
+
src: r,
|
|
24
|
+
alt: s = "preview",
|
|
25
|
+
className: l
|
|
26
|
+
}) {
|
|
27
|
+
const p = y(null), d = y(null), [o, x] = P({
|
|
28
|
+
scale: 1,
|
|
29
|
+
x: 0,
|
|
30
|
+
y: 0
|
|
31
|
+
}), [k, B] = P(!1), [Z, g] = P(!1), [O, z] = P(!0), C = y(o);
|
|
32
|
+
C.current = o;
|
|
33
|
+
const a = y(/* @__PURE__ */ new Map()), u = y(null), R = y(null), h = y(null);
|
|
34
|
+
E(() => {
|
|
35
|
+
x({ scale: 1, x: 0, y: 0 }), g(!1);
|
|
36
|
+
}, [r]);
|
|
37
|
+
const I = () => {
|
|
38
|
+
h.current && clearTimeout(h.current), h.current = setTimeout(() => z(!1), 2e3);
|
|
39
|
+
}, $ = () => {
|
|
40
|
+
z(!0), I();
|
|
41
|
+
}, V = () => {
|
|
42
|
+
h.current && clearTimeout(h.current), z(!0);
|
|
43
|
+
};
|
|
44
|
+
E(() => (I(), () => {
|
|
45
|
+
h.current && clearTimeout(h.current);
|
|
46
|
+
}), []);
|
|
47
|
+
const b = (e) => {
|
|
48
|
+
if (e.scale <= i) return e;
|
|
49
|
+
const n = d.current?.getBoundingClientRect();
|
|
50
|
+
if (!n) return e;
|
|
51
|
+
const t = n.width * (e.scale - 1) / 2, c = n.height * (e.scale - 1) / 2;
|
|
52
|
+
return {
|
|
53
|
+
...e,
|
|
54
|
+
x: S(e.x, -t, t),
|
|
55
|
+
y: S(e.y, -c, c)
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
E(() => {
|
|
59
|
+
const e = d.current;
|
|
60
|
+
if (!e) return;
|
|
61
|
+
const n = (t) => {
|
|
62
|
+
t.preventDefault();
|
|
63
|
+
const c = e.getBoundingClientRect(), f = {
|
|
64
|
+
x: t.clientX - c.left - c.width / 2,
|
|
65
|
+
y: t.clientY - c.top - c.height / 2
|
|
66
|
+
}, M = t.deltaY < 0 ? T : 1 / T;
|
|
67
|
+
g(!1), x(
|
|
68
|
+
(w) => b(v(w, w.scale * M, f))
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
return e.addEventListener("wheel", n, { passive: !1 }), () => e.removeEventListener("wheel", n);
|
|
72
|
+
}, []);
|
|
73
|
+
const _ = (e, n) => {
|
|
74
|
+
const t = d.current?.getBoundingClientRect();
|
|
75
|
+
return t ? {
|
|
76
|
+
x: e - t.left - t.width / 2,
|
|
77
|
+
y: n - t.top - t.height / 2
|
|
78
|
+
} : { x: 0, y: 0 };
|
|
79
|
+
}, F = (e) => {
|
|
80
|
+
if (e.currentTarget.setPointerCapture(e.pointerId), g(!1), a.current.set(e.pointerId, { x: e.clientX, y: e.clientY }), a.current.size === 2) {
|
|
81
|
+
u.current = null;
|
|
82
|
+
const [n, t] = [...a.current.values()];
|
|
83
|
+
R.current = j(n, t);
|
|
84
|
+
} else C.current.scale > i && (u.current = { x: e.clientX, y: e.clientY });
|
|
85
|
+
}, H = (e) => {
|
|
86
|
+
if (!a.current.has(e.pointerId)) return;
|
|
87
|
+
a.current.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
88
|
+
const n = [...a.current.values()];
|
|
89
|
+
if (n.length >= 2) {
|
|
90
|
+
const t = j(n[0], n[1]), c = R.current;
|
|
91
|
+
if (R.current = t, c) {
|
|
92
|
+
const f = J(n[0], n[1]), M = _(f.x, f.y);
|
|
93
|
+
x(
|
|
94
|
+
(w) => b(v(w, w.scale * (t / c), M))
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (u.current && C.current.scale > i) {
|
|
100
|
+
const t = e.clientX - u.current.x, c = e.clientY - u.current.y;
|
|
101
|
+
u.current = { x: e.clientX, y: e.clientY }, k || B(!0), x(
|
|
102
|
+
(f) => b({ ...f, x: f.x + t, y: f.y + c })
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}, D = (e) => {
|
|
106
|
+
if (a.current.delete(e.pointerId), a.current.size < 2 && (R.current = null), a.current.size === 1) {
|
|
107
|
+
const [n] = [...a.current.values()];
|
|
108
|
+
u.current = { ...n };
|
|
109
|
+
} else a.current.size === 0 && (u.current = null, B(!1));
|
|
110
|
+
}, U = () => {
|
|
111
|
+
g(!0), x(
|
|
112
|
+
(e) => b(v(e, e.scale * T, { x: 0, y: 0 }))
|
|
113
|
+
);
|
|
114
|
+
}, W = () => {
|
|
115
|
+
g(!0), x(
|
|
116
|
+
(e) => b(v(e, e.scale / T, { x: 0, y: 0 }))
|
|
117
|
+
);
|
|
118
|
+
}, q = () => {
|
|
119
|
+
g(!0), x({ scale: 1, x: 0, y: 0 });
|
|
120
|
+
}, G = o.scale === i && o.x === 0 && o.y === 0;
|
|
121
|
+
return /* @__PURE__ */ N(
|
|
122
|
+
"div",
|
|
123
|
+
{
|
|
124
|
+
ref: p,
|
|
125
|
+
className: L("relative h-full w-full overflow-hidden", l),
|
|
126
|
+
onPointerMove: $,
|
|
127
|
+
children: [
|
|
128
|
+
/* @__PURE__ */ m(
|
|
129
|
+
"div",
|
|
130
|
+
{
|
|
131
|
+
ref: d,
|
|
132
|
+
className: "flex h-full w-full touch-none items-center justify-center select-none",
|
|
133
|
+
onPointerDown: F,
|
|
134
|
+
onPointerMove: H,
|
|
135
|
+
onPointerUp: D,
|
|
136
|
+
onPointerCancel: D,
|
|
137
|
+
style: {
|
|
138
|
+
cursor: o.scale > i ? k ? "grabbing" : "grab" : "default"
|
|
139
|
+
},
|
|
140
|
+
children: /* @__PURE__ */ m(
|
|
141
|
+
"img",
|
|
142
|
+
{
|
|
143
|
+
src: r,
|
|
144
|
+
alt: s,
|
|
145
|
+
draggable: !1,
|
|
146
|
+
onDragStart: (e) => e.preventDefault(),
|
|
147
|
+
className: "max-h-full w-auto max-w-full object-contain",
|
|
148
|
+
style: {
|
|
149
|
+
transform: `translate(${o.x}px, ${o.y}px) scale(${o.scale})`,
|
|
150
|
+
transformOrigin: "center",
|
|
151
|
+
transition: Z ? "transform 150ms ease-out" : "none"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
/* @__PURE__ */ N(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
onPointerEnter: V,
|
|
161
|
+
onPointerLeave: I,
|
|
162
|
+
className: L(
|
|
163
|
+
"border-d-border bg-d-background/90 absolute bottom-3 left-1/2 flex -translate-x-1/2 items-center gap-1 rounded-md border p-1 shadow-sm backdrop-blur transition-opacity duration-300",
|
|
164
|
+
O ? "opacity-100" : "pointer-events-none opacity-0"
|
|
165
|
+
),
|
|
166
|
+
children: [
|
|
167
|
+
/* @__PURE__ */ m(
|
|
168
|
+
X,
|
|
169
|
+
{
|
|
170
|
+
variant: "ghost",
|
|
171
|
+
size: "icon",
|
|
172
|
+
"aria-label": "Riduci zoom",
|
|
173
|
+
onClick: W,
|
|
174
|
+
disabled: o.scale <= i,
|
|
175
|
+
children: /* @__PURE__ */ m(Y, { name: "ZoomOut", className: "h-4 w-4" })
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
/* @__PURE__ */ N("span", { className: "text-d-foreground min-w-[3.5ch] text-center text-xs tabular-nums", children: [
|
|
179
|
+
Math.round(o.scale * 100),
|
|
180
|
+
"%"
|
|
181
|
+
] }),
|
|
182
|
+
/* @__PURE__ */ m(
|
|
183
|
+
X,
|
|
184
|
+
{
|
|
185
|
+
variant: "ghost",
|
|
186
|
+
size: "icon",
|
|
187
|
+
"aria-label": "Aumenta zoom",
|
|
188
|
+
onClick: U,
|
|
189
|
+
disabled: o.scale >= A,
|
|
190
|
+
children: /* @__PURE__ */ m(Y, { name: "ZoomIn", className: "h-4 w-4" })
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
/* @__PURE__ */ m(
|
|
194
|
+
X,
|
|
195
|
+
{
|
|
196
|
+
variant: "ghost",
|
|
197
|
+
size: "icon",
|
|
198
|
+
"aria-label": "Reimposta zoom",
|
|
199
|
+
onClick: q,
|
|
200
|
+
disabled: G,
|
|
201
|
+
children: /* @__PURE__ */ m(Y, { name: "RotateCcw", className: "h-4 w-4" })
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
]
|
|
208
|
+
}
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
export {
|
|
212
|
+
re as ZoomableImage
|
|
213
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { stringify as w } from "../../comma-separated-tokens/index.js";
|
|
|
3
3
|
import { ok as u } from "../../devlop/lib/default.js";
|
|
4
4
|
import { svg as m, html as C } from "../../property-information/index.js";
|
|
5
5
|
import { stringify as N } from "../../space-separated-tokens/index.js";
|
|
6
|
-
import S from "../../../_virtual/
|
|
6
|
+
import S from "../../../_virtual/index3.js";
|
|
7
7
|
import { whitespace as j } from "../../hast-util-whitespace/lib/index.js";
|
|
8
8
|
import { name as x } from "../../estree-util-is-identifier-name/lib/index.js";
|
|
9
9
|
import { VFileMessage as h } from "../../vfile-message/lib/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { bail as P } from "../../bail/index.js";
|
|
3
|
-
import y from "../../../_virtual/
|
|
3
|
+
import y from "../../../_virtual/index4.js";
|
|
4
4
|
import z from "../../is-plain-obj/index.js";
|
|
5
5
|
import { CallableInstance as C } from "./callable-instance.js";
|
|
6
6
|
import { trough as A } from "../../trough/lib/index.js";
|