@blastlabs/utils 1.22.0 → 2.1.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.
Files changed (42) hide show
  1. package/README.md +102 -8
  2. package/dist/components/dev/DevPanel.d.ts +16 -11
  3. package/dist/components/dev/DevPanel.d.ts.map +1 -1
  4. package/dist/components/dev/DevPanel.js +71 -77
  5. package/dist/components/dev/DevPanel.test.d.ts +2 -0
  6. package/dist/components/dev/DevPanel.test.d.ts.map +1 -0
  7. package/dist/components/dev/DevPanel.test.js +194 -0
  8. package/dist/components/dev/DevToolsProvider/DevToolsProvider.d.ts +97 -0
  9. package/dist/components/dev/DevToolsProvider/DevToolsProvider.d.ts.map +1 -0
  10. package/dist/components/dev/DevToolsProvider/DevToolsProvider.js +122 -0
  11. package/dist/components/dev/DevToolsProvider/DevToolsProvider.test.d.ts +2 -0
  12. package/dist/components/dev/DevToolsProvider/DevToolsProvider.test.d.ts.map +1 -0
  13. package/dist/components/dev/DevToolsProvider/DevToolsProvider.test.js +104 -0
  14. package/dist/components/dev/DevToolsProvider/index.d.ts +3 -0
  15. package/dist/components/dev/DevToolsProvider/index.d.ts.map +1 -0
  16. package/dist/components/dev/DevToolsProvider/index.js +1 -0
  17. package/dist/components/dev/FormDevTools/FormDevTools.d.ts +5 -70
  18. package/dist/components/dev/FormDevTools/FormDevTools.d.ts.map +1 -1
  19. package/dist/components/dev/FormDevTools/FormDevTools.js +163 -236
  20. package/dist/components/dev/FormDevTools/FormDevToolsContent.d.ts +27 -0
  21. package/dist/components/dev/FormDevTools/FormDevToolsContent.d.ts.map +1 -0
  22. package/dist/components/dev/FormDevTools/FormDevToolsContent.js +298 -0
  23. package/dist/components/dev/TimezoneDevTools/TimezoneDevTools.d.ts +29 -0
  24. package/dist/components/dev/TimezoneDevTools/TimezoneDevTools.d.ts.map +1 -0
  25. package/dist/components/dev/TimezoneDevTools/TimezoneDevTools.js +122 -0
  26. package/dist/components/dev/TimezoneDevTools/TimezoneDevToolsContent.d.ts +4 -0
  27. package/dist/components/dev/TimezoneDevTools/TimezoneDevToolsContent.d.ts.map +1 -0
  28. package/dist/components/dev/TimezoneDevTools/TimezoneDevToolsContent.js +121 -0
  29. package/dist/components/dev/TimezoneDevTools/index.d.ts +3 -0
  30. package/dist/components/dev/TimezoneDevTools/index.d.ts.map +1 -0
  31. package/dist/components/dev/TimezoneDevTools/index.js +1 -0
  32. package/dist/components/dev/TimezoneDevTools/styles.d.ts +12 -0
  33. package/dist/components/dev/TimezoneDevTools/styles.d.ts.map +1 -0
  34. package/dist/components/dev/TimezoneDevTools/styles.js +65 -0
  35. package/dist/components/dev/ZIndexDebugger.js +1 -1
  36. package/dist/components/dev/index.d.ts +4 -2
  37. package/dist/components/dev/index.d.ts.map +1 -1
  38. package/dist/components/dev/index.js +6 -1
  39. package/dist/date/index.d.ts +11 -0
  40. package/dist/date/index.d.ts.map +1 -1
  41. package/dist/date/index.js +43 -0
  42. package/package.json +2 -1
@@ -1,15 +1,15 @@
1
1
  import React, { useState, useRef, useEffect } from 'react';
2
2
  import { useCopyToClipboard } from '../../../hooks';
3
- import { getContainerStyle, getToggleButtonStyle, getPanelStyle, headerStyle, headerTitleStyle, getStatusBadgeStyle, getCopyButtonStyle, tabContainerStyle, getTabStyle, contentStyle, sectionTitleStyle, codeBlockStyle, errorItemStyle, errorLabelStyle, errorMessageStyle, statsContainerStyle, statCardStyle, statLabelStyle, statValueStyle, resizeHandleStyle, resizeHandleIndicatorStyle, } from './styles';
3
+ import { getPanelStyle, headerStyle, headerTitleStyle, getStatusBadgeStyle, getCopyButtonStyle, tabContainerStyle, getTabStyle, contentStyle, sectionTitleStyle, codeBlockStyle, errorItemStyle, errorLabelStyle, errorMessageStyle, statsContainerStyle, statCardStyle, statLabelStyle, statValueStyle, resizeHandleStyle, resizeHandleIndicatorStyle, } from './styles';
4
4
  /**
5
5
  * react-hook-form의 상태를 실시간으로 시각화하는 개발용 컴포넌트
6
6
  * form의 values, errors, dirtyFields, touchedFields 등을 한눈에 확인할 수 있습니다.
7
7
  *
8
8
  * @example
9
9
  * ```tsx
10
- * // Vite 프로젝트 - 간단한 사용법
11
10
  * import { useForm } from 'react-hook-form';
12
- * import { FormDevTools } from '@blastlabs/utils/components/dev';
11
+ * import { useRegisterForm } from '@blastlabs/utils/components/dev';
12
+ * import FormDevTools from '@blastlabs/utils/components/dev';
13
13
  *
14
14
  * function MyForm() {
15
15
  * const form = useForm({
@@ -20,88 +20,24 @@ import { getContainerStyle, getToggleButtonStyle, getPanelStyle, headerStyle, he
20
20
  * }
21
21
  * });
22
22
  *
23
- * return (
24
- * <form onSubmit={form.handleSubmit(onSubmit)}>
25
- * <input {...form.register('username')} />
26
- * <input {...form.register('email')} />
27
- * <button type="submit">Submit</button>
28
- *
29
- * {import.meta.env.DEV && <FormDevTools form={form} />}
30
- * </form>
31
- * );
32
- * }
33
- * ```
34
- *
35
- * @example
36
- * ```tsx
37
- * // Mock 데이터 생성 기능 포함
38
- * function MyForm() {
39
- * const form = useForm({
40
- * defaultValues: {
41
- * username: '',
42
- * email: '',
43
- * age: 0,
44
- * }
45
- * });
23
+ * // 페이지에서 form 주입
24
+ * useRegisterForm(form);
46
25
  *
47
26
  * return (
48
27
  * <form onSubmit={form.handleSubmit(onSubmit)}>
49
28
  * <input {...form.register('username')} />
50
29
  * <input {...form.register('email')} />
51
30
  * <button type="submit">Submit</button>
52
- *
53
- * {import.meta.env.DEV && (
54
- * <FormDevTools
55
- * form={form}
56
- * generateMock={async ({ values, originalValues }) => {
57
- * // Mock 데이터 생성 로직
58
- * return {
59
- * username: 'test_user',
60
- * email: 'test@example.com',
61
- * age: 25,
62
- * };
63
- * }}
64
- * />
65
- * )}
66
- * </form>
67
- * );
68
- * }
69
- * ```
70
- *
71
- * @example
72
- * ```tsx
73
- * // 수정 폼 예시
74
- * function EditForm({ userData }) {
75
- * const form = useForm();
76
- *
77
- * useEffect(() => {
78
- * form.reset(userData);
79
- * }, [userData]);
80
- *
81
- * return (
82
- * <form onSubmit={form.handleSubmit(onSubmit)}>
83
- * <input {...form.register('username')} />
84
- * <input {...form.register('email')} />
85
- * <button type="submit">Update</button>
86
- *
87
- * {process.env.NODE_ENV === 'development' && (
88
- * <FormDevTools
89
- * form={form}
90
- * position="top-right"
91
- * title="Edit Form Debug"
92
- * />
93
- * )}
94
31
  * </form>
95
32
  * );
96
33
  * }
97
34
  * ```
98
35
  */
99
- export default function FormDevTools({ form, validationSchema, generateMock, position = 'bottom-left', title = 'Form DevTools' }) {
36
+ export default function FormDevTools({ form, validationSchema, generateMock, title = 'Form DevTools' }) {
100
37
  // form 객체에서 필요한 값들 추출
101
38
  const { formState, watch, setValue, trigger } = form;
102
- const values = watch(); // 모든 값을 watch
103
- const originalValues = formState.defaultValues; // defaultValues를 원본 값으로 사용
104
- const [isOpen, setIsOpen] = useState(false);
39
+ const values = watch();
40
+ const originalValues = formState.defaultValues;
105
41
  const [activeTab, setActiveTab] = useState('all');
106
42
  const [panelPosition, setPanelPosition] = useState({ x: 0, y: 0 });
107
43
  const [panelSize, setPanelSize] = useState({ width: 500, height: 400 });
@@ -179,7 +115,7 @@ export default function FormDevTools({ form, validationSchema, generateMock, pos
179
115
  if (isResizing) {
180
116
  const deltaX = e.clientX - resizeStart.x;
181
117
  const deltaY = e.clientY - resizeStart.y;
182
- const maxHeight = window.innerHeight * 0.85; // 화면 높이의 85%를 최대값으로
118
+ const maxHeight = window.innerHeight * 0.85;
183
119
  setPanelSize({
184
120
  width: Math.max(300, resizeStart.width + deltaX),
185
121
  height: Math.min(maxHeight, Math.max(200, resizeStart.height + deltaY)),
@@ -240,33 +176,26 @@ export default function FormDevTools({ form, validationSchema, generateMock, pos
240
176
  setIsGenerating(true);
241
177
  setGenerateError(null);
242
178
  try {
243
- // 사용자가 제공한 generateMock 함수 사용
244
179
  const mockData = await generateMock({
245
180
  values,
246
181
  originalValues,
247
182
  });
248
- // setValue를 사용하여 각 필드를 설정
249
- // reset을 사용하면 defaultValues가 업데이트되어 changedFields 계산이 부정확해짐
250
- // setValue만 사용하면 originalValues와의 비교가 정확하게 유지됨
251
183
  const setNestedValue = (data, prefix = '') => {
252
184
  Object.keys(data).forEach((key) => {
253
185
  const fullPath = prefix ? `${prefix}.${key}` : key;
254
186
  const value = data[key];
255
187
  if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
256
- // 중첩된 객체인 경우 재귀적으로 처리
257
188
  setNestedValue(value, fullPath);
258
189
  }
259
190
  else {
260
- // 최종 필드인 경우 setValue 호출
261
191
  setValue(fullPath, value, {
262
- shouldDirty: true, // dirty를 true로 설정 (changedFields에 반영됨)
263
- shouldValidate: true, // validation 실행
192
+ shouldDirty: true,
193
+ shouldValidate: true,
264
194
  });
265
195
  }
266
196
  });
267
197
  };
268
198
  setNestedValue(mockData);
269
- // 전체 validation 실행
270
199
  if (trigger) {
271
200
  await trigger();
272
201
  }
@@ -278,165 +207,163 @@ export default function FormDevTools({ form, validationSchema, generateMock, pos
278
207
  setIsGenerating(false);
279
208
  }
280
209
  };
281
- return (React.createElement("div", { style: getContainerStyle(position) },
282
- React.createElement("button", { type: "button", onClick: () => setIsOpen(!isOpen), style: getToggleButtonStyle(formState.isValid), onMouseEnter: (e) => (e.currentTarget.style.backgroundColor = formState.isValid === false ? '#dc2626' : '#7c3aed'), onMouseLeave: (e) => (e.currentTarget.style.backgroundColor = formState.isValid === false ? '#ef4444' : '#8b5cf6') }, isOpen ? '✕' : '📝'),
283
- isOpen && (React.createElement("div", { ref: panelRef, style: getPanelStyle(position, panelPosition, panelSize, isDragging) },
284
- React.createElement("div", { style: headerStyle, onMouseDown: handleHeaderMouseDown },
285
- React.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
286
- React.createElement("div", { style: headerTitleStyle },
287
- "\uD83D\uDCDD ",
288
- title),
289
- React.createElement("div", { style: getStatusBadgeStyle(formState.isValid) }, formState.isValid ? '✓ Valid' : `✗ ${errorCount} Error${errorCount > 1 ? 's' : ''}`)),
290
- React.createElement("div", { style: { display: 'flex', gap: '8px', alignItems: 'center' } },
291
- generateMock && (React.createElement("button", { type: "button", onClick: handleGenerateMock, disabled: isGenerating, style: {
292
- ...getCopyButtonStyle(false),
293
- backgroundColor: isGenerating ? '#9ca3af' : '#10b981',
294
- opacity: isGenerating ? 0.6 : 1,
295
- cursor: isGenerating ? 'not-allowed' : 'pointer',
296
- }, onMouseEnter: (e) => {
297
- if (!isGenerating)
298
- e.currentTarget.style.backgroundColor = '#059669';
299
- }, onMouseLeave: (e) => {
300
- if (!isGenerating)
301
- e.currentTarget.style.backgroundColor = '#10b981';
302
- } }, isGenerating ? '⏳ Generating...' : '🤖 Generate Mock')),
303
- React.createElement("button", { type: "button", onClick: handleCopy, style: getCopyButtonStyle(isCopied), onMouseEnter: (e) => {
304
- if (!isCopied)
305
- e.currentTarget.style.backgroundColor = '#2563eb';
306
- }, onMouseLeave: (e) => {
307
- if (!isCopied)
308
- e.currentTarget.style.backgroundColor = '#3b82f6';
309
- } }, isCopied ? '✓ Copied' : 'Copy All'))),
310
- generateError && (React.createElement("div", { style: {
311
- padding: '8px 16px',
312
- backgroundColor: '#fef2f2',
313
- borderBottom: '1px solid #fecaca',
314
- fontSize: '12px',
315
- color: '#991b1b',
316
- } }, generateError)),
317
- React.createElement("div", { style: tabContainerStyle },
318
- React.createElement("button", { type: "button", onClick: () => setActiveTab('all'), style: getTabStyle(activeTab === 'all'), onMouseEnter: (e) => {
319
- if (activeTab !== 'all')
320
- e.currentTarget.style.backgroundColor = '#f3f4f6';
321
- }, onMouseLeave: (e) => {
322
- if (activeTab !== 'all')
323
- e.currentTarget.style.backgroundColor = 'transparent';
324
- } }, "All"),
325
- React.createElement("button", { type: "button", onClick: () => setActiveTab('values'), style: getTabStyle(activeTab === 'values'), onMouseEnter: (e) => {
326
- if (activeTab !== 'values')
327
- e.currentTarget.style.backgroundColor = '#f3f4f6';
328
- }, onMouseLeave: (e) => {
329
- if (activeTab !== 'values')
330
- e.currentTarget.style.backgroundColor = 'transparent';
331
- } }, "Values"),
332
- React.createElement("button", { type: "button", onClick: () => setActiveTab('errors'), style: getTabStyle(activeTab === 'errors'), onMouseEnter: (e) => {
333
- if (activeTab !== 'errors')
334
- e.currentTarget.style.backgroundColor = '#f3f4f6';
210
+ return (React.createElement("div", { ref: panelRef, style: getPanelStyle('bottom-right', panelPosition, panelSize, isDragging) },
211
+ React.createElement("div", { style: headerStyle, onMouseDown: handleHeaderMouseDown },
212
+ React.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' } },
213
+ React.createElement("div", { style: headerTitleStyle },
214
+ "\uD83D\uDCDD ",
215
+ title),
216
+ React.createElement("div", { style: getStatusBadgeStyle(formState.isValid) }, formState.isValid ? '✓ Valid' : `✗ ${errorCount} Error${errorCount > 1 ? 's' : ''}`)),
217
+ React.createElement("div", { style: { display: 'flex', gap: '8px', alignItems: 'center' } },
218
+ generateMock && (React.createElement("button", { type: "button", onClick: handleGenerateMock, disabled: isGenerating, style: {
219
+ ...getCopyButtonStyle(false),
220
+ backgroundColor: isGenerating ? '#9ca3af' : '#10b981',
221
+ opacity: isGenerating ? 0.6 : 1,
222
+ cursor: isGenerating ? 'not-allowed' : 'pointer',
223
+ }, onMouseEnter: (e) => {
224
+ if (!isGenerating)
225
+ e.currentTarget.style.backgroundColor = '#059669';
335
226
  }, onMouseLeave: (e) => {
336
- if (activeTab !== 'errors')
337
- e.currentTarget.style.backgroundColor = 'transparent';
338
- } },
339
- "Errors ",
340
- errorCount > 0 && `(${errorCount})`),
341
- React.createElement("button", { type: "button", onClick: () => setActiveTab('changed'), style: getTabStyle(activeTab === 'changed'), onMouseEnter: (e) => {
342
- if (activeTab !== 'changed')
343
- e.currentTarget.style.backgroundColor = '#f3f4f6';
344
- }, onMouseLeave: (e) => {
345
- if (activeTab !== 'changed')
346
- e.currentTarget.style.backgroundColor = 'transparent';
347
- } },
348
- "Changed ",
349
- changedFieldsCount > 0 && `(${changedFieldsCount})`),
350
- React.createElement("button", { type: "button", onClick: () => setActiveTab('state'), style: getTabStyle(activeTab === 'state'), onMouseEnter: (e) => {
351
- if (activeTab !== 'state')
352
- e.currentTarget.style.backgroundColor = '#f3f4f6';
353
- }, onMouseLeave: (e) => {
354
- if (activeTab !== 'state')
355
- e.currentTarget.style.backgroundColor = 'transparent';
356
- } }, "State"),
357
- validationSchema && (React.createElement("button", { type: "button", onClick: () => setActiveTab('validation'), style: getTabStyle(activeTab === 'validation'), onMouseEnter: (e) => {
358
- if (activeTab !== 'validation')
359
- e.currentTarget.style.backgroundColor = '#f3f4f6';
227
+ if (!isGenerating)
228
+ e.currentTarget.style.backgroundColor = '#10b981';
229
+ } }, isGenerating ? '⏳ Generating...' : '🤖 Generate Mock')),
230
+ React.createElement("button", { type: "button", onClick: handleCopy, style: getCopyButtonStyle(isCopied), onMouseEnter: (e) => {
231
+ if (!isCopied)
232
+ e.currentTarget.style.backgroundColor = '#2563eb';
360
233
  }, onMouseLeave: (e) => {
361
- if (activeTab !== 'validation')
362
- e.currentTarget.style.backgroundColor = 'transparent';
363
- } }, "Validation"))),
364
- React.createElement("div", { style: contentStyle },
365
- activeTab === 'all' && (React.createElement(React.Fragment, null,
366
- React.createElement("div", { style: statsContainerStyle },
367
- React.createElement("div", { style: statCardStyle },
368
- React.createElement("div", { style: statLabelStyle }, "Dirty Fields"),
369
- React.createElement("div", { style: statValueStyle }, dirtyFieldsCount)),
370
- React.createElement("div", { style: statCardStyle },
371
- React.createElement("div", { style: statLabelStyle }, "Touched Fields"),
372
- React.createElement("div", { style: statValueStyle }, touchedFieldsCount)),
373
- React.createElement("div", { style: statCardStyle },
374
- React.createElement("div", { style: statLabelStyle }, "Submit Count"),
375
- React.createElement("div", { style: statValueStyle }, formState.submitCount || 0)),
376
- React.createElement("div", { style: statCardStyle },
377
- React.createElement("div", { style: statLabelStyle }, "Submitting"),
378
- React.createElement("div", { style: statValueStyle }, formState.isSubmitting ? 'Yes' : 'No'))),
379
- React.createElement("div", { style: sectionTitleStyle }, "Form Values"),
380
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(values || {}, null, 2)),
381
- errorCount > 0 && (React.createElement(React.Fragment, null,
382
- React.createElement("div", { style: sectionTitleStyle },
383
- "Validation Errors (",
384
- errorCount,
385
- ")"),
386
- renderErrors())),
387
- changedFieldsCount > 0 && (React.createElement(React.Fragment, null,
388
- React.createElement("div", { style: sectionTitleStyle },
389
- "Changed Fields (",
390
- changedFieldsCount,
391
- ")"),
392
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(changedFields, null, 2)))),
393
- dirtyFieldsCount > 0 && (React.createElement(React.Fragment, null,
394
- React.createElement("div", { style: sectionTitleStyle }, "Dirty Fields"),
395
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.dirtyFields || {}, null, 2)))),
396
- touchedFieldsCount > 0 && (React.createElement(React.Fragment, null,
397
- React.createElement("div", { style: sectionTitleStyle }, "Touched Fields"),
398
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.touchedFields || {}, null, 2)))))),
399
- activeTab === 'values' && (React.createElement(React.Fragment, null, values && Object.keys(values).length > 0 ? (React.createElement(React.Fragment, null,
400
- React.createElement("div", { style: sectionTitleStyle }, "Form Values"),
401
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(values, null, 2)))) : (React.createElement("div", { style: { textAlign: 'center', color: '#9ca3af', padding: '40px 20px', fontSize: '13px' } },
402
- React.createElement("div", { style: { marginBottom: '8px' } }, "No form values"),
403
- React.createElement("div", { style: { fontSize: '11px', color: '#d1d5db' } }, "Form values will appear here"))))),
404
- activeTab === 'errors' && (React.createElement(React.Fragment, null,
234
+ if (!isCopied)
235
+ e.currentTarget.style.backgroundColor = '#3b82f6';
236
+ } }, isCopied ? '✓ Copied' : 'Copy All'))),
237
+ generateError && (React.createElement("div", { style: {
238
+ padding: '8px 16px',
239
+ backgroundColor: '#fef2f2',
240
+ borderBottom: '1px solid #fecaca',
241
+ fontSize: '12px',
242
+ color: '#991b1b',
243
+ } }, generateError)),
244
+ React.createElement("div", { style: tabContainerStyle },
245
+ React.createElement("button", { type: "button", onClick: () => setActiveTab('all'), style: getTabStyle(activeTab === 'all'), onMouseEnter: (e) => {
246
+ if (activeTab !== 'all')
247
+ e.currentTarget.style.backgroundColor = '#f3f4f6';
248
+ }, onMouseLeave: (e) => {
249
+ if (activeTab !== 'all')
250
+ e.currentTarget.style.backgroundColor = 'transparent';
251
+ } }, "All"),
252
+ React.createElement("button", { type: "button", onClick: () => setActiveTab('values'), style: getTabStyle(activeTab === 'values'), onMouseEnter: (e) => {
253
+ if (activeTab !== 'values')
254
+ e.currentTarget.style.backgroundColor = '#f3f4f6';
255
+ }, onMouseLeave: (e) => {
256
+ if (activeTab !== 'values')
257
+ e.currentTarget.style.backgroundColor = 'transparent';
258
+ } }, "Values"),
259
+ React.createElement("button", { type: "button", onClick: () => setActiveTab('errors'), style: getTabStyle(activeTab === 'errors'), onMouseEnter: (e) => {
260
+ if (activeTab !== 'errors')
261
+ e.currentTarget.style.backgroundColor = '#f3f4f6';
262
+ }, onMouseLeave: (e) => {
263
+ if (activeTab !== 'errors')
264
+ e.currentTarget.style.backgroundColor = 'transparent';
265
+ } },
266
+ "Errors ",
267
+ errorCount > 0 && `(${errorCount})`),
268
+ React.createElement("button", { type: "button", onClick: () => setActiveTab('changed'), style: getTabStyle(activeTab === 'changed'), onMouseEnter: (e) => {
269
+ if (activeTab !== 'changed')
270
+ e.currentTarget.style.backgroundColor = '#f3f4f6';
271
+ }, onMouseLeave: (e) => {
272
+ if (activeTab !== 'changed')
273
+ e.currentTarget.style.backgroundColor = 'transparent';
274
+ } },
275
+ "Changed ",
276
+ changedFieldsCount > 0 && `(${changedFieldsCount})`),
277
+ React.createElement("button", { type: "button", onClick: () => setActiveTab('state'), style: getTabStyle(activeTab === 'state'), onMouseEnter: (e) => {
278
+ if (activeTab !== 'state')
279
+ e.currentTarget.style.backgroundColor = '#f3f4f6';
280
+ }, onMouseLeave: (e) => {
281
+ if (activeTab !== 'state')
282
+ e.currentTarget.style.backgroundColor = 'transparent';
283
+ } }, "State"),
284
+ validationSchema && (React.createElement("button", { type: "button", onClick: () => setActiveTab('validation'), style: getTabStyle(activeTab === 'validation'), onMouseEnter: (e) => {
285
+ if (activeTab !== 'validation')
286
+ e.currentTarget.style.backgroundColor = '#f3f4f6';
287
+ }, onMouseLeave: (e) => {
288
+ if (activeTab !== 'validation')
289
+ e.currentTarget.style.backgroundColor = 'transparent';
290
+ } }, "Validation"))),
291
+ React.createElement("div", { style: contentStyle },
292
+ activeTab === 'all' && (React.createElement(React.Fragment, null,
293
+ React.createElement("div", { style: statsContainerStyle },
294
+ React.createElement("div", { style: statCardStyle },
295
+ React.createElement("div", { style: statLabelStyle }, "Dirty Fields"),
296
+ React.createElement("div", { style: statValueStyle }, dirtyFieldsCount)),
297
+ React.createElement("div", { style: statCardStyle },
298
+ React.createElement("div", { style: statLabelStyle }, "Touched Fields"),
299
+ React.createElement("div", { style: statValueStyle }, touchedFieldsCount)),
300
+ React.createElement("div", { style: statCardStyle },
301
+ React.createElement("div", { style: statLabelStyle }, "Submit Count"),
302
+ React.createElement("div", { style: statValueStyle }, formState.submitCount || 0)),
303
+ React.createElement("div", { style: statCardStyle },
304
+ React.createElement("div", { style: statLabelStyle }, "Submitting"),
305
+ React.createElement("div", { style: statValueStyle }, formState.isSubmitting ? 'Yes' : 'No'))),
306
+ React.createElement("div", { style: sectionTitleStyle }, "Form Values"),
307
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(values || {}, null, 2)),
308
+ errorCount > 0 && (React.createElement(React.Fragment, null,
405
309
  React.createElement("div", { style: sectionTitleStyle },
406
- "Validation Errors ",
407
- errorCount > 0 && `(${errorCount})`),
408
- errorCount > 0 ? renderErrors() : (React.createElement("div", { style: { textAlign: 'center', color: '#9ca3af', padding: '20px', fontSize: '13px' } }, "No validation errors")))),
409
- activeTab === 'changed' && (React.createElement(React.Fragment, null, changedFieldsCount > 0 ? (React.createElement(React.Fragment, null,
310
+ "Validation Errors (",
311
+ errorCount,
312
+ ")"),
313
+ renderErrors())),
314
+ changedFieldsCount > 0 && (React.createElement(React.Fragment, null,
410
315
  React.createElement("div", { style: sectionTitleStyle },
411
316
  "Changed Fields (",
412
317
  changedFieldsCount,
413
318
  ")"),
414
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(changedFields, null, 2)))) : (React.createElement("div", { style: { textAlign: 'center', color: '#9ca3af', padding: '40px 20px', fontSize: '13px' } },
415
- React.createElement("div", { style: { marginBottom: '8px' } }, "No changed fields"),
416
- React.createElement("div", { style: { fontSize: '11px', color: '#d1d5db' } }, "Fields will appear here when you modify form values"))))),
417
- activeTab === 'state' && (React.createElement(React.Fragment, null,
418
- React.createElement("div", { style: statsContainerStyle },
419
- React.createElement("div", { style: statCardStyle },
420
- React.createElement("div", { style: statLabelStyle }, "Dirty Fields"),
421
- React.createElement("div", { style: statValueStyle }, dirtyFieldsCount)),
422
- React.createElement("div", { style: statCardStyle },
423
- React.createElement("div", { style: statLabelStyle }, "Touched Fields"),
424
- React.createElement("div", { style: statValueStyle }, touchedFieldsCount)),
425
- React.createElement("div", { style: statCardStyle },
426
- React.createElement("div", { style: statLabelStyle }, "Submit Count"),
427
- React.createElement("div", { style: statValueStyle }, formState.submitCount || 0)),
428
- React.createElement("div", { style: statCardStyle },
429
- React.createElement("div", { style: statLabelStyle }, "Submitting"),
430
- React.createElement("div", { style: statValueStyle }, formState.isSubmitting ? 'Yes' : 'No'))),
431
- dirtyFieldsCount > 0 && (React.createElement(React.Fragment, null,
432
- React.createElement("div", { style: sectionTitleStyle }, "Dirty Fields"),
433
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.dirtyFields || {}, null, 2)))),
434
- touchedFieldsCount > 0 && (React.createElement(React.Fragment, null,
435
- React.createElement("div", { style: sectionTitleStyle }, "Touched Fields"),
436
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.touchedFields || {}, null, 2)))))),
437
- activeTab === 'validation' && validationSchema && (React.createElement(React.Fragment, null,
438
- React.createElement("div", { style: sectionTitleStyle }, "Validation Schema"),
439
- React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(validationSchema, null, 2))))),
440
- React.createElement("div", { onMouseDown: handleResizeMouseDown, style: resizeHandleStyle }),
441
- React.createElement("div", { onMouseDown: handleResizeMouseDown, style: resizeHandleIndicatorStyle })))));
319
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(changedFields, null, 2)))),
320
+ dirtyFieldsCount > 0 && (React.createElement(React.Fragment, null,
321
+ React.createElement("div", { style: sectionTitleStyle }, "Dirty Fields"),
322
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.dirtyFields || {}, null, 2)))),
323
+ touchedFieldsCount > 0 && (React.createElement(React.Fragment, null,
324
+ React.createElement("div", { style: sectionTitleStyle }, "Touched Fields"),
325
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.touchedFields || {}, null, 2)))))),
326
+ activeTab === 'values' && (values && Object.keys(values).length > 0 ? (React.createElement(React.Fragment, null,
327
+ React.createElement("div", { style: sectionTitleStyle }, "Form Values"),
328
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(values, null, 2)))) : (React.createElement("div", { style: { textAlign: 'center', color: '#9ca3af', padding: '40px 20px', fontSize: '13px' } },
329
+ React.createElement("div", { style: { marginBottom: '8px' } }, "No form values"),
330
+ React.createElement("div", { style: { fontSize: '11px', color: '#d1d5db' } }, "Form values will appear here")))),
331
+ activeTab === 'errors' && (React.createElement(React.Fragment, null,
332
+ React.createElement("div", { style: sectionTitleStyle },
333
+ "Validation Errors ",
334
+ errorCount > 0 && `(${errorCount})`),
335
+ errorCount > 0 ? renderErrors() : (React.createElement("div", { style: { textAlign: 'center', color: '#9ca3af', padding: '20px', fontSize: '13px' } }, "No validation errors")))),
336
+ activeTab === 'changed' && (changedFieldsCount > 0 ? (React.createElement(React.Fragment, null,
337
+ React.createElement("div", { style: sectionTitleStyle },
338
+ "Changed Fields (",
339
+ changedFieldsCount,
340
+ ")"),
341
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(changedFields, null, 2)))) : (React.createElement("div", { style: { textAlign: 'center', color: '#9ca3af', padding: '40px 20px', fontSize: '13px' } },
342
+ React.createElement("div", { style: { marginBottom: '8px' } }, "No changed fields"),
343
+ React.createElement("div", { style: { fontSize: '11px', color: '#d1d5db' } }, "Fields will appear here when you modify form values")))),
344
+ activeTab === 'state' && (React.createElement(React.Fragment, null,
345
+ React.createElement("div", { style: statsContainerStyle },
346
+ React.createElement("div", { style: statCardStyle },
347
+ React.createElement("div", { style: statLabelStyle }, "Dirty Fields"),
348
+ React.createElement("div", { style: statValueStyle }, dirtyFieldsCount)),
349
+ React.createElement("div", { style: statCardStyle },
350
+ React.createElement("div", { style: statLabelStyle }, "Touched Fields"),
351
+ React.createElement("div", { style: statValueStyle }, touchedFieldsCount)),
352
+ React.createElement("div", { style: statCardStyle },
353
+ React.createElement("div", { style: statLabelStyle }, "Submit Count"),
354
+ React.createElement("div", { style: statValueStyle }, formState.submitCount || 0)),
355
+ React.createElement("div", { style: statCardStyle },
356
+ React.createElement("div", { style: statLabelStyle }, "Submitting"),
357
+ React.createElement("div", { style: statValueStyle }, formState.isSubmitting ? 'Yes' : 'No'))),
358
+ dirtyFieldsCount > 0 && (React.createElement(React.Fragment, null,
359
+ React.createElement("div", { style: sectionTitleStyle }, "Dirty Fields"),
360
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.dirtyFields || {}, null, 2)))),
361
+ touchedFieldsCount > 0 && (React.createElement(React.Fragment, null,
362
+ React.createElement("div", { style: sectionTitleStyle }, "Touched Fields"),
363
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(formState.touchedFields || {}, null, 2)))))),
364
+ activeTab === 'validation' && validationSchema && (React.createElement(React.Fragment, null,
365
+ React.createElement("div", { style: sectionTitleStyle }, "Validation Schema"),
366
+ React.createElement("pre", { style: codeBlockStyle }, JSON.stringify(validationSchema, null, 2))))),
367
+ React.createElement("div", { onMouseDown: handleResizeMouseDown, style: resizeHandleStyle }),
368
+ React.createElement("div", { onMouseDown: handleResizeMouseDown, style: resizeHandleIndicatorStyle })));
442
369
  }
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ type FormType = {
3
+ formState: {
4
+ errors?: Record<string, any>;
5
+ dirtyFields?: Record<string, any>;
6
+ touchedFields?: Record<string, any>;
7
+ isValid?: boolean;
8
+ isSubmitting?: boolean;
9
+ submitCount?: number;
10
+ defaultValues?: Record<string, any>;
11
+ };
12
+ watch: () => any;
13
+ setValue: (name: any, value: any, options?: any) => void;
14
+ trigger?: () => Promise<boolean>;
15
+ };
16
+ type Props = {
17
+ form: FormType;
18
+ generateMock?: (params: {
19
+ values?: Record<string, any>;
20
+ originalValues?: Record<string, any>;
21
+ }) => Promise<Record<string, any>> | Record<string, any>;
22
+ validationSchema?: Record<string, any>;
23
+ title?: string;
24
+ };
25
+ export default function FormDevToolsContent({ form, validationSchema, generateMock, title }: Props): React.JSX.Element;
26
+ export {};
27
+ //# sourceMappingURL=FormDevToolsContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormDevToolsContent.d.ts","sourceRoot":"","sources":["../../../../src/components/dev/FormDevTools/FormDevToolsContent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAwB3D,KAAK,QAAQ,GAAG;IACd,SAAS,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC7B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAClC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACpC,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACrC,CAAC;IACF,KAAK,EAAE,MAAM,GAAG,CAAC;IACjB,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE;QACtB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC7B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACtC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACzD,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,YAAY,EAAE,KAAuB,EAAE,EAAE,KAAK,qBAyUnH"}