import React, { useState, useEffect } from 'react'; import Link from '@docusaurus/Link'; function CodeValue({ value }) { if (!value) return null; if (value.includes('\n') || value.length > 50) { return (
        {value}
      
); } return {value}; } function NestedTypeTable({ nestedTypes }) { if (!nestedTypes || nestedTypes.length === 0) return null; return ( {nestedTypes.map((type, idx) => ( ))}
Type Description
{type.type === 'link' ? ( {type.text} ) : ( type.name || type.type )} {type.description || type.content}
); } export function ConfigDetail({ config }) { const styles = { descriptionSection: { marginBottom: '2rem', }, documentationLink: { color: 'var(--ifm-color-primary)', textDecoration: 'none', }, typeCell: { position: 'relative', }, expandButton: { background: 'none', border: 'none', cursor: 'pointer', padding: '0 4px', color: 'var(--ifm-color-primary)', display: 'inline-flex', alignItems: 'center', marginLeft: '5px' }, nestedTableContainer: { marginTop: '8px', marginBottom: '4px', backgroundColor: 'var(--ifm-table-stripe-background)', borderRadius: '4px', padding: '8px', border: '1px solid var(--ifm-table-border-color)' } }; const { name, description, documentationUrl, parameters } = config; // Initialize expandedParams state const [expandedParams, setExpandedParams] = useState({}); // Use useEffect to set initial expand state when component mounts useEffect(() => { const initialExpanded = {}; parameters.forEach(param => { // Auto-expand if nested types count is less than 5 if (param.nestedTypes && param.nestedTypes.length > 0 && param.nestedTypes.length < 5) { initialExpanded[param.name] = true; } }); setExpandedParams(initialExpanded); }, [parameters]); const toggleExpand = (paramName) => { setExpandedParams(prev => ({ ...prev, [paramName]: !prev[paramName] })); }; return (
{description && (

{description}

{documentationUrl && (

Details can be found in:
{documentationUrl}

)}
)}

Parameters

{parameters.map((param) => { const hasNestedTypes = param.nestedTypes && param.nestedTypes.length > 0; const isExpanded = expandedParams[param.name]; return ( ); })}
Name Type Required Description
{param.name} {param.type} {hasNestedTypes && ( )} {hasNestedTypes && isExpanded && (
)}
{param.required ? '✅' : '❌'}
{param.description}
{param.validValues && (
Valid values: {param.validValues.map((value, idx) => ( {idx > 0 && ', '} ))}
)} {param.defaultValue && (
Defaults:
)}
); }