@jsonforms/core 3.1.0-beta.1 → 3.1.1-alpha.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/i18n/combinatorTranslations.d.ts +14 -0
- package/lib/i18n/i18nUtil.d.ts +2 -0
- package/lib/i18n/index.d.ts +1 -0
- package/lib/jsonforms-core.cjs.js +45 -3
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +43 -3
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/util/renderer.d.ts +2 -1
- package/package.json +8 -7
- package/src/i18n/combinatorTranslations.ts +28 -0
- package/src/i18n/i18nUtil.ts +18 -0
- package/src/i18n/index.ts +1 -0
- package/src/reducers/core.ts +14 -5
- package/src/util/renderer.ts +16 -4
|
@@ -4,6 +4,7 @@ import keys from 'lodash/keys';
|
|
|
4
4
|
import merge from 'lodash/merge';
|
|
5
5
|
import cloneDeep from 'lodash/cloneDeep';
|
|
6
6
|
import setFp from 'lodash/fp/set';
|
|
7
|
+
import unsetFp from 'lodash/fp/unset';
|
|
7
8
|
import get from 'lodash/get';
|
|
8
9
|
import filter from 'lodash/filter';
|
|
9
10
|
import isEqual from 'lodash/isEqual';
|
|
@@ -529,7 +530,13 @@ const coreReducer = (state = initState, action) => {
|
|
|
529
530
|
else {
|
|
530
531
|
const oldData = get(state.data, action.path);
|
|
531
532
|
const newData = action.updater(cloneDeep(oldData));
|
|
532
|
-
|
|
533
|
+
let newState;
|
|
534
|
+
if (newData !== undefined) {
|
|
535
|
+
newState = setFp(action.path, newData, state.data === undefined ? {} : state.data);
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
newState = unsetFp(action.path, state.data === undefined ? {} : state.data);
|
|
539
|
+
}
|
|
533
540
|
const errors = validate(state.validator, newState);
|
|
534
541
|
return {
|
|
535
542
|
...state,
|
|
@@ -740,6 +747,14 @@ const getArrayTranslations = (t, defaultTranslations, i18nKeyPrefix, label) => {
|
|
|
740
747
|
});
|
|
741
748
|
return translations;
|
|
742
749
|
};
|
|
750
|
+
const getCombinatorTranslations = (t, defaultTranslations, i18nKeyPrefix, label) => {
|
|
751
|
+
const translations = {};
|
|
752
|
+
defaultTranslations.forEach((controlElement) => {
|
|
753
|
+
const key = addI18nKeyToPrefix(i18nKeyPrefix, controlElement.key);
|
|
754
|
+
translations[controlElement.key] = t(key, controlElement.default(label));
|
|
755
|
+
});
|
|
756
|
+
return translations;
|
|
757
|
+
};
|
|
743
758
|
|
|
744
759
|
var ArrayTranslationEnum;
|
|
745
760
|
(function (ArrayTranslationEnum) {
|
|
@@ -787,6 +802,26 @@ const arrayDefaultTranslations = [
|
|
|
787
802
|
{ key: ArrayTranslationEnum.deleteDialogDecline, default: () => 'No' },
|
|
788
803
|
];
|
|
789
804
|
|
|
805
|
+
var CombinatorTranslationEnum;
|
|
806
|
+
(function (CombinatorTranslationEnum) {
|
|
807
|
+
CombinatorTranslationEnum["clearDialogTitle"] = "clearDialogTitle";
|
|
808
|
+
CombinatorTranslationEnum["clearDialogMessage"] = "clearDialogMessage";
|
|
809
|
+
CombinatorTranslationEnum["clearDialogAccept"] = "clearDialogAccept";
|
|
810
|
+
CombinatorTranslationEnum["clearDialogDecline"] = "clearDialogDecline";
|
|
811
|
+
})(CombinatorTranslationEnum || (CombinatorTranslationEnum = {}));
|
|
812
|
+
const combinatorDefaultTranslations = [
|
|
813
|
+
{
|
|
814
|
+
key: CombinatorTranslationEnum.clearDialogTitle,
|
|
815
|
+
default: () => 'Clear form?',
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
key: CombinatorTranslationEnum.clearDialogMessage,
|
|
819
|
+
default: () => 'Your data will be cleared. Do you want to proceed?',
|
|
820
|
+
},
|
|
821
|
+
{ key: CombinatorTranslationEnum.clearDialogAccept, default: () => 'Yes' },
|
|
822
|
+
{ key: CombinatorTranslationEnum.clearDialogDecline, default: () => 'No' },
|
|
823
|
+
];
|
|
824
|
+
|
|
790
825
|
const defaultJsonFormsI18nState = {
|
|
791
826
|
locale: 'en',
|
|
792
827
|
translate: defaultTranslator,
|
|
@@ -1807,8 +1842,10 @@ const controlDefaultProps = {
|
|
|
1807
1842
|
errors: [],
|
|
1808
1843
|
};
|
|
1809
1844
|
const mapStateToCombinatorRendererProps = (state, ownProps, keyword) => {
|
|
1810
|
-
const { data, schema, rootSchema, ...props } = mapStateToControlProps(state, ownProps);
|
|
1845
|
+
const { data, schema, rootSchema, i18nKeyPrefix, label, ...props } = mapStateToControlProps(state, ownProps);
|
|
1811
1846
|
const ajv = state.jsonforms.core.ajv;
|
|
1847
|
+
const t = getTranslator()(state);
|
|
1848
|
+
const translations = getCombinatorTranslations(t, combinatorDefaultTranslations, i18nKeyPrefix, label);
|
|
1812
1849
|
const structuralKeywords = [
|
|
1813
1850
|
'required',
|
|
1814
1851
|
'additionalProperties',
|
|
@@ -1844,8 +1881,11 @@ const mapStateToCombinatorRendererProps = (state, ownProps, keyword) => {
|
|
|
1844
1881
|
schema,
|
|
1845
1882
|
rootSchema,
|
|
1846
1883
|
...props,
|
|
1884
|
+
i18nKeyPrefix,
|
|
1885
|
+
label,
|
|
1847
1886
|
indexOfFittingSchema,
|
|
1848
1887
|
uischemas: getUISchemas(state),
|
|
1888
|
+
translations,
|
|
1849
1889
|
};
|
|
1850
1890
|
};
|
|
1851
1891
|
const mapStateToAllOfProps = (state, ownProps) => mapStateToCombinatorRendererProps(state, ownProps, 'allOf');
|
|
@@ -2330,5 +2370,5 @@ const Helpers = {
|
|
|
2330
2370
|
convertToValidClassName,
|
|
2331
2371
|
};
|
|
2332
2372
|
|
|
2333
|
-
export { ADD_CELL, ADD_DEFAULT_DATA, ADD_RENDERER, ADD_UI_SCHEMA, index as Actions, ArrayTranslationEnum, 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$1 as Test, UPDATE_CORE, UPDATE_DATA, UPDATE_ERRORS, UPDATE_I18N, VALIDATE, addI18nKeyToPrefix, and, arrayDefaultTranslations, categorizationHasCategory, cellReducer, clearAllIds, compose, compose as composePaths, composeWithUi, computeLabel, configReducer, controlDefaultProps, convertToValidClassName, coreReducer, createAjv, createCleanLabel, createCombinatorRenderInfos, createControlElement, createDefaultValue, createId, createLabelDescriptionFrom, decode, defaultDataReducer, defaultErrorTranslator, defaultJsonFormsI18nState, defaultMapDispatchToControlProps, defaultMapStateToEnumCellProps, defaultTranslator, deriveLabelForUISchemaElement, deriveTypes, encode, enumToEnumOptionMapper, errorAt, errorsAt, evalEnablement, evalVisibility, extractAjv, extractData, extractDefaultData, extractSchema, extractUiSchema, fetchErrorTranslator, fetchLocale, fetchTranslator, findAllRefs, findMatchingUISchema, findUISchema, formatErrorMessage, formatIs, generateDefaultUISchema, generateJsonSchema, getAjv, getArrayTranslations, getCells, getCombinedErrorMessage, getConfig, getControlPath, getData, getDefaultData, getErrorAt, getErrorTranslator, getFirstPrimitiveProp, getI18nKey, getI18nKeyPrefix, getI18nKeyPrefixBySchema, getLocale, getRenderers, getSchema, getSubErrorsAt, getTranslator, getUISchemas, getUiSchema, hasCategory, hasEnableRule, hasShowRule, hasType, i18nReducer, init, isAllOfControl, isAnyOfControl, isArrayObjectControl, isBooleanControl, isCategorization, isCategory, isControl, isDateControl, isDateTimeControl, isDescriptionHidden, isEnabled, isEnumControl, isGroup, isInherentlyEnabled, isIntegerControl, isInternationalized, isLabelable, isLabeled, isLayout, isMultiLineControl, isNumberControl, isNumberFormatControl, isObjectArray, isObjectArrayControl, isObjectArrayWithNesting, isObjectControl, isOneOfControl, isOneOfEnumControl, isOneOfEnumSchema, isPrimitiveArrayControl, isRangeControl, isScopable, isScoped, isStringControl, isTimeControl, 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 };
|
|
2373
|
+
export { ADD_CELL, ADD_DEFAULT_DATA, ADD_RENDERER, ADD_UI_SCHEMA, index 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$1 as Test, UPDATE_CORE, UPDATE_DATA, UPDATE_ERRORS, UPDATE_I18N, VALIDATE, addI18nKeyToPrefix, and, arrayDefaultTranslations, categorizationHasCategory, cellReducer, clearAllIds, combinatorDefaultTranslations, compose, compose as composePaths, composeWithUi, computeLabel, configReducer, controlDefaultProps, convertToValidClassName, coreReducer, createAjv, createCleanLabel, createCombinatorRenderInfos, createControlElement, createDefaultValue, createId, createLabelDescriptionFrom, decode, defaultDataReducer, defaultErrorTranslator, defaultJsonFormsI18nState, defaultMapDispatchToControlProps, defaultMapStateToEnumCellProps, defaultTranslator, deriveLabelForUISchemaElement, deriveTypes, encode, enumToEnumOptionMapper, errorAt, errorsAt, evalEnablement, evalVisibility, extractAjv, extractData, extractDefaultData, extractSchema, extractUiSchema, fetchErrorTranslator, fetchLocale, fetchTranslator, findAllRefs, findMatchingUISchema, findUISchema, formatErrorMessage, formatIs, generateDefaultUISchema, generateJsonSchema, getAjv, getArrayTranslations, getCells, getCombinatorTranslations, getCombinedErrorMessage, getConfig, getControlPath, getData, getDefaultData, getErrorAt, getErrorTranslator, getFirstPrimitiveProp, getI18nKey, getI18nKeyPrefix, getI18nKeyPrefixBySchema, getLocale, getRenderers, getSchema, getSubErrorsAt, getTranslator, getUISchemas, getUiSchema, hasCategory, hasEnableRule, hasShowRule, hasType, i18nReducer, init, isAllOfControl, isAnyOfControl, isArrayObjectControl, isBooleanControl, isCategorization, isCategory, isControl, isDateControl, isDateTimeControl, isDescriptionHidden, isEnabled, isEnumControl, isGroup, isInherentlyEnabled, isIntegerControl, isInternationalized, isLabelable, isLabeled, isLayout, isMultiLineControl, isNumberControl, isNumberFormatControl, isObjectArray, isObjectArrayControl, isObjectArrayWithNesting, isObjectControl, isOneOfControl, isOneOfEnumControl, isOneOfEnumSchema, isPrimitiveArrayControl, isRangeControl, isScopable, isScoped, isStringControl, isTimeControl, 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 };
|
|
2334
2374
|
//# sourceMappingURL=jsonforms-core.esm.js.map
|