refactor(json-schema-2020-12): drop optimizeExpansion config option (#8612)
This option was removed and codebase has been modified in a way as this option is always true. Refs #8513
This commit is contained in:
@@ -9,7 +9,6 @@ import * as propTypes from "../../prop-types"
|
|||||||
import {
|
import {
|
||||||
useComponent,
|
useComponent,
|
||||||
useLevel,
|
useLevel,
|
||||||
useConfig,
|
|
||||||
useFn,
|
useFn,
|
||||||
useIsEmbedded,
|
useIsEmbedded,
|
||||||
useIsExpandedDeeply,
|
useIsExpandedDeeply,
|
||||||
@@ -24,7 +23,6 @@ import {
|
|||||||
|
|
||||||
const JSONSchema = forwardRef(({ schema, name }, ref) => {
|
const JSONSchema = forwardRef(({ schema, name }, ref) => {
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const config = useConfig()
|
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||||
@@ -127,7 +125,7 @@ const JSONSchema = forwardRef(({ schema, name }, ref) => {
|
|||||||
"json-schema-2020-12-body--collapsed": !expanded,
|
"json-schema-2020-12-body--collapsed": !expanded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!expanded && config.optimizeExpansion ? null : (
|
{expanded && (
|
||||||
<>
|
<>
|
||||||
<KeywordDescription schema={schema} />
|
<KeywordDescription schema={schema} />
|
||||||
{!isCircular && isExpandable && (
|
{!isCircular && isExpandable && (
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ import React, { useCallback, useState } from "react"
|
|||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
import { schema } from "../../prop-types"
|
import { schema } from "../../prop-types"
|
||||||
import { useConfig, useComponent, useIsExpandedDeeply } from "../../hooks"
|
import { useComponent, useIsExpandedDeeply } from "../../hooks"
|
||||||
import { JSONSchemaDeepExpansionContext } from "../../context"
|
import { JSONSchemaDeepExpansionContext } from "../../context"
|
||||||
|
|
||||||
const $defs = ({ schema }) => {
|
const $defs = ({ schema }) => {
|
||||||
const $defs = schema?.$defs || {}
|
const $defs = schema?.$defs || {}
|
||||||
const config = useConfig()
|
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||||
@@ -51,7 +50,7 @@ const $defs = ({ schema }) => {
|
|||||||
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!expanded && config.optimizeExpansion ? null : (
|
{expanded && (
|
||||||
<>
|
<>
|
||||||
{Object.entries($defs).map(([schemaName, schema]) => (
|
{Object.entries($defs).map(([schemaName, schema]) => (
|
||||||
<li key={schemaName} className="json-schema-2020-12-property">
|
<li key={schemaName} className="json-schema-2020-12-property">
|
||||||
|
|||||||
@@ -5,18 +5,12 @@ import React, { useCallback, useState } from "react"
|
|||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
import { schema } from "../../prop-types"
|
import { schema } from "../../prop-types"
|
||||||
import {
|
import { useFn, useComponent, useIsExpandedDeeply } from "../../hooks"
|
||||||
useFn,
|
|
||||||
useConfig,
|
|
||||||
useComponent,
|
|
||||||
useIsExpandedDeeply,
|
|
||||||
} from "../../hooks"
|
|
||||||
import { JSONSchemaDeepExpansionContext } from "../../context"
|
import { JSONSchemaDeepExpansionContext } from "../../context"
|
||||||
|
|
||||||
const AllOf = ({ schema }) => {
|
const AllOf = ({ schema }) => {
|
||||||
const allOf = schema?.allOf || []
|
const allOf = schema?.allOf || []
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const config = useConfig()
|
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||||
@@ -58,7 +52,7 @@ const AllOf = ({ schema }) => {
|
|||||||
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!expanded && config.optimizeExpansion ? null : (
|
{expanded && (
|
||||||
<>
|
<>
|
||||||
{allOf.map((schema, index) => (
|
{allOf.map((schema, index) => (
|
||||||
<li key={`#${index}`} className="json-schema-2020-12-property">
|
<li key={`#${index}`} className="json-schema-2020-12-property">
|
||||||
|
|||||||
@@ -5,18 +5,12 @@ import React, { useCallback, useState } from "react"
|
|||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
import { schema } from "../../prop-types"
|
import { schema } from "../../prop-types"
|
||||||
import {
|
import { useFn, useComponent, useIsExpandedDeeply } from "../../hooks"
|
||||||
useFn,
|
|
||||||
useConfig,
|
|
||||||
useComponent,
|
|
||||||
useIsExpandedDeeply,
|
|
||||||
} from "../../hooks"
|
|
||||||
import { JSONSchemaDeepExpansionContext } from "../../context"
|
import { JSONSchemaDeepExpansionContext } from "../../context"
|
||||||
|
|
||||||
const AnyOf = ({ schema }) => {
|
const AnyOf = ({ schema }) => {
|
||||||
const anyOf = schema?.anyOf || []
|
const anyOf = schema?.anyOf || []
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const config = useConfig()
|
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||||
@@ -58,7 +52,7 @@ const AnyOf = ({ schema }) => {
|
|||||||
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!expanded && config.optimizeExpansion ? null : (
|
{expanded && (
|
||||||
<>
|
<>
|
||||||
{anyOf.map((schema, index) => (
|
{anyOf.map((schema, index) => (
|
||||||
<li key={`#${index}`} className="json-schema-2020-12-property">
|
<li key={`#${index}`} className="json-schema-2020-12-property">
|
||||||
|
|||||||
@@ -5,12 +5,11 @@ import React, { useCallback, useState } from "react"
|
|||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
import { schema } from "../../prop-types"
|
import { schema } from "../../prop-types"
|
||||||
import { useConfig, useComponent, useIsExpandedDeeply } from "../../hooks"
|
import { useComponent, useIsExpandedDeeply } from "../../hooks"
|
||||||
import { JSONSchemaDeepExpansionContext } from "../../context"
|
import { JSONSchemaDeepExpansionContext } from "../../context"
|
||||||
|
|
||||||
const DependentSchemas = ({ schema }) => {
|
const DependentSchemas = ({ schema }) => {
|
||||||
const dependentSchemas = schema?.dependentSchemas || []
|
const dependentSchemas = schema?.dependentSchemas || []
|
||||||
const config = useConfig()
|
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||||
@@ -50,7 +49,7 @@ const DependentSchemas = ({ schema }) => {
|
|||||||
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!expanded && config.optimizeExpansion ? null : (
|
{expanded && (
|
||||||
<>
|
<>
|
||||||
{Object.entries(dependentSchemas).map(([schemaName, schema]) => (
|
{Object.entries(dependentSchemas).map(([schemaName, schema]) => (
|
||||||
<li key={schemaName} className="json-schema-2020-12-property">
|
<li key={schemaName} className="json-schema-2020-12-property">
|
||||||
|
|||||||
@@ -5,18 +5,12 @@ import React, { useCallback, useState } from "react"
|
|||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
import { schema } from "../../prop-types"
|
import { schema } from "../../prop-types"
|
||||||
import {
|
import { useFn, useComponent, useIsExpandedDeeply } from "../../hooks"
|
||||||
useFn,
|
|
||||||
useConfig,
|
|
||||||
useComponent,
|
|
||||||
useIsExpandedDeeply,
|
|
||||||
} from "../../hooks"
|
|
||||||
import { JSONSchemaDeepExpansionContext } from "../../context"
|
import { JSONSchemaDeepExpansionContext } from "../../context"
|
||||||
|
|
||||||
const OneOf = ({ schema }) => {
|
const OneOf = ({ schema }) => {
|
||||||
const oneOf = schema?.oneOf || []
|
const oneOf = schema?.oneOf || []
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const config = useConfig()
|
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||||
@@ -58,7 +52,7 @@ const OneOf = ({ schema }) => {
|
|||||||
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!expanded && config.optimizeExpansion ? null : (
|
{expanded && (
|
||||||
<>
|
<>
|
||||||
{oneOf.map((schema, index) => (
|
{oneOf.map((schema, index) => (
|
||||||
<li key={`#${index}`} className="json-schema-2020-12-property">
|
<li key={`#${index}`} className="json-schema-2020-12-property">
|
||||||
|
|||||||
@@ -5,18 +5,12 @@ import React, { useCallback, useState } from "react"
|
|||||||
import classNames from "classnames"
|
import classNames from "classnames"
|
||||||
|
|
||||||
import { schema } from "../../prop-types"
|
import { schema } from "../../prop-types"
|
||||||
import {
|
import { useFn, useComponent, useIsExpandedDeeply } from "../../hooks"
|
||||||
useFn,
|
|
||||||
useConfig,
|
|
||||||
useComponent,
|
|
||||||
useIsExpandedDeeply,
|
|
||||||
} from "../../hooks"
|
|
||||||
import { JSONSchemaDeepExpansionContext } from "../../context"
|
import { JSONSchemaDeepExpansionContext } from "../../context"
|
||||||
|
|
||||||
const PrefixItems = ({ schema }) => {
|
const PrefixItems = ({ schema }) => {
|
||||||
const prefixItems = schema?.prefixItems || []
|
const prefixItems = schema?.prefixItems || []
|
||||||
const fn = useFn()
|
const fn = useFn()
|
||||||
const config = useConfig()
|
|
||||||
const isExpandedDeeply = useIsExpandedDeeply()
|
const isExpandedDeeply = useIsExpandedDeeply()
|
||||||
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
const [expanded, setExpanded] = useState(isExpandedDeeply)
|
||||||
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
const [expandedDeeply, setExpandedDeeply] = useState(false)
|
||||||
@@ -58,7 +52,7 @@ const PrefixItems = ({ schema }) => {
|
|||||||
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
"json-schema-2020-12-keyword__children--collapsed": !expanded,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{!expanded && config.optimizeExpansion ? null : (
|
{expanded && (
|
||||||
<>
|
<>
|
||||||
{prefixItems.map((schema, index) => (
|
{prefixItems.map((schema, index) => (
|
||||||
<li key={`#${index}`} className="json-schema-2020-12-property">
|
<li key={`#${index}`} className="json-schema-2020-12-property">
|
||||||
|
|||||||
@@ -97,14 +97,6 @@ export const withJSONSchemaContext = (Component, overrides = {}) => {
|
|||||||
* 3 -> [0]...(3)
|
* 3 -> [0]...(3)
|
||||||
*/
|
*/
|
||||||
defaultExpandedLevels: 0, // 2 = 0...2
|
defaultExpandedLevels: 0, // 2 = 0...2
|
||||||
/**
|
|
||||||
* Can be turned on for complex and extensive schemas.
|
|
||||||
* Child schemas are not rendered until parent schema is expanded.
|
|
||||||
*
|
|
||||||
* By default, entire schema tree is rendered and collapsed parts of the
|
|
||||||
* tree are hidden with css.
|
|
||||||
*/
|
|
||||||
optimizeExpansion: true,
|
|
||||||
...overrides.config,
|
...overrides.config,
|
||||||
},
|
},
|
||||||
fn: {
|
fn: {
|
||||||
|
|||||||
Reference in New Issue
Block a user