import TabItem from "@theme-original/TabItem" import Tabs from "@theme-original/Tabs" import { CreateNodes } from "@theme/JSONSchemaViewer/components" import { SchemaHierarchyComponent } from "@theme/JSONSchemaViewer/contexts" import { IfLabel, ThenLabel, ElseLabel } from "@theme/JSONSchemaViewer/labels" import type { JSX } from "react" import type { JSONSchema } from "@theme/JSONSchemaViewer/types" type Props = { schema: Exclude [x: string]: any } // Handle if else then export default function IfElseThen(props: Props): JSX.Element { const { schema } = props const hasThen = schema.then !== undefined const hasElse = schema.else !== undefined // values for Tabs let values = [ { value: "schema_if", label: , }, hasThen && { value: "schema_then", label: , }, hasElse && { value: "schema_else", label: , }, ].filter((v) => typeof v !== "boolean") as { value: "schema_if" | "schema_then" | "schema_else" label: JSX.Element }[] // Render appropriate case function renderSwitch( value: "schema_if" | "schema_then" | "schema_else", schema: Exclude, ) { switch (value) { case "schema_if": return ( ) case "schema_then": return ( ) case "schema_else": return ( ) } } return ( {values.map((val) => ( {renderSwitch(val.value, schema)} ))} ) }