diff --git a/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss b/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss index 7b64689d..5fdb824d 100644 --- a/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss +++ b/src/core/plugins/json-schema-2020-12/components/JSONSchema/_json-schema.scss @@ -32,21 +32,6 @@ border-radius: 4px; } - &-core-keyword { - color: #6b6b6b; - font-size: 12px; - font-style: italic; - margin-left: 20px; - font-weight: bold; - - &__value { - color: #6b6b6b; - font-style: italic; - font-size: 12px; - font-weight: normal; - } - } - //&-note { // @include text_headline($section-models-model-title-font-color); // padding: 10px 0 0 20px; @@ -55,8 +40,4 @@ //} } -.json-schema-2020-12-core-keyword + .json-schema-2020-12-core-keyword__value::before { - content: '=' -} - diff --git a/src/core/plugins/json-schema-2020-12/components/_all.scss b/src/core/plugins/json-schema-2020-12/components/_all.scss index 6b1b3cd0..9f312225 100644 --- a/src/core/plugins/json-schema-2020-12/components/_all.scss +++ b/src/core/plugins/json-schema-2020-12/components/_all.scss @@ -6,18 +6,4 @@ @import './JSONSchema/json-schema'; @import './Accordion/accordion'; @import './ExpandDeepButton/expand-deep-button'; -@import './keywords/$vocabulary/$vocabulary'; -@import './keywords/$defs/$defs'; -@import './keywords/AllOf/all-of'; -@import './keywords/AnyOf/any-of'; -@import './keywords/OneOf/one-of'; -@import './keywords/Not/not'; -@import './keywords/If/if'; -@import './keywords/Then/then'; -@import './keywords/Else/else'; -@import './keywords/DependentSchemas/dependent-schemas'; -@import './keywords/Type/type'; -@import './keywords/Format/format'; -@import './keywords/Description/description'; -@import './keywords/Title/title'; -@import './keywords/Properties/properties'; +@import './keywords/all'; diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$anchor.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$anchor.jsx index 8bc3046e..106d0dd5 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$anchor.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$anchor.jsx @@ -9,9 +9,11 @@ const $anchor = ({ schema }) => { if (!schema?.$anchor) return null return ( -
- $anchor - +
+ + $anchor + + {schema.$anchor}
diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx index 844fe13e..72442725 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$comment.jsx @@ -9,9 +9,11 @@ const $comment = ({ schema }) => { if (!schema?.$comment) return null return ( -
- $comment - +
+ + $comment + + {schema.$comment}
diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$defs/$defs.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$defs.jsx similarity index 70% rename from src/core/plugins/json-schema-2020-12/components/keywords/$defs/$defs.jsx rename to src/core/plugins/json-schema-2020-12/components/keywords/$defs.jsx index 21c764ee..6af86286 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$defs/$defs.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$defs.jsx @@ -3,8 +3,8 @@ */ import React, { useCallback, useState } from "react" -import { schema } from "../../../prop-types" -import { useComponent, useIsExpandedDeeply } from "../../../hooks" +import { schema } from "../../prop-types" +import { useComponent, useIsExpandedDeeply } from "../../hooks" const $defs = ({ schema }) => { const $defs = schema?.$defs || {} @@ -23,15 +23,17 @@ const $defs = ({ schema }) => { }, []) return ( -
+
- $defs - object + + $defs + + object {expanded && (
    {Object.entries($defs).map(([schemaName, schema]) => ( -
  • +
  • ))} diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$defs/_$defs.scss b/src/core/plugins/json-schema-2020-12/components/keywords/$defs/_$defs.scss deleted file mode 100644 index 1eccd561..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$defs/_$defs.scss +++ /dev/null @@ -1,12 +0,0 @@ -.json-schema-2020-12 { - &__\$defs { - & ul { - @include expansion-border; - padding: 0; - } - } - - &-\$def { - @extend .json-schema-2020-12-property; - } -} diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx index 40296168..64e7a031 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicAnchor.jsx @@ -9,9 +9,11 @@ const $dynamicAnchor = ({ schema }) => { if (!schema?.$dynamicAnchor) return null return ( -
    - $dynamicAnchor - +
    + + $dynamicAnchor + + {schema.$dynamicAnchor}
    diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicRef.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicRef.jsx index a3e70839..b148cdd5 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicRef.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$dynamicRef.jsx @@ -9,9 +9,11 @@ const $dynamicRef = ({ schema }) => { if (!schema?.$dynamicRef) return null return ( -
    - $dynamicRef - +
    + + $dynamicRef + + {schema.$dynamicRef}
    diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$id.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$id.jsx index fb701fc0..669ab2ed 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$id.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$id.jsx @@ -9,9 +9,11 @@ const $id = ({ schema }) => { if (!schema?.$id) return null return ( -
    - $id - +
    + + $id + + {schema.$id}
    diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$ref.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$ref.jsx index 5971a5a5..4971bcef 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$ref.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$ref.jsx @@ -9,9 +9,11 @@ const $ref = ({ schema }) => { if (!schema?.$ref) return null return ( -
    - $ref - +
    + + $ref + + {schema.$ref}
    diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$schema.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$schema.jsx index b0b419a9..b8d67b40 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$schema.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$schema.jsx @@ -9,9 +9,11 @@ const $schema = ({ schema }) => { if (!schema?.$schema) return null return ( -
    - $schema - +
    + + $schema + + {schema.$schema}
    diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/$vocabulary.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/$vocabulary.jsx index 312995b4..b56b7003 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/$vocabulary.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/$vocabulary.jsx @@ -20,21 +20,23 @@ const $vocabulary = ({ schema }) => { }, []) return ( -
    +
    - $vocabulary - object + + $vocabulary + + object
      {expanded && Object.entries(schema.$vocabulary).map(([uri, enabled]) => (
    • - + {uri}
    • diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/_$vocabulary.scss b/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/_$vocabulary.scss index 1c47515b..4b973368 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/_$vocabulary.scss +++ b/src/core/plugins/json-schema-2020-12/components/keywords/$vocabulary/_$vocabulary.scss @@ -1,11 +1,13 @@ .json-schema-2020-12 { - &__\$vocabulary { + &-keyword--\$vocabulary { ul { @include expansion-border; } } - &__\$vocabulary-uri { + &-\$vocabulary-uri { + margin-left: 35px; + &--disabled { text-decoration: line-through; } diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/AllOf.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/AllOf.jsx new file mode 100644 index 00000000..f6fb1fa8 --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/AllOf.jsx @@ -0,0 +1,68 @@ +/** + * @prettier + */ +import React, { useCallback, useState } from "react" + +import { schema } from "../../prop-types" +import { useFn, useComponent, useIsExpandedDeeply } from "../../hooks" +import { JSONSchemaDeepExpansionContext } from "../../context" + +const AllOf = ({ schema }) => { + const allOf = schema?.allOf || [] + + if (!Array.isArray(allOf) || allOf.length === 0) { + return null + } + + const fn = useFn() + const isExpandedDeeply = useIsExpandedDeeply() + const [expanded, setExpanded] = useState(isExpandedDeeply) + const [expandedDeeply, setExpandedDeeply] = useState(false) + const Accordion = useComponent("Accordion") + const ExpandDeepButton = useComponent("ExpandDeepButton") + const JSONSchema = useComponent("JSONSchema") + const KeywordType = useComponent("KeywordType") + + /** + * Event handlers. + */ + const handleExpansion = useCallback(() => { + setExpanded((prev) => !prev) + }, []) + const handleExpansionDeep = useCallback((e, expandedDeepNew) => { + setExpanded(expandedDeepNew) + setExpandedDeeply(expandedDeepNew) + }, []) + + return ( + +
      + + + All of + + + + + {expanded && ( +
        + {allOf.map((schema, index) => ( +
      • + +
      • + ))} +
      + )} +
      +
      + ) +} + +AllOf.propTypes = { + schema: schema.isRequired, +} + +export default AllOf diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/AllOf/AllOf.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/AllOf/AllOf.jsx deleted file mode 100644 index 7a2a4dc3..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/AllOf/AllOf.jsx +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @prettier - */ -import React, { useCallback, useState } from "react" - -import { schema } from "../../../prop-types" -import { useFn, useComponent, useIsExpandedDeeply } from "../../../hooks" - -const AllOf = ({ schema }) => { - const allOf = schema?.allOf || [] - - if (!Array.isArray(allOf) || allOf.length === 0) { - return null - } - - const fn = useFn() - const isExpandedDeeply = useIsExpandedDeeply() - const [expanded, setExpanded] = useState(isExpandedDeeply) - const Accordion = useComponent("Accordion") - const JSONSchema = useComponent("JSONSchema") - - const handleExpansion = useCallback(() => { - setExpanded((prev) => !prev) - }, []) - - return ( -
      - - - All of - - - {fn.getType({ allOf })} - - - {expanded && ( -
        - {allOf.map((schema, index) => ( -
      • - -
      • - ))} -
      - )} -
      - ) -} - -AllOf.propTypes = { - schema: schema.isRequired, -} - -export default AllOf diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/AllOf/_all-of.scss b/src/core/plugins/json-schema-2020-12/components/keywords/AllOf/_all-of.scss deleted file mode 100644 index 7c425b5d..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/AllOf/_all-of.scss +++ /dev/null @@ -1,19 +0,0 @@ -.json-schema-2020-12 { - &__allOf { - margin: 5px 0 5px 0; - - & > ul { - @include expansion-border; - padding: 0; - } - } - - &-core-keyword { - &--allOf { - color: $text-code-default-font-color; - font-style: normal; - } - } -} - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf.jsx new file mode 100644 index 00000000..2b6041bc --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf.jsx @@ -0,0 +1,68 @@ +/** + * @prettier + */ +import React, { useCallback, useState } from "react" + +import { schema } from "../../prop-types" +import { useFn, useComponent, useIsExpandedDeeply } from "../../hooks" +import { JSONSchemaDeepExpansionContext } from "../../context" + +const AnyOf = ({ schema }) => { + const anyOf = schema?.anyOf || [] + + if (!Array.isArray(anyOf) || anyOf.length === 0) { + return null + } + + const fn = useFn() + const isExpandedDeeply = useIsExpandedDeeply() + const [expanded, setExpanded] = useState(isExpandedDeeply) + const [expandedDeeply, setExpandedDeeply] = useState(false) + const Accordion = useComponent("Accordion") + const ExpandDeepButton = useComponent("ExpandDeepButton") + const JSONSchema = useComponent("JSONSchema") + const KeywordType = useComponent("KeywordType") + + /** + * Event handlers. + */ + const handleExpansion = useCallback(() => { + setExpanded((prev) => !prev) + }, []) + const handleExpansionDeep = useCallback((e, expandedDeepNew) => { + setExpanded(expandedDeepNew) + setExpandedDeeply(expandedDeepNew) + }, []) + + return ( + +
      + + + Any of + + + + + {expanded && ( +
        + {anyOf.map((schema, index) => ( +
      • + +
      • + ))} +
      + )} +
      +
      + ) +} + +AnyOf.propTypes = { + schema: schema.isRequired, +} + +export default AnyOf diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf/AnyOf.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf/AnyOf.jsx deleted file mode 100644 index e197743c..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf/AnyOf.jsx +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @prettier - */ -import React, { useCallback, useState } from "react" - -import { schema } from "../../../prop-types" -import { useFn, useComponent, useIsExpandedDeeply } from "../../../hooks" - -const AnyOf = ({ schema }) => { - const anyOf = schema?.anyOf || [] - - if (!Array.isArray(anyOf) || anyOf.length === 0) { - return null - } - - const fn = useFn() - const isExpandedDeeply = useIsExpandedDeeply() - const [expanded, setExpanded] = useState(isExpandedDeeply) - const Accordion = useComponent("Accordion") - const JSONSchema = useComponent("JSONSchema") - - const handleExpansion = useCallback(() => { - setExpanded((prev) => !prev) - }, []) - - return ( -
      - - - Any of - - - {fn.getType({ anyOf })} - - - {expanded && ( -
        - {anyOf.map((schema, index) => ( -
      • - -
      • - ))} -
      - )} -
      - ) -} - -AnyOf.propTypes = { - schema: schema.isRequired, -} - -export default AnyOf diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf/_any-of.scss b/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf/_any-of.scss deleted file mode 100644 index b80bcab9..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/AnyOf/_any-of.scss +++ /dev/null @@ -1,13 +0,0 @@ -.json-schema-2020-12 { - &__anyOf { - @extend .json-schema-2020-12__allOf; - } - - &-core-keyword { - &--anyOf { - @extend .json-schema-2020-12-core-keyword--allOf; - } - } -} - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas.jsx new file mode 100644 index 00000000..c9e326dd --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas.jsx @@ -0,0 +1,62 @@ +/** + * @prettier + */ +import React, { useCallback, useState } from "react" + +import { schema } from "../../prop-types" +import { useComponent, useIsExpandedDeeply } from "../../hooks" +import { JSONSchemaDeepExpansionContext } from "../../context" + +const DependentSchemas = ({ schema }) => { + const dependentSchemas = schema?.dependentSchemas || [] + + if (typeof dependentSchemas !== "object") return null + if (Object.keys(dependentSchemas).length === 0) return null + + const isExpandedDeeply = useIsExpandedDeeply() + const [expanded, setExpanded] = useState(isExpandedDeeply) + const [expandedDeeply, setExpandedDeeply] = useState(false) + const Accordion = useComponent("Accordion") + const ExpandDeepButton = useComponent("ExpandDeepButton") + const JSONSchema = useComponent("JSONSchema") + + /** + * Event handlers. + */ + const handleExpansion = useCallback(() => { + setExpanded((prev) => !prev) + }, []) + const handleExpansionDeep = useCallback((e, expandedDeepNew) => { + setExpanded(expandedDeepNew) + setExpandedDeeply(expandedDeepNew) + }, []) + + return ( + +
      + + + Dependent schemas + + + + object + {expanded && ( +
        + {Object.entries(dependentSchemas).map(([schemaName, schema]) => ( +
      • + +
      • + ))} +
      + )} +
      +
      + ) +} + +DependentSchemas.propTypes = { + schema: schema.isRequired, +} + +export default DependentSchemas diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas/DependentSchemas.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas/DependentSchemas.jsx deleted file mode 100644 index 0d609b2d..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas/DependentSchemas.jsx +++ /dev/null @@ -1,49 +0,0 @@ -/** - * @prettier - */ -import React, { useCallback, useState } from "react" - -import { schema } from "../../../prop-types" -import { useComponent, useIsExpandedDeeply } from "../../../hooks" - -const DependentSchemas = ({ schema }) => { - const dependentSchemas = schema?.dependentSchemas || [] - - if (typeof dependentSchemas !== "object") return null - if (Object.keys(dependentSchemas).length === 0) return null - - const isExpandedDeeply = useIsExpandedDeeply() - const [expanded, setExpanded] = useState(isExpandedDeeply) - const Accordion = useComponent("Accordion") - const JSONSchema = useComponent("JSONSchema") - - const handleExpansion = useCallback(() => { - setExpanded((prev) => !prev) - }, []) - - return ( -
      - - - Dependent schemas - - object - - {expanded && ( -
        - {Object.entries(dependentSchemas).map(([schemaName, schema]) => ( -
      • - -
      • - ))} -
      - )} -
      - ) -} - -DependentSchemas.propTypes = { - schema: schema.isRequired, -} - -export default DependentSchemas diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas/_dependent-schemas.scss b/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas/_dependent-schemas.scss deleted file mode 100644 index 4cd130f8..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/DependentSchemas/_dependent-schemas.scss +++ /dev/null @@ -1,13 +0,0 @@ -.json-schema-2020-12 { - &__dependentSchemas { - @extend .json-schema-2020-12__allOf; - } - - &-core-keyword { - &--dependentSchemas { - @extend .json-schema-2020-12-core-keyword--allOf; - } - } -} - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Description/Description.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Description/Description.jsx index fa6159e7..133667a1 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Description/Description.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Description/Description.jsx @@ -9,7 +9,11 @@ const Description = ({ schema }) => { if (!schema?.description) return null return ( -
      {schema.description}
      +
      +
      + {schema.description} +
      +
      ) } diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Description/_description.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Description/_description.scss index 98fb434f..30c6a71b 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Description/_description.scss +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Description/_description.scss @@ -1,4 +1,4 @@ -.json-schema-2020-12__description { +.json-schema-2020-12-keyword--description { color: #6b6b6b; font-size: 12px; margin-left: 20px; diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Else/Else.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx similarity index 57% rename from src/core/plugins/json-schema-2020-12/components/keywords/Else/Else.jsx rename to src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx index 5c81ba0b..7341c995 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Else/Else.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Else.jsx @@ -3,21 +3,21 @@ */ import React from "react" -import { schema } from "../../../prop-types" -import { useComponent } from "../../../hooks" +import { schema } from "../../prop-types" +import { useComponent } from "../../hooks" const Else = ({ schema }) => { if (!schema?.else) return null const JSONSchema = useComponent("JSONSchema") const name = ( - + Else ) return ( -
      +
      ) diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Else/_else.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Else/_else.scss deleted file mode 100644 index e3eb5eb4..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Else/_else.scss +++ /dev/null @@ -1,10 +0,0 @@ -.json-schema-2020-12 { - &__else { - .json-schema-2020-12-core-keyword--else { - @extend .json-schema-2020-12-core-keyword--allOf; - } - } -} - - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/If/If.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx similarity index 56% rename from src/core/plugins/json-schema-2020-12/components/keywords/If/If.jsx rename to src/core/plugins/json-schema-2020-12/components/keywords/If.jsx index 81ce6b61..881ddc18 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/If/If.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/If.jsx @@ -3,21 +3,21 @@ */ import React from "react" -import { schema } from "../../../prop-types" -import { useComponent } from "../../../hooks" +import { schema } from "../../prop-types" +import { useComponent } from "../../hooks" const If = ({ schema }) => { if (!schema?.if) return null const JSONSchema = useComponent("JSONSchema") const name = ( - + If ) return ( -
      +
      ) diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/If/_if.scss b/src/core/plugins/json-schema-2020-12/components/keywords/If/_if.scss deleted file mode 100644 index 52a490be..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/If/_if.scss +++ /dev/null @@ -1,10 +0,0 @@ -.json-schema-2020-12 { - &__if { - .json-schema-2020-12-core-keyword--if { - @extend .json-schema-2020-12-core-keyword--allOf; - } - } -} - - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Not/Not.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx similarity index 56% rename from src/core/plugins/json-schema-2020-12/components/keywords/Not/Not.jsx rename to src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx index 27f2a173..b6b6626a 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Not/Not.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Not.jsx @@ -3,21 +3,21 @@ */ import React from "react" -import { schema } from "../../../prop-types" -import { useComponent } from "../../../hooks" +import { schema } from "../../prop-types" +import { useComponent } from "../../hooks" const Not = ({ schema }) => { if (!schema?.not) return null const JSONSchema = useComponent("JSONSchema") const name = ( - + Not ) return ( -
      +
      ) diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Not/_not.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Not/_not.scss deleted file mode 100644 index 35c5a35f..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Not/_not.scss +++ /dev/null @@ -1,10 +0,0 @@ -.json-schema-2020-12 { - &__not { - .json-schema-2020-12-core-keyword--not { - @extend .json-schema-2020-12-core-keyword--allOf; - } - } -} - - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/OneOf.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/OneOf.jsx new file mode 100644 index 00000000..7ec08e0b --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/OneOf.jsx @@ -0,0 +1,68 @@ +/** + * @prettier + */ +import React, { useCallback, useState } from "react" + +import { schema } from "../../prop-types" +import { useFn, useComponent, useIsExpandedDeeply } from "../../hooks" +import { JSONSchemaDeepExpansionContext } from "../../context" + +const OneOf = ({ schema }) => { + const oneOf = schema?.oneOf || [] + + if (!Array.isArray(oneOf) || oneOf.length === 0) { + return null + } + + const fn = useFn() + const isExpandedDeeply = useIsExpandedDeeply() + const [expanded, setExpanded] = useState(isExpandedDeeply) + const [expandedDeeply, setExpandedDeeply] = useState(false) + const Accordion = useComponent("Accordion") + const ExpandDeepButton = useComponent("ExpandDeepButton") + const JSONSchema = useComponent("JSONSchema") + const KeywordType = useComponent("KeywordType") + + /** + * Event handlers. + */ + const handleExpansion = useCallback(() => { + setExpanded((prev) => !prev) + }, []) + const handleExpansionDeep = useCallback((e, expandedDeepNew) => { + setExpanded(expandedDeepNew) + setExpandedDeeply(expandedDeepNew) + }, []) + + return ( + +
      + + + One of + + + + + {expanded && ( +
        + {oneOf.map((schema, index) => ( +
      • + +
      • + ))} +
      + )} +
      +
      + ) +} + +OneOf.propTypes = { + schema: schema.isRequired, +} + +export default OneOf diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/OneOf/OneOf.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/OneOf/OneOf.jsx deleted file mode 100644 index e094153d..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/OneOf/OneOf.jsx +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @prettier - */ -import React, { useCallback, useState } from "react" - -import { schema } from "../../../prop-types" -import { useFn, useComponent, useIsExpandedDeeply } from "../../../hooks" - -const OneOf = ({ schema }) => { - const oneOf = schema?.oneOf || [] - - if (!Array.isArray(oneOf) || oneOf.length === 0) { - return null - } - - const fn = useFn() - const isExpandedDeeply = useIsExpandedDeeply() - const [expanded, setExpanded] = useState(isExpandedDeeply) - const Accordion = useComponent("Accordion") - const JSONSchema = useComponent("JSONSchema") - - const handleExpansion = useCallback(() => { - setExpanded((prev) => !prev) - }, []) - - return ( -
      - - - One of - - - {fn.getType({ oneOf })} - - - {expanded && ( -
        - {oneOf.map((schema, index) => ( -
      • - -
      • - ))} -
      - )} -
      - ) -} - -OneOf.propTypes = { - schema: schema.isRequired, -} - -export default OneOf diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/OneOf/_one-of.scss b/src/core/plugins/json-schema-2020-12/components/keywords/OneOf/_one-of.scss deleted file mode 100644 index 3b7c88af..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/OneOf/_one-of.scss +++ /dev/null @@ -1,13 +0,0 @@ -.json-schema-2020-12 { - &__oneOf { - @extend .json-schema-2020-12__allOf; - } - - &-core-keyword { - &--oneOf { - @extend .json-schema-2020-12-core-keyword--allOf; - } - } -} - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Then/Then.jsx b/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx similarity index 57% rename from src/core/plugins/json-schema-2020-12/components/keywords/Then/Then.jsx rename to src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx index 5ae714fd..d06d2b8b 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Then/Then.jsx +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Then.jsx @@ -3,21 +3,21 @@ */ import React from "react" -import { schema } from "../../../prop-types" -import { useComponent } from "../../../hooks" +import { schema } from "../../prop-types" +import { useComponent } from "../../hooks" const Then = ({ schema }) => { if (!schema?.then) return null const JSONSchema = useComponent("JSONSchema") const name = ( - + Then ) return ( -
      +
      ) diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Then/_then.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Then/_then.scss deleted file mode 100644 index 4acd067c..00000000 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Then/_then.scss +++ /dev/null @@ -1,10 +0,0 @@ -.json-schema-2020-12 { - &__then { - .json-schema-2020-12-core-keyword--then { - @extend .json-schema-2020-12-core-keyword--allOf; - } - } -} - - - diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss b/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss index 1b8828fd..45f1cb98 100644 --- a/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss +++ b/src/core/plugins/json-schema-2020-12/components/keywords/Title/_title.scss @@ -4,13 +4,11 @@ display: inline-block; font-weight: bold; - & .json-schema-2020-12-core-keyword { + & .json-schema-2020-12-keyword__name { margin: 0; } } - - &-property { margin: 7px 0; diff --git a/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss b/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss new file mode 100644 index 00000000..f90fa61f --- /dev/null +++ b/src/core/plugins/json-schema-2020-12/components/keywords/_all.scss @@ -0,0 +1,51 @@ +.json-schema-2020-12-keyword { + margin: 5px 0 5px 0; + + & > ul { + @include expansion-border; + padding: 0; + } + + &__name { + font-size: 12px; + margin-left: 20px; + font-weight: bold; + + &--primary { + color: $text-code-default-font-color; + font-style: normal; + } + + &--secondary { + color: #6b6b6b; + font-style: italic; + } + } + + &__value { + color: #6b6b6b; + font-style: italic; + font-size: 12px; + font-weight: normal; + + &--primary { + color: $text-code-default-font-color; + font-style: normal; + } + + &--secondary { + color: #6b6b6b; + font-style: italic; + } + } +} +.json-schema-2020-12-keyword__name--secondary + .json-schema-2020-12-keyword__value--secondary::before { + content: '=' +} + +@import './$vocabulary/$vocabulary'; +@import './Type/type'; +@import './Format/format'; +@import './Description/description'; +@import './Title/title'; +@import './Properties/properties'; diff --git a/src/core/plugins/json-schema-2020-12/hoc.jsx b/src/core/plugins/json-schema-2020-12/hoc.jsx index e38ebaad..d65a8c63 100644 --- a/src/core/plugins/json-schema-2020-12/hoc.jsx +++ b/src/core/plugins/json-schema-2020-12/hoc.jsx @@ -11,16 +11,16 @@ import Keyword$anchor from "./components/keywords/$anchor" import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" import Keyword$ref from "./components/keywords/$ref" import Keyword$dynamicRef from "./components/keywords/$dynamicRef" -import Keyword$defs from "./components/keywords/$defs/$defs" +import Keyword$defs from "./components/keywords/$defs" import Keyword$comment from "./components/keywords/$comment" -import KeywordAllOf from "./components/keywords/AllOf/AllOf" -import KeywordAnyOf from "./components/keywords/AnyOf/AnyOf" -import KeywordOneOf from "./components/keywords/OneOf/OneOf" -import KeywordNot from "./components/keywords/Not/Not" -import KeywordIf from "./components/keywords/If/If" -import KeywordThen from "./components/keywords/Then/Then" -import KeywordElse from "./components/keywords/Else/Else" -import KeywordDependentSchemas from "./components/keywords/DependentSchemas/DependentSchemas" +import KeywordAllOf from "./components/keywords/AllOf" +import KeywordAnyOf from "./components/keywords/AnyOf" +import KeywordOneOf from "./components/keywords/OneOf" +import KeywordNot from "./components/keywords/Not" +import KeywordIf from "./components/keywords/If" +import KeywordThen from "./components/keywords/Then" +import KeywordElse from "./components/keywords/Else" +import KeywordDependentSchemas from "./components/keywords/DependentSchemas" import KeywordProperties from "./components/keywords/Properties/Properties" import KeywordType from "./components/keywords/Type/Type" import KeywordFormat from "./components/keywords/Format/Format" diff --git a/src/core/plugins/json-schema-2020-12/index.js b/src/core/plugins/json-schema-2020-12/index.js index 81d605b3..8358c4af 100644 --- a/src/core/plugins/json-schema-2020-12/index.js +++ b/src/core/plugins/json-schema-2020-12/index.js @@ -10,16 +10,16 @@ import Keyword$anchor from "./components/keywords/$anchor" import Keyword$dynamicAnchor from "./components/keywords/$dynamicAnchor" import Keyword$ref from "./components/keywords/$ref" import Keyword$dynamicRef from "./components/keywords/$dynamicRef" -import Keyword$defs from "./components/keywords/$defs/$defs" +import Keyword$defs from "./components/keywords/$defs" import Keyword$comment from "./components/keywords/$comment" -import KeywordAllOf from "./components/keywords/AllOf/AllOf" -import KeywordAnyOf from "./components/keywords/AnyOf/AnyOf" -import KeywordOneOf from "./components/keywords/OneOf/OneOf" -import KeywordNot from "./components/keywords/Not/Not" -import KeywordIf from "./components/keywords/If/If" -import KeywordThen from "./components/keywords/Then/Then" -import KeywordElse from "./components/keywords/Else/Else" -import KeywordDependentSchemas from "./components/keywords/DependentSchemas/DependentSchemas" +import KeywordAllOf from "./components/keywords/AllOf" +import KeywordAnyOf from "./components/keywords/AnyOf" +import KeywordOneOf from "./components/keywords/OneOf" +import KeywordNot from "./components/keywords/Not" +import KeywordIf from "./components/keywords/If" +import KeywordThen from "./components/keywords/Then" +import KeywordElse from "./components/keywords/Else" +import KeywordDependentSchemas from "./components/keywords/DependentSchemas" import KeywordType from "./components/keywords/Type/Type" import KeywordFormat from "./components/keywords/Format/Format" import KeywordTitle from "./components/keywords/Title/Title" diff --git a/src/core/plugins/oas31/wrap-components/json-schema-2020-12-keyword-description.jsx b/src/core/plugins/oas31/wrap-components/json-schema-2020-12-keyword-description.jsx index b16d41df..87338757 100644 --- a/src/core/plugins/oas31/wrap-components/json-schema-2020-12-keyword-description.jsx +++ b/src/core/plugins/oas31/wrap-components/json-schema-2020-12-keyword-description.jsx @@ -11,8 +11,10 @@ const JSONSchema202012KeywordDescriptionWrapper = const MarkDown = getComponent("Markdown") return ( -
      - +
      +
      + +
      ) })