uilint-react 0.1.22 → 0.1.23

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.
@@ -0,0 +1,221 @@
1
+ "use client";
2
+ "use client";
3
+ import {
4
+ useUILintContext
5
+ } from "./chunk-XPAUSE5Z.js";
6
+
7
+ // src/components/ui-lint/ElementBadges.tsx
8
+ import { useState, useEffect } from "react";
9
+ import { createPortal } from "react-dom";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ var STYLES = {
12
+ bg: "rgba(17, 24, 39, 0.95)",
13
+ success: "#10B981",
14
+ warning: "#F59E0B",
15
+ error: "#EF4444",
16
+ text: "#FFFFFF",
17
+ border: "rgba(255, 255, 255, 0.2)",
18
+ font: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
19
+ shadow: "0 2px 8px rgba(0, 0, 0, 0.3)"
20
+ };
21
+ function getBadgeColor(issueCount) {
22
+ if (issueCount === 0) return STYLES.success;
23
+ if (issueCount <= 2) return STYLES.warning;
24
+ return STYLES.error;
25
+ }
26
+ function ElementBadge({ element, issue }) {
27
+ const [rect, setRect] = useState(null);
28
+ useEffect(() => {
29
+ const updateRect = () => {
30
+ if (element.element && document.contains(element.element)) {
31
+ setRect(element.element.getBoundingClientRect());
32
+ } else {
33
+ setRect(null);
34
+ }
35
+ };
36
+ updateRect();
37
+ let rafId;
38
+ const handleUpdate = () => {
39
+ updateRect();
40
+ rafId = requestAnimationFrame(handleUpdate);
41
+ };
42
+ rafId = requestAnimationFrame(handleUpdate);
43
+ return () => {
44
+ cancelAnimationFrame(rafId);
45
+ };
46
+ }, [element.element]);
47
+ if (!rect) return null;
48
+ const badgeStyle = {
49
+ position: "fixed",
50
+ top: rect.top - 8,
51
+ left: rect.right - 8,
52
+ zIndex: 99995,
53
+ pointerEvents: "none"
54
+ };
55
+ if (rect.top < -50 || rect.top > window.innerHeight + 50) return null;
56
+ if (rect.left < -50 || rect.left > window.innerWidth + 50) return null;
57
+ return /* @__PURE__ */ jsxs("div", { style: badgeStyle, "data-ui-lint": true, children: [
58
+ issue.status === "scanning" && /* @__PURE__ */ jsx(ScanningBadge, {}),
59
+ issue.status === "complete" && /* @__PURE__ */ jsx(IssueBadge, { count: issue.issues.length }),
60
+ issue.status === "error" && /* @__PURE__ */ jsx(ErrorBadge, {}),
61
+ issue.status === "pending" && /* @__PURE__ */ jsx(PendingBadge, {})
62
+ ] });
63
+ }
64
+ function IssueBadge({ count }) {
65
+ const color = getBadgeColor(count);
66
+ if (count === 0) {
67
+ return /* @__PURE__ */ jsx(
68
+ "div",
69
+ {
70
+ style: {
71
+ display: "flex",
72
+ alignItems: "center",
73
+ justifyContent: "center",
74
+ width: "18px",
75
+ height: "18px",
76
+ borderRadius: "50%",
77
+ backgroundColor: color,
78
+ boxShadow: STYLES.shadow,
79
+ border: `1px solid ${STYLES.border}`
80
+ },
81
+ children: /* @__PURE__ */ jsx(CheckIcon, {})
82
+ }
83
+ );
84
+ }
85
+ return /* @__PURE__ */ jsx(
86
+ "div",
87
+ {
88
+ style: {
89
+ display: "flex",
90
+ alignItems: "center",
91
+ justifyContent: "center",
92
+ minWidth: "18px",
93
+ height: "18px",
94
+ padding: "0 5px",
95
+ borderRadius: "9px",
96
+ backgroundColor: color,
97
+ color: STYLES.text,
98
+ fontSize: "10px",
99
+ fontWeight: 700,
100
+ fontFamily: STYLES.font,
101
+ boxShadow: STYLES.shadow,
102
+ border: `1px solid ${STYLES.border}`
103
+ },
104
+ children: count > 9 ? "9+" : count
105
+ }
106
+ );
107
+ }
108
+ function ScanningBadge() {
109
+ return /* @__PURE__ */ jsxs(
110
+ "div",
111
+ {
112
+ style: {
113
+ display: "flex",
114
+ alignItems: "center",
115
+ justifyContent: "center",
116
+ width: "18px",
117
+ height: "18px",
118
+ borderRadius: "50%",
119
+ backgroundColor: STYLES.bg,
120
+ boxShadow: STYLES.shadow,
121
+ border: `1px solid ${STYLES.border}`
122
+ },
123
+ children: [
124
+ /* @__PURE__ */ jsx("style", { children: `
125
+ @keyframes uilint-badge-spin {
126
+ from { transform: rotate(0deg); }
127
+ to { transform: rotate(360deg); }
128
+ }
129
+ ` }),
130
+ /* @__PURE__ */ jsx(
131
+ "div",
132
+ {
133
+ style: {
134
+ width: "10px",
135
+ height: "10px",
136
+ border: "2px solid rgba(59, 130, 246, 0.3)",
137
+ borderTopColor: "#3B82F6",
138
+ borderRadius: "50%",
139
+ animation: "uilint-badge-spin 0.8s linear infinite"
140
+ }
141
+ }
142
+ )
143
+ ]
144
+ }
145
+ );
146
+ }
147
+ function PendingBadge() {
148
+ return /* @__PURE__ */ jsx(
149
+ "div",
150
+ {
151
+ style: {
152
+ width: "10px",
153
+ height: "10px",
154
+ borderRadius: "50%",
155
+ backgroundColor: "rgba(156, 163, 175, 0.5)",
156
+ boxShadow: STYLES.shadow
157
+ }
158
+ }
159
+ );
160
+ }
161
+ function ErrorBadge() {
162
+ return /* @__PURE__ */ jsx(
163
+ "div",
164
+ {
165
+ style: {
166
+ display: "flex",
167
+ alignItems: "center",
168
+ justifyContent: "center",
169
+ width: "18px",
170
+ height: "18px",
171
+ borderRadius: "50%",
172
+ backgroundColor: STYLES.error,
173
+ boxShadow: STYLES.shadow,
174
+ border: `1px solid ${STYLES.border}`
175
+ },
176
+ children: /* @__PURE__ */ jsx(ExclamationIcon, {})
177
+ }
178
+ );
179
+ }
180
+ function ElementBadges() {
181
+ const { autoScanState, elementIssuesCache } = useUILintContext();
182
+ const [mounted, setMounted] = useState(false);
183
+ useEffect(() => {
184
+ setMounted(true);
185
+ }, []);
186
+ if (!mounted) return null;
187
+ if (autoScanState.status === "idle") return null;
188
+ const content = /* @__PURE__ */ jsx("div", { "data-ui-lint": true, children: autoScanState.elements.map((element) => {
189
+ const issue = elementIssuesCache.get(element.id);
190
+ if (!issue) return null;
191
+ return /* @__PURE__ */ jsx(ElementBadge, { element, issue }, element.id);
192
+ }) });
193
+ return createPortal(content, document.body);
194
+ }
195
+ function CheckIcon() {
196
+ return /* @__PURE__ */ jsx("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
197
+ "path",
198
+ {
199
+ d: "M20 6L9 17l-5-5",
200
+ stroke: STYLES.text,
201
+ strokeWidth: "3",
202
+ strokeLinecap: "round",
203
+ strokeLinejoin: "round"
204
+ }
205
+ ) });
206
+ }
207
+ function ExclamationIcon() {
208
+ return /* @__PURE__ */ jsx("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
209
+ "path",
210
+ {
211
+ d: "M12 8v4M12 16h.01",
212
+ stroke: STYLES.text,
213
+ strokeWidth: "3",
214
+ strokeLinecap: "round",
215
+ strokeLinejoin: "round"
216
+ }
217
+ ) });
218
+ }
219
+ export {
220
+ ElementBadges
221
+ };
@@ -2,8 +2,8 @@
2
2
  "use client";
3
3
  import {
4
4
  InspectionPanel
5
- } from "./chunk-CWCKS753.js";
6
- import "./chunk-EBU7YY73.js";
5
+ } from "./chunk-7BJIS7PI.js";
6
+ import "./chunk-XPAUSE5Z.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-3DNDKMZ4.js";
7
- import "./chunk-EBU7YY73.js";
6
+ } from "./chunk-ZMGUWRAO.js";
7
+ import "./chunk-XPAUSE5Z.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-GUF36FGA.js";
6
- import "./chunk-EBU7YY73.js";
5
+ } from "./chunk-7M2NF7HT.js";
6
+ import "./chunk-XPAUSE5Z.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-EBU7YY73.js";
5
+ } from "./chunk-XPAUSE5Z.js";
6
6
 
7
7
  // src/components/ui-lint/InspectionPanel.tsx
8
8
  import { useState, useEffect, useCallback } from "react";