@jsonforms/core 3.4.1 → 3.5.0-beta.1
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/lib/jsonforms-core.cjs.js +57 -16
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +52 -12
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/mappers/renderer.d.ts +12 -1
- package/lib/util/uischema.d.ts +1 -1
- package/lib/util/util.d.ts +1 -1
- package/package.json +2 -2
- package/src/mappers/renderer.ts +87 -12
- package/src/util/resolvers.ts +2 -1
|
@@ -286,7 +286,7 @@ const resolveSchemaWithSegments = (schema, pathSegments, rootSchema) => {
|
|
|
286
286
|
if (isEmpty(schema)) {
|
|
287
287
|
return undefined;
|
|
288
288
|
}
|
|
289
|
-
if (schema.$ref) {
|
|
289
|
+
if (typeof schema.$ref === 'string') {
|
|
290
290
|
schema = resolveSchema(rootSchema, schema.$ref, rootSchema);
|
|
291
291
|
}
|
|
292
292
|
if (!pathSegments || pathSegments.length === 0) {
|
|
@@ -1990,7 +1990,13 @@ const showAsRequired = (required, hideRequiredAsterisk) => {
|
|
|
1990
1990
|
return required && !hideRequiredAsterisk;
|
|
1991
1991
|
};
|
|
1992
1992
|
const createDefaultValue = (schema, rootSchema) => {
|
|
1993
|
-
const
|
|
1993
|
+
const defaultValue = doCreateDefaultValue(schema, rootSchema);
|
|
1994
|
+
return defaultValue === undefined ? {} : defaultValue;
|
|
1995
|
+
};
|
|
1996
|
+
const doCreateDefaultValue = (schema, rootSchema) => {
|
|
1997
|
+
const resolvedSchema = typeof schema.$ref === 'string'
|
|
1998
|
+
? Resolve.schema(rootSchema, schema.$ref, rootSchema)
|
|
1999
|
+
: schema;
|
|
1994
2000
|
if (resolvedSchema.default !== undefined) {
|
|
1995
2001
|
return extractDefaults(resolvedSchema, rootSchema);
|
|
1996
2002
|
}
|
|
@@ -2002,25 +2008,42 @@ const createDefaultValue = (schema, rootSchema) => {
|
|
|
2002
2008
|
}
|
|
2003
2009
|
return '';
|
|
2004
2010
|
}
|
|
2005
|
-
|
|
2006
|
-
hasType(resolvedSchema, 'number')) {
|
|
2011
|
+
if (hasType(resolvedSchema, 'integer') || hasType(resolvedSchema, 'number')) {
|
|
2007
2012
|
return 0;
|
|
2008
2013
|
}
|
|
2009
|
-
|
|
2014
|
+
if (hasType(resolvedSchema, 'boolean')) {
|
|
2010
2015
|
return false;
|
|
2011
2016
|
}
|
|
2012
|
-
|
|
2017
|
+
if (hasType(resolvedSchema, 'array')) {
|
|
2013
2018
|
return [];
|
|
2014
2019
|
}
|
|
2015
|
-
|
|
2020
|
+
if (hasType(resolvedSchema, 'object')) {
|
|
2016
2021
|
return extractDefaults(resolvedSchema, rootSchema);
|
|
2017
2022
|
}
|
|
2018
|
-
|
|
2023
|
+
if (hasType(resolvedSchema, 'null')) {
|
|
2019
2024
|
return null;
|
|
2020
2025
|
}
|
|
2021
|
-
|
|
2022
|
-
|
|
2026
|
+
const combinators = ['oneOf', 'anyOf', 'allOf'];
|
|
2027
|
+
for (const combinator of combinators) {
|
|
2028
|
+
if (schema[combinator] && Array.isArray(schema[combinator])) {
|
|
2029
|
+
const combinatorDefault = createDefaultValueForCombinatorSchema(schema[combinator], rootSchema);
|
|
2030
|
+
if (combinatorDefault !== undefined) {
|
|
2031
|
+
return combinatorDefault;
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
return undefined;
|
|
2036
|
+
};
|
|
2037
|
+
const createDefaultValueForCombinatorSchema = (combinatorSchemas, rootSchema) => {
|
|
2038
|
+
if (combinatorSchemas.length > 0) {
|
|
2039
|
+
for (const combinatorSchema of combinatorSchemas) {
|
|
2040
|
+
const result = doCreateDefaultValue(combinatorSchema, rootSchema);
|
|
2041
|
+
if (result !== undefined) {
|
|
2042
|
+
return result;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2023
2045
|
}
|
|
2046
|
+
return undefined;
|
|
2024
2047
|
};
|
|
2025
2048
|
const extractDefaults = (schema, rootSchema) => {
|
|
2026
2049
|
if (hasType(schema, 'object') && schema.default === undefined) {
|
|
@@ -2030,10 +2053,25 @@ const extractDefaults = (schema, rootSchema) => {
|
|
|
2030
2053
|
const resolvedProperty = property.$ref
|
|
2031
2054
|
? Resolve.schema(rootSchema, property.$ref, rootSchema)
|
|
2032
2055
|
: property;
|
|
2033
|
-
if (resolvedProperty.default !== undefined) {
|
|
2056
|
+
if (resolvedProperty && resolvedProperty.default !== undefined) {
|
|
2034
2057
|
result[key] = cloneDeep(resolvedProperty.default);
|
|
2035
2058
|
}
|
|
2036
2059
|
}
|
|
2060
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
2061
|
+
schema.allOf.forEach((allOfSchema) => {
|
|
2062
|
+
if (allOfSchema && allOfSchema.properties) {
|
|
2063
|
+
for (const key in allOfSchema.properties) {
|
|
2064
|
+
const property = allOfSchema.properties[key];
|
|
2065
|
+
const resolvedProperty = property.$ref
|
|
2066
|
+
? Resolve.schema(rootSchema, property.$ref, rootSchema)
|
|
2067
|
+
: property;
|
|
2068
|
+
if (resolvedProperty && resolvedProperty.default !== undefined) {
|
|
2069
|
+
result[key] = cloneDeep(resolvedProperty.default);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
}
|
|
2037
2075
|
return result;
|
|
2038
2076
|
}
|
|
2039
2077
|
return cloneDeep(schema.default);
|
|
@@ -2192,6 +2230,7 @@ const mapStateToArrayControlProps = (state, ownProps) => {
|
|
|
2192
2230
|
path,
|
|
2193
2231
|
uischema,
|
|
2194
2232
|
schema: resolvedSchema,
|
|
2233
|
+
arraySchema: schema,
|
|
2195
2234
|
childErrors,
|
|
2196
2235
|
renderers: ownProps.renderers || getRenderers(state),
|
|
2197
2236
|
cells: ownProps.cells || getCells(state),
|
|
@@ -2378,6 +2417,7 @@ const mapStateToArrayLayoutProps = (state, ownProps) => {
|
|
|
2378
2417
|
path,
|
|
2379
2418
|
uischema,
|
|
2380
2419
|
schema: resolvedSchema,
|
|
2420
|
+
arraySchema: schema,
|
|
2381
2421
|
data: props.data ? props.data.length : 0,
|
|
2382
2422
|
errors: allErrors,
|
|
2383
2423
|
minItems: schema.minItems,
|
|
@@ -2518,5 +2558,5 @@ const createCombinatorRenderInfos = (combinatorSubSchemas, rootSchema, keyword,
|
|
|
2518
2558
|
};
|
|
2519
2559
|
});
|
|
2520
2560
|
|
|
2521
|
-
export { ADD_CELL, ADD_DEFAULT_DATA, ADD_RENDERER, ADD_UI_SCHEMA, index$1 as Actions, ArrayTranslationEnum, CombinatorTranslationEnum, Draft4, Generate, Helpers, INIT, NOT_APPLICABLE, Paths, REMOVE_CELL, REMOVE_DEFAULT_DATA, REMOVE_RENDERER, REMOVE_UI_SCHEMA, Resolve, RuleEffect, Runtime, SET_AJV, SET_CONFIG, SET_LOCALE, SET_SCHEMA, SET_TRANSLATOR, SET_UISCHEMA, SET_VALIDATION_MODE, index as Test, UPDATE_CORE, UPDATE_DATA, UPDATE_ERRORS, UPDATE_I18N, VALIDATE, addI18nKeyToPrefix, and, arrayDefaultTranslations, categorizationHasCategory, cellReducer, clearAllIds, combinatorDefaultTranslations, compose, compose as composePaths, composeWithUi, computeChildLabel, computeLabel, configReducer, controlDefaultProps, convertDateToString, convertToValidClassName, coreReducer, createAjv, createCleanLabel, createCombinatorRenderInfos, createControlElement, createDefaultValue, createId, createLabelDescriptionFrom, decode, defaultDataReducer, defaultDateFormat, defaultDateTimeFormat, defaultErrorTranslator, defaultJsonFormsI18nState, defaultMapDispatchToControlProps, defaultMapStateToEnumCellProps, defaultMiddleware, defaultTimeFormat, defaultTranslator, deriveLabelForUISchemaElement, deriveTypes, encode, enumToEnumOptionMapper, errorAt, errorsAt, evalEnablement, evalVisibility, extractAjv, extractData, extractDefaultData, extractDefaults, extractSchema, extractUiSchema, fetchErrorTranslator, fetchLocale, fetchTranslator, findAllRefs, findMatchingUISchema, findUISchema, findUiControl, formatErrorMessage, formatIs, generateDefaultUISchema, generateJsonSchema, getAdditionalErrors, getAjv, getArrayTranslations, getCells, getCombinatorTranslations, getCombinedErrorMessage, getConfig, getControlPath, getData, getDefaultData, getErrorAt, getErrorTranslator, getFirstPrimitiveProp, getI18nKey, getI18nKeyPrefix, getI18nKeyPrefixBySchema, getLocale, getOrCreateAjv, getPropPath, getRenderers, getSchema, getSubErrorsAt, getTranslator, getUISchemas, getUiSchema, getValidationMode, hasCategory, hasEnableRule, hasOption, hasShowRule, hasType, i18nReducer, init, initState, isAllOfControl, isAnyOfControl, isArrayObjectControl, isBooleanControl, isCategorization, isCategory, isControl, isControlElement, isDateControl, isDateTimeControl, isDescriptionHidden, isEnabled, isEnumControl, isEnumSchema, isGroup, isInherentlyEnabled, isIntegerControl, isInternationalized, isLabelable, isLabeled, isLayout, isMultiLineControl, isNumberControl, isNumberFormatControl, isObjectArray, isObjectArrayControl, isObjectArrayWithNesting, isObjectControl, isOneOfControl, isOneOfEnumControl, isOneOfEnumSchema, isPrimitiveArrayControl, isRangeControl, isScopable, isScoped, isStringControl, isTimeControl, isUpdateArrayContext, isVisible, iterateSchema, jsonFormsReducerConfig, layoutDefaultProps, mapDispatchToArrayControlProps, mapDispatchToCellProps, mapDispatchToControlProps, mapDispatchToMultiEnumProps, mapStateToAllOfProps, mapStateToAnyOfProps, mapStateToArrayControlProps, mapStateToArrayLayoutProps, mapStateToCellProps, mapStateToCombinatorRendererProps, mapStateToControlProps, mapStateToControlWithDetailProps, mapStateToDispatchCellProps, mapStateToEnumControlProps, mapStateToJsonFormsRendererProps, mapStateToLabelProps, mapStateToLayoutProps, mapStateToMasterListItemProps, mapStateToMultiEnumControlProps, mapStateToOneOfEnumCellProps, mapStateToOneOfEnumControlProps, mapStateToOneOfProps, moveDown, moveUp, not, oneOfToEnumOptionMapper, optionIs, or, rankWith, registerCell, registerDefaultData, registerRenderer, registerUISchema, removeId, rendererReducer, resolveData, resolveSchema, schemaMatches, schemaSubPathMatches, schemaTypeIs, scopeEndIs, scopeEndsWith, setAjv, setConfig, setLocale, setReadonly, setSchema, setTranslator, setUISchema, setValidationMode, showAsRequired, subErrorsAt, toDataPath, toDataPathSegments, transformPathToI18nPrefix, uiTypeIs, uischemaRegistryReducer, unregisterCell, unregisterDefaultData, unregisterRenderer, unregisterUISchema, unsetReadonly, update, updateCore, updateErrors, updateI18n, validate, withIncreasedRank };
|
|
2561
|
+
export { ADD_CELL, ADD_DEFAULT_DATA, ADD_RENDERER, ADD_UI_SCHEMA, index$1 as Actions, ArrayTranslationEnum, CombinatorTranslationEnum, Draft4, Generate, Helpers, INIT, NOT_APPLICABLE, Paths, REMOVE_CELL, REMOVE_DEFAULT_DATA, REMOVE_RENDERER, REMOVE_UI_SCHEMA, Resolve, RuleEffect, Runtime, SET_AJV, SET_CONFIG, SET_LOCALE, SET_SCHEMA, SET_TRANSLATOR, SET_UISCHEMA, SET_VALIDATION_MODE, index as Test, UPDATE_CORE, UPDATE_DATA, UPDATE_ERRORS, UPDATE_I18N, VALIDATE, addI18nKeyToPrefix, and, arrayDefaultTranslations, categorizationHasCategory, cellReducer, clearAllIds, combinatorDefaultTranslations, compose, compose as composePaths, composeWithUi, computeChildLabel, computeLabel, configReducer, controlDefaultProps, convertDateToString, convertToValidClassName, coreReducer, createAjv, createCleanLabel, createCombinatorRenderInfos, createControlElement, createDefaultValue, createId, createLabelDescriptionFrom, decode, defaultDataReducer, defaultDateFormat, defaultDateTimeFormat, defaultErrorTranslator, defaultJsonFormsI18nState, defaultMapDispatchToControlProps, defaultMapStateToEnumCellProps, defaultMiddleware, defaultTimeFormat, defaultTranslator, deriveLabelForUISchemaElement, deriveTypes, doCreateDefaultValue, encode, enumToEnumOptionMapper, errorAt, errorsAt, evalEnablement, evalVisibility, extractAjv, extractData, extractDefaultData, extractDefaults, extractSchema, extractUiSchema, fetchErrorTranslator, fetchLocale, fetchTranslator, findAllRefs, findMatchingUISchema, findUISchema, findUiControl, formatErrorMessage, formatIs, generateDefaultUISchema, generateJsonSchema, getAdditionalErrors, getAjv, getArrayTranslations, getCells, getCombinatorTranslations, getCombinedErrorMessage, getConfig, getControlPath, getData, getDefaultData, getErrorAt, getErrorTranslator, getFirstPrimitiveProp, getI18nKey, getI18nKeyPrefix, getI18nKeyPrefixBySchema, getLocale, getOrCreateAjv, getPropPath, getRenderers, getSchema, getSubErrorsAt, getTranslator, getUISchemas, getUiSchema, getValidationMode, hasCategory, hasEnableRule, hasOption, hasShowRule, hasType, i18nReducer, init, initState, isAllOfControl, isAnyOfControl, isArrayObjectControl, isBooleanControl, isCategorization, isCategory, isControl, isControlElement, isDateControl, isDateTimeControl, isDescriptionHidden, isEnabled, isEnumControl, isEnumSchema, isGroup, isInherentlyEnabled, isIntegerControl, isInternationalized, isLabelable, isLabeled, isLayout, isMultiLineControl, isNumberControl, isNumberFormatControl, isObjectArray, isObjectArrayControl, isObjectArrayWithNesting, isObjectControl, isOneOfControl, isOneOfEnumControl, isOneOfEnumSchema, isPrimitiveArrayControl, isRangeControl, isScopable, isScoped, isStringControl, isTimeControl, isUpdateArrayContext, isVisible, iterateSchema, jsonFormsReducerConfig, layoutDefaultProps, mapDispatchToArrayControlProps, mapDispatchToCellProps, mapDispatchToControlProps, mapDispatchToMultiEnumProps, mapStateToAllOfProps, mapStateToAnyOfProps, mapStateToArrayControlProps, mapStateToArrayLayoutProps, mapStateToCellProps, mapStateToCombinatorRendererProps, mapStateToControlProps, mapStateToControlWithDetailProps, mapStateToDispatchCellProps, mapStateToEnumControlProps, mapStateToJsonFormsRendererProps, mapStateToLabelProps, mapStateToLayoutProps, mapStateToMasterListItemProps, mapStateToMultiEnumControlProps, mapStateToOneOfEnumCellProps, mapStateToOneOfEnumControlProps, mapStateToOneOfProps, moveDown, moveUp, not, oneOfToEnumOptionMapper, optionIs, or, rankWith, registerCell, registerDefaultData, registerRenderer, registerUISchema, removeId, rendererReducer, resolveData, resolveSchema, schemaMatches, schemaSubPathMatches, schemaTypeIs, scopeEndIs, scopeEndsWith, setAjv, setConfig, setLocale, setReadonly, setSchema, setTranslator, setUISchema, setValidationMode, showAsRequired, subErrorsAt, toDataPath, toDataPathSegments, transformPathToI18nPrefix, uiTypeIs, uischemaRegistryReducer, unregisterCell, unregisterDefaultData, unregisterRenderer, unregisterUISchema, unsetReadonly, update, updateCore, updateErrors, updateI18n, validate, withIncreasedRank };
|
|
2522
2562
|
//# sourceMappingURL=jsonforms-core.esm.js.map
|