Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsonforms/react

Package Overview
Dependencies
Maintainers
6
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsonforms/react - npm Package Compare versions

Comparing version 3.1.0-alpha.1 to 3.1.0-alpha.2

2

lib/DispatchCell.d.ts

@@ -6,3 +6,3 @@ import React from 'react';

*/
export declare const Dispatch: ({ uischema, schema, rootSchema, path, cells, id, enabled, renderers, config }: DispatchCellProps) => JSX.Element;
export declare const Dispatch: ({ uischema, schema, rootSchema, path, cells, id, enabled, renderers, config, }: DispatchCellProps) => JSX.Element;
export declare const DispatchCell: React.ComponentType<import("@jsonforms/core").OwnPropsOfCell>;

@@ -95,3 +95,3 @@ 'use strict';

value: props.data ? props.data : '',
isFocused: false
isFocused: false,
};

@@ -128,3 +128,3 @@ return _this;

core: initialCoreState,
renderers: []
renderers: [],
});

@@ -145,7 +145,19 @@ var useEffectAfterFirstRender = function (effect, dependencies) {

var _e = initState.core, data = _e.data, schema = _e.schema, uischema = _e.uischema, ajv = _e.ajv, validationMode = _e.validationMode, additionalErrors = _e.additionalErrors;
var _f = React.useReducer(core.coreReducer, undefined, function () { return core.coreReducer(initState.core, core.Actions.init(data, schema, uischema, { ajv: ajv, validationMode: validationMode, additionalErrors: additionalErrors })); }), core$1 = _f[0], coreDispatch = _f[1];
var _f = React.useReducer(core.coreReducer, undefined, function () {
return core.coreReducer(initState.core, core.Actions.init(data, schema, uischema, {
ajv: ajv,
validationMode: validationMode,
additionalErrors: additionalErrors,
}));
}), core$1 = _f[0], coreDispatch = _f[1];
React.useEffect(function () {
coreDispatch(core.Actions.updateCore(data, schema, uischema, { ajv: ajv, validationMode: validationMode, additionalErrors: additionalErrors }));
coreDispatch(core.Actions.updateCore(data, schema, uischema, {
ajv: ajv,
validationMode: validationMode,
additionalErrors: additionalErrors,
}));
}, [data, schema, uischema, ajv, validationMode, additionalErrors]);
var _g = React.useReducer(core.configReducer, undefined, function () { return core.configReducer(undefined, core.Actions.setConfig(initState.config)); }), config = _g[0], configDispatch = _g[1];
var _g = React.useReducer(core.configReducer, undefined, function () {
return core.configReducer(undefined, core.Actions.setConfig(initState.config));
}), config = _g[0], configDispatch = _g[1];
useEffectAfterFirstRender(function () {

@@ -161,3 +173,7 @@ configDispatch(core.Actions.setConfig(initState.config));

i18nDispatch(core.Actions.updateI18n((_a = initState.i18n) === null || _a === void 0 ? void 0 : _a.locale, (_b = initState.i18n) === null || _b === void 0 ? void 0 : _b.translate, (_c = initState.i18n) === null || _c === void 0 ? void 0 : _c.translateError));
}, [(_b = initState.i18n) === null || _b === void 0 ? void 0 : _b.locale, (_c = initState.i18n) === null || _c === void 0 ? void 0 : _c.translate, (_d = initState.i18n) === null || _d === void 0 ? void 0 : _d.translateError]);
}, [
(_b = initState.i18n) === null || _b === void 0 ? void 0 : _b.locale,
(_c = initState.i18n) === null || _c === void 0 ? void 0 : _c.translate,
(_d = initState.i18n) === null || _d === void 0 ? void 0 : _d.translateError,
]);
var contextValue = React.useMemo(function () { return ({

@@ -172,3 +188,11 @@ core: core$1,

dispatch: coreDispatch,
}); }, [core$1, initState.renderers, initState.cells, config, initState.uischemas, initState.readonly, i18n]);
}); }, [
core$1,
initState.renderers,
initState.cells,
config,
initState.uischemas,
initState.readonly,
i18n,
]);
var onChangeRef = React.useRef(onChange);

@@ -194,14 +218,6 @@ React.useEffect(function () {

};
var ctxToArrayLayoutProps = function (ctx, props) {
return core.mapStateToArrayLayoutProps({ jsonforms: __assign({}, ctx) }, props);
};
var ctxToArrayControlProps = function (ctx, props) {
return core.mapStateToArrayControlProps({ jsonforms: __assign({}, ctx) }, props);
};
var ctxToLayoutProps = function (ctx, props) {
return core.mapStateToLayoutProps({ jsonforms: __assign({}, ctx) }, props);
};
var ctxToControlProps = function (ctx, props) {
return core.mapStateToControlProps({ jsonforms: __assign({}, ctx) }, props);
};
var ctxToArrayLayoutProps = function (ctx, props) { return core.mapStateToArrayLayoutProps({ jsonforms: __assign({}, ctx) }, props); };
var ctxToArrayControlProps = function (ctx, props) { return core.mapStateToArrayControlProps({ jsonforms: __assign({}, ctx) }, props); };
var ctxToLayoutProps = function (ctx, props) { return core.mapStateToLayoutProps({ jsonforms: __assign({}, ctx) }, props); };
var ctxToControlProps = function (ctx, props) { return core.mapStateToControlProps({ jsonforms: __assign({}, ctx) }, props); };
var ctxToEnumControlProps = function (ctx, props) {

@@ -270,141 +286,145 @@ var _a;

};
var withJsonFormsContext = function (Component) { return function (props) {
var ctx = useJsonForms();
return React__default["default"].createElement(Component, { ctx: ctx, props: props });
}; };
var withJsonFormsContext = function (Component) {
return function WithJsonFormsContext(props) {
var ctx = useJsonForms();
return React__default["default"].createElement(Component, { ctx: ctx, props: props });
};
};
var withContextToJsonFormsRendererProps = function (Component) {
return function (_a) {
return function WithContextToJsonFormsRendererProps(_a) {
var ctx = _a.ctx, props = _a.props;
var contextProps = ctxToJsonFormsRendererProps(ctx, props);
return (React__default["default"].createElement(Component, __assign({}, props, contextProps)));
return React__default["default"].createElement(Component, __assign({}, props, contextProps));
};
};
var withContextToControlProps = function (Component) {
return function (_a) {
return function WithContextToControlProps(_a) {
var ctx = _a.ctx, props = _a.props;
var controlProps = ctxToControlProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, controlProps, dispatchProps)));
return React__default["default"].createElement(Component, __assign({}, props, controlProps, dispatchProps));
};
};
var withContextToLayoutProps = function (Component) {
return function (_a) {
return function WithContextToLayoutProps(_a) {
var ctx = _a.ctx, props = _a.props;
var layoutProps = ctxToLayoutProps(ctx, props);
return (React__default["default"].createElement(Component, __assign({}, props, layoutProps)));
return React__default["default"].createElement(Component, __assign({}, props, layoutProps));
};
};
var withContextToOneOfProps = function (Component) {
return function (_a) {
return function WithContextToOneOfProps(_a) {
var ctx = _a.ctx, props = _a.props;
var oneOfProps = ctxToOneOfProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, oneOfProps, dispatchProps)));
return React__default["default"].createElement(Component, __assign({}, props, oneOfProps, dispatchProps));
};
};
var withContextToAnyOfProps = function (Component) {
return function (_a) {
return function WithContextToAnyOfProps(_a) {
var ctx = _a.ctx, props = _a.props;
var oneOfProps = ctxToAnyOfProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, oneOfProps, dispatchProps)));
return React__default["default"].createElement(Component, __assign({}, props, oneOfProps, dispatchProps));
};
};
var withContextToAllOfProps = function (Component) {
return function (_a) {
return function WithContextToAllOfProps(_a) {
var ctx = _a.ctx, props = _a.props;
var allOfProps = ctxToAllOfProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, allOfProps, dispatchProps)));
return React__default["default"].createElement(Component, __assign({}, props, allOfProps, dispatchProps));
};
};
var withContextToDetailProps = function (Component) {
return function (_a) {
return function WithContextToDetailProps(_a) {
var ctx = _a.ctx, props = _a.props;
var detailProps = ctxToControlWithDetailProps(ctx, props);
return (React__default["default"].createElement(Component, __assign({}, props, detailProps)));
return React__default["default"].createElement(Component, __assign({}, props, detailProps));
};
};
var withContextToArrayLayoutProps = function (Component) {
return function (_a) {
return function WithContextToArrayLayoutProps(_a) {
var ctx = _a.ctx, props = _a.props;
var arrayLayoutProps = ctxToArrayLayoutProps(ctx, props);
var dispatchProps = ctxDispatchToArrayControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, arrayLayoutProps, dispatchProps)));
return React__default["default"].createElement(Component, __assign({}, props, arrayLayoutProps, dispatchProps));
};
};
var withContextToArrayControlProps = function (Component) {
return function (_a) {
return function WithContextToArrayControlProps(_a) {
var ctx = _a.ctx, props = _a.props;
var stateProps = ctxToArrayControlProps(ctx, props);
var dispatchProps = ctxDispatchToArrayControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, stateProps, dispatchProps)));
return React__default["default"].createElement(Component, __assign({}, props, stateProps, dispatchProps));
};
};
var withContextToMasterListItemProps = function (Component) {
return function (_a) {
return function WithContextToMasterListItemProps(_a) {
var ctx = _a.ctx, props = _a.props;
var stateProps = ctxToMasterListItemProps(ctx, props);
return (React__default["default"].createElement(Component, __assign({}, props, stateProps)));
return React__default["default"].createElement(Component, __assign({}, props, stateProps));
};
};
var withContextToCellProps = function (Component) {
return function (_a) {
return function WithContextToCellProps(_a) {
var ctx = _a.ctx, props = _a.props;
var cellProps = ctxToCellProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps)));
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps));
};
};
var withContextToDispatchCellProps = function (Component) { return function (_a) {
var ctx = _a.ctx, props = _a.props;
var cellProps = ctxToDispatchCellProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps));
}; };
var withContextToDispatchCellProps = function (Component) {
return function WithContextToDispatchCellProps(_a) {
var ctx = _a.ctx, props = _a.props;
var cellProps = ctxToDispatchCellProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps));
};
};
var withContextToEnumCellProps = function (Component) {
return function (_a) {
return function WithContextToEnumCellProps(_a) {
var ctx = _a.ctx, props = _a.props;
var cellProps = ctxToEnumCellProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps)));
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps));
};
};
var withContextToEnumProps = function (Component) {
return function (_a) {
return function WithContextToEnumProps(_a) {
var ctx = _a.ctx, props = _a.props;
var stateProps = ctxToEnumControlProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, dispatchProps, stateProps)));
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, stateProps));
};
};
var withContextToOneOfEnumCellProps = function (Component) {
return function (_a) {
return function WithContextToOneOfEnumCellProps(_a) {
var ctx = _a.ctx, props = _a.props;
var cellProps = ctxToOneOfEnumCellProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps)));
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, cellProps));
};
};
var withContextToOneOfEnumProps = function (Component) {
return function (_a) {
return function WithContextToOneOfEnumProps(_a) {
var ctx = _a.ctx, props = _a.props;
var stateProps = ctxToOneOfEnumControlProps(ctx, props);
var dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, dispatchProps, stateProps)));
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, stateProps));
};
};
var withContextToMultiEnumProps = function (Component) {
return function (_a) {
return function WithContextToMultiEnumProps(_a) {
var ctx = _a.ctx, props = _a.props;
var stateProps = ctxToMultiEnumControlProps(ctx, props);
var dispatchProps = ctxDispatchToMultiEnumProps(ctx.dispatch);
return (React__default["default"].createElement(Component, __assign({}, props, dispatchProps, stateProps)));
return React__default["default"].createElement(Component, __assign({}, props, dispatchProps, stateProps));
};
};
var withContextToLabelProps = function (Component) {
return function (_a) {
return function WithContextToLabelProps(_a) {
var ctx = _a.ctx, props = _a.props;
var stateProps = ctxToLabelProps(ctx, props);
return (React__default["default"].createElement(Component, __assign({}, props, stateProps)));
return React__default["default"].createElement(Component, __assign({}, props, stateProps));
};

@@ -485,3 +505,3 @@ };

var withTranslateProps = function (Component) {
return function (props) {
return function WithTranslateProps(props) {
var _a, _b, _c, _d;

@@ -491,3 +511,3 @@ var ctx = useJsonForms();

var t = (_d = (_c = ctx.i18n) === null || _c === void 0 ? void 0 : _c.translate) !== null && _d !== void 0 ? _d : core.defaultJsonFormsI18nState.translate;
return (React__default["default"].createElement(Component, __assign({}, props, { locale: locale, t: t })));
return React__default["default"].createElement(Component, __assign({}, props, { locale: locale, t: t }));
};

@@ -518,8 +538,12 @@ };

}(React__default["default"].Component));
var TestAndRender = React__default["default"].memo(function (props) {
var TestAndRender = React__default["default"].memo(function TestAndRender(props) {
var testerContext = React.useMemo(function () { return ({
rootSchema: props.rootSchema,
config: props.config
config: props.config,
}); }, [props.rootSchema, props.config]);
var renderer = React.useMemo(function () { return maxBy__default["default"](props.renderers, function (r) { return r.tester(props.uischema, props.schema, testerContext); }); }, [props.renderers, props.uischema, props.schema, testerContext]);
var renderer = React.useMemo(function () {
return maxBy__default["default"](props.renderers, function (r) {
return r.tester(props.uischema, props.schema, testerContext);
});
}, [props.renderers, props.uischema, props.schema, testerContext]);
if (renderer === undefined ||

@@ -556,3 +580,3 @@ renderer.tester(props.uischema, props.schema, testerContext) === -1) {

validationMode: validationMode,
additionalErrors: additionalErrors
additionalErrors: additionalErrors,
},

@@ -564,3 +588,3 @@ config: config,

readonly: readonly,
i18n: i18n
i18n: i18n,
}, onChange: onChange },

@@ -574,6 +598,7 @@ React__default["default"].createElement(JsonFormsDispatch, null)));

rootSchema: rootSchema,
config: config
config: config,
}); }, [rootSchema, config]);
var cell = React.useMemo(function () { return maxBy__default["default"](cells, function (r) { return r.tester(uischema, schema, testerContext); }); }, [cells, uischema, schema, testerContext]);
if (cell === undefined || cell.tester(uischema, schema, testerContext) === -1) {
if (cell === undefined ||
cell.tester(uischema, schema, testerContext) === -1) {
return React__default["default"].createElement(UnknownRenderer, { type: 'cell' });

@@ -580,0 +605,0 @@ }

@@ -30,3 +30,3 @@ import React, { Component, useReducer, useEffect, useMemo, useRef, useCallback, useContext } from 'react';

value: props.data ? props.data : '',
isFocused: false
isFocused: false,
};

@@ -56,3 +56,3 @@ }

core: initialCoreState,
renderers: []
renderers: [],
});

@@ -69,7 +69,15 @@ const useEffectAfterFirstRender = (effect, dependencies) => {

};
const JsonFormsStateProvider = ({ children, initState, onChange }) => {
const JsonFormsStateProvider = ({ children, initState, onChange, }) => {
const { data, schema, uischema, ajv, validationMode, additionalErrors } = initState.core;
const [core, coreDispatch] = useReducer(coreReducer, undefined, () => coreReducer(initState.core, Actions.init(data, schema, uischema, { ajv, validationMode, additionalErrors })));
const [core, coreDispatch] = useReducer(coreReducer, undefined, () => coreReducer(initState.core, Actions.init(data, schema, uischema, {
ajv,
validationMode,
additionalErrors,
})));
useEffect(() => {
coreDispatch(Actions.updateCore(data, schema, uischema, { ajv, validationMode, additionalErrors }));
coreDispatch(Actions.updateCore(data, schema, uischema, {
ajv,
validationMode,
additionalErrors,
}));
}, [data, schema, uischema, ajv, validationMode, additionalErrors]);

@@ -83,3 +91,7 @@ const [config, configDispatch] = useReducer(configReducer, undefined, () => configReducer(undefined, Actions.setConfig(initState.config)));

i18nDispatch(Actions.updateI18n(initState.i18n?.locale, initState.i18n?.translate, initState.i18n?.translateError));
}, [initState.i18n?.locale, initState.i18n?.translate, initState.i18n?.translateError]);
}, [
initState.i18n?.locale,
initState.i18n?.translate,
initState.i18n?.translateError,
]);
const contextValue = useMemo(() => ({

@@ -94,3 +106,11 @@ core,

dispatch: coreDispatch,
}), [core, initState.renderers, initState.cells, config, initState.uischemas, initState.readonly, i18n]);
}), [
core,
initState.renderers,
initState.cells,
config,
initState.uischemas,
initState.readonly,
i18n,
]);
const onChangeRef = useRef(onChange);

@@ -130,3 +150,3 @@ useEffect(() => {

return {
...props
...props,
};

@@ -140,3 +160,3 @@ };

...props,
...dispatchProps
...dispatchProps,
};

@@ -149,3 +169,3 @@ };

...props,
...dispatchProps
...dispatchProps,
};

@@ -156,3 +176,3 @@ };

...ctxDispatchToControlProps(dispatch),
...useMemo(() => mapDispatchToArrayControlProps(dispatch), [dispatch])
...useMemo(() => mapDispatchToArrayControlProps(dispatch), [dispatch]),
});

@@ -178,3 +198,3 @@ const ctxToMasterListItemProps = (ctx, ownProps) => mapStateToMasterListItemProps({ jsonforms: { ...ctx } }, ownProps);

...ctxDispatchToControlProps(dispatch),
...useMemo(() => mapDispatchToMultiEnumProps(dispatch), [dispatch])
...useMemo(() => mapDispatchToMultiEnumProps(dispatch), [dispatch]),
});

@@ -184,58 +204,58 @@ const ctxToLabelProps = (ctx, ownProps) => {

};
const withJsonFormsContext = (Component) => (props) => {
const withJsonFormsContext = (Component) => function WithJsonFormsContext(props) {
const ctx = useJsonForms();
return React.createElement(Component, { ctx: ctx, props: props });
};
const withContextToJsonFormsRendererProps = (Component) => ({ ctx, props }) => {
const withContextToJsonFormsRendererProps = (Component) => function WithContextToJsonFormsRendererProps({ ctx, props, }) {
const contextProps = ctxToJsonFormsRendererProps(ctx, props);
return (React.createElement(Component, Object.assign({}, props, contextProps)));
return React.createElement(Component, Object.assign({}, props, contextProps));
};
const withContextToControlProps = (Component) => ({ ctx, props }) => {
const withContextToControlProps = (Component) => function WithContextToControlProps({ ctx, props, }) {
const controlProps = ctxToControlProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, controlProps, dispatchProps)));
return React.createElement(Component, Object.assign({}, props, controlProps, dispatchProps));
};
const withContextToLayoutProps = (Component) => ({ ctx, props }) => {
const withContextToLayoutProps = (Component) => function WithContextToLayoutProps({ ctx, props, }) {
const layoutProps = ctxToLayoutProps(ctx, props);
return (React.createElement(Component, Object.assign({}, props, layoutProps)));
return React.createElement(Component, Object.assign({}, props, layoutProps));
};
const withContextToOneOfProps = (Component) => ({ ctx, props }) => {
const withContextToOneOfProps = (Component) => function WithContextToOneOfProps({ ctx, props, }) {
const oneOfProps = ctxToOneOfProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, oneOfProps, dispatchProps)));
return React.createElement(Component, Object.assign({}, props, oneOfProps, dispatchProps));
};
const withContextToAnyOfProps = (Component) => ({ ctx, props }) => {
const withContextToAnyOfProps = (Component) => function WithContextToAnyOfProps({ ctx, props, }) {
const oneOfProps = ctxToAnyOfProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, oneOfProps, dispatchProps)));
return React.createElement(Component, Object.assign({}, props, oneOfProps, dispatchProps));
};
const withContextToAllOfProps = (Component) => ({ ctx, props }) => {
const withContextToAllOfProps = (Component) => function WithContextToAllOfProps({ ctx, props, }) {
const allOfProps = ctxToAllOfProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, allOfProps, dispatchProps)));
return React.createElement(Component, Object.assign({}, props, allOfProps, dispatchProps));
};
const withContextToDetailProps = (Component) => ({ ctx, props }) => {
const withContextToDetailProps = (Component) => function WithContextToDetailProps({ ctx, props, }) {
const detailProps = ctxToControlWithDetailProps(ctx, props);
return (React.createElement(Component, Object.assign({}, props, detailProps)));
return React.createElement(Component, Object.assign({}, props, detailProps));
};
const withContextToArrayLayoutProps = (Component) => ({ ctx, props }) => {
const withContextToArrayLayoutProps = (Component) => function WithContextToArrayLayoutProps({ ctx, props, }) {
const arrayLayoutProps = ctxToArrayLayoutProps(ctx, props);
const dispatchProps = ctxDispatchToArrayControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, arrayLayoutProps, dispatchProps)));
return React.createElement(Component, Object.assign({}, props, arrayLayoutProps, dispatchProps));
};
const withContextToArrayControlProps = (Component) => ({ ctx, props }) => {
const withContextToArrayControlProps = (Component) => function WithContextToArrayControlProps({ ctx, props, }) {
const stateProps = ctxToArrayControlProps(ctx, props);
const dispatchProps = ctxDispatchToArrayControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, stateProps, dispatchProps)));
return React.createElement(Component, Object.assign({}, props, stateProps, dispatchProps));
};
const withContextToMasterListItemProps = (Component) => ({ ctx, props }) => {
const withContextToMasterListItemProps = (Component) => function WithContextToMasterListItemProps({ ctx, props, }) {
const stateProps = ctxToMasterListItemProps(ctx, props);
return (React.createElement(Component, Object.assign({}, props, stateProps)));
return React.createElement(Component, Object.assign({}, props, stateProps));
};
const withContextToCellProps = (Component) => ({ ctx, props }) => {
const withContextToCellProps = (Component) => function WithContextToCellProps({ ctx, props, }) {
const cellProps = ctxToCellProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, dispatchProps, cellProps)));
return React.createElement(Component, Object.assign({}, props, dispatchProps, cellProps));
};
const withContextToDispatchCellProps = (Component) => ({ ctx, props }) => {
const withContextToDispatchCellProps = (Component) => function WithContextToDispatchCellProps({ ctx, props, }) {
const cellProps = ctxToDispatchCellProps(ctx, props);

@@ -245,30 +265,30 @@ const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);

};
const withContextToEnumCellProps = (Component) => ({ ctx, props }) => {
const withContextToEnumCellProps = (Component) => function WithContextToEnumCellProps({ ctx, props, }) {
const cellProps = ctxToEnumCellProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, dispatchProps, cellProps)));
return React.createElement(Component, Object.assign({}, props, dispatchProps, cellProps));
};
const withContextToEnumProps = (Component) => ({ ctx, props }) => {
const withContextToEnumProps = (Component) => function WithContextToEnumProps({ ctx, props, }) {
const stateProps = ctxToEnumControlProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, dispatchProps, stateProps)));
return React.createElement(Component, Object.assign({}, props, dispatchProps, stateProps));
};
const withContextToOneOfEnumCellProps = (Component) => ({ ctx, props }) => {
const withContextToOneOfEnumCellProps = (Component) => function WithContextToOneOfEnumCellProps({ ctx, props, }) {
const cellProps = ctxToOneOfEnumCellProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, dispatchProps, cellProps)));
return React.createElement(Component, Object.assign({}, props, dispatchProps, cellProps));
};
const withContextToOneOfEnumProps = (Component) => ({ ctx, props }) => {
const withContextToOneOfEnumProps = (Component) => function WithContextToOneOfEnumProps({ ctx, props, }) {
const stateProps = ctxToOneOfEnumControlProps(ctx, props);
const dispatchProps = ctxDispatchToControlProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, dispatchProps, stateProps)));
return React.createElement(Component, Object.assign({}, props, dispatchProps, stateProps));
};
const withContextToMultiEnumProps = (Component) => ({ ctx, props }) => {
const withContextToMultiEnumProps = (Component) => function WithContextToMultiEnumProps({ ctx, props, }) {
const stateProps = ctxToMultiEnumControlProps(ctx, props);
const dispatchProps = ctxDispatchToMultiEnumProps(ctx.dispatch);
return (React.createElement(Component, Object.assign({}, props, dispatchProps, stateProps)));
return React.createElement(Component, Object.assign({}, props, dispatchProps, stateProps));
};
const withContextToLabelProps = (Component) => ({ ctx, props }) => {
const withContextToLabelProps = (Component) => function WithContextToLabelProps({ ctx, props, }) {
const stateProps = ctxToLabelProps(ctx, props);
return (React.createElement(Component, Object.assign({}, props, stateProps)));
return React.createElement(Component, Object.assign({}, props, stateProps));
};

@@ -293,7 +313,7 @@ const withJsonFormsRendererProps = (Component, memoize = true) => withJsonFormsContext(withContextToJsonFormsRendererProps(memoize ? React.memo(Component) : Component));

const withJsonFormsLabelProps = (Component, memoize = true) => withJsonFormsContext(withContextToLabelProps(memoize ? React.memo(Component) : Component));
const withTranslateProps = (Component) => (props) => {
const withTranslateProps = (Component) => function WithTranslateProps(props) {
const ctx = useJsonForms();
const locale = ctx.i18n?.locale ?? defaultJsonFormsI18nState.locale;
const t = ctx.i18n?.translate ?? defaultJsonFormsI18nState.translate;
return (React.createElement(Component, Object.assign({}, props, { locale: locale, t: t })));
return React.createElement(Component, Object.assign({}, props, { locale: locale, t: t }));
};

@@ -316,12 +336,12 @@

render() {
const { schema, rootSchema, uischema, path, enabled, renderers, cells, config } = this.props;
const { schema, rootSchema, uischema, path, enabled, renderers, cells, config, } = this.props;
return (React.createElement(TestAndRender, { uischema: uischema, schema: schema, rootSchema: rootSchema, path: path, enabled: enabled, renderers: renderers, cells: cells, id: this.state.id, config: config }));
}
}
const TestAndRender = React.memo((props) => {
const TestAndRender = React.memo(function TestAndRender(props) {
const testerContext = useMemo(() => ({
rootSchema: props.rootSchema,
config: props.config
config: props.config,
}), [props.rootSchema, props.config]);
const renderer = useMemo(() => maxBy(props.renderers, r => r.tester(props.uischema, props.schema, testerContext)), [props.renderers, props.uischema, props.schema, testerContext]);
const renderer = useMemo(() => maxBy(props.renderers, (r) => r.tester(props.uischema, props.schema, testerContext)), [props.renderers, props.uischema, props.schema, testerContext]);
if (renderer === undefined ||

@@ -344,3 +364,3 @@ renderer.tester(props.uischema, props.schema, testerContext) === -1) {

const JsonForms = (props) => {
const { ajv, data, schema, uischema, renderers, cells, onChange, config, uischemas, readonly, validationMode, i18n, additionalErrors } = props;
const { ajv, data, schema, uischema, renderers, cells, onChange, config, uischemas, readonly, validationMode, i18n, additionalErrors, } = props;
const schemaToUse = useMemo(() => (schema !== undefined ? schema : Generate.jsonSchema(data)), [schema, data]);

@@ -355,3 +375,3 @@ const uischemaToUse = useMemo(() => typeof uischema === 'object' ? uischema : Generate.uiSchema(schemaToUse), [uischema, schemaToUse]);

validationMode: validationMode,
additionalErrors: additionalErrors
additionalErrors: additionalErrors,
},

@@ -363,3 +383,3 @@ config,

readonly,
i18n
i18n,
}, onChange: onChange },

@@ -369,9 +389,10 @@ React.createElement(JsonFormsDispatch, null)));

const Dispatch = ({ uischema, schema, rootSchema, path, cells, id, enabled, renderers, config }) => {
const Dispatch = ({ uischema, schema, rootSchema, path, cells, id, enabled, renderers, config, }) => {
const testerContext = useMemo(() => ({
rootSchema: rootSchema,
config: config
config: config,
}), [rootSchema, config]);
const cell = useMemo(() => maxBy(cells, r => r.tester(uischema, schema, testerContext)), [cells, uischema, schema, testerContext]);
if (cell === undefined || cell.tester(uischema, schema, testerContext) === -1) {
const cell = useMemo(() => maxBy(cells, (r) => r.tester(uischema, schema, testerContext)), [cells, uischema, schema, testerContext]);
if (cell === undefined ||
cell.tester(uischema, schema, testerContext) === -1) {
return React.createElement(UnknownRenderer, { type: 'cell' });

@@ -378,0 +399,0 @@ }

@@ -7,3 +7,3 @@ import { ArrayControlProps, ArrayLayoutProps, CellProps, CombinatorRendererProps, ControlProps, DispatchCellProps, DispatchPropsOfControl, EnumCellProps, JsonFormsProps, JsonFormsSubStates, LayoutProps, OwnPropsOfCell, OwnPropsOfControl, OwnPropsOfEnum, OwnPropsOfEnumCell, OwnPropsOfJsonFormsRenderer, OwnPropsOfLayout, OwnPropsOfMasterListItem, StatePropsOfControlWithDetail, StatePropsOfMasterItem, coreReducer, DispatchPropsOfMultiEnumControl, Translator, OwnPropsOfLabel, LabelProps } from '@jsonforms/core';

export declare const JsonFormsContext: React.Context<JsonFormsStateContext>;
export declare const JsonFormsStateProvider: ({ children, initState, onChange }: any) => JSX.Element;
export declare const JsonFormsStateProvider: ({ children, initState, onChange, }: any) => JSX.Element;
export declare const useJsonForms: () => JsonFormsStateContext;

@@ -27,2 +27,3 @@ export interface JsonFormsReduxContextProps extends JsonFormsSubStates {

required?: boolean;
i18nKeyPrefix?: string;
uischema: import("@jsonforms/core").ControlElement;

@@ -49,2 +50,3 @@ errors: string;

required?: boolean;
i18nKeyPrefix?: string;
uischema: import("@jsonforms/core").ControlElement;

@@ -71,2 +73,3 @@ errors: string;

required?: boolean;
i18nKeyPrefix?: string;
uischema: import("@jsonforms/core").ControlElement;

@@ -99,2 +102,3 @@ errors: string;

required?: boolean;
i18nKeyPrefix?: string;
uischema: import("@jsonforms/core").ControlElement;

@@ -101,0 +105,0 @@ errors: string;

@@ -10,7 +10,7 @@ import { coreReducer, rendererReducer, cellReducer, configReducer, uischemaRegistryReducer, i18nReducer } from '@jsonforms/core';

dispatch,
...other
...other,
} }, children));
};
const JsonFormsReduxContext = connect((state) => ({
...state.jsonforms
...state.jsonforms,
}))(JsonFormsReduxProvider);

@@ -24,3 +24,3 @@ const jsonformsReducer = (additionalReducers = {}) => combineReducers({

i18n: i18nReducer,
...additionalReducers
...additionalReducers,
});

@@ -27,0 +27,0 @@

@@ -17,4 +17,3 @@ import React from 'react';

*/
export interface StatelessRenderer<P extends RendererProps> extends React.StatelessComponent<P> {
}
export declare type StatelessRenderer<P extends RendererProps> = React.StatelessComponent<P>;
/**

@@ -21,0 +20,0 @@ * Represents a Renderer, which might either be a component or a function.

{
"name": "@jsonforms/react",
"version": "3.1.0-alpha.1",
"version": "3.1.0-alpha.2",
"description": "React module of JSON Forms",

@@ -42,3 +42,4 @@ "repository": "https://github.com/eclipsesource/jsonforms",

"clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
"lint": "tslint --project tsconfig.json --exclude src/models/jsonSchema.ts",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"report": "nyc report --reporter=html",

@@ -88,3 +89,3 @@ "test": "jest --no-cache",

"peerDependencies": {
"@jsonforms/core": "3.1.0-alpha.1",
"@jsonforms/core": "3.1.0-alpha.2",
"react": "^16.12.0 || ^17.0.0 || ^18.0.0"

@@ -96,3 +97,3 @@ },

"devDependencies": {
"@jsonforms/core": "^3.1.0-alpha.1",
"@jsonforms/core": "^3.1.0-alpha.2",
"@rollup/plugin-alias": "^3.1.8",

@@ -103,7 +104,15 @@ "@types/enzyme": "^3.10.3",

"@types/react-redux": "^7.1.5",
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
"cross-env": "^7.0.2",
"enzyme": "^3.10.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.32.2",
"jest": "^26.6.3",
"nyc": "^15.1.0",
"prettier": "^2.8.4",
"react": "^17.0.2",

@@ -119,7 +128,6 @@ "react-dom": "^17.0.2",

"rollup-plugin-visualizer": "^5.4.1",
"tslint": "^5.20.1",
"typedoc": "^0.19.2",
"typescript": "4.2.3"
},
"gitHead": "386174994eabc41758450b8d551e1c859498a468"
"gitHead": "1e1ccad5f7ebfaf80412c8af3e422faebb12d0d5"
}
# JSON Forms - More Forms. Less Code
*Complex forms in the blink of an eye*
_Complex forms in the blink of an eye_

@@ -23,16 +23,16 @@ JSON Forms eliminates the tedious task of writing fully-featured forms by hand by leveraging the capabilities of JSON, JSON Schema and Javascript.

* `data: any` - the data to show
* `renderers: JsonFormsRendererRegistryEntry[]` - the React renderer set to use
- `data: any` - the data to show
- `renderers: JsonFormsRendererRegistryEntry[]` - the React renderer set to use
Optional props:
* `schema: JsonSchema` - the data schema for the given data. Will be generated when not given.
* `uischema: UISchemaElement` - the UI schema for the given data schema. Will be generated when not given.
* `cells: JsonFormsCellRendererRegistryEntry[]` - the React cell renderer set to use
* `config: any` - form-wide options. May contain default ui schema options.
* `readonly: boolean` - whether all controls shall be readonly.
* `uischemas: JsonFormsUiSchemaEntry[]` - registry for dynamic ui schema dispatching
* `validationMode: 'ValidateAndShow' | 'ValidateAndHide' | 'NoValidation'` - the validation mode for the form
* `ajv: AJV` - custom Ajv instance for the form
* `onChange` - callback which is called on each data change, containing the updated data and the validation result.
- `schema: JsonSchema` - the data schema for the given data. Will be generated when not given.
- `uischema: UISchemaElement` - the UI schema for the given data schema. Will be generated when not given.
- `cells: JsonFormsCellRendererRegistryEntry[]` - the React cell renderer set to use
- `config: any` - form-wide options. May contain default ui schema options.
- `readonly: boolean` - whether all controls shall be readonly.
- `uischemas: JsonFormsUiSchemaEntry[]` - registry for dynamic ui schema dispatching
- `validationMode: 'ValidateAndShow' | 'ValidateAndHide' | 'NoValidation'` - the validation mode for the form
- `ajv: AJV` - custom Ajv instance for the form
- `onChange` - callback which is called on each data change, containing the updated data and the validation result.

@@ -45,3 +45,3 @@ Example:

materialRenderers,
materialCells
materialCells,
} from '@jsonforms/material-renderers';

@@ -55,17 +55,17 @@ import { JsonForms } from '@jsonforms/react';

type: 'string',
minLength: 1
minLength: 1,
},
done: {
type: 'boolean'
type: 'boolean',
},
due_date: {
type: 'string',
format: 'date'
format: 'date',
},
recurrence: {
type: 'string',
enum: ['Never', 'Daily', 'Weekly', 'Monthly']
}
enum: ['Never', 'Daily', 'Weekly', 'Monthly'],
},
},
required: ['name', 'due_date']
required: ['name', 'due_date'],
};

@@ -78,7 +78,7 @@ const uischema = {

label: false,
scope: '#/properties/done'
scope: '#/properties/done',
},
{
type: 'Control',
scope: '#/properties/name'
scope: '#/properties/name',
},

@@ -90,11 +90,11 @@ {

type: 'Control',
scope: '#/properties/due_date'
scope: '#/properties/due_date',
},
{
type: 'Control',
scope: '#/properties/recurrence'
}
]
}
]
scope: '#/properties/recurrence',
},
],
},
],
};

@@ -101,0 +101,0 @@ const initialData = {};

@@ -40,8 +40,6 @@ /*

super(props);
// tslint:disable:no-object-literal-type-assertion
this.state = {
value: props.data ? props.data : '',
isFocused: false
isFocused: false,
} as S;
// tslint:enable:no-object-literal-type-assertion
}

@@ -48,0 +46,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc