uilint-react 0.1.34 → 0.1.35

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-MO4NS6EG.js";
5
+ } from "./chunk-I4JDR36K.js";
6
6
 
7
7
  // src/components/ui-lint/ElementBadges.tsx
8
8
  import React, { useState, useEffect, useCallback, useMemo } from "react";
@@ -167,6 +167,17 @@ function formatElementLabel(element) {
167
167
  return componentName ? `${tag} > ${componentName}` : tag;
168
168
  }
169
169
  var NEARBY_THRESHOLD = 30;
170
+ function shouldShowBadge(issue, isAltKeyPressed) {
171
+ if (issue.status === "error") return true;
172
+ if (issue.status === "complete" && issue.issues.length > 0) return true;
173
+ if (issue.status === "complete" && issue.issues.length === 0) {
174
+ return isAltKeyPressed;
175
+ }
176
+ if (issue.status === "scanning" || issue.status === "pending") {
177
+ return isAltKeyPressed;
178
+ }
179
+ return false;
180
+ }
170
181
  function BadgeAnimationStyles() {
171
182
  return /* @__PURE__ */ jsx("style", { children: `
172
183
  @keyframes uilint-badge-spin {
@@ -180,9 +191,33 @@ function ElementBadges() {
180
191
  const [mounted, setMounted] = useState(false);
181
192
  const [cursorPos, setCursorPos] = useState({ x: 0, y: 0 });
182
193
  const [badgePositions, setBadgePositions] = useState([]);
194
+ const [isAltKeyPressed, setIsAltKeyPressed] = useState(false);
183
195
  useEffect(() => {
184
196
  setMounted(true);
185
197
  }, []);
198
+ useEffect(() => {
199
+ const handleKeyDown = (e) => {
200
+ if (e.altKey) {
201
+ setIsAltKeyPressed(true);
202
+ }
203
+ };
204
+ const handleKeyUp = (e) => {
205
+ if (!e.altKey) {
206
+ setIsAltKeyPressed(false);
207
+ }
208
+ };
209
+ const handleBlur = () => {
210
+ setIsAltKeyPressed(false);
211
+ };
212
+ window.addEventListener("keydown", handleKeyDown);
213
+ window.addEventListener("keyup", handleKeyUp);
214
+ window.addEventListener("blur", handleBlur);
215
+ return () => {
216
+ window.removeEventListener("keydown", handleKeyDown);
217
+ window.removeEventListener("keyup", handleKeyUp);
218
+ window.removeEventListener("blur", handleBlur);
219
+ };
220
+ }, []);
186
221
  useEffect(() => {
187
222
  const handleMouseMove = (e) => {
188
223
  setCursorPos({ x: e.clientX, y: e.clientY });
@@ -236,17 +271,22 @@ function ElementBadges() {
236
271
  () => BadgeLayoutBuilder.create(badgePositions).minDistance(24).repulsion(50).anchorStrength(0.3).iterations(50).compute(),
237
272
  [badgePositions]
238
273
  );
274
+ const visibleBadges = useMemo(() => {
275
+ return nudgedPositions.filter(
276
+ (pos) => shouldShowBadge(pos.issue, isAltKeyPressed)
277
+ );
278
+ }, [nudgedPositions, isAltKeyPressed]);
239
279
  if (!mounted) return null;
240
280
  if (autoScanState.status === "idle") return null;
241
281
  const content = /* @__PURE__ */ jsxs("div", { "data-ui-lint": true, children: [
242
282
  /* @__PURE__ */ jsx(BadgeAnimationStyles, {}),
243
- nudgedPositions.map((nudgedPos) => {
283
+ visibleBadges.map((nudgedPos) => {
244
284
  const distance = Math.hypot(
245
285
  nudgedPos.nudgedX - cursorPos.x,
246
286
  nudgedPos.nudgedY - cursorPos.y
247
287
  );
248
288
  const nearbyBadges = findNearbyBadges(
249
- nudgedPositions,
289
+ visibleBadges,
250
290
  nudgedPos.nudgedX,
251
291
  nudgedPos.nudgedY,
252
292
  NEARBY_THRESHOLD
@@ -379,7 +419,7 @@ function NudgedBadge({
379
419
  left: nudgedX - 9,
380
420
  zIndex: isExpanded ? 99999 : 99995,
381
421
  cursor: "pointer",
382
- transition: "transform 0.1s ease-out, top 0.15s ease-out, left 0.15s ease-out",
422
+ transition: "transform 0.1s ease-out",
383
423
  transform: `scale(${scale})`,
384
424
  transformOrigin: "center center"
385
425
  },
@@ -2,8 +2,8 @@
2
2
  "use client";
3
3
  import {
4
4
  InspectionPanel
5
- } from "./chunk-JBBUE3Y5.js";
6
- import "./chunk-MO4NS6EG.js";
5
+ } from "./chunk-GKYWTCFU.js";
6
+ import "./chunk-I4JDR36K.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-Z6PWYQGW.js";
7
- import "./chunk-MO4NS6EG.js";
6
+ } from "./chunk-3YZH4UAT.js";
7
+ import "./chunk-I4JDR36K.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-HTNIKCEM.js";
6
- import "./chunk-MO4NS6EG.js";
5
+ } from "./chunk-IGVNY64A.js";
6
+ import "./chunk-I4JDR36K.js";
7
7
  export {
8
8
  UILintToolbar
9
9
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useUILintContext
4
- } from "./chunk-MO4NS6EG.js";
4
+ } from "./chunk-I4JDR36K.js";
5
5
 
6
6
  // src/components/ui-lint/LocatorOverlay.tsx
7
7
  import { useState, useEffect, useMemo } from "react";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  buildEditorUrl,
4
4
  useUILintContext
5
- } from "./chunk-MO4NS6EG.js";
5
+ } from "./chunk-I4JDR36K.js";
6
6
 
7
7
  // src/components/ui-lint/InspectionPanel.tsx
8
8
  import { useState, useEffect, useCallback, useMemo } from "react";
@@ -1033,10 +1033,10 @@ function UILintUI() {
1033
1033
  const [components, setComponents] = useState(null);
1034
1034
  useEffect(() => {
1035
1035
  Promise.all([
1036
- import("./UILintToolbar-WNV5RS2L.js"),
1037
- import("./InspectionPanel-JNLWBL4D.js"),
1038
- import("./LocatorOverlay-6SAH7LN2.js"),
1039
- import("./ElementBadges-TBAUB3KM.js")
1036
+ import("./UILintToolbar-WF5WHENS.js"),
1037
+ import("./InspectionPanel-Z2F7PDVS.js"),
1038
+ import("./LocatorOverlay-YTDVYPJQ.js"),
1039
+ import("./ElementBadges-M7WT4MWJ.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-MO4NS6EG.js";
5
+ } from "./chunk-I4JDR36K.js";
6
6
 
7
7
  // src/components/ui-lint/UILintToolbar.tsx
8
8
  import { useState, useRef, useEffect } from "react";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  UILintToolbar
4
- } from "./chunk-HTNIKCEM.js";
4
+ } from "./chunk-IGVNY64A.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-JBBUE3Y5.js";
12
+ } from "./chunk-GKYWTCFU.js";
13
13
  import {
14
14
  LocatorOverlay
15
- } from "./chunk-Z6PWYQGW.js";
15
+ } from "./chunk-3YZH4UAT.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-MO4NS6EG.js";
34
+ } from "./chunk-I4JDR36K.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.34",
3
+ "version": "0.1.35",
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.34",
37
+ "uilint-core": "^0.1.35",
38
38
  "zustand": "^5.0.5"
39
39
  },
40
40
  "peerDependencies": {