uilint-react 0.1.24 → 0.1.26
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/{ElementBadges-T4N3VQRI.js → ElementBadges-HFQNIIO2.js} +29 -51
- package/dist/{InspectionPanel-47JBBKBL.js → InspectionPanel-4OWY4FVY.js} +2 -2
- package/dist/{LocatorOverlay-ADJUWU2H.js → LocatorOverlay-JJDOKNOS.js} +2 -2
- package/dist/{UILintToolbar-5PG6WVW6.js → UILintToolbar-GMZ6YSI2.js} +2 -2
- package/dist/{chunk-I4C3NAUH.js → chunk-5VJ2Q2QW.js} +402 -286
- package/dist/{chunk-GFURSJEQ.js → chunk-7X5HN55P.js} +1 -1
- package/dist/chunk-QYRESGFG.js +1463 -0
- package/dist/{chunk-EB6K2KGR.js → chunk-XLIDEQXH.js} +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/index.js +4 -4
- package/package.json +3 -2
- package/dist/chunk-FWYNI6JG.js +0 -1359
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
4
|
useUILintContext
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-5VJ2Q2QW.js";
|
|
6
6
|
|
|
7
7
|
// src/components/ui-lint/ElementBadges.tsx
|
|
8
8
|
import React, { useState, useEffect, useCallback, useMemo } from "react";
|
|
@@ -19,7 +19,16 @@ var STYLES = {
|
|
|
19
19
|
font: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
20
20
|
shadow: "0 2px 8px rgba(0, 0, 0, 0.3)"
|
|
21
21
|
};
|
|
22
|
-
var
|
|
22
|
+
var NEAR_DISTANCE = 0;
|
|
23
|
+
var FAR_DISTANCE = 150;
|
|
24
|
+
var MIN_SCALE = 0.5;
|
|
25
|
+
var MAX_SCALE = 1;
|
|
26
|
+
function getScaleFromDistance(distance) {
|
|
27
|
+
if (distance <= NEAR_DISTANCE) return MAX_SCALE;
|
|
28
|
+
if (distance >= FAR_DISTANCE) return MIN_SCALE;
|
|
29
|
+
const t = (distance - NEAR_DISTANCE) / (FAR_DISTANCE - NEAR_DISTANCE);
|
|
30
|
+
return MAX_SCALE - t * (MAX_SCALE - MIN_SCALE);
|
|
31
|
+
}
|
|
23
32
|
var CLUSTER_THRESHOLD = 24;
|
|
24
33
|
function getBadgeColor(issueCount) {
|
|
25
34
|
if (issueCount === 0) return STYLES.success;
|
|
@@ -29,7 +38,7 @@ function getBadgeColor(issueCount) {
|
|
|
29
38
|
function ElementBadge({
|
|
30
39
|
element,
|
|
31
40
|
issue,
|
|
32
|
-
|
|
41
|
+
distance,
|
|
33
42
|
onSelect
|
|
34
43
|
}) {
|
|
35
44
|
const [rect, setRect] = useState(null);
|
|
@@ -64,16 +73,17 @@ function ElementBadge({
|
|
|
64
73
|
if (!rect) return null;
|
|
65
74
|
if (rect.top < -50 || rect.top > window.innerHeight + 50) return null;
|
|
66
75
|
if (rect.left < -50 || rect.left > window.innerWidth + 50) return null;
|
|
76
|
+
const scale = isHovered ? 1.1 : getScaleFromDistance(distance);
|
|
67
77
|
const badgeStyle = {
|
|
68
78
|
position: "fixed",
|
|
69
79
|
top: rect.top - 8,
|
|
70
80
|
left: rect.right - 8,
|
|
71
81
|
zIndex: isHovered ? 99999 : 99995,
|
|
72
82
|
cursor: "pointer",
|
|
73
|
-
transition: "transform 0.
|
|
74
|
-
transform:
|
|
83
|
+
transition: "transform 0.1s ease-out",
|
|
84
|
+
transform: `scale(${scale})`,
|
|
85
|
+
transformOrigin: "center center"
|
|
75
86
|
};
|
|
76
|
-
const badgeColor = issue.status === "complete" ? getBadgeColor(issue.issues.length) : issue.status === "error" ? STYLES.error : issue.status === "scanning" ? STYLES.highlight : "rgba(156, 163, 175, 0.5)";
|
|
77
87
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
88
|
isHovered && /* @__PURE__ */ jsx(
|
|
79
89
|
"div",
|
|
@@ -93,7 +103,7 @@ function ElementBadge({
|
|
|
93
103
|
"data-ui-lint": true
|
|
94
104
|
}
|
|
95
105
|
),
|
|
96
|
-
/* @__PURE__ */
|
|
106
|
+
/* @__PURE__ */ jsxs(
|
|
97
107
|
"div",
|
|
98
108
|
{
|
|
99
109
|
style: badgeStyle,
|
|
@@ -101,32 +111,16 @@ function ElementBadge({
|
|
|
101
111
|
onMouseEnter: () => setIsHovered(true),
|
|
102
112
|
onMouseLeave: () => setIsHovered(false),
|
|
103
113
|
onClick: handleClick,
|
|
104
|
-
children:
|
|
114
|
+
children: [
|
|
105
115
|
issue.status === "scanning" && /* @__PURE__ */ jsx(ScanningBadge, {}),
|
|
106
116
|
issue.status === "complete" && /* @__PURE__ */ jsx(IssueBadge, { count: issue.issues.length }),
|
|
107
117
|
issue.status === "error" && /* @__PURE__ */ jsx(ErrorBadge, {}),
|
|
108
118
|
issue.status === "pending" && /* @__PURE__ */ jsx(PendingBadge, {})
|
|
109
|
-
]
|
|
119
|
+
]
|
|
110
120
|
}
|
|
111
121
|
)
|
|
112
122
|
] });
|
|
113
123
|
}
|
|
114
|
-
function MinimizedBadge({ color }) {
|
|
115
|
-
return /* @__PURE__ */ jsx(
|
|
116
|
-
"div",
|
|
117
|
-
{
|
|
118
|
-
style: {
|
|
119
|
-
width: "6px",
|
|
120
|
-
height: "6px",
|
|
121
|
-
borderRadius: "50%",
|
|
122
|
-
backgroundColor: color,
|
|
123
|
-
opacity: 0.7,
|
|
124
|
-
transition: "all 0.15s ease-out",
|
|
125
|
-
boxShadow: STYLES.shadow
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
124
|
function IssueBadge({ count }) {
|
|
131
125
|
const color = getBadgeColor(count);
|
|
132
126
|
if (count === 0) {
|
|
@@ -357,13 +351,12 @@ function ElementBadges() {
|
|
|
357
351
|
if (cluster.badges.length === 1) {
|
|
358
352
|
const { element, issue, x, y } = cluster.badges[0];
|
|
359
353
|
const distance = Math.hypot(x - cursorPos.x, y - cursorPos.y);
|
|
360
|
-
const isNearCursor = distance <= PROXIMITY_THRESHOLD;
|
|
361
354
|
return /* @__PURE__ */ jsx(
|
|
362
355
|
ElementBadge,
|
|
363
356
|
{
|
|
364
357
|
element,
|
|
365
358
|
issue,
|
|
366
|
-
|
|
359
|
+
distance,
|
|
367
360
|
onSelect: handleSelect
|
|
368
361
|
},
|
|
369
362
|
element.id
|
|
@@ -373,12 +366,11 @@ function ElementBadges() {
|
|
|
373
366
|
cluster.centroidX - cursorPos.x,
|
|
374
367
|
cluster.centroidY - cursorPos.y
|
|
375
368
|
);
|
|
376
|
-
const isNearCursor = distance <= PROXIMITY_THRESHOLD;
|
|
377
369
|
return /* @__PURE__ */ jsx(
|
|
378
370
|
ClusteredBadge,
|
|
379
371
|
{
|
|
380
372
|
cluster,
|
|
381
|
-
|
|
373
|
+
distance,
|
|
382
374
|
onSelect: handleSelect
|
|
383
375
|
},
|
|
384
376
|
cluster.id
|
|
@@ -387,11 +379,7 @@ function ElementBadges() {
|
|
|
387
379
|
}) });
|
|
388
380
|
return createPortal(content, document.body);
|
|
389
381
|
}
|
|
390
|
-
function ClusteredBadge({
|
|
391
|
-
cluster,
|
|
392
|
-
isNearCursor,
|
|
393
|
-
onSelect
|
|
394
|
-
}) {
|
|
382
|
+
function ClusteredBadge({ cluster, distance, onSelect }) {
|
|
395
383
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
396
384
|
const [hoveredIndex, setHoveredIndex] = useState(null);
|
|
397
385
|
const closeTimeoutRef = React.useRef(null);
|
|
@@ -413,17 +401,6 @@ function ClusteredBadge({
|
|
|
413
401
|
}
|
|
414
402
|
});
|
|
415
403
|
}, [cluster.badges]);
|
|
416
|
-
const worstColor = useMemo(() => {
|
|
417
|
-
let worst = 0;
|
|
418
|
-
for (const { issue } of cluster.badges) {
|
|
419
|
-
if (issue.status === "complete") {
|
|
420
|
-
worst = Math.max(worst, issue.issues.length);
|
|
421
|
-
} else if (issue.status === "error") {
|
|
422
|
-
worst = Math.max(worst, 10);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
return getBadgeColor(worst);
|
|
426
|
-
}, [cluster.badges]);
|
|
427
404
|
const handleMouseEnter = useCallback(() => {
|
|
428
405
|
if (closeTimeoutRef.current) {
|
|
429
406
|
clearTimeout(closeTimeoutRef.current);
|
|
@@ -484,12 +461,15 @@ function ClusteredBadge({
|
|
|
484
461
|
top: cluster.centroidY - 9,
|
|
485
462
|
left: cluster.centroidX - 9,
|
|
486
463
|
zIndex: isExpanded ? 99999 : 99995,
|
|
487
|
-
cursor: "pointer"
|
|
464
|
+
cursor: "pointer",
|
|
465
|
+
transition: "transform 0.1s ease-out",
|
|
466
|
+
transform: `scale(${isExpanded ? 1.1 : getScaleFromDistance(distance)})`,
|
|
467
|
+
transformOrigin: "center center"
|
|
488
468
|
},
|
|
489
469
|
"data-ui-lint": true,
|
|
490
470
|
onMouseEnter: handleMouseEnter,
|
|
491
471
|
onMouseLeave: handleMouseLeave,
|
|
492
|
-
children:
|
|
472
|
+
children: /* @__PURE__ */ jsx(
|
|
493
473
|
"div",
|
|
494
474
|
{
|
|
495
475
|
style: {
|
|
@@ -500,9 +480,7 @@ function ClusteredBadge({
|
|
|
500
480
|
backgroundColor: STYLES.bg,
|
|
501
481
|
boxShadow: STYLES.shadow,
|
|
502
482
|
border: `1px solid ${STYLES.border}`,
|
|
503
|
-
overflow: "hidden"
|
|
504
|
-
transition: "transform 0.15s ease-out",
|
|
505
|
-
transform: isExpanded ? "scale(1.1)" : "scale(1)"
|
|
483
|
+
overflow: "hidden"
|
|
506
484
|
},
|
|
507
485
|
children: badgeSegments.map((segment, index) => /* @__PURE__ */ jsxs(
|
|
508
486
|
"div",
|
|
@@ -560,7 +538,7 @@ function ClusteredBadge({
|
|
|
560
538
|
index
|
|
561
539
|
))
|
|
562
540
|
}
|
|
563
|
-
)
|
|
541
|
+
)
|
|
564
542
|
}
|
|
565
543
|
),
|
|
566
544
|
isExpanded && /* @__PURE__ */ jsx(
|