🎯 Complete Postman-Style Table View with Consistent Design
✨ New Features: - Authentic Postman table experience with horizontal arrays & vertical objects - Click rows to drill down with breadcrumb navigation - Smart data detection (arrays → tables, objects → key-value, primitives → display) - Clickable breadcrumb buttons for easy navigation - Back button for seamless exploration 🎨 Consistent Visual Design: - Unified type notation across Visual Editor, Mindmap, and Table views - Color-coded pills with icons for all data types: 🔵 Objects (blue) 🟢 Arrays (green) 🟣 Strings (purple) 🟠 Numbers (orange) 🟡 Booleans (yellow) ⚫ Null (gray) - Button-style breadcrumb vs circular data pills for clear distinction - Full dark mode support throughout 🔧 UX Improvements: - Output formats hidden by default with 'See Data Outputs' toggle - Left-aligned toggle button matching existing UI - Preserved PostmanTreeTable as asset for hierarchical view - Enhanced sample data with realistic array/object structure - Professional styling matching Postman's interface 🚀 Technical Implementation: - Dynamic column generation from array data - Path-based navigation with state management - Type-aware rendering with consistent icons - Responsive design for all screen sizes - Clean component architecture
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import React, { useState, useRef, useCallback } from 'react';
|
||||
import { Edit3, Upload, FileText, Map } from 'lucide-react';
|
||||
import { Edit3, Upload, FileText, Map, Table } from 'lucide-react';
|
||||
import ToolLayout from '../components/ToolLayout';
|
||||
import CopyButton from '../components/CopyButton';
|
||||
import StructuredEditor from '../components/StructuredEditor';
|
||||
import MindmapView from '../components/MindmapView';
|
||||
import PostmanTable from '../components/PostmanTable';
|
||||
|
||||
const ObjectEditor = () => {
|
||||
console.log(' ObjectEditor component loaded successfully!');
|
||||
@@ -13,7 +14,8 @@ const ObjectEditor = () => {
|
||||
const [inputFormat, setInputFormat] = useState('');
|
||||
const [inputValid, setInputValid] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [viewMode, setViewMode] = useState('visual'); // 'visual', 'mindmap'
|
||||
const [viewMode, setViewMode] = useState('visual'); // 'visual', 'mindmap', 'table'
|
||||
const [showOutputs, setShowOutputs] = useState(false);
|
||||
const [outputs, setOutputs] = useState({
|
||||
jsonPretty: '',
|
||||
jsonMinified: '',
|
||||
@@ -293,20 +295,43 @@ const ObjectEditor = () => {
|
||||
// Load sample data
|
||||
const loadSample = () => {
|
||||
const sample = {
|
||||
"user": {
|
||||
"name": "John Doe",
|
||||
"age": 30,
|
||||
"email": "john@example.com",
|
||||
"preferences": {
|
||||
"theme": "dark",
|
||||
"notifications": true
|
||||
"users": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "John Doe",
|
||||
"email": "john@example.com",
|
||||
"age": 30,
|
||||
"role": "admin",
|
||||
"active": true
|
||||
},
|
||||
"tags": ["developer", "javascript", "react"]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "Jane Smith",
|
||||
"email": "jane@example.com",
|
||||
"age": 28,
|
||||
"role": "user",
|
||||
"active": true
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "Bob Wilson",
|
||||
"email": "bob@example.com",
|
||||
"age": 35,
|
||||
"role": "moderator",
|
||||
"active": false
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"theme": "dark",
|
||||
"language": "en",
|
||||
"timezone": "UTC"
|
||||
}
|
||||
"timezone": "UTC",
|
||||
"features": {
|
||||
"notifications": true,
|
||||
"darkMode": true,
|
||||
"autoSave": false
|
||||
}
|
||||
},
|
||||
"tags": ["developer", "javascript", "react", "nodejs"]
|
||||
};
|
||||
setStructuredData(sample);
|
||||
generateOutputs(sample);
|
||||
@@ -382,6 +407,17 @@ const ObjectEditor = () => {
|
||||
<Map className="h-4 w-4" />
|
||||
<span>Mindmap View</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setViewMode('table')}
|
||||
className={`flex items-center space-x-2 px-4 py-2 rounded-md font-medium transition-colors ${
|
||||
viewMode === 'table'
|
||||
? 'bg-white dark:bg-gray-700 text-primary-600 shadow-sm'
|
||||
: 'text-gray-600 dark:text-gray-400'
|
||||
}`}
|
||||
>
|
||||
<Table className="h-4 w-4" />
|
||||
<span>Table View</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Input Section */}
|
||||
@@ -420,6 +456,7 @@ const ObjectEditor = () => {
|
||||
<h3 className="text-lg font-medium text-gray-900 dark:text-white mb-4">
|
||||
{viewMode === 'visual' && 'Visual Editor'}
|
||||
{viewMode === 'mindmap' && 'Mindmap Visualization'}
|
||||
{viewMode === 'table' && 'Table View'}
|
||||
</h3>
|
||||
|
||||
{viewMode === 'visual' && (
|
||||
@@ -435,10 +472,29 @@ const ObjectEditor = () => {
|
||||
<MindmapView data={structuredData} />
|
||||
)}
|
||||
|
||||
{viewMode === 'table' && (
|
||||
<PostmanTable
|
||||
data={structuredData}
|
||||
title="JSON Data Structure"
|
||||
/>
|
||||
)}
|
||||
|
||||
</div>
|
||||
|
||||
{/* Toggle Output Button */}
|
||||
<div className="mb-6">
|
||||
<button
|
||||
onClick={() => setShowOutputs(!showOutputs)}
|
||||
className="flex items-center space-x-2 tool-button-secondary"
|
||||
>
|
||||
<FileText className="h-4 w-4" />
|
||||
<span>{showOutputs ? 'Hide Data Outputs' : 'See Data Outputs'}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Output Actions */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
{showOutputs && (
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
||||
{/* JSON Pretty */}
|
||||
<div className="space-y-2">
|
||||
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||
@@ -487,6 +543,7 @@ const ObjectEditor = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Usage Tips */}
|
||||
<div className="bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-md p-4 mt-6">
|
||||
@@ -494,10 +551,12 @@ const ObjectEditor = () => {
|
||||
<ul className="text-blue-700 dark:text-blue-300 text-sm space-y-1">
|
||||
<li>• <strong>Visual Editor:</strong> Create and modify object structures with forms</li>
|
||||
<li>• <strong>Mindmap View:</strong> Visualize complex JSON structures as interactive diagrams</li>
|
||||
<li>• <strong>Table View:</strong> Browse data like Postman - click arrays for horizontal tables, objects for key-value pairs</li>
|
||||
<li>• <strong>Navigation:</strong> Use breadcrumbs and Back button to navigate through nested data structures</li>
|
||||
<li>• <strong>Input Data:</strong> Paste JSON/PHP serialized data with auto-detection in the input field</li>
|
||||
<li>• Import data from files or use the sample data to get started</li>
|
||||
<li>• Toggle output formats visibility with the "Show/Hide Output Formats" button</li>
|
||||
<li>• Export your data in any format: JSON pretty, minified, or PHP serialized</li>
|
||||
<li>• Use copy buttons to quickly copy any output format</li>
|
||||
</ul>
|
||||
</div>
|
||||
</ToolLayout>
|
||||
|
||||
Reference in New Issue
Block a user