@promakeai/inspector 0.2.1 → 1.0.0
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/inspector.css +1 -0
- package/dist/inspector.js +8740 -0
- package/dist/packages/inspector/src/App.d.ts +5 -0
- package/dist/packages/inspector/src/App.d.ts.map +1 -0
- package/dist/packages/inspector/src/__tests__/App.test.d.ts +5 -0
- package/dist/packages/inspector/src/__tests__/App.test.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/Badge.d.ts +9 -0
- package/dist/packages/inspector/src/components/Badge.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ControlBox/ContentArea.d.ts +10 -0
- package/dist/packages/inspector/src/components/ControlBox/ContentArea.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ControlBox/PromptInput.d.ts +12 -0
- package/dist/packages/inspector/src/components/ControlBox/PromptInput.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ControlBox/index.d.ts +21 -0
- package/dist/packages/inspector/src/components/ControlBox/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ImageEditor/UploadBox.d.ts +10 -0
- package/dist/packages/inspector/src/components/ImageEditor/UploadBox.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ImageEditor/index.d.ts +11 -0
- package/dist/packages/inspector/src/components/ImageEditor/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/Overlay.d.ts +11 -0
- package/dist/packages/inspector/src/components/Overlay.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/BorderSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/BorderSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/ColorPicker.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/ColorPicker.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/DisplaySection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/DisplaySection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/ImageSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/ImageSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/LayoutSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/LayoutSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/NumberInput.d.ts +17 -0
- package/dist/packages/inspector/src/components/StyleEditor/NumberInput.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/SliderInput.d.ts +16 -0
- package/dist/packages/inspector/src/components/StyleEditor/SliderInput.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/SpacingSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/SpacingSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/TextSection.d.ts +13 -0
- package/dist/packages/inspector/src/components/StyleEditor/TextSection.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/StyleEditor/index.d.ts +12 -0
- package/dist/packages/inspector/src/components/StyleEditor/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/TextEditor/index.d.ts +11 -0
- package/dist/packages/inspector/src/components/TextEditor/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/CustomCollapsible.d.ts +26 -0
- package/dist/packages/inspector/src/components/ui/CustomCollapsible.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/button.d.ts +9 -0
- package/dist/packages/inspector/src/components/ui/button.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/color-picker.d.ts +10 -0
- package/dist/packages/inspector/src/components/ui/color-picker.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/input.d.ts +6 -0
- package/dist/packages/inspector/src/components/ui/input.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/popover.d.ts +8 -0
- package/dist/packages/inspector/src/components/ui/popover.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/select.d.ts +16 -0
- package/dist/packages/inspector/src/components/ui/select.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/slider.d.ts +5 -0
- package/dist/packages/inspector/src/components/ui/slider.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/textarea.d.ts +4 -0
- package/dist/packages/inspector/src/components/ui/textarea.d.ts.map +1 -0
- package/dist/packages/inspector/src/components/ui/tooltip.d.ts +8 -0
- package/dist/packages/inspector/src/components/ui/tooltip.d.ts.map +1 -0
- package/dist/packages/inspector/src/core/highlighter.d.ts +40 -0
- package/dist/packages/inspector/src/core/highlighter.d.ts.map +1 -0
- package/dist/packages/inspector/src/hooks/useMessageBridge.d.ts +9 -0
- package/dist/packages/inspector/src/hooks/useMessageBridge.d.ts.map +1 -0
- package/dist/packages/inspector/src/hooks/useStylePreview.d.ts +11 -0
- package/dist/packages/inspector/src/hooks/useStylePreview.d.ts.map +1 -0
- package/dist/packages/inspector/src/index.d.ts +16 -0
- package/dist/packages/inspector/src/index.d.ts.map +1 -0
- package/dist/packages/inspector/src/lib/utils.d.ts +3 -0
- package/dist/packages/inspector/src/lib/utils.d.ts.map +1 -0
- package/dist/packages/inspector/src/plugin.d.ts +4 -0
- package/dist/packages/inspector/src/plugin.d.ts.map +1 -0
- package/dist/packages/inspector/src/store/useInspectorStore.d.ts +13 -0
- package/dist/packages/inspector/src/store/useInspectorStore.d.ts.map +1 -0
- package/dist/packages/inspector/src/styles.d.ts +5 -0
- package/dist/packages/inspector/src/styles.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/colorUtils.d.ts +49 -0
- package/dist/packages/inspector/src/utils/colorUtils.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/elementNames.d.ts +7 -0
- package/dist/packages/inspector/src/utils/elementNames.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/elementUtils.d.ts +28 -0
- package/dist/packages/inspector/src/utils/elementUtils.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/errorTracker.d.ts +48 -0
- package/dist/packages/inspector/src/utils/errorTracker.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/inputStyles.d.ts +23 -0
- package/dist/packages/inspector/src/utils/inputStyles.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/styleUtils.d.ts +27 -0
- package/dist/packages/inspector/src/utils/styleUtils.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/tailwindMapper.d.ts +9 -0
- package/dist/packages/inspector/src/utils/tailwindMapper.d.ts.map +1 -0
- package/dist/packages/inspector/src/utils/urlTracker.d.ts +27 -0
- package/dist/packages/inspector/src/utils/urlTracker.d.ts.map +1 -0
- package/dist/packages/inspector/tsconfig.tsbuildinfo +1 -0
- package/dist/plugin.js +10 -1813
- package/package.json +86 -76
- package/src/App.tsx +912 -0
- package/src/__tests__/App.test.tsx +373 -0
- package/src/assets/fonts/Satoshi-Variable.woff +0 -0
- package/src/assets/fonts/Satoshi-Variable.woff2 +0 -0
- package/src/components/Badge.tsx +118 -0
- package/src/components/ControlBox/ContentArea.tsx +13 -0
- package/src/components/ControlBox/PromptInput.module.css +66 -0
- package/src/components/ControlBox/PromptInput.tsx +104 -0
- package/src/components/ControlBox/index.module.css +81 -0
- package/src/components/ControlBox/index.tsx +409 -0
- package/src/components/ImageEditor/UploadBox.module.css +69 -0
- package/src/components/ImageEditor/UploadBox.tsx +113 -0
- package/src/components/ImageEditor/index.module.css +11 -0
- package/src/components/ImageEditor/index.tsx +84 -0
- package/src/components/Overlay.tsx +157 -0
- package/src/components/StyleEditor/BorderSection.tsx +147 -0
- package/src/components/StyleEditor/ColorPicker.tsx +182 -0
- package/src/components/StyleEditor/DisplaySection.tsx +349 -0
- package/src/components/StyleEditor/ImageSection.tsx +105 -0
- package/src/components/StyleEditor/LayoutSection.tsx +63 -0
- package/src/components/StyleEditor/NumberInput.tsx +138 -0
- package/src/components/StyleEditor/SliderInput.tsx +121 -0
- package/src/components/StyleEditor/SpacingSection.tsx +365 -0
- package/src/components/StyleEditor/TextSection.tsx +381 -0
- package/src/components/StyleEditor/index.module.css +133 -0
- package/src/components/StyleEditor/index.tsx +612 -0
- package/src/components/StyleEditor/shared.module.css +193 -0
- package/src/components/TextEditor/index.module.css +31 -0
- package/src/components/TextEditor/index.tsx +166 -0
- package/src/components/ui/CustomCollapsible.tsx +159 -0
- package/src/components/ui/button.module.css +141 -0
- package/src/components/ui/button.tsx +73 -0
- package/src/components/ui/color-picker.module.css +112 -0
- package/src/components/ui/color-picker.tsx +146 -0
- package/src/components/ui/input.module.css +49 -0
- package/src/components/ui/input.tsx +34 -0
- package/src/components/ui/popover.module.css +42 -0
- package/src/components/ui/popover.tsx +59 -0
- package/src/components/ui/select.module.css +160 -0
- package/src/components/ui/select.tsx +216 -0
- package/src/components/ui/slider.module.css +75 -0
- package/src/components/ui/slider.tsx +60 -0
- package/src/components/ui/textarea.module.css +30 -0
- package/src/components/ui/textarea.tsx +23 -0
- package/src/components/ui/tooltip.module.css +11 -0
- package/src/components/ui/tooltip.tsx +37 -0
- package/src/core/highlighter.ts +197 -0
- package/src/hooks/useMessageBridge.ts +49 -0
- package/src/hooks/useStylePreview.ts +332 -0
- package/src/index.ts +20 -0
- package/src/lib/utils.ts +5 -0
- package/src/plugin.ts +11 -0
- package/src/store/useInspectorStore.ts +235 -0
- package/src/styles/fonts.css +15 -0
- package/src/styles/global.css +138 -0
- package/src/styles/variables.css +151 -0
- package/src/styles.ts +5 -0
- package/src/utils/colorUtils.ts +133 -0
- package/src/utils/elementNames.ts +103 -0
- package/src/utils/elementUtils.ts +90 -0
- package/src/utils/errorTracker.ts +186 -0
- package/src/utils/inputStyles.ts +30 -0
- package/src/utils/styleUtils.ts +226 -0
- package/src/utils/tailwindMapper.ts +554 -0
- package/src/utils/urlTracker.ts +75 -0
- package/src/vite-env.d.ts +7 -0
- package/README.md +0 -866
- package/dist/hook.d.ts +0 -115
- package/dist/hook.d.ts.map +0 -1
- package/dist/hook.js +0 -288
- package/dist/plugin.d.ts +0 -44
- package/dist/plugin.d.ts.map +0 -1
- package/dist/types.d.ts +0 -139
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -7
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for real-time style preview on elements
|
|
3
|
+
* Simple approach: track changed properties, add incrementally, remove on reset
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { useCallback, useRef, useEffect } from "react";
|
|
7
|
+
import type { StyleChanges } from "@promakeai/inspector-types";
|
|
8
|
+
|
|
9
|
+
export function useStylePreview(element: HTMLElement | null) {
|
|
10
|
+
// Track which style properties have been changed
|
|
11
|
+
const changedPropertiesRef = useRef<Set<keyof StyleChanges>>(new Set());
|
|
12
|
+
|
|
13
|
+
// Clear tracking when element changes
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (element) {
|
|
16
|
+
changedPropertiesRef.current.clear();
|
|
17
|
+
}
|
|
18
|
+
}, [element]);
|
|
19
|
+
|
|
20
|
+
const previewStyle = useCallback(
|
|
21
|
+
(property: keyof StyleChanges, value: string) => {
|
|
22
|
+
if (!element) return;
|
|
23
|
+
|
|
24
|
+
// Add the property to changed set
|
|
25
|
+
changedPropertiesRef.current.add(property);
|
|
26
|
+
|
|
27
|
+
// Apply the single property directly to element.style with !important
|
|
28
|
+
switch (property) {
|
|
29
|
+
case "backgroundColor":
|
|
30
|
+
element.style.setProperty("background-color", value, "important");
|
|
31
|
+
break;
|
|
32
|
+
case "height":
|
|
33
|
+
element.style.setProperty("height", value, "important");
|
|
34
|
+
break;
|
|
35
|
+
case "width":
|
|
36
|
+
element.style.setProperty("width", value, "important");
|
|
37
|
+
break;
|
|
38
|
+
case "color":
|
|
39
|
+
element.style.setProperty("color", value, "important");
|
|
40
|
+
break;
|
|
41
|
+
case "fontSize":
|
|
42
|
+
element.style.setProperty("font-size", value, "important");
|
|
43
|
+
break;
|
|
44
|
+
case "fontWeight":
|
|
45
|
+
element.style.setProperty("font-weight", value, "important");
|
|
46
|
+
break;
|
|
47
|
+
case "fontFamily":
|
|
48
|
+
element.style.setProperty("font-family", value, "important");
|
|
49
|
+
break;
|
|
50
|
+
case "textAlign":
|
|
51
|
+
element.style.setProperty("text-align", value, "important");
|
|
52
|
+
break;
|
|
53
|
+
case "borderRadius":
|
|
54
|
+
element.style.setProperty("border-radius", value, "important");
|
|
55
|
+
break;
|
|
56
|
+
case "borderWidth":
|
|
57
|
+
element.style.setProperty("border-width", value, "important");
|
|
58
|
+
// Border needs style to be visible - set default if not present
|
|
59
|
+
if (!element.style.borderStyle) {
|
|
60
|
+
element.style.setProperty("border-style", "solid", "important");
|
|
61
|
+
changedPropertiesRef.current.add("borderStyle");
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
case "borderColor":
|
|
65
|
+
element.style.setProperty("border-color", value, "important");
|
|
66
|
+
// Border needs style and width to be visible
|
|
67
|
+
if (!element.style.borderStyle) {
|
|
68
|
+
element.style.setProperty("border-style", "solid", "important");
|
|
69
|
+
changedPropertiesRef.current.add("borderStyle");
|
|
70
|
+
}
|
|
71
|
+
if (!element.style.borderWidth) {
|
|
72
|
+
element.style.setProperty("border-width", "1px", "important");
|
|
73
|
+
changedPropertiesRef.current.add("borderWidth");
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case "borderStyle":
|
|
77
|
+
element.style.setProperty("border-style", value, "important");
|
|
78
|
+
break;
|
|
79
|
+
case "display":
|
|
80
|
+
element.style.setProperty("display", value, "important");
|
|
81
|
+
break;
|
|
82
|
+
case "opacity":
|
|
83
|
+
element.style.setProperty("opacity", value, "important");
|
|
84
|
+
break;
|
|
85
|
+
case "flex":
|
|
86
|
+
element.style.setProperty("flex", value, "important");
|
|
87
|
+
break;
|
|
88
|
+
case "flexDirection":
|
|
89
|
+
element.style.setProperty("flex-direction", value, "important");
|
|
90
|
+
break;
|
|
91
|
+
case "justifyContent":
|
|
92
|
+
element.style.setProperty("justify-content", value, "important");
|
|
93
|
+
break;
|
|
94
|
+
case "alignItems":
|
|
95
|
+
element.style.setProperty("align-items", value, "important");
|
|
96
|
+
break;
|
|
97
|
+
case "objectFit":
|
|
98
|
+
element.style.setProperty("object-fit", value, "important");
|
|
99
|
+
break;
|
|
100
|
+
case "textDecoration":
|
|
101
|
+
element.style.setProperty("text-decoration", value, "important");
|
|
102
|
+
break;
|
|
103
|
+
case "paddingVertical":
|
|
104
|
+
element.style.setProperty("padding-top", value, "important");
|
|
105
|
+
element.style.setProperty("padding-bottom", value, "important");
|
|
106
|
+
break;
|
|
107
|
+
case "paddingHorizontal":
|
|
108
|
+
element.style.setProperty("padding-left", value, "important");
|
|
109
|
+
element.style.setProperty("padding-right", value, "important");
|
|
110
|
+
break;
|
|
111
|
+
case "paddingTop":
|
|
112
|
+
element.style.setProperty("padding-top", value, "important");
|
|
113
|
+
break;
|
|
114
|
+
case "paddingRight":
|
|
115
|
+
element.style.setProperty("padding-right", value, "important");
|
|
116
|
+
break;
|
|
117
|
+
case "paddingBottom":
|
|
118
|
+
element.style.setProperty("padding-bottom", value, "important");
|
|
119
|
+
break;
|
|
120
|
+
case "paddingLeft":
|
|
121
|
+
element.style.setProperty("padding-left", value, "important");
|
|
122
|
+
break;
|
|
123
|
+
case "marginVertical":
|
|
124
|
+
element.style.setProperty("margin-top", value, "important");
|
|
125
|
+
element.style.setProperty("margin-bottom", value, "important");
|
|
126
|
+
break;
|
|
127
|
+
case "marginHorizontal":
|
|
128
|
+
element.style.setProperty("margin-left", value, "important");
|
|
129
|
+
element.style.setProperty("margin-right", value, "important");
|
|
130
|
+
break;
|
|
131
|
+
case "marginTop":
|
|
132
|
+
element.style.setProperty("margin-top", value, "important");
|
|
133
|
+
break;
|
|
134
|
+
case "marginRight":
|
|
135
|
+
element.style.setProperty("margin-right", value, "important");
|
|
136
|
+
break;
|
|
137
|
+
case "marginBottom":
|
|
138
|
+
element.style.setProperty("margin-bottom", value, "important");
|
|
139
|
+
break;
|
|
140
|
+
case "marginLeft":
|
|
141
|
+
element.style.setProperty("margin-left", value, "important");
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
[element]
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const resetStyles = useCallback(() => {
|
|
149
|
+
if (!element) return;
|
|
150
|
+
|
|
151
|
+
// Remove each changed property from element.style
|
|
152
|
+
changedPropertiesRef.current.forEach((property) => {
|
|
153
|
+
switch (property) {
|
|
154
|
+
case "backgroundColor":
|
|
155
|
+
element.style.removeProperty("background-color");
|
|
156
|
+
break;
|
|
157
|
+
case "height":
|
|
158
|
+
element.style.removeProperty("height");
|
|
159
|
+
break;
|
|
160
|
+
case "width":
|
|
161
|
+
element.style.removeProperty("width");
|
|
162
|
+
break;
|
|
163
|
+
case "color":
|
|
164
|
+
element.style.removeProperty("color");
|
|
165
|
+
break;
|
|
166
|
+
case "fontSize":
|
|
167
|
+
element.style.removeProperty("font-size");
|
|
168
|
+
break;
|
|
169
|
+
case "fontWeight":
|
|
170
|
+
element.style.removeProperty("font-weight");
|
|
171
|
+
break;
|
|
172
|
+
case "fontFamily":
|
|
173
|
+
element.style.removeProperty("font-family");
|
|
174
|
+
break;
|
|
175
|
+
case "textAlign":
|
|
176
|
+
element.style.removeProperty("text-align");
|
|
177
|
+
break;
|
|
178
|
+
case "borderRadius":
|
|
179
|
+
element.style.removeProperty("border-radius");
|
|
180
|
+
break;
|
|
181
|
+
case "borderWidth":
|
|
182
|
+
element.style.removeProperty("border-width");
|
|
183
|
+
break;
|
|
184
|
+
case "borderColor":
|
|
185
|
+
element.style.removeProperty("border-color");
|
|
186
|
+
break;
|
|
187
|
+
case "borderStyle":
|
|
188
|
+
element.style.removeProperty("border-style");
|
|
189
|
+
break;
|
|
190
|
+
case "paddingVertical":
|
|
191
|
+
element.style.removeProperty("padding-top");
|
|
192
|
+
element.style.removeProperty("padding-bottom");
|
|
193
|
+
break;
|
|
194
|
+
case "paddingHorizontal":
|
|
195
|
+
element.style.removeProperty("padding-left");
|
|
196
|
+
element.style.removeProperty("padding-right");
|
|
197
|
+
break;
|
|
198
|
+
case "marginVertical":
|
|
199
|
+
element.style.removeProperty("margin-top");
|
|
200
|
+
element.style.removeProperty("margin-bottom");
|
|
201
|
+
break;
|
|
202
|
+
case "marginHorizontal":
|
|
203
|
+
element.style.removeProperty("margin-left");
|
|
204
|
+
element.style.removeProperty("margin-right");
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Clear the tracking set
|
|
210
|
+
changedPropertiesRef.current.clear();
|
|
211
|
+
}, [element]);
|
|
212
|
+
|
|
213
|
+
const resetSingleProperty = useCallback(
|
|
214
|
+
(property: keyof StyleChanges) => {
|
|
215
|
+
if (!element) return;
|
|
216
|
+
|
|
217
|
+
// Remove the specific property from element.style
|
|
218
|
+
switch (property) {
|
|
219
|
+
case "backgroundColor":
|
|
220
|
+
element.style.removeProperty("background-color");
|
|
221
|
+
break;
|
|
222
|
+
case "height":
|
|
223
|
+
element.style.removeProperty("height");
|
|
224
|
+
break;
|
|
225
|
+
case "width":
|
|
226
|
+
element.style.removeProperty("width");
|
|
227
|
+
break;
|
|
228
|
+
case "color":
|
|
229
|
+
element.style.removeProperty("color");
|
|
230
|
+
break;
|
|
231
|
+
case "fontSize":
|
|
232
|
+
element.style.removeProperty("font-size");
|
|
233
|
+
break;
|
|
234
|
+
case "fontWeight":
|
|
235
|
+
element.style.removeProperty("font-weight");
|
|
236
|
+
break;
|
|
237
|
+
case "fontFamily":
|
|
238
|
+
element.style.removeProperty("font-family");
|
|
239
|
+
break;
|
|
240
|
+
case "textAlign":
|
|
241
|
+
element.style.removeProperty("text-align");
|
|
242
|
+
break;
|
|
243
|
+
case "borderRadius":
|
|
244
|
+
element.style.removeProperty("border-radius");
|
|
245
|
+
break;
|
|
246
|
+
case "borderWidth":
|
|
247
|
+
element.style.removeProperty("border-width");
|
|
248
|
+
break;
|
|
249
|
+
case "borderColor":
|
|
250
|
+
element.style.removeProperty("border-color");
|
|
251
|
+
break;
|
|
252
|
+
case "borderStyle":
|
|
253
|
+
element.style.removeProperty("border-style");
|
|
254
|
+
break;
|
|
255
|
+
case "display":
|
|
256
|
+
element.style.removeProperty("display");
|
|
257
|
+
break;
|
|
258
|
+
case "opacity":
|
|
259
|
+
element.style.removeProperty("opacity");
|
|
260
|
+
break;
|
|
261
|
+
case "flex":
|
|
262
|
+
element.style.removeProperty("flex");
|
|
263
|
+
break;
|
|
264
|
+
case "flexDirection":
|
|
265
|
+
element.style.removeProperty("flex-direction");
|
|
266
|
+
break;
|
|
267
|
+
case "justifyContent":
|
|
268
|
+
element.style.removeProperty("justify-content");
|
|
269
|
+
break;
|
|
270
|
+
case "alignItems":
|
|
271
|
+
element.style.removeProperty("align-items");
|
|
272
|
+
break;
|
|
273
|
+
case "objectFit":
|
|
274
|
+
element.style.removeProperty("object-fit");
|
|
275
|
+
break;
|
|
276
|
+
case "textDecoration":
|
|
277
|
+
element.style.removeProperty("text-decoration");
|
|
278
|
+
break;
|
|
279
|
+
case "paddingVertical":
|
|
280
|
+
element.style.removeProperty("padding-top");
|
|
281
|
+
element.style.removeProperty("padding-bottom");
|
|
282
|
+
break;
|
|
283
|
+
case "paddingHorizontal":
|
|
284
|
+
element.style.removeProperty("padding-left");
|
|
285
|
+
element.style.removeProperty("padding-right");
|
|
286
|
+
break;
|
|
287
|
+
case "paddingTop":
|
|
288
|
+
element.style.removeProperty("padding-top");
|
|
289
|
+
break;
|
|
290
|
+
case "paddingRight":
|
|
291
|
+
element.style.removeProperty("padding-right");
|
|
292
|
+
break;
|
|
293
|
+
case "paddingBottom":
|
|
294
|
+
element.style.removeProperty("padding-bottom");
|
|
295
|
+
break;
|
|
296
|
+
case "paddingLeft":
|
|
297
|
+
element.style.removeProperty("padding-left");
|
|
298
|
+
break;
|
|
299
|
+
case "marginVertical":
|
|
300
|
+
element.style.removeProperty("margin-top");
|
|
301
|
+
element.style.removeProperty("margin-bottom");
|
|
302
|
+
break;
|
|
303
|
+
case "marginHorizontal":
|
|
304
|
+
element.style.removeProperty("margin-left");
|
|
305
|
+
element.style.removeProperty("margin-right");
|
|
306
|
+
break;
|
|
307
|
+
case "marginTop":
|
|
308
|
+
element.style.removeProperty("margin-top");
|
|
309
|
+
break;
|
|
310
|
+
case "marginRight":
|
|
311
|
+
element.style.removeProperty("margin-right");
|
|
312
|
+
break;
|
|
313
|
+
case "marginBottom":
|
|
314
|
+
element.style.removeProperty("margin-bottom");
|
|
315
|
+
break;
|
|
316
|
+
case "marginLeft":
|
|
317
|
+
element.style.removeProperty("margin-left");
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// Remove from tracking set
|
|
322
|
+
changedPropertiesRef.current.delete(property);
|
|
323
|
+
},
|
|
324
|
+
[element]
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
return {
|
|
328
|
+
previewStyle,
|
|
329
|
+
resetStyles,
|
|
330
|
+
resetSingleProperty,
|
|
331
|
+
};
|
|
332
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @promakeai/inspector - React Component Package
|
|
3
|
+
*
|
|
4
|
+
* Visual element inspector component for React apps with AI prompt support.
|
|
5
|
+
* This is now a React component (not a Vite plugin).
|
|
6
|
+
*
|
|
7
|
+
* IMPORTANT: Import the CSS file separately:
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { Inspector } from "@promakeai/inspector";
|
|
10
|
+
* import "@promakeai/inspector/style.css"; // Required!
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Import CSS to be bundled
|
|
15
|
+
import "./styles/global.css";
|
|
16
|
+
|
|
17
|
+
export { App as Inspector, App } from "./App";
|
|
18
|
+
|
|
19
|
+
// Re-export all types from types package
|
|
20
|
+
export type * from "@promakeai/inspector-types";
|
package/src/lib/utils.ts
ADDED
package/src/plugin.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import componentDebugger, { TagOptions } from "vite-plugin-component-debugger";
|
|
2
|
+
import type { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
export const inspectorDebugger = (options: TagOptions = {}): Plugin<any> => {
|
|
5
|
+
return componentDebugger({
|
|
6
|
+
enabled: true,
|
|
7
|
+
attributePrefix: "data-dev",
|
|
8
|
+
extensions: [".jsx", ".tsx"],
|
|
9
|
+
...options,
|
|
10
|
+
}) as Plugin<any>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zustand store for Inspector global state
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { create } from "zustand";
|
|
6
|
+
import type {
|
|
7
|
+
InspectorTheme,
|
|
8
|
+
InspectorLabels,
|
|
9
|
+
} from "@promakeai/inspector-types";
|
|
10
|
+
|
|
11
|
+
interface InspectorStore {
|
|
12
|
+
theme: Required<InspectorTheme>;
|
|
13
|
+
labels: Required<InspectorLabels>;
|
|
14
|
+
setTheme: (theme: Partial<InspectorTheme>) => void;
|
|
15
|
+
setLabels: (labels: Partial<InspectorLabels>) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const defaultTheme: Required<InspectorTheme> = {
|
|
19
|
+
backgroundColor: "#ffffff",
|
|
20
|
+
textColor: "#0f172a",
|
|
21
|
+
secondaryTextColor: "#64748b",
|
|
22
|
+
buttonColor: "rgb(58, 18, 189)", // Darker purple
|
|
23
|
+
buttonTextColor: "#ffffff",
|
|
24
|
+
buttonHoverColor: "rgb(78, 38, 209)", // Slightly lighter for hover
|
|
25
|
+
secondaryButtonColor: "#f1f5f9",
|
|
26
|
+
secondaryButtonTextColor: "#475569",
|
|
27
|
+
secondaryButtonHoverColor: "#e2e8f0",
|
|
28
|
+
dangerButtonColor: "#ef4444",
|
|
29
|
+
dangerButtonTextColor: "#ffffff",
|
|
30
|
+
inputBackgroundColor: "#ffffff",
|
|
31
|
+
inputTextColor: "#0f172a",
|
|
32
|
+
inputBorderColor: "#e2e8f0",
|
|
33
|
+
inputFocusBorderColor: "rgb(58, 18, 189)", // Darker purple
|
|
34
|
+
inputPlaceholderColor: "#94a3b8",
|
|
35
|
+
borderColor: "#e2e8f0",
|
|
36
|
+
warningColor: "#f59e0b",
|
|
37
|
+
successColor: "#10b981",
|
|
38
|
+
errorColor: "#ef4444",
|
|
39
|
+
tabContainerBg: "#f8fafc",
|
|
40
|
+
tabActiveBg: "rgb(58, 18, 189)", // Darker purple
|
|
41
|
+
tabInactiveBg: "transparent",
|
|
42
|
+
tabActiveColor: "#ffffff",
|
|
43
|
+
tabInactiveColor: "#64748b",
|
|
44
|
+
badgeGradientStart: "rgb(58, 18, 189)", // Darker purple
|
|
45
|
+
badgeGradientEnd: "#ec4899",
|
|
46
|
+
badgeTextColor: "#ffffff",
|
|
47
|
+
overlayColor: "rgb(58, 18, 189)", // Darker purple
|
|
48
|
+
overlayOpacity: 0.15,
|
|
49
|
+
dialogBackdropColor: "rgba(15, 23, 42, 0.4)",
|
|
50
|
+
dialogBackgroundColor: "#ffffff",
|
|
51
|
+
dialogTextColor: "#0f172a",
|
|
52
|
+
dialogSecondaryTextColor: "#64748b",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const defaultLabels: Required<InspectorLabels> = {
|
|
56
|
+
// Text Editor
|
|
57
|
+
editText: "Edit Content",
|
|
58
|
+
textContentLabel: "Text Content",
|
|
59
|
+
textPlaceholder: "Enter content...",
|
|
60
|
+
linkUrlLabel: "Link URL (href)",
|
|
61
|
+
updateText: "Update",
|
|
62
|
+
|
|
63
|
+
// Image Editor
|
|
64
|
+
editImage: "Change Image",
|
|
65
|
+
imageUploadTitle: "Select Image",
|
|
66
|
+
imageUploadHint: "Click or drag",
|
|
67
|
+
updateImage: "Update",
|
|
68
|
+
|
|
69
|
+
// Prompt Input
|
|
70
|
+
promptPlaceholder: "Ask AI...",
|
|
71
|
+
|
|
72
|
+
// Style Editor
|
|
73
|
+
styleEditorTitle: "Style Editor",
|
|
74
|
+
layoutSectionTitle: "Layout",
|
|
75
|
+
displaySectionTitle: "Display",
|
|
76
|
+
imageSectionTitle: "Image",
|
|
77
|
+
textSectionTitle: "Text",
|
|
78
|
+
borderSectionTitle: "Border",
|
|
79
|
+
spacingSectionTitle: "Spacing",
|
|
80
|
+
|
|
81
|
+
// Style Properties
|
|
82
|
+
backgroundColorLabel: "Background Color",
|
|
83
|
+
heightLabel: "Height",
|
|
84
|
+
widthLabel: "Width",
|
|
85
|
+
displayLabel: "Display",
|
|
86
|
+
opacityLabel: "Opacity",
|
|
87
|
+
flexLabel: "Flex",
|
|
88
|
+
flexDirectionLabel: "Flex Direction",
|
|
89
|
+
justifyContentLabel: "Justify Content",
|
|
90
|
+
alignItemsLabel: "Align Items",
|
|
91
|
+
objectFitLabel: "Object Fit",
|
|
92
|
+
colorLabel: "Color",
|
|
93
|
+
fontSizeLabel: "Font Size",
|
|
94
|
+
fontWeightLabel: "Font Weight",
|
|
95
|
+
fontFamilyLabel: "Font Family",
|
|
96
|
+
textAlignLabel: "Text Align",
|
|
97
|
+
textDecorationLabel: "Text Decoration",
|
|
98
|
+
borderRadiusLabel: "Border Radius",
|
|
99
|
+
borderWidthLabel: "Border Width",
|
|
100
|
+
borderColorLabel: "Border Color",
|
|
101
|
+
borderStyleLabel: "Border Style",
|
|
102
|
+
paddingLabel: "Padding",
|
|
103
|
+
paddingVerticalLabel: "Vertical",
|
|
104
|
+
paddingHorizontalLabel: "Horizontal",
|
|
105
|
+
marginLabel: "Margin",
|
|
106
|
+
marginVerticalLabel: "Vertical",
|
|
107
|
+
marginHorizontalLabel: "Horizontal",
|
|
108
|
+
|
|
109
|
+
// Element name labels
|
|
110
|
+
elementContainer: "Container",
|
|
111
|
+
elementText: "Text",
|
|
112
|
+
elementImage: "Image",
|
|
113
|
+
elementButton: "Button",
|
|
114
|
+
elementLink: "Link",
|
|
115
|
+
elementInput: "Input",
|
|
116
|
+
elementTextArea: "TextArea",
|
|
117
|
+
elementHeading: "Heading",
|
|
118
|
+
elementParagraph: "Paragraph",
|
|
119
|
+
elementSection: "Section",
|
|
120
|
+
elementDefault: "Element",
|
|
121
|
+
|
|
122
|
+
// Display Dropdown Options
|
|
123
|
+
displayBlock: "Block",
|
|
124
|
+
displayInline: "Inline",
|
|
125
|
+
displayInlineBlock: "Inline Block",
|
|
126
|
+
displayFlex: "Flex",
|
|
127
|
+
displayGrid: "Grid",
|
|
128
|
+
displayNone: "None",
|
|
129
|
+
|
|
130
|
+
// Flex Direction Dropdown Options
|
|
131
|
+
flexDirectionRow: "Row",
|
|
132
|
+
flexDirectionRowReverse: "Row Reverse",
|
|
133
|
+
flexDirectionColumn: "Column",
|
|
134
|
+
flexDirectionColumnReverse: "Column Reverse",
|
|
135
|
+
|
|
136
|
+
// Justify Content Dropdown Options
|
|
137
|
+
justifyContentFlexStart: "Flex Start",
|
|
138
|
+
justifyContentCenter: "Center",
|
|
139
|
+
justifyContentFlexEnd: "Flex End",
|
|
140
|
+
justifyContentSpaceBetween: "Space Between",
|
|
141
|
+
justifyContentSpaceAround: "Space Around",
|
|
142
|
+
justifyContentSpaceEvenly: "Space Evenly",
|
|
143
|
+
|
|
144
|
+
// Align Items Dropdown Options
|
|
145
|
+
alignItemsFlexStart: "Flex Start",
|
|
146
|
+
alignItemsCenter: "Center",
|
|
147
|
+
alignItemsFlexEnd: "Flex End",
|
|
148
|
+
alignItemsStretch: "Stretch",
|
|
149
|
+
alignItemsBaseline: "Baseline",
|
|
150
|
+
|
|
151
|
+
// Font Size Dropdown Options
|
|
152
|
+
fontSizeXS: "XS",
|
|
153
|
+
fontSizeSM: "SM",
|
|
154
|
+
fontSizeBase: "Base",
|
|
155
|
+
fontSizeLG: "LG",
|
|
156
|
+
fontSizeXL: "XL",
|
|
157
|
+
fontSize2XL: "2XL",
|
|
158
|
+
fontSize3XL: "3XL",
|
|
159
|
+
fontSize4XL: "4XL",
|
|
160
|
+
fontSize5XL: "5XL",
|
|
161
|
+
|
|
162
|
+
// Font Weight Dropdown Options
|
|
163
|
+
fontWeightThin: "Thin",
|
|
164
|
+
fontWeightExtralight: "Extralight",
|
|
165
|
+
fontWeightNormal: "Normal",
|
|
166
|
+
fontWeightMedium: "Medium",
|
|
167
|
+
fontWeightSemibold: "Semibold",
|
|
168
|
+
fontWeightBold: "Bold",
|
|
169
|
+
fontWeightExtrabold: "Extrabold",
|
|
170
|
+
fontWeightBlack: "Black",
|
|
171
|
+
|
|
172
|
+
// Text Decoration Dropdown Options
|
|
173
|
+
textDecorationNone: "None",
|
|
174
|
+
textDecorationUnderline: "Underline",
|
|
175
|
+
textDecorationLineThrough: "Line Through",
|
|
176
|
+
textDecorationOverline: "Overline",
|
|
177
|
+
|
|
178
|
+
// Border Style Dropdown Options
|
|
179
|
+
borderStyleSolid: "Solid",
|
|
180
|
+
borderStyleDashed: "Dashed",
|
|
181
|
+
borderStyleDotted: "Dotted",
|
|
182
|
+
borderStyleDouble: "Double",
|
|
183
|
+
borderStyleGroove: "Groove",
|
|
184
|
+
borderStyleRidge: "Ridge",
|
|
185
|
+
borderStyleInset: "Inset",
|
|
186
|
+
borderStyleOutset: "Outset",
|
|
187
|
+
borderStyleNone: "None",
|
|
188
|
+
|
|
189
|
+
// Object Fit Dropdown Options
|
|
190
|
+
objectFitContain: "Contain",
|
|
191
|
+
objectFitCover: "Cover",
|
|
192
|
+
objectFitFill: "Fill",
|
|
193
|
+
objectFitNone: "None",
|
|
194
|
+
objectFitScaleDown: "Scale Down",
|
|
195
|
+
|
|
196
|
+
// Action Buttons
|
|
197
|
+
saveButton: "Save",
|
|
198
|
+
resetButton: "Reset",
|
|
199
|
+
cancelButton: "Cancel",
|
|
200
|
+
|
|
201
|
+
// Status Messages
|
|
202
|
+
unsavedChangesText: "Unsaved Changes",
|
|
203
|
+
savingText: "Saving...",
|
|
204
|
+
hintText: "Changes preview in real-time",
|
|
205
|
+
|
|
206
|
+
// Unsaved Changes Dialog
|
|
207
|
+
unsavedDialogTitle: "Unsaved Changes",
|
|
208
|
+
unsavedDialogMessage:
|
|
209
|
+
"You have unsaved style changes. What would you like to do?",
|
|
210
|
+
saveChangesButton: "Save",
|
|
211
|
+
discardChangesButton: "Discard",
|
|
212
|
+
continueEditingButton: "Continue",
|
|
213
|
+
|
|
214
|
+
// Tab Names
|
|
215
|
+
textTabLabel: "Content",
|
|
216
|
+
imageTabLabel: "Image",
|
|
217
|
+
styleTabLabel: "Design",
|
|
218
|
+
|
|
219
|
+
// Badge
|
|
220
|
+
badgeText: "Built by Promake",
|
|
221
|
+
badgeUrl: "https://promake.ai",
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export const useInspectorStore = create<InspectorStore>((set) => ({
|
|
225
|
+
theme: defaultTheme,
|
|
226
|
+
labels: defaultLabels,
|
|
227
|
+
setTheme: (theme) =>
|
|
228
|
+
set((state) => ({
|
|
229
|
+
theme: { ...state.theme, ...theme },
|
|
230
|
+
})),
|
|
231
|
+
setLabels: (labels) =>
|
|
232
|
+
set((state) => ({
|
|
233
|
+
labels: { ...state.labels, ...labels },
|
|
234
|
+
})),
|
|
235
|
+
}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Satoshi Font Family
|
|
3
|
+
* Only essential weights for Inspector
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* Variable font - supports all weights (400-700) */
|
|
7
|
+
@font-face {
|
|
8
|
+
font-family: 'Satoshi';
|
|
9
|
+
src: url('../assets/fonts/Satoshi-Variable.woff2') format('woff2'),
|
|
10
|
+
url('../assets/fonts/Satoshi-Variable.woff') format('woff');
|
|
11
|
+
font-weight: 400 700;
|
|
12
|
+
font-display: swap;
|
|
13
|
+
font-style: normal;
|
|
14
|
+
}
|
|
15
|
+
|