-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(json-schema-2020-12): add support for enum keyword (#8623)
Refs #8513
- Loading branch information
Showing
8 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/core/plugins/json-schema-2020-12/components/keywords/Enum/Enum.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
import React from "react" | ||
|
||
import { schema } from "../../../prop-types" | ||
import { useFn } from "../../../hooks" | ||
|
||
const Enum = ({ schema }) => { | ||
const fn = useFn() | ||
|
||
if (!Array.isArray(schema?.enum)) return null | ||
|
||
return ( | ||
<div className="json-schema-2020-12-keyword json-schema-2020-12-keyword--enum"> | ||
<span className="json-schema-2020-12-keyword__name json-schema-2020-12-keyword__name--primary"> | ||
Allowed values | ||
</span> | ||
<ul> | ||
{schema.enum.map((element) => { | ||
const strigifiedElement = fn.stringify(element) | ||
|
||
return ( | ||
<li key={strigifiedElement}> | ||
<span className="json-schema-2020-12-keyword__value json-schema-2020-12-keyword__value--const"> | ||
{strigifiedElement} | ||
</span> | ||
</li> | ||
) | ||
})} | ||
</ul> | ||
</div> | ||
) | ||
} | ||
|
||
Enum.propTypes = { | ||
schema: schema.isRequired, | ||
} | ||
|
||
export default Enum |
12 changes: 12 additions & 0 deletions
12
src/core/plugins/json-schema-2020-12/components/keywords/Enum/_enum.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.json-schema-2020-12-keyword--enum { | ||
& > ul { | ||
display: inline-block; | ||
padding: 0; | ||
margin: 0; | ||
|
||
li { | ||
display: inline; | ||
list-style-type: none; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters