@jsonforms/core
Advanced tools
Comparing version 3.1.0 to 3.1.1-alpha.0
@@ -5,2 +5,3 @@ import type { ErrorObject } from 'ajv'; | ||
import { ArrayDefaultTranslation, ArrayTranslations } from './arrayTranslations'; | ||
import { CombinatorDefaultTranslation, CombinatorTranslations } from './combinatorTranslations'; | ||
export declare const getI18nKeyPrefixBySchema: (schema: i18nJsonSchema | undefined, uischema: unknown | undefined) => string | undefined; | ||
@@ -28,1 +29,2 @@ /** | ||
export declare const getArrayTranslations: (t: Translator, defaultTranslations: ArrayDefaultTranslation[], i18nKeyPrefix: string, label: string) => ArrayTranslations; | ||
export declare const getCombinatorTranslations: (t: Translator, defaultTranslations: CombinatorDefaultTranslation[], i18nKeyPrefix: string, label: string) => CombinatorTranslations; |
export * from './i18nTypes'; | ||
export * from './i18nUtil'; | ||
export * from './arrayTranslations'; | ||
export * from './combinatorTranslations'; |
@@ -9,3 +9,3 @@ import { ControlElement, JsonSchema, LabelElement, UISchemaElement } from '../models'; | ||
import type { JsonFormsState } from '../store'; | ||
import { Translator } from '../i18n'; | ||
import { Translator, CombinatorTranslations } from '../i18n'; | ||
import { ArrayTranslations } from '../i18n/arrayTranslations'; | ||
@@ -379,2 +379,3 @@ /** | ||
data: any; | ||
translations: CombinatorTranslations; | ||
} | ||
@@ -381,0 +382,0 @@ export declare const mapStateToCombinatorRendererProps: (state: JsonFormsState, ownProps: OwnPropsOfControl, keyword: CombinatorKeyword) => StatePropsOfCombinator; |
{ | ||
"name": "@jsonforms/core", | ||
"version": "3.1.0", | ||
"version": "3.1.1-alpha.0", | ||
"description": "Core module of JSON Forms", | ||
@@ -47,3 +47,3 @@ "repository": "https://github.com/eclipsesource/jsonforms", | ||
"test-cov": "rimraf -rf .nyc_output && cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\",\\\"target\\\":\\\"es5\\\"} nyc ava", | ||
"doc": "typedoc --name 'JSON Forms Core' --mode file --excludeExternals --theme ../../typedoc-jsonforms --out docs src" | ||
"doc": "typedoc --name 'JSON Forms Core' --excludeExternals --theme ../../typedoc-jsonforms --out docs src" | ||
}, | ||
@@ -73,3 +73,3 @@ "ava": { | ||
"ajv-formats": "^2.1.0", | ||
"lodash": "^4.17.15" | ||
"lodash": "^4.17.21" | ||
}, | ||
@@ -88,3 +88,3 @@ "devDependencies": { | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"jsdom": "^15.2.1", | ||
"jsdom": "^22.0.0", | ||
"jsdom-global": "^3.0.2", | ||
@@ -98,10 +98,11 @@ "nyc": "^15.1.0", | ||
"rollup-plugin-cleanup": "^3.2.1", | ||
"rollup-plugin-typescript2": "^0.31.1", | ||
"rollup-plugin-typescript2": "^0.34.1", | ||
"rollup-plugin-visualizer": "^5.4.1", | ||
"source-map-support": "0.5.16", | ||
"ts-node": "^10.4.0", | ||
"typedoc": "^0.19.2", | ||
"tslib": "^2.5.0", | ||
"typedoc": "~0.21.9", | ||
"typescript": "4.2.3" | ||
}, | ||
"gitHead": "7e0115feeced7711b0768d325566aaa6b054c32b" | ||
"gitHead": "071b32056d62e9548fb2b300a3a173cdbcb5b69a" | ||
} |
@@ -10,2 +10,6 @@ import type { ErrorObject } from 'ajv'; | ||
} from './arrayTranslations'; | ||
import { | ||
CombinatorDefaultTranslation, | ||
CombinatorTranslations, | ||
} from './combinatorTranslations'; | ||
@@ -177,1 +181,15 @@ export const getI18nKeyPrefixBySchema = ( | ||
}; | ||
export const getCombinatorTranslations = ( | ||
t: Translator, | ||
defaultTranslations: CombinatorDefaultTranslation[], | ||
i18nKeyPrefix: string, | ||
label: string | ||
): CombinatorTranslations => { | ||
const translations: CombinatorTranslations = {}; | ||
defaultTranslations.forEach((controlElement) => { | ||
const key = addI18nKeyToPrefix(i18nKeyPrefix, controlElement.key); | ||
translations[controlElement.key] = t(key, controlElement.default(label)); | ||
}); | ||
return translations; | ||
}; |
export * from './i18nTypes'; | ||
export * from './i18nUtil'; | ||
export * from './arrayTranslations'; | ||
export * from './combinatorTranslations'; |
@@ -28,2 +28,3 @@ /* | ||
import setFp from 'lodash/fp/set'; | ||
import unsetFp from 'lodash/fp/unset'; | ||
import get from 'lodash/get'; | ||
@@ -289,7 +290,15 @@ import filter from 'lodash/filter'; | ||
const newData = action.updater(cloneDeep(oldData)); | ||
const newState: any = setFp( | ||
action.path, | ||
newData, | ||
state.data === undefined ? {} : state.data | ||
); | ||
let newState: any; | ||
if (newData !== undefined) { | ||
newState = setFp( | ||
action.path, | ||
newData, | ||
state.data === undefined ? {} : state.data | ||
); | ||
} else { | ||
newState = unsetFp( | ||
action.path, | ||
state.data === undefined ? {} : state.data | ||
); | ||
} | ||
const errors = validate(state.validator, newState); | ||
@@ -296,0 +305,0 @@ return { |
@@ -73,2 +73,5 @@ /* | ||
Translator, | ||
CombinatorTranslations, | ||
getCombinatorTranslations, | ||
combinatorDefaultTranslations, | ||
} from '../i18n'; | ||
@@ -974,2 +977,3 @@ import { | ||
data: any; | ||
translations: CombinatorTranslations; | ||
} | ||
@@ -982,8 +986,13 @@ | ||
): StatePropsOfCombinator => { | ||
const { data, schema, rootSchema, ...props } = mapStateToControlProps( | ||
state, | ||
ownProps | ||
); | ||
const { data, schema, rootSchema, i18nKeyPrefix, label, ...props } = | ||
mapStateToControlProps(state, ownProps); | ||
const ajv = state.jsonforms.core.ajv; | ||
const t = getTranslator()(state); | ||
const translations = getCombinatorTranslations( | ||
t, | ||
combinatorDefaultTranslations, | ||
i18nKeyPrefix, | ||
label | ||
); | ||
const structuralKeywords = [ | ||
@@ -1031,4 +1040,7 @@ 'required', | ||
...props, | ||
i18nKeyPrefix, | ||
label, | ||
indexOfFittingSchema, | ||
uischemas: getUISchemas(state), | ||
translations, | ||
}; | ||
@@ -1035,0 +1047,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 too big to display
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
1022661
105
13330
27
1
Updatedlodash@^4.17.21