uilint-react 0.1.35 → 0.1.38

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.
@@ -2,7 +2,7 @@
2
2
  "use client";
3
3
  import {
4
4
  useUILintContext
5
- } from "./chunk-I4JDR36K.js";
5
+ } from "./chunk-PU6XPNPN.js";
6
6
 
7
7
  // src/components/ui-lint/ElementBadges.tsx
8
8
  import React, { useState, useEffect, useCallback, useMemo } from "react";
@@ -163,10 +163,21 @@ function formatElementLabel(element) {
163
163
  const fileName = source.fileName.split("/").pop() || "Unknown";
164
164
  return `${tag} > ${fileName}`;
165
165
  }
166
- const componentName = element.componentStack[0]?.name;
167
- return componentName ? `${tag} > ${componentName}` : tag;
166
+ return tag;
168
167
  }
169
168
  var NEARBY_THRESHOLD = 30;
169
+ var WINDOW_EDGE_THRESHOLD = 20;
170
+ var BADGE_SIZE = 18;
171
+ function snapToWindowBounds(x, y) {
172
+ const minX = WINDOW_EDGE_THRESHOLD;
173
+ const maxX = window.innerWidth - BADGE_SIZE - WINDOW_EDGE_THRESHOLD;
174
+ const minY = WINDOW_EDGE_THRESHOLD;
175
+ const maxY = window.innerHeight - BADGE_SIZE - WINDOW_EDGE_THRESHOLD;
176
+ return {
177
+ x: Math.max(minX, Math.min(maxX, x)),
178
+ y: Math.max(minY, Math.min(maxY, y))
179
+ };
180
+ }
170
181
  function shouldShowBadge(issue, isAltKeyPressed) {
171
182
  if (issue.status === "error") return true;
172
183
  if (issue.status === "complete" && issue.issues.length > 0) return true;
@@ -259,7 +270,6 @@ function ElementBadges() {
259
270
  const inspected = {
260
271
  element: element.element,
261
272
  source: element.source,
262
- componentStack: element.componentStack,
263
273
  rect: element.element.getBoundingClientRect(),
264
274
  scannedElementId: element.id
265
275
  };
@@ -318,6 +328,10 @@ function NudgedBadge({
318
328
  const closeTimeoutRef = React.useRef(null);
319
329
  const { element, issue, rect, nudgedX, nudgedY } = position;
320
330
  const hasNearbyBadges = nearbyBadges.length > 1;
331
+ const snappedPosition = useMemo(
332
+ () => snapToWindowBounds(nudgedX, nudgedY),
333
+ [nudgedX, nudgedY]
334
+ );
321
335
  const badgeColor = useMemo(() => {
322
336
  if (issue.status === "error") return STYLES.error;
323
337
  if (issue.status === "scanning") return STYLES.highlight;
@@ -353,14 +367,14 @@ function NudgedBadge({
353
367
  return nearbyBadges[hoveredIndex] ?? null;
354
368
  }, [hoveredIndex, nearbyBadges]);
355
369
  const dropdownStyle = useMemo(() => {
356
- const preferRight = nudgedX < window.innerWidth - 220;
357
- const preferBelow = nudgedY < window.innerHeight - 200;
370
+ const preferRight = snappedPosition.x < window.innerWidth - 220;
371
+ const preferBelow = snappedPosition.y < window.innerHeight - 200;
358
372
  return {
359
373
  position: "fixed",
360
- top: preferBelow ? nudgedY + 12 : void 0,
361
- bottom: preferBelow ? void 0 : window.innerHeight - nudgedY + 12,
362
- left: preferRight ? nudgedX - 8 : void 0,
363
- right: preferRight ? void 0 : window.innerWidth - nudgedX - 8,
374
+ top: preferBelow ? snappedPosition.y + 12 : void 0,
375
+ bottom: preferBelow ? void 0 : window.innerHeight - snappedPosition.y + 12,
376
+ left: preferRight ? snappedPosition.x - 8 : void 0,
377
+ right: preferRight ? void 0 : window.innerWidth - snappedPosition.x - 8,
364
378
  zIndex: 1e5,
365
379
  backgroundColor: STYLES.bg,
366
380
  borderRadius: "8px",
@@ -370,7 +384,7 @@ function NudgedBadge({
370
384
  minWidth: "200px",
371
385
  fontFamily: STYLES.font
372
386
  };
373
- }, [nudgedX, nudgedY]);
387
+ }, [snappedPosition]);
374
388
  const scale = isExpanded ? 1.1 : getScaleFromDistance(distance);
375
389
  const issueCount = issue.status === "complete" ? issue.issues.length : 0;
376
390
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -415,8 +429,8 @@ function NudgedBadge({
415
429
  {
416
430
  style: {
417
431
  position: "fixed",
418
- top: nudgedY - 9,
419
- left: nudgedX - 9,
432
+ top: snappedPosition.y - 0,
433
+ left: snappedPosition.x - 0,
420
434
  zIndex: isExpanded ? 99999 : 99995,
421
435
  cursor: "pointer",
422
436
  transition: "transform 0.1s ease-out",
@@ -2,8 +2,8 @@
2
2
  "use client";
3
3
  import {
4
4
  InspectionPanel
5
- } from "./chunk-GKYWTCFU.js";
6
- import "./chunk-I4JDR36K.js";
5
+ } from "./chunk-GZOQ6QWC.js";
6
+ import "./chunk-PU6XPNPN.js";
7
7
  export {
8
8
  InspectionPanel
9
9
  };
@@ -3,8 +3,8 @@
3
3
  import {
4
4
  InspectedElementHighlight,
5
5
  LocatorOverlay
6
- } from "./chunk-3YZH4UAT.js";
7
- import "./chunk-I4JDR36K.js";
6
+ } from "./chunk-V4273T5B.js";
7
+ import "./chunk-PU6XPNPN.js";
8
8
  export {
9
9
  InspectedElementHighlight,
10
10
  LocatorOverlay
@@ -2,8 +2,8 @@
2
2
  "use client";
3
3
  import {
4
4
  UILintToolbar
5
- } from "./chunk-IGVNY64A.js";
6
- import "./chunk-I4JDR36K.js";
5
+ } from "./chunk-WEBVLQL5.js";
6
+ import "./chunk-PU6XPNPN.js";
7
7
  export {
8
8
  UILintToolbar
9
9
  };
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  buildEditorUrl,
4
4
  useUILintContext
5
- } from "./chunk-I4JDR36K.js";
5
+ } from "./chunk-PU6XPNPN.js";
6
6
 
7
7
  // src/components/ui-lint/InspectionPanel.tsx
8
8
  import { useState, useEffect, useCallback, useMemo } from "react";
@@ -199,7 +199,7 @@ function PanelHeader({
199
199
  element,
200
200
  onClose
201
201
  }) {
202
- const componentName = element.componentStack[0]?.name || element.element.tagName.toLowerCase();
202
+ const tagName = element.element.tagName.toLowerCase();
203
203
  const handleOpenInCursor = useCallback(() => {
204
204
  if (element.source) {
205
205
  const url = buildEditorUrl(element.source, "cursor");
@@ -219,11 +219,15 @@ function PanelHeader({
219
219
  },
220
220
  children: [
221
221
  /* @__PURE__ */ jsxs("div", { children: [
222
- /* @__PURE__ */ jsx("div", { style: { fontSize: "14px", fontWeight: 600 }, children: componentName }),
223
- /* @__PURE__ */ jsxs("div", { style: { fontSize: "11px", color: STYLES.textMuted }, children: [
222
+ /* @__PURE__ */ jsxs("div", { style: { fontSize: "14px", fontWeight: 600 }, children: [
224
223
  "<",
225
- element.element.tagName.toLowerCase(),
224
+ tagName,
226
225
  ">"
226
+ ] }),
227
+ element.source && /* @__PURE__ */ jsxs("div", { style: { fontSize: "11px", color: STYLES.textMuted }, children: [
228
+ element.source.fileName.split("/").pop(),
229
+ ":",
230
+ element.source.lineNumber
227
231
  ] })
228
232
  ] }),
229
233
  /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
@@ -357,38 +361,6 @@ function InfoTab({ element }) {
357
361
  children: element.source.fileName
358
362
  }
359
363
  ) }),
360
- element.componentStack.length > 0 && /* @__PURE__ */ jsx(Section, { title: "Component Stack", children: /* @__PURE__ */ jsxs(
361
- "div",
362
- {
363
- style: { display: "flex", flexDirection: "column", gap: "4px" },
364
- children: [
365
- element.componentStack.slice(0, 10).map((comp, index) => /* @__PURE__ */ jsx(
366
- ComponentStackItem,
367
- {
368
- component: comp,
369
- index,
370
- isFirst: index === 0
371
- },
372
- index
373
- )),
374
- element.componentStack.length > 10 && /* @__PURE__ */ jsxs(
375
- "div",
376
- {
377
- style: {
378
- fontSize: "11px",
379
- color: STYLES.textDim,
380
- marginTop: "4px"
381
- },
382
- children: [
383
- "...and ",
384
- element.componentStack.length - 10,
385
- " more"
386
- ]
387
- }
388
- )
389
- ]
390
- }
391
- ) }),
392
364
  /* @__PURE__ */ jsxs(Section, { title: "Dimensions", children: [
393
365
  /* @__PURE__ */ jsx(
394
366
  InfoRow,
@@ -666,26 +638,6 @@ function ScanSection({ element }) {
666
638
  }
667
639
  ),
668
640
  showCachedResult && /* @__PURE__ */ jsxs("div", { children: [
669
- /* @__PURE__ */ jsxs(
670
- "div",
671
- {
672
- style: {
673
- display: "flex",
674
- alignItems: "center",
675
- gap: "8px",
676
- marginBottom: "12px",
677
- padding: "8px 12px",
678
- backgroundColor: "rgba(16, 185, 129, 0.1)",
679
- borderRadius: "6px",
680
- fontSize: "11px",
681
- color: STYLES.success
682
- },
683
- children: [
684
- /* @__PURE__ */ jsx(CheckIconSmall, {}),
685
- "Scan complete"
686
- ]
687
- }
688
- ),
689
641
  eslintIssues.length > 0 && /* @__PURE__ */ jsx(ESLintIssuesSection, { issues: eslintIssues }),
690
642
  eslintIssues.length === 0 && /* @__PURE__ */ jsx(
691
643
  "div",
@@ -831,18 +783,6 @@ function ESLintIssuesSection({ issues }) {
831
783
  )
832
784
  ] });
833
785
  }
834
- function CheckIconSmall() {
835
- return /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
836
- "path",
837
- {
838
- d: "M20 6L9 17l-5-5",
839
- stroke: "currentColor",
840
- strokeWidth: "2",
841
- strokeLinecap: "round",
842
- strokeLinejoin: "round"
843
- }
844
- ) });
845
- }
846
786
  function Section({
847
787
  title,
848
788
  children
@@ -899,70 +839,6 @@ function InfoRow({
899
839
  }
900
840
  );
901
841
  }
902
- function ComponentStackItem({
903
- component,
904
- index,
905
- isFirst
906
- }) {
907
- const handleClick = useCallback(() => {
908
- if (component.source) {
909
- const url = buildEditorUrl(component.source, "cursor");
910
- window.open(url, "_blank");
911
- }
912
- }, [component.source]);
913
- return /* @__PURE__ */ jsxs(
914
- "div",
915
- {
916
- style: {
917
- display: "flex",
918
- alignItems: "center",
919
- gap: "8px",
920
- padding: "6px 8px",
921
- marginLeft: index * 8,
922
- backgroundColor: isFirst ? "rgba(59, 130, 246, 0.1)" : "transparent",
923
- borderRadius: "4px",
924
- cursor: component.source ? "pointer" : "default",
925
- transition: "background-color 0.15s"
926
- },
927
- onClick: handleClick,
928
- onMouseEnter: (e) => {
929
- if (component.source) {
930
- e.currentTarget.style.backgroundColor = "rgba(59, 130, 246, 0.15)";
931
- }
932
- },
933
- onMouseLeave: (e) => {
934
- e.currentTarget.style.backgroundColor = isFirst ? "rgba(59, 130, 246, 0.1)" : "transparent";
935
- },
936
- children: [
937
- /* @__PURE__ */ jsx(
938
- "span",
939
- {
940
- style: {
941
- fontSize: "12px",
942
- fontWeight: isFirst ? 600 : 400,
943
- color: isFirst ? STYLES.accent : STYLES.textMuted
944
- },
945
- children: component.name
946
- }
947
- ),
948
- component.source && /* @__PURE__ */ jsxs(
949
- "span",
950
- {
951
- style: {
952
- fontSize: "10px",
953
- color: STYLES.textDim,
954
- fontFamily: STYLES.fontMono
955
- },
956
- children: [
957
- ":",
958
- component.source.lineNumber
959
- ]
960
- }
961
- )
962
- ]
963
- }
964
- );
965
- }
966
842
  function CursorIcon() {
967
843
  return /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
968
844
  "path",