@jsonforms/core
Advanced tools
Comparing version 2.3.0 to 2.3.1-alpha.0
@@ -5,2 +5,3 @@ export declare const configDefault: { | ||
showUnfocusedDescription: boolean; | ||
hideRequiredAsterisk: boolean; | ||
}; |
@@ -41,4 +41,8 @@ "use strict"; | ||
*/ | ||
showUnfocusedDescription: false | ||
showUnfocusedDescription: false, | ||
/* | ||
* [text] if asterisks in labels for required fields should be hidden | ||
*/ | ||
hideRequiredAsterisk: false | ||
}; | ||
//# sourceMappingURL=configDefault.js.map |
@@ -26,3 +26,3 @@ import { JsonSchema, Scopable, UISchemaElement } from '../'; | ||
}; | ||
export { resolveData, resolveSchema, findRefs } from './resolvers'; | ||
export { resolveData, resolveSchema, findRefs, SchemaRef, SchemaRefs } from './resolvers'; | ||
export { Resolve }; | ||
@@ -29,0 +29,0 @@ declare const Paths: { |
@@ -23,3 +23,3 @@ import { ControlElement, UISchemaElement } from '../models/uischema'; | ||
*/ | ||
export declare const computeLabel: (label: string, required: boolean) => string; | ||
export declare const computeLabel: (label: string, required: boolean, hideRequiredAsterisk: boolean) => string; | ||
/** | ||
@@ -26,0 +26,0 @@ * Create a default value based on the given scheam. |
@@ -79,4 +79,4 @@ "use strict"; | ||
*/ | ||
exports.computeLabel = function (label, required) { | ||
return required ? label + '*' : label; | ||
exports.computeLabel = function (label, required, hideRequiredAsterisk) { | ||
return required && !hideRequiredAsterisk ? label + '*' : label; | ||
}; | ||
@@ -83,0 +83,0 @@ /** |
@@ -26,2 +26,14 @@ import { JsonSchema } from '..'; | ||
export declare const resolveSchema: (schema: JsonSchema, schemaPath: string, rootSchema?: JsonSchema) => JsonSchema; | ||
export declare const findRefs: (obj: any) => any; | ||
/** | ||
* Interface for describing result of an extracted schema ref | ||
*/ | ||
export interface SchemaRef { | ||
uri: string; | ||
} | ||
/** | ||
* Interface wraps SchemaRef | ||
*/ | ||
export interface SchemaRefs { | ||
[id: string]: SchemaRef; | ||
} | ||
export declare const findRefs: (obj: JsonSchema) => SchemaRefs; |
@@ -166,9 +166,4 @@ "use strict"; | ||
} | ||
// copied and adapted from JsonRefs | ||
exports.findRefs = function (obj) { | ||
var refs = {}; | ||
// Validate the provided document | ||
if (!isArray_1.default(obj) && !isObject_1.default(obj)) { | ||
throw new TypeError('obj must be an Array or an Object'); | ||
} | ||
// Walk the document (or sub document) and find all JSON References | ||
@@ -175,0 +170,0 @@ walk([], obj, [], function (_a, node, path) { |
{ | ||
"name": "@jsonforms/core", | ||
"version": "2.3.0", | ||
"version": "2.3.1-alpha.0", | ||
"description": "Core module of JSON Forms", | ||
@@ -70,3 +70,3 @@ "repository": "https://github.com/eclipsesource/jsonforms", | ||
}, | ||
"gitHead": "927e387935b3413463c3bde4cadf49ba495b20af" | ||
"gitHead": "67b4123ff5f0df73f886265b34061a36b33e7ddc" | ||
} |
@@ -41,3 +41,8 @@ /* | ||
*/ | ||
showUnfocusedDescription: false | ||
showUnfocusedDescription: false, | ||
/* | ||
* [text] if asterisks in labels for required fields should be hidden | ||
*/ | ||
hideRequiredAsterisk: false | ||
}; |
@@ -114,3 +114,9 @@ /* | ||
}; | ||
export { resolveData, resolveSchema, findRefs } from './resolvers'; | ||
export { | ||
resolveData, | ||
resolveSchema, | ||
findRefs, | ||
SchemaRef, | ||
SchemaRefs | ||
} from './resolvers'; | ||
export { Resolve }; | ||
@@ -117,0 +123,0 @@ |
@@ -108,4 +108,8 @@ /* | ||
*/ | ||
export const computeLabel = (label: string, required: boolean): string => { | ||
return required ? label + '*' : label; | ||
export const computeLabel = ( | ||
label: string, | ||
required: boolean, | ||
hideRequiredAsterisk: boolean | ||
): string => { | ||
return required && !hideRequiredAsterisk ? label + '*' : label; | ||
}; | ||
@@ -112,0 +116,0 @@ |
@@ -190,10 +190,19 @@ /* | ||
export const findRefs = (obj: any) => { | ||
const refs = {} as any; | ||
/** | ||
* Interface for describing result of an extracted schema ref | ||
*/ | ||
export interface SchemaRef { | ||
uri: string; | ||
} | ||
// Validate the provided document | ||
if (!isArray(obj) && !isObject(obj)) { | ||
throw new TypeError('obj must be an Array or an Object'); | ||
} | ||
/** | ||
* Interface wraps SchemaRef | ||
*/ | ||
export interface SchemaRefs { | ||
[id: string]: SchemaRef; | ||
} | ||
export const findRefs = (obj: JsonSchema): SchemaRefs => { | ||
const refs: SchemaRefs = {}; | ||
// Walk the document (or sub document) and find all JSON References | ||
@@ -200,0 +209,0 @@ walk([], obj, [], ({}, node: any, path: any) => { |
@@ -38,3 +38,4 @@ /* | ||
mapStateToArrayLayoutProps, | ||
mapStateToOneOfProps | ||
mapStateToOneOfProps, | ||
computeLabel | ||
} from '../../src/util'; | ||
@@ -848,1 +849,21 @@ import configureStore from 'redux-mock-store'; | ||
}); | ||
test('computeLabel - should not edit label if not required and hideRequiredAsterisk is false', t => { | ||
const computedLabel = computeLabel('Test Label', false, false); | ||
t.is(computedLabel, 'Test Label'); | ||
}); | ||
test('computeLabel - should not edit label if not required and hideRequiredAsterisk is true', t => { | ||
const computedLabel = computeLabel('Test Label', false, true); | ||
t.is(computedLabel, 'Test Label'); | ||
}); | ||
test('computeLabel - should not edit label if required but hideRequiredAsterisk is true', t => { | ||
const computedLabel = computeLabel('Test Label', true, true); | ||
t.is(computedLabel, 'Test Label'); | ||
}); | ||
test('computeLabel - should add asterisk if required but hideRequiredAsterisk is false', t => { | ||
const computedLabel = computeLabel('Test Label', true, false); | ||
t.is(computedLabel, 'Test Label*'); | ||
}); |
@@ -35,4 +35,7 @@ /* | ||
const refObject = { | ||
myitem: { | ||
$ref: 'http://myref.com/ref' | ||
type: 'object', | ||
properties: { | ||
myitem: { | ||
$ref: 'http://myref.com/ref' | ||
} | ||
} | ||
@@ -39,0 +42,0 @@ }; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5580678
259
17849
3