@nolwenture/formik-jsonschema-form 1.2.4 → 1.2.6
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.
|
@@ -124,7 +124,7 @@ exports.MultipleChoiceFieldWrapper = styled_components_1.default.div `
|
|
|
124
124
|
break-inside: avoid;
|
|
125
125
|
`;
|
|
126
126
|
const BooleanFieldValue = ({ name, className, value, label, }) => {
|
|
127
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: className, children: value === true ? ((0, jsx_runtime_1.jsxs)(Selected, { children: [(0, jsx_runtime_1.jsx)(SelectedBox, { children: (0, jsx_runtime_1.jsx)(exports.SelectedIcon, {}) }), (0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldLabel, { children: label !== undefined ? label : "Selected" })] })) : ((0, jsx_runtime_1.jsxs)(Selected, { children: [(0, jsx_runtime_1.jsx)(
|
|
127
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: className, children: value === true ? ((0, jsx_runtime_1.jsxs)(Selected, { children: [(0, jsx_runtime_1.jsx)(SelectedBox, { children: (0, jsx_runtime_1.jsx)(exports.SelectedIcon, {}) }), (0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldLabel, { children: label !== undefined ? label : "Selected" })] })) : ((0, jsx_runtime_1.jsxs)(Selected, { children: [(0, jsx_runtime_1.jsx)(NotSelectedCircle, { children: (0, jsx_runtime_1.jsx)(exports.NotSelectedIcon, {}) }), (0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldLabel, { children: label !== undefined ? label : "Not selected" })] })) }));
|
|
128
128
|
};
|
|
129
129
|
exports.BooleanFieldValue = BooleanFieldValue;
|
|
130
130
|
const MultipleChoiceFieldValue = ({ inputProps, name, className, style, selected, notSelected }) => {
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.solveReferences = solveReferences;
|
|
4
4
|
const mergeSchemas_1 = require("./mergeSchemas");
|
|
5
|
+
const formik_1 = require("formik");
|
|
5
6
|
function solveReferences(schema, definitions, uiSchema, uiSchemaDefinitions) {
|
|
6
7
|
let solvedSchema = schema;
|
|
7
8
|
let solvedUiSchema = uiSchema;
|
|
8
9
|
if (typeof schema === "object" && schema["$ref"] && definitions) {
|
|
9
|
-
const
|
|
10
|
+
const pathParts = schema["$ref"].split("/");
|
|
11
|
+
if (pathParts[0] !== "#" || pathParts[1] !== "definitions") {
|
|
12
|
+
throw new Error("Only references to definitions are supported");
|
|
13
|
+
}
|
|
14
|
+
const path = pathParts.slice(2).join(".");
|
|
10
15
|
// TODO: Should we overwrite rather than merge? Maybe add a flag for choosing the behavior?
|
|
11
|
-
solvedSchema = (0, mergeSchemas_1.mergeSchemas)(definitions
|
|
16
|
+
solvedSchema = (0, mergeSchemas_1.mergeSchemas)((0, formik_1.getIn)(definitions, path) ?? {}, schema ?? {});
|
|
12
17
|
delete solvedSchema.$ref;
|
|
13
|
-
solvedUiSchema = (0, mergeSchemas_1.mergeSchemas)(uiSchemaDefinitions
|
|
18
|
+
solvedUiSchema = (0, mergeSchemas_1.mergeSchemas)((0, formik_1.getIn)(uiSchemaDefinitions, path) ?? {}, uiSchema ?? {});
|
|
14
19
|
}
|
|
15
20
|
return { schema: solvedSchema, uiSchema: solvedUiSchema };
|
|
16
21
|
}
|
|
@@ -118,7 +118,7 @@ export const MultipleChoiceFieldWrapper = styled.div `
|
|
|
118
118
|
break-inside: avoid;
|
|
119
119
|
`;
|
|
120
120
|
export const BooleanFieldValue = ({ name, className, value, label, }) => {
|
|
121
|
-
return (_jsx("div", { className: className, children: value === true ? (_jsxs(Selected, { children: [_jsx(SelectedBox, { children: _jsx(SelectedIcon, {}) }), _jsx(MultipleChoiceFieldLabel, { children: label !== undefined ? label : "Selected" })] })) : (_jsxs(Selected, { children: [_jsx(
|
|
121
|
+
return (_jsx("div", { className: className, children: value === true ? (_jsxs(Selected, { children: [_jsx(SelectedBox, { children: _jsx(SelectedIcon, {}) }), _jsx(MultipleChoiceFieldLabel, { children: label !== undefined ? label : "Selected" })] })) : (_jsxs(Selected, { children: [_jsx(NotSelectedCircle, { children: _jsx(NotSelectedIcon, {}) }), _jsx(MultipleChoiceFieldLabel, { children: label !== undefined ? label : "Not selected" })] })) }));
|
|
122
122
|
};
|
|
123
123
|
export const MultipleChoiceFieldValue = ({ inputProps, name, className, style, selected, notSelected }) => {
|
|
124
124
|
return (_jsx(MultipleChoiceFieldWrapper, { children: _jsxs(MultipleChoiceFieldContainer, { className: className, style: getStyle(style ?? ""), children: [!selected && !notSelected && _jsx(_Fragment, { children: "Nothing was selected" }), selected &&
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { mergeSchemas } from "./mergeSchemas";
|
|
2
|
+
import { getIn } from "formik";
|
|
2
3
|
export function solveReferences(schema, definitions, uiSchema, uiSchemaDefinitions) {
|
|
3
4
|
let solvedSchema = schema;
|
|
4
5
|
let solvedUiSchema = uiSchema;
|
|
5
6
|
if (typeof schema === "object" && schema["$ref"] && definitions) {
|
|
6
|
-
const
|
|
7
|
+
const pathParts = schema["$ref"].split("/");
|
|
8
|
+
if (pathParts[0] !== "#" || pathParts[1] !== "definitions") {
|
|
9
|
+
throw new Error("Only references to definitions are supported");
|
|
10
|
+
}
|
|
11
|
+
const path = pathParts.slice(2).join(".");
|
|
7
12
|
// TODO: Should we overwrite rather than merge? Maybe add a flag for choosing the behavior?
|
|
8
|
-
solvedSchema = mergeSchemas(definitions
|
|
13
|
+
solvedSchema = mergeSchemas(getIn(definitions, path) ?? {}, schema ?? {});
|
|
9
14
|
delete solvedSchema.$ref;
|
|
10
|
-
solvedUiSchema = mergeSchemas(uiSchemaDefinitions
|
|
15
|
+
solvedUiSchema = mergeSchemas(getIn(uiSchemaDefinitions, path) ?? {}, uiSchema ?? {});
|
|
11
16
|
}
|
|
12
17
|
return { schema: solvedSchema, uiSchema: solvedUiSchema };
|
|
13
18
|
}
|