goodchuck-utils 1.5.0 → 1.7.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/components/dev/ApiLogger.d.ts +136 -0
- package/dist/components/dev/ApiLogger.d.ts.map +1 -0
- package/dist/components/dev/ApiLogger.js +408 -0
- package/dist/components/dev/DevPanel.d.ts +32 -0
- package/dist/components/dev/DevPanel.d.ts.map +1 -0
- package/dist/components/dev/DevPanel.js +196 -0
- package/dist/components/dev/FormDevTools/FormDevTools.d.ts +75 -0
- package/dist/components/dev/FormDevTools/FormDevTools.d.ts.map +1 -0
- package/dist/components/dev/FormDevTools/FormDevTools.js +196 -0
- package/dist/components/dev/FormDevTools/index.d.ts +3 -0
- package/dist/components/dev/FormDevTools/index.d.ts.map +1 -0
- package/dist/components/dev/FormDevTools/index.js +1 -0
- package/dist/components/dev/FormDevTools/styles.d.ts +43 -0
- package/dist/components/dev/FormDevTools/styles.d.ts.map +1 -0
- package/dist/components/dev/FormDevTools/styles.js +176 -0
- package/dist/components/dev/IdSelector.d.ts +10 -1
- package/dist/components/dev/IdSelector.d.ts.map +1 -1
- package/dist/components/dev/IdSelector.js +89 -12
- package/dist/components/dev/WindowSizeDisplay.d.ts +44 -0
- package/dist/components/dev/WindowSizeDisplay.d.ts.map +1 -0
- package/dist/components/dev/WindowSizeDisplay.js +74 -0
- package/dist/components/dev/ZIndexDebugger.d.ts +32 -0
- package/dist/components/dev/ZIndexDebugger.d.ts.map +1 -0
- package/dist/components/dev/ZIndexDebugger.js +184 -0
- package/dist/components/dev/index.d.ts +7 -0
- package/dist/components/dev/index.d.ts.map +1 -1
- package/dist/components/dev/index.js +5 -0
- package/package.json +4 -2
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* z-index 값을 시각화하는 개발용 컴포넌트
|
|
4
|
+
* 페이지의 모든 요소의 z-index를 하이라이트하고 목록으로 표시합니다.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // Vite 프로젝트
|
|
9
|
+
* import { ZIndexDebugger } from 'goodchuck-utils/components/dev';
|
|
10
|
+
*
|
|
11
|
+
* function App() {
|
|
12
|
+
* return (
|
|
13
|
+
* <div>
|
|
14
|
+
* {import.meta.env.DEV && <ZIndexDebugger />}
|
|
15
|
+
* </div>
|
|
16
|
+
* );
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* // Create React App 프로젝트
|
|
23
|
+
* {process.env.NODE_ENV === 'development' && <ZIndexDebugger position="top-right" />}
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export default function ZIndexDebugger({ position = 'bottom-left' }) {
|
|
27
|
+
const [isActive, setIsActive] = useState(false);
|
|
28
|
+
const [elements, setElements] = useState([]);
|
|
29
|
+
const [hoveredElement, setHoveredElement] = useState(null);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (!isActive) {
|
|
32
|
+
setElements([]);
|
|
33
|
+
setHoveredElement(null);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const scanElements = () => {
|
|
37
|
+
const allElements = document.querySelectorAll('*');
|
|
38
|
+
const elementsWithZIndex = [];
|
|
39
|
+
allElements.forEach((el) => {
|
|
40
|
+
if (!(el instanceof HTMLElement))
|
|
41
|
+
return;
|
|
42
|
+
const computedStyle = window.getComputedStyle(el);
|
|
43
|
+
const zIndex = computedStyle.zIndex;
|
|
44
|
+
// z-index가 설정된 요소만 수집 (auto가 아닌 경우)
|
|
45
|
+
if (zIndex !== 'auto' && zIndex !== '0') {
|
|
46
|
+
elementsWithZIndex.push({
|
|
47
|
+
element: el,
|
|
48
|
+
zIndex,
|
|
49
|
+
tagName: el.tagName.toLowerCase(),
|
|
50
|
+
id: el.id || undefined,
|
|
51
|
+
className: el.className || undefined,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// z-index 값으로 정렬 (높은 순)
|
|
56
|
+
elementsWithZIndex.sort((a, b) => {
|
|
57
|
+
const zA = parseInt(a.zIndex) || 0;
|
|
58
|
+
const zB = parseInt(b.zIndex) || 0;
|
|
59
|
+
return zB - zA;
|
|
60
|
+
});
|
|
61
|
+
setElements(elementsWithZIndex);
|
|
62
|
+
};
|
|
63
|
+
scanElements();
|
|
64
|
+
// DOM 변경 감지
|
|
65
|
+
const observer = new MutationObserver(scanElements);
|
|
66
|
+
observer.observe(document.body, {
|
|
67
|
+
childList: true,
|
|
68
|
+
subtree: true,
|
|
69
|
+
attributes: true,
|
|
70
|
+
attributeFilter: ['style', 'class'],
|
|
71
|
+
});
|
|
72
|
+
return () => observer.disconnect();
|
|
73
|
+
}, [isActive]);
|
|
74
|
+
// 호버된 요소 하이라이트
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (!hoveredElement)
|
|
77
|
+
return;
|
|
78
|
+
const originalOutline = hoveredElement.style.outline;
|
|
79
|
+
const originalOutlineOffset = hoveredElement.style.outlineOffset;
|
|
80
|
+
hoveredElement.style.outline = '3px solid #f59e0b';
|
|
81
|
+
hoveredElement.style.outlineOffset = '2px';
|
|
82
|
+
return () => {
|
|
83
|
+
hoveredElement.style.outline = originalOutline;
|
|
84
|
+
hoveredElement.style.outlineOffset = originalOutlineOffset;
|
|
85
|
+
};
|
|
86
|
+
}, [hoveredElement]);
|
|
87
|
+
const positionStyles = {
|
|
88
|
+
'top-left': { top: 16, left: 16 },
|
|
89
|
+
'top-right': { top: 16, right: 16 },
|
|
90
|
+
'bottom-left': { bottom: 16, left: 16 },
|
|
91
|
+
'bottom-right': { bottom: 16, right: 16 },
|
|
92
|
+
};
|
|
93
|
+
const containerStyle = {
|
|
94
|
+
position: 'fixed',
|
|
95
|
+
...positionStyles[position],
|
|
96
|
+
zIndex: 999999,
|
|
97
|
+
fontFamily: 'system-ui, -apple-system, sans-serif',
|
|
98
|
+
};
|
|
99
|
+
const buttonStyle = {
|
|
100
|
+
padding: '8px 16px',
|
|
101
|
+
backgroundColor: isActive ? '#ef4444' : '#3b82f6',
|
|
102
|
+
color: 'white',
|
|
103
|
+
border: 'none',
|
|
104
|
+
borderRadius: '8px',
|
|
105
|
+
cursor: 'pointer',
|
|
106
|
+
fontSize: '13px',
|
|
107
|
+
fontWeight: 600,
|
|
108
|
+
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
109
|
+
transition: 'background-color 0.2s',
|
|
110
|
+
};
|
|
111
|
+
const panelStyle = {
|
|
112
|
+
marginTop: '8px',
|
|
113
|
+
backgroundColor: 'white',
|
|
114
|
+
borderRadius: '12px',
|
|
115
|
+
boxShadow: '0 10px 25px rgba(0, 0, 0, 0.15)',
|
|
116
|
+
border: '1px solid #e5e7eb',
|
|
117
|
+
width: '320px',
|
|
118
|
+
maxHeight: '400px',
|
|
119
|
+
overflow: 'hidden',
|
|
120
|
+
display: 'flex',
|
|
121
|
+
flexDirection: 'column',
|
|
122
|
+
};
|
|
123
|
+
const headerStyle = {
|
|
124
|
+
padding: '12px 16px',
|
|
125
|
+
borderBottom: '1px solid #e5e7eb',
|
|
126
|
+
fontWeight: 'bold',
|
|
127
|
+
fontSize: '14px',
|
|
128
|
+
color: '#111827',
|
|
129
|
+
backgroundColor: '#f9fafb',
|
|
130
|
+
};
|
|
131
|
+
const listContainerStyle = {
|
|
132
|
+
overflowY: 'auto',
|
|
133
|
+
maxHeight: '350px',
|
|
134
|
+
};
|
|
135
|
+
const itemStyle = (isHovered) => ({
|
|
136
|
+
padding: '10px 16px',
|
|
137
|
+
borderBottom: '1px solid #f3f4f6',
|
|
138
|
+
cursor: 'pointer',
|
|
139
|
+
backgroundColor: isHovered ? '#fef3c7' : 'white',
|
|
140
|
+
transition: 'background-color 0.15s',
|
|
141
|
+
});
|
|
142
|
+
const zIndexBadgeStyle = {
|
|
143
|
+
display: 'inline-block',
|
|
144
|
+
padding: '2px 8px',
|
|
145
|
+
backgroundColor: '#dbeafe',
|
|
146
|
+
color: '#1e40af',
|
|
147
|
+
borderRadius: '6px',
|
|
148
|
+
fontSize: '12px',
|
|
149
|
+
fontWeight: 'bold',
|
|
150
|
+
fontFamily: 'monospace',
|
|
151
|
+
marginRight: '8px',
|
|
152
|
+
};
|
|
153
|
+
const tagStyle = {
|
|
154
|
+
fontSize: '12px',
|
|
155
|
+
color: '#6b7280',
|
|
156
|
+
fontFamily: 'monospace',
|
|
157
|
+
};
|
|
158
|
+
const getElementLabel = (info) => {
|
|
159
|
+
let label = info.tagName;
|
|
160
|
+
if (info.id)
|
|
161
|
+
label += `#${info.id}`;
|
|
162
|
+
if (info.className && typeof info.className === 'string') {
|
|
163
|
+
const classes = info.className.split(' ').filter(Boolean).slice(0, 2);
|
|
164
|
+
if (classes.length > 0) {
|
|
165
|
+
label += `.${classes.join('.')}`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return label.length > 40 ? label.slice(0, 40) + '...' : label;
|
|
169
|
+
};
|
|
170
|
+
const handleElementClick = (element) => {
|
|
171
|
+
element.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
172
|
+
};
|
|
173
|
+
return (React.createElement("div", { style: containerStyle },
|
|
174
|
+
React.createElement("button", { onClick: () => setIsActive(!isActive), style: buttonStyle, onMouseEnter: (e) => (e.currentTarget.style.backgroundColor = isActive ? '#dc2626' : '#2563eb'), onMouseLeave: (e) => (e.currentTarget.style.backgroundColor = isActive ? '#ef4444' : '#3b82f6') }, isActive ? '🔴 Z-Index 디버거 종료' : '🔍 Z-Index 디버거'),
|
|
175
|
+
isActive && (React.createElement("div", { style: panelStyle },
|
|
176
|
+
React.createElement("div", { style: headerStyle },
|
|
177
|
+
"\uD83D\uDCCA Z-Index \uBAA9\uB85D (",
|
|
178
|
+
elements.length,
|
|
179
|
+
"\uAC1C)"),
|
|
180
|
+
React.createElement("div", { style: listContainerStyle }, elements.length === 0 ? (React.createElement("div", { style: { padding: '20px', textAlign: 'center', color: '#9ca3af', fontSize: '13px' } }, "z-index\uAC00 \uC124\uC815\uB41C \uC694\uC18C\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.")) : (elements.map((info, index) => (React.createElement("div", { key: index, style: itemStyle(hoveredElement === info.element), onMouseEnter: () => setHoveredElement(info.element), onMouseLeave: () => setHoveredElement(null), onClick: () => handleElementClick(info.element) },
|
|
181
|
+
React.createElement("div", null,
|
|
182
|
+
React.createElement("span", { style: zIndexBadgeStyle }, info.zIndex),
|
|
183
|
+
React.createElement("span", { style: tagStyle }, getElementLabel(info))))))))))));
|
|
184
|
+
}
|
|
@@ -5,4 +5,11 @@
|
|
|
5
5
|
* production 환경에서는 제외하는 것을 권장합니다.
|
|
6
6
|
*/
|
|
7
7
|
export { default as IdSelector } from './IdSelector';
|
|
8
|
+
export { default as WindowSizeDisplay } from './WindowSizeDisplay';
|
|
9
|
+
export { default as DevPanel } from './DevPanel';
|
|
10
|
+
export { default as ZIndexDebugger } from './ZIndexDebugger';
|
|
11
|
+
export { default as ApiLogger, addApiLog, clearApiLogs } from './ApiLogger';
|
|
12
|
+
export { default as FormDevTools } from './FormDevTools';
|
|
13
|
+
export type { FormDevToolsProps, FormState as FormDevToolsFormState } from './FormDevTools';
|
|
14
|
+
export type { ApiLogEntry } from './ApiLogger';
|
|
8
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dev/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/dev/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,SAAS,IAAI,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAC5F,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -5,3 +5,8 @@
|
|
|
5
5
|
* production 환경에서는 제외하는 것을 권장합니다.
|
|
6
6
|
*/
|
|
7
7
|
export { default as IdSelector } from './IdSelector';
|
|
8
|
+
export { default as WindowSizeDisplay } from './WindowSizeDisplay';
|
|
9
|
+
export { default as DevPanel } from './DevPanel';
|
|
10
|
+
export { default as ZIndexDebugger } from './ZIndexDebugger';
|
|
11
|
+
export { default as ApiLogger, addApiLog, clearApiLogs } from './ApiLogger';
|
|
12
|
+
export { default as FormDevTools } from './FormDevTools';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goodchuck-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prepare": "npm run build:tsc",
|
|
12
|
-
"prepublishOnly": "npm run test:run && npm run build:tsc",
|
|
12
|
+
"prepublishOnly": "npm run test:run && npm run clean && npm run build:tsc",
|
|
13
13
|
"build": "npm run build",
|
|
14
14
|
"build:tsc": "tsc",
|
|
15
|
+
"clean": "rm -rf dist",
|
|
16
|
+
"dev": "tsc --watch",
|
|
15
17
|
"test": "vitest",
|
|
16
18
|
"test:ui": "vitest --ui",
|
|
17
19
|
"test:run": "vitest run",
|