@jsonforms/core 3.2.0-alpha.1 → 3.2.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsonforms/core",
3
- "version": "3.2.0-alpha.1",
3
+ "version": "3.2.0-alpha.2",
4
4
  "description": "Core module of JSON Forms",
5
5
  "repository": "https://github.com/eclipsesource/jsonforms",
6
6
  "bugs": "https://github.com/eclipsesource/jsonforms/issues",
@@ -99,5 +99,5 @@
99
99
  "typedoc": "~0.21.9",
100
100
  "typescript": "4.2.3"
101
101
  },
102
- "gitHead": "deb2c7cd71f6065cca7777420b1018f17e73052a"
102
+ "gitHead": "f922f48cb7548cefd8f1acd939a9afbd14b36f9b"
103
103
  }
@@ -78,6 +78,7 @@ import {
78
78
  arrayDefaultTranslations,
79
79
  ArrayTranslations,
80
80
  } from '../i18n/arrayTranslations';
81
+ import { resolveSchema } from './resolvers';
81
82
 
82
83
  const isRequired = (
83
84
  schema: JsonSchema,
@@ -617,7 +618,11 @@ export const mapStateToMultiEnumControlProps = (
617
618
  ownProps: OwnPropsOfControl & OwnPropsOfEnum
618
619
  ): StatePropsOfControl & OwnPropsOfEnum => {
619
620
  const props: StatePropsOfControl = mapStateToControlProps(state, ownProps);
620
- const items = props.schema.items as JsonSchema;
621
+ let items = props.schema.items as JsonSchema;
622
+ items =
623
+ items && items.$ref
624
+ ? resolveSchema(props.rootSchema, items.$ref, props.rootSchema)
625
+ : items;
621
626
  const options: EnumOption[] =
622
627
  ownProps.options ||
623
628
  (items?.oneOf &&
package/src/util/util.ts CHANGED
@@ -77,7 +77,17 @@ export const deriveTypes = (jsonSchema: JsonSchema): string[] => {
77
77
  if (!isEmpty(jsonSchema.items)) {
78
78
  return ['array'];
79
79
  }
80
-
80
+ if (!isEmpty(jsonSchema.enum)) {
81
+ const types: Set<string> = new Set();
82
+ jsonSchema.enum.forEach((enumElement) => {
83
+ if (typeof enumElement === 'string') {
84
+ types.add('string');
85
+ } else {
86
+ deriveTypes(enumElement).forEach((type) => types.add(type));
87
+ }
88
+ });
89
+ return Array.from(types);
90
+ }
81
91
  if (!isEmpty(jsonSchema.allOf)) {
82
92
  const allOfType = find(
83
93
  jsonSchema.allOf,