uilint-react 0.1.37 → 0.1.39
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-BASN6P5L.js → ElementBadges-3AFD2W4Z.js} +49 -18
- package/dist/{InspectionPanel-FY7QVWP5.js → InspectionPanel-VAHZBVVL.js} +2 -2
- package/dist/{LocatorOverlay-IUZV5OVI.js → LocatorOverlay-BEJYHU6S.js} +2 -2
- package/dist/{UILintToolbar-TM3DVGPO.js → UILintToolbar-4SH33QJU.js} +2 -2
- package/dist/chunk-4TLFW7LD.js +1143 -0
- package/dist/{chunk-LZX53CPI.js → chunk-7434TUMX.js} +23 -63
- package/dist/{chunk-DEHJKJNT.js → chunk-ILK73X6L.js} +285 -292
- package/dist/{chunk-ITKEGCAZ.js → chunk-NCNRCF5A.js} +9 -101
- package/dist/index.d.ts +43 -69
- package/dist/index.js +6 -12
- package/package.json +2 -2
- package/dist/chunk-EYWLUDXI.js +0 -695
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
|
-
useUILintContext
|
|
5
|
-
|
|
4
|
+
useUILintContext,
|
|
5
|
+
useUILintStore
|
|
6
|
+
} from "./chunk-ILK73X6L.js";
|
|
6
7
|
|
|
7
8
|
// src/components/ui-lint/ElementBadges.tsx
|
|
8
9
|
import React, { useState, useEffect, useCallback, useMemo } from "react";
|
|
@@ -153,8 +154,7 @@ function getScaleFromDistance(distance) {
|
|
|
153
154
|
}
|
|
154
155
|
function getBadgeColor(issueCount) {
|
|
155
156
|
if (issueCount === 0) return STYLES.success;
|
|
156
|
-
|
|
157
|
-
return STYLES.error;
|
|
157
|
+
return STYLES.warning;
|
|
158
158
|
}
|
|
159
159
|
function formatElementLabel(element) {
|
|
160
160
|
const tag = element.tagName.toLowerCase();
|
|
@@ -163,8 +163,7 @@ function formatElementLabel(element) {
|
|
|
163
163
|
const fileName = source.fileName.split("/").pop() || "Unknown";
|
|
164
164
|
return `${tag} > ${fileName}`;
|
|
165
165
|
}
|
|
166
|
-
|
|
167
|
-
return componentName ? `${tag} > ${componentName}` : tag;
|
|
166
|
+
return tag;
|
|
168
167
|
}
|
|
169
168
|
var NEARBY_THRESHOLD = 30;
|
|
170
169
|
var WINDOW_EDGE_THRESHOLD = 20;
|
|
@@ -204,6 +203,10 @@ function ElementBadges() {
|
|
|
204
203
|
const [cursorPos, setCursorPos] = useState({ x: 0, y: 0 });
|
|
205
204
|
const [badgePositions, setBadgePositions] = useState([]);
|
|
206
205
|
const [isAltKeyPressed, setIsAltKeyPressed] = useState(false);
|
|
206
|
+
const hoveredFilePath = useUILintStore((s) => s.hoveredFilePath);
|
|
207
|
+
const selectedFilePath = useUILintStore(
|
|
208
|
+
(s) => s.selectedFilePath
|
|
209
|
+
);
|
|
207
210
|
useEffect(() => {
|
|
208
211
|
setMounted(true);
|
|
209
212
|
}, []);
|
|
@@ -257,21 +260,39 @@ function ElementBadges() {
|
|
|
257
260
|
}
|
|
258
261
|
setBadgePositions(positions);
|
|
259
262
|
};
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
263
|
+
let rafId = null;
|
|
264
|
+
const scheduleUpdate = () => {
|
|
265
|
+
if (rafId !== null) return;
|
|
266
|
+
rafId = requestAnimationFrame(() => {
|
|
267
|
+
rafId = null;
|
|
268
|
+
updatePositions();
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
scheduleUpdate();
|
|
272
|
+
const handleScroll = () => scheduleUpdate();
|
|
273
|
+
const handleResize = () => scheduleUpdate();
|
|
274
|
+
const handleVisibility = () => {
|
|
275
|
+
if (document.visibilityState === "visible") {
|
|
276
|
+
scheduleUpdate();
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
window.addEventListener("scroll", handleScroll, true);
|
|
280
|
+
window.addEventListener("resize", handleResize);
|
|
281
|
+
document.addEventListener("visibilitychange", handleVisibility);
|
|
282
|
+
return () => {
|
|
283
|
+
if (rafId !== null) {
|
|
284
|
+
cancelAnimationFrame(rafId);
|
|
285
|
+
}
|
|
286
|
+
window.removeEventListener("scroll", handleScroll, true);
|
|
287
|
+
window.removeEventListener("resize", handleResize);
|
|
288
|
+
document.removeEventListener("visibilitychange", handleVisibility);
|
|
265
289
|
};
|
|
266
|
-
|
|
267
|
-
return () => cancelAnimationFrame(rafId);
|
|
268
|
-
}, [autoScanState, elementIssuesCache]);
|
|
290
|
+
}, [autoScanState.status, autoScanState.elements, elementIssuesCache]);
|
|
269
291
|
const handleSelect = useCallback(
|
|
270
292
|
(element, issue) => {
|
|
271
293
|
const inspected = {
|
|
272
294
|
element: element.element,
|
|
273
295
|
source: element.source,
|
|
274
|
-
componentStack: element.componentStack,
|
|
275
296
|
rect: element.element.getBoundingClientRect(),
|
|
276
297
|
scannedElementId: element.id
|
|
277
298
|
};
|
|
@@ -284,15 +305,25 @@ function ElementBadges() {
|
|
|
284
305
|
[badgePositions]
|
|
285
306
|
);
|
|
286
307
|
const visibleBadges = useMemo(() => {
|
|
287
|
-
|
|
308
|
+
let filtered = nudgedPositions.filter(
|
|
288
309
|
(pos) => shouldShowBadge(pos.issue, isAltKeyPressed)
|
|
289
310
|
);
|
|
290
|
-
|
|
311
|
+
const activeFilePath = selectedFilePath || hoveredFilePath;
|
|
312
|
+
if (activeFilePath) {
|
|
313
|
+
filtered = filtered.filter(
|
|
314
|
+
(pos) => pos.element.source.fileName === activeFilePath
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
return filtered;
|
|
318
|
+
}, [nudgedPositions, isAltKeyPressed, selectedFilePath, hoveredFilePath]);
|
|
291
319
|
if (!mounted) return null;
|
|
292
320
|
if (autoScanState.status === "idle") return null;
|
|
293
321
|
const content = /* @__PURE__ */ jsxs("div", { "data-ui-lint": true, children: [
|
|
294
322
|
/* @__PURE__ */ jsx(BadgeAnimationStyles, {}),
|
|
295
|
-
visibleBadges.
|
|
323
|
+
visibleBadges.filter((pos, idx, arr) => {
|
|
324
|
+
const id = pos.element.id;
|
|
325
|
+
return arr.findIndex((p) => p.element.id === id) === idx;
|
|
326
|
+
}).map((nudgedPos) => {
|
|
296
327
|
const distance = Math.hypot(
|
|
297
328
|
nudgedPos.nudgedX - cursorPos.x,
|
|
298
329
|
nudgedPos.nudgedY - cursorPos.y
|