@jsonforms/core 3.4.1-beta.0 → 3.5.0-beta.0
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 +56 -15
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +51 -11
- 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
|
@@ -2189,7 +2189,13 @@ var showAsRequired = function (required, hideRequiredAsterisk) {
|
|
|
2189
2189
|
return required && !hideRequiredAsterisk;
|
|
2190
2190
|
};
|
|
2191
2191
|
var createDefaultValue = function (schema, rootSchema) {
|
|
2192
|
-
var
|
|
2192
|
+
var defaultValue = doCreateDefaultValue(schema, rootSchema);
|
|
2193
|
+
return defaultValue === undefined ? {} : defaultValue;
|
|
2194
|
+
};
|
|
2195
|
+
var doCreateDefaultValue = function (schema, rootSchema) {
|
|
2196
|
+
var resolvedSchema = typeof schema.$ref === 'string'
|
|
2197
|
+
? Resolve.schema(rootSchema, schema.$ref, rootSchema)
|
|
2198
|
+
: schema;
|
|
2193
2199
|
if (resolvedSchema.default !== undefined) {
|
|
2194
2200
|
return extractDefaults(resolvedSchema, rootSchema);
|
|
2195
2201
|
}
|
|
@@ -2201,39 +2207,73 @@ var createDefaultValue = function (schema, rootSchema) {
|
|
|
2201
2207
|
}
|
|
2202
2208
|
return '';
|
|
2203
2209
|
}
|
|
2204
|
-
|
|
2205
|
-
hasType(resolvedSchema, 'number')) {
|
|
2210
|
+
if (hasType(resolvedSchema, 'integer') || hasType(resolvedSchema, 'number')) {
|
|
2206
2211
|
return 0;
|
|
2207
2212
|
}
|
|
2208
|
-
|
|
2213
|
+
if (hasType(resolvedSchema, 'boolean')) {
|
|
2209
2214
|
return false;
|
|
2210
2215
|
}
|
|
2211
|
-
|
|
2216
|
+
if (hasType(resolvedSchema, 'array')) {
|
|
2212
2217
|
return [];
|
|
2213
2218
|
}
|
|
2214
|
-
|
|
2219
|
+
if (hasType(resolvedSchema, 'object')) {
|
|
2215
2220
|
return extractDefaults(resolvedSchema, rootSchema);
|
|
2216
2221
|
}
|
|
2217
|
-
|
|
2222
|
+
if (hasType(resolvedSchema, 'null')) {
|
|
2218
2223
|
return null;
|
|
2219
2224
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2225
|
+
var combinators = ['oneOf', 'anyOf', 'allOf'];
|
|
2226
|
+
for (var _i = 0, combinators_1 = combinators; _i < combinators_1.length; _i++) {
|
|
2227
|
+
var combinator = combinators_1[_i];
|
|
2228
|
+
if (schema[combinator] && Array.isArray(schema[combinator])) {
|
|
2229
|
+
var combinatorDefault = createDefaultValueForCombinatorSchema(schema[combinator], rootSchema);
|
|
2230
|
+
if (combinatorDefault !== undefined) {
|
|
2231
|
+
return combinatorDefault;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return undefined;
|
|
2236
|
+
};
|
|
2237
|
+
var createDefaultValueForCombinatorSchema = function (combinatorSchemas, rootSchema) {
|
|
2238
|
+
if (combinatorSchemas.length > 0) {
|
|
2239
|
+
for (var _i = 0, combinatorSchemas_1 = combinatorSchemas; _i < combinatorSchemas_1.length; _i++) {
|
|
2240
|
+
var combinatorSchema = combinatorSchemas_1[_i];
|
|
2241
|
+
var result = doCreateDefaultValue(combinatorSchema, rootSchema);
|
|
2242
|
+
if (result !== undefined) {
|
|
2243
|
+
return result;
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2222
2246
|
}
|
|
2247
|
+
return undefined;
|
|
2223
2248
|
};
|
|
2224
2249
|
var extractDefaults = function (schema, rootSchema) {
|
|
2225
2250
|
if (hasType(schema, 'object') && schema.default === undefined) {
|
|
2226
|
-
var
|
|
2251
|
+
var result_1 = {};
|
|
2227
2252
|
for (var key in schema.properties) {
|
|
2228
2253
|
var property = schema.properties[key];
|
|
2229
2254
|
var resolvedProperty = property.$ref
|
|
2230
2255
|
? Resolve.schema(rootSchema, property.$ref, rootSchema)
|
|
2231
2256
|
: property;
|
|
2232
|
-
if (resolvedProperty.default !== undefined) {
|
|
2233
|
-
|
|
2257
|
+
if (resolvedProperty && resolvedProperty.default !== undefined) {
|
|
2258
|
+
result_1[key] = cloneDeep__default["default"](resolvedProperty.default);
|
|
2234
2259
|
}
|
|
2235
2260
|
}
|
|
2236
|
-
|
|
2261
|
+
if (schema.allOf && Array.isArray(schema.allOf)) {
|
|
2262
|
+
schema.allOf.forEach(function (allOfSchema) {
|
|
2263
|
+
if (allOfSchema && allOfSchema.properties) {
|
|
2264
|
+
for (var key in allOfSchema.properties) {
|
|
2265
|
+
var property = allOfSchema.properties[key];
|
|
2266
|
+
var resolvedProperty = property.$ref
|
|
2267
|
+
? Resolve.schema(rootSchema, property.$ref, rootSchema)
|
|
2268
|
+
: property;
|
|
2269
|
+
if (resolvedProperty && resolvedProperty.default !== undefined) {
|
|
2270
|
+
result_1[key] = cloneDeep__default["default"](resolvedProperty.default);
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
2276
|
+
return result_1;
|
|
2237
2277
|
}
|
|
2238
2278
|
return cloneDeep__default["default"](schema.default);
|
|
2239
2279
|
};
|
|
@@ -2383,7 +2423,7 @@ var mapStateToArrayControlProps = function (state, ownProps) {
|
|
|
2383
2423
|
var _a = mapStateToControlWithDetailProps(state, ownProps), path = _a.path, schema = _a.schema, uischema = _a.uischema, label = _a.label, props = __rest(_a, ["path", "schema", "uischema", "label"]);
|
|
2384
2424
|
var resolvedSchema = Resolve.schema(schema, 'items', props.rootSchema);
|
|
2385
2425
|
var childErrors = getSubErrorsAt(path, resolvedSchema)(state);
|
|
2386
|
-
return __assign(__assign({}, props), { label: label, path: path, uischema: uischema, schema: resolvedSchema, childErrors: childErrors, renderers: ownProps.renderers || getRenderers(state), cells: ownProps.cells || getCells(state) });
|
|
2426
|
+
return __assign(__assign({}, props), { label: label, path: path, uischema: uischema, schema: resolvedSchema, arraySchema: schema, childErrors: childErrors, renderers: ownProps.renderers || getRenderers(state), cells: ownProps.cells || getCells(state) });
|
|
2387
2427
|
};
|
|
2388
2428
|
var mapDispatchToArrayControlProps = function (dispatch) { return ({
|
|
2389
2429
|
addItem: function (path, value) { return function () {
|
|
@@ -2539,7 +2579,7 @@ var mapStateToArrayLayoutProps = function (state, ownProps) {
|
|
|
2539
2579
|
var allErrors = errors +
|
|
2540
2580
|
(errors.length > 0 && childErrors.length > 0 ? '\n' : '') +
|
|
2541
2581
|
childErrors;
|
|
2542
|
-
return __assign(__assign({}, props), { label: label, path: path, uischema: uischema, schema: resolvedSchema, data: props.data ? props.data.length : 0, errors: allErrors, minItems: schema.minItems });
|
|
2582
|
+
return __assign(__assign({}, props), { label: label, path: path, uischema: uischema, schema: resolvedSchema, arraySchema: schema, data: props.data ? props.data.length : 0, errors: allErrors, minItems: schema.minItems });
|
|
2543
2583
|
};
|
|
2544
2584
|
var mapStateToLabelProps = function (state, props) {
|
|
2545
2585
|
var uischema = props.uischema;
|
|
@@ -2742,6 +2782,7 @@ exports.defaultTimeFormat = defaultTimeFormat;
|
|
|
2742
2782
|
exports.defaultTranslator = defaultTranslator;
|
|
2743
2783
|
exports.deriveLabelForUISchemaElement = deriveLabelForUISchemaElement;
|
|
2744
2784
|
exports.deriveTypes = deriveTypes;
|
|
2785
|
+
exports.doCreateDefaultValue = doCreateDefaultValue;
|
|
2745
2786
|
exports.encode = encode;
|
|
2746
2787
|
exports.enumToEnumOptionMapper = enumToEnumOptionMapper;
|
|
2747
2788
|
exports.errorAt = errorAt;
|