uilint-react 0.1.35 → 0.1.37

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-DEHJKJNT.js";
6
6
 
7
7
  // src/components/ui-lint/ElementBadges.tsx
8
8
  import React, { useState, useEffect, useCallback, useMemo } from "react";
@@ -167,6 +167,18 @@ function formatElementLabel(element) {
167
167
  return componentName ? `${tag} > ${componentName}` : tag;
168
168
  }
169
169
  var NEARBY_THRESHOLD = 30;
170
+ var WINDOW_EDGE_THRESHOLD = 20;
171
+ var BADGE_SIZE = 18;
172
+ function snapToWindowBounds(x, y) {
173
+ const minX = WINDOW_EDGE_THRESHOLD;
174
+ const maxX = window.innerWidth - BADGE_SIZE - WINDOW_EDGE_THRESHOLD;
175
+ const minY = WINDOW_EDGE_THRESHOLD;
176
+ const maxY = window.innerHeight - BADGE_SIZE - WINDOW_EDGE_THRESHOLD;
177
+ return {
178
+ x: Math.max(minX, Math.min(maxX, x)),
179
+ y: Math.max(minY, Math.min(maxY, y))
180
+ };
181
+ }
170
182
  function shouldShowBadge(issue, isAltKeyPressed) {
171
183
  if (issue.status === "error") return true;
172
184
  if (issue.status === "complete" && issue.issues.length > 0) return true;
@@ -318,6 +330,10 @@ function NudgedBadge({
318
330
  const closeTimeoutRef = React.useRef(null);
319
331
  const { element, issue, rect, nudgedX, nudgedY } = position;
320
332
  const hasNearbyBadges = nearbyBadges.length > 1;
333
+ const snappedPosition = useMemo(
334
+ () => snapToWindowBounds(nudgedX, nudgedY),
335
+ [nudgedX, nudgedY]
336
+ );
321
337
  const badgeColor = useMemo(() => {
322
338
  if (issue.status === "error") return STYLES.error;
323
339
  if (issue.status === "scanning") return STYLES.highlight;
@@ -353,14 +369,14 @@ function NudgedBadge({
353
369
  return nearbyBadges[hoveredIndex] ?? null;
354
370
  }, [hoveredIndex, nearbyBadges]);
355
371
  const dropdownStyle = useMemo(() => {
356
- const preferRight = nudgedX < window.innerWidth - 220;
357
- const preferBelow = nudgedY < window.innerHeight - 200;
372
+ const preferRight = snappedPosition.x < window.innerWidth - 220;
373
+ const preferBelow = snappedPosition.y < window.innerHeight - 200;
358
374
  return {
359
375
  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,
376
+ top: preferBelow ? snappedPosition.y + 12 : void 0,
377
+ bottom: preferBelow ? void 0 : window.innerHeight - snappedPosition.y + 12,
378
+ left: preferRight ? snappedPosition.x - 8 : void 0,
379
+ right: preferRight ? void 0 : window.innerWidth - snappedPosition.x - 8,
364
380
  zIndex: 1e5,
365
381
  backgroundColor: STYLES.bg,
366
382
  borderRadius: "8px",
@@ -370,7 +386,7 @@ function NudgedBadge({
370
386
  minWidth: "200px",
371
387
  fontFamily: STYLES.font
372
388
  };
373
- }, [nudgedX, nudgedY]);
389
+ }, [snappedPosition]);
374
390
  const scale = isExpanded ? 1.1 : getScaleFromDistance(distance);
375
391
  const issueCount = issue.status === "complete" ? issue.issues.length : 0;
376
392
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -415,8 +431,8 @@ function NudgedBadge({
415
431
  {
416
432
  style: {
417
433
  position: "fixed",
418
- top: nudgedY - 9,
419
- left: nudgedX - 9,
434
+ top: snappedPosition.y - 0,
435
+ left: snappedPosition.x - 0,
420
436
  zIndex: isExpanded ? 99999 : 99995,
421
437
  cursor: "pointer",
422
438
  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-ITKEGCAZ.js";
6
+ import "./chunk-DEHJKJNT.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-LZX53CPI.js";
7
+ import "./chunk-DEHJKJNT.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-EYWLUDXI.js";
6
+ import "./chunk-DEHJKJNT.js";
7
7
  export {
8
8
  UILintToolbar
9
9
  };
@@ -1033,10 +1033,10 @@ function UILintUI() {
1033
1033
  const [components, setComponents] = useState(null);
1034
1034
  useEffect(() => {
1035
1035
  Promise.all([
1036
- import("./UILintToolbar-WF5WHENS.js"),
1037
- import("./InspectionPanel-Z2F7PDVS.js"),
1038
- import("./LocatorOverlay-YTDVYPJQ.js"),
1039
- import("./ElementBadges-M7WT4MWJ.js")
1036
+ import("./UILintToolbar-TM3DVGPO.js"),
1037
+ import("./InspectionPanel-FY7QVWP5.js"),
1038
+ import("./LocatorOverlay-IUZV5OVI.js"),
1039
+ import("./ElementBadges-BASN6P5L.js")
1040
1040
  ]).then(([toolbar, panel, locator, badges]) => {
1041
1041
  setComponents({
1042
1042
  Toolbar: toolbar.UILintToolbar,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  useUILintContext,
4
4
  useUILintStore
5
- } from "./chunk-I4JDR36K.js";
5
+ } from "./chunk-DEHJKJNT.js";
6
6
 
7
7
  // src/components/ui-lint/UILintToolbar.tsx
8
8
  import { useState, useRef, useEffect } from "react";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  buildEditorUrl,
4
4
  useUILintContext
5
- } from "./chunk-I4JDR36K.js";
5
+ } from "./chunk-DEHJKJNT.js";
6
6
 
7
7
  // src/components/ui-lint/InspectionPanel.tsx
8
8
  import { useState, useEffect, useCallback, useMemo } from "react";
@@ -666,26 +666,6 @@ function ScanSection({ element }) {
666
666
  }
667
667
  ),
668
668
  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
669
  eslintIssues.length > 0 && /* @__PURE__ */ jsx(ESLintIssuesSection, { issues: eslintIssues }),
690
670
  eslintIssues.length === 0 && /* @__PURE__ */ jsx(
691
671
  "div",
@@ -831,18 +811,6 @@ function ESLintIssuesSection({ issues }) {
831
811
  )
832
812
  ] });
833
813
  }
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
814
  function Section({
847
815
  title,
848
816
  children
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useUILintContext
4
- } from "./chunk-I4JDR36K.js";
4
+ } from "./chunk-DEHJKJNT.js";
5
5
 
6
6
  // src/components/ui-lint/LocatorOverlay.tsx
7
7
  import { useState, useEffect, useMemo } from "react";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  UILintToolbar
4
- } from "./chunk-IGVNY64A.js";
4
+ } from "./chunk-EYWLUDXI.js";
5
5
  import {
6
6
  InspectionPanel,
7
7
  clearSourceCache,
@@ -9,10 +9,10 @@ import {
9
9
  fetchSourceWithContext,
10
10
  getCachedSource,
11
11
  prefetchSources
12
- } from "./chunk-GKYWTCFU.js";
12
+ } from "./chunk-ITKEGCAZ.js";
13
13
  import {
14
14
  LocatorOverlay
15
- } from "./chunk-3YZH4UAT.js";
15
+ } from "./chunk-LZX53CPI.js";
16
16
  import {
17
17
  DATA_UILINT_ID,
18
18
  DEFAULT_SETTINGS,
@@ -31,7 +31,7 @@ import {
31
31
  scanDOMForSources,
32
32
  updateElementRects,
33
33
  useUILintContext
34
- } from "./chunk-I4JDR36K.js";
34
+ } from "./chunk-DEHJKJNT.js";
35
35
 
36
36
  // src/consistency/snapshot.ts
37
37
  var DATA_ELEMENTS_ATTR = "data-elements";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uilint-react",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "React component for AI-powered UI consistency checking",
5
5
  "author": "Peter Suggate",
6
6
  "repository": {
@@ -34,7 +34,7 @@
34
34
  "node": ">=20.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "uilint-core": "^0.1.35",
37
+ "uilint-core": "^0.1.37",
38
38
  "zustand": "^5.0.5"
39
39
  },
40
40
  "peerDependencies": {