@nolwenture/formik-jsonschema-form 1.2.6 → 1.2.8
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/dist/cjs/Form/components/FieldInput.js +5 -3
- package/dist/cjs/Form/fields/FilesUploadField/styledComponents.js +22 -11
- package/dist/cjs/Form/fields/MultipleChoiceField/styledComponents.js +9 -7
- package/dist/cjs/Form/templates/ObjectFieldTemplate/styledComponents.js +5 -2
- package/dist/cjs/FormView/components/Field.js +13 -13
- package/dist/cjs/utils/getStyle.js +1 -1
- package/dist/cjs/utils/setTitleValues.js +2 -2
- package/dist/cjs/utils/solveReferences.js +5 -1
- package/dist/esm/Form/components/FieldInput.js +5 -3
- package/dist/esm/Form/fields/FilesUploadField/styledComponents.js +22 -11
- package/dist/esm/Form/fields/MultipleChoiceField/styledComponents.js +9 -7
- package/dist/esm/Form/templates/ObjectFieldTemplate/styledComponents.js +5 -2
- package/dist/esm/FormView/components/Field.js +13 -13
- package/dist/esm/utils/getStyle.js +1 -1
- package/dist/esm/utils/setTitleValues.js +2 -2
- package/dist/esm/utils/solveReferences.js +5 -1
- package/package.json +2 -2
|
@@ -40,10 +40,10 @@ const formik = __importStar(require("formik"));
|
|
|
40
40
|
exports.FieldWrapper = styled_components_1.styled.div `
|
|
41
41
|
display: flex;
|
|
42
42
|
flex-direction: column;
|
|
43
|
-
|
|
43
|
+
gap: ${(props) => props.theme.spacing.xs};
|
|
44
44
|
color: ${(props) => props.theme.color.text.default};
|
|
45
45
|
opacity: ${(props) => (props.$isDisabled ? 0.6 : 1)};
|
|
46
|
-
pointer-events: ${(props) => (props.$isDisabled ?
|
|
46
|
+
pointer-events: ${(props) => (props.$isDisabled ? "none" : "auto")};
|
|
47
47
|
`;
|
|
48
48
|
exports.FieldTitleInfoWrapper = styled_components_1.styled.div `
|
|
49
49
|
display: flex;
|
|
@@ -62,7 +62,9 @@ exports.FieldDescription = styled_components_1.styled.p `
|
|
|
62
62
|
margin: 0;
|
|
63
63
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
64
64
|
font-size: ${(props) => props.theme.typography.size.base};
|
|
65
|
-
font-weight: ${(props) =>
|
|
65
|
+
font-weight: ${(props) => props.$isReadOnly
|
|
66
|
+
? props.theme.typography.weight.bold
|
|
67
|
+
: props.theme.typography.weight.normal};
|
|
66
68
|
`;
|
|
67
69
|
exports.FieldHelp = styled_components_1.styled.p `
|
|
68
70
|
color: ${(props) => props.theme.color.text.default};
|
|
@@ -10,19 +10,21 @@ const fa_1 = require("react-icons/fa");
|
|
|
10
10
|
const component_library_1 = require("@nolwenture/component-library");
|
|
11
11
|
exports.FileUploadFieldContainer = styled_components_1.default.div `
|
|
12
12
|
align-items: center;
|
|
13
|
-
background-color: ${(props) => props.$readOnly ?
|
|
14
|
-
border: ${(props) => props.$readOnly
|
|
13
|
+
background-color: ${(props) => props.$readOnly ? "transparent" : props.theme.color.background.input};
|
|
14
|
+
border: ${(props) => props.$readOnly
|
|
15
|
+
? "none"
|
|
16
|
+
: `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
|
|
15
17
|
display: flex;
|
|
16
18
|
flex-direction: column;
|
|
17
19
|
gap: ${(props) => props.theme.spacing.m};
|
|
18
20
|
justify-content: center;
|
|
19
|
-
padding: ${(props) => props.$readOnly ?
|
|
20
|
-
margin
|
|
21
|
+
padding: ${(props) => (props.$readOnly ? "0" : props.theme.spacing.xxl)};
|
|
22
|
+
margin: ${(props) => `${props.theme.spacing.s} 0 ${props.theme.spacing.l} 0`};
|
|
21
23
|
position: relative;
|
|
22
24
|
transition: 0.3s filter ease;
|
|
23
25
|
|
|
24
26
|
&:hover {
|
|
25
|
-
filter: ${(props) => props.$readOnly ?
|
|
27
|
+
filter: ${(props) => (props.$readOnly ? "none" : "brightness(110%)")};
|
|
26
28
|
}
|
|
27
29
|
`;
|
|
28
30
|
exports.HiddenFileInput = styled_components_1.default.input `
|
|
@@ -44,7 +46,12 @@ exports.InfoText = styled_components_1.default.p `
|
|
|
44
46
|
margin: 0;
|
|
45
47
|
`;
|
|
46
48
|
exports.Divider = styled_components_1.default.div `
|
|
47
|
-
background: linear-gradient(
|
|
49
|
+
background: linear-gradient(
|
|
50
|
+
180deg,
|
|
51
|
+
transparent calc(50% - 2px),
|
|
52
|
+
${(props) => props.theme.color.palette.neutral[500]} calc(50%),
|
|
53
|
+
transparent 50%
|
|
54
|
+
);
|
|
48
55
|
color: ${(props) => props.theme.color.palette.neutral[500]};
|
|
49
56
|
display: flex;
|
|
50
57
|
flex-direction: row;
|
|
@@ -99,15 +106,19 @@ exports.FileItemContainer = styled_components_1.default.div `
|
|
|
99
106
|
`;
|
|
100
107
|
exports.UploadedFileItemContainer = styled_components_1.default.div `
|
|
101
108
|
align-items: center;
|
|
102
|
-
background-color: ${(props) => props.$readOnly ?
|
|
103
|
-
border: ${(props) => props.$readOnly
|
|
109
|
+
background-color: ${(props) => props.$readOnly ? "transparent" : props.theme.color.background.default};
|
|
110
|
+
border: ${(props) => props.$readOnly
|
|
111
|
+
? "none"
|
|
112
|
+
: `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
|
|
104
113
|
display: flex;
|
|
105
114
|
flex-direction: row;
|
|
106
115
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
107
116
|
gap: ${(props) => props.theme.spacing.m};
|
|
108
117
|
justify-content: space-between;
|
|
109
118
|
margin: 0;
|
|
110
|
-
padding: ${(props) => props.$readOnly
|
|
119
|
+
padding: ${(props) => props.$readOnly
|
|
120
|
+
? "0"
|
|
121
|
+
: `${props.theme.spacing.m} ${props.theme.spacing.l}`};
|
|
111
122
|
width: 100%;
|
|
112
123
|
`;
|
|
113
124
|
exports.UploadedFileInfoContainer = styled_components_1.default.div `
|
|
@@ -190,9 +201,9 @@ exports.DragOverlay = styled_components_1.default.div `
|
|
|
190
201
|
font-weight: ${(props) => props.theme.typography.weight.bold};
|
|
191
202
|
justify-content: center;
|
|
192
203
|
left: 0;
|
|
193
|
-
pointer-events: none;
|
|
204
|
+
pointer-events: none;
|
|
194
205
|
position: absolute;
|
|
195
206
|
right: 0;
|
|
196
207
|
top: 0;
|
|
197
|
-
z-index: 3;
|
|
208
|
+
z-index: 3;
|
|
198
209
|
`;
|
|
@@ -7,14 +7,16 @@ exports.MultipleChoiceFieldLabel = exports.MultipleChoiceFieldInputElement = exp
|
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
8
|
const styledComponents_1 = require("../RadioField/styledComponents");
|
|
9
9
|
exports.MultipleChoiceFieldContainer = (0, styled_components_1.default)(styledComponents_1.RadioFieldContainer) `
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
justify-content: start;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: ${(props) => props.theme.spacing.l};
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
&:has(input[readonly]) {
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
gap: ${(props) => props.theme.spacing.s};
|
|
19
|
+
}
|
|
18
20
|
`;
|
|
19
21
|
exports.MultipleChoiceFieldElement = (0, styled_components_1.default)(styledComponents_1.RadioFieldElement) ``;
|
|
20
22
|
exports.MultipleChoiceFieldInputElement = (0, styled_components_1.default)(styledComponents_1.RadioFieldInputElement) ``;
|
|
@@ -7,12 +7,16 @@ const styled_components_1 = require("styled-components");
|
|
|
7
7
|
exports.ObjectFieldTemplateWrapper = styled_components_1.styled.fieldset `
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
10
|
+
gap: ${(props) => props.theme.spacing.m};
|
|
10
11
|
color: ${(props) => props.theme.color.text.default};
|
|
11
12
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
12
13
|
margin-inline: 0;
|
|
13
14
|
margin-bottom: ${(props) => props.theme.spacing.xs};
|
|
14
15
|
|
|
15
|
-
&:has(input[disabled]),
|
|
16
|
+
&:has(input[disabled]),
|
|
17
|
+
&:has(option[disabled]),
|
|
18
|
+
&:has(select[disabled]),
|
|
19
|
+
&:has(textarea[disabled]) {
|
|
16
20
|
border-color: ${(props) => (0, polished_1.lighten)(0.4, props.theme.color.border.default)};
|
|
17
21
|
|
|
18
22
|
legend {
|
|
@@ -23,7 +27,6 @@ exports.ObjectFieldTemplateWrapper = styled_components_1.styled.fieldset `
|
|
|
23
27
|
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
|
-
|
|
27
30
|
`;
|
|
28
31
|
exports.ObjectFieldTemplateTitle = styled_components_1.styled.legend `
|
|
29
32
|
color: ${(props) => props.theme.color.text.default};
|
|
@@ -12,7 +12,8 @@ const fa_1 = require("react-icons/fa");
|
|
|
12
12
|
exports.FieldWrapper = styled_components_1.default.div `
|
|
13
13
|
color: ${(props) => props.theme.color.text.default};
|
|
14
14
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
15
|
-
|
|
15
|
+
gap: ${(props) => props.theme.spacing.s};
|
|
16
|
+
margin-bottom: ${(props) => props.theme.spacing.s};
|
|
16
17
|
width: min(100%, 70rem);
|
|
17
18
|
`;
|
|
18
19
|
exports.FieldTitle = styled_components_1.default.label `
|
|
@@ -21,7 +22,6 @@ exports.FieldTitle = styled_components_1.default.label `
|
|
|
21
22
|
font-family: ${(props) => props.theme.typography.fontFamily.heading};
|
|
22
23
|
font-size: ${(props) => props.theme.typography.size.base};
|
|
23
24
|
font-weight: ${(props) => props.theme.typography.weight.bold};
|
|
24
|
-
margin: ${(props) => `${props.theme.spacing.xs} 0 ${props.theme.spacing.s} 0`};
|
|
25
25
|
width: 100%;
|
|
26
26
|
`;
|
|
27
27
|
exports.FieldDescription = styled_components_1.default.div `
|
|
@@ -30,13 +30,12 @@ exports.FieldDescription = styled_components_1.default.div `
|
|
|
30
30
|
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
31
31
|
font-style: italic;
|
|
32
32
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
33
|
-
margin-bottom: ${(props) => props.theme.spacing.s};
|
|
34
33
|
`;
|
|
35
34
|
exports.StringFieldValue = styled_components_1.default.div `
|
|
36
35
|
color: ${(props) => props.theme.color.text.default};
|
|
37
36
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
38
37
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
39
|
-
|
|
38
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
40
39
|
padding-left: ${(props) => props.theme.spacing.l};
|
|
41
40
|
white-space: pre-line;
|
|
42
41
|
`;
|
|
@@ -44,7 +43,7 @@ exports.TextAreaValue = styled_components_1.default.div `
|
|
|
44
43
|
color: ${(props) => props.theme.color.text.default};
|
|
45
44
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
46
45
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
47
|
-
|
|
46
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
48
47
|
padding-left: ${(props) => props.theme.spacing.l};
|
|
49
48
|
white-space: pre-line;
|
|
50
49
|
`;
|
|
@@ -52,15 +51,16 @@ exports.ArrayFieldItem = styled_components_1.default.div `
|
|
|
52
51
|
color: ${(props) => props.theme.color.text.default};
|
|
53
52
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
54
53
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
54
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
55
55
|
background-color: ${(props) => props.theme.color.background.default};
|
|
56
56
|
padding: ${(props) => props.theme.spacing.l};
|
|
57
57
|
border: ${(props) => `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
|
|
58
|
-
margin-bottom: ${(props) => props.theme.spacing.s};
|
|
59
58
|
`;
|
|
60
59
|
exports.EJSFieldValue = styled_components_1.default.div `
|
|
61
60
|
color: ${(props) => props.theme.color.text.default};
|
|
62
61
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
63
62
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
63
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
64
64
|
padding-left: ${(props) => props.theme.spacing.l};
|
|
65
65
|
width: 100%;
|
|
66
66
|
`;
|
|
@@ -76,8 +76,8 @@ const SelectedBox = styled_components_1.default.div `
|
|
|
76
76
|
color: ${(props) => props.theme.color.text.default};
|
|
77
77
|
background: ${(props) => props.theme.color.background.default};
|
|
78
78
|
border: ${(props) => props.theme.strokeWidth.thin} solid
|
|
79
|
-
|
|
80
|
-
padding: 0 .05rem;
|
|
79
|
+
${(props) => props.theme.color.border.default};
|
|
80
|
+
padding: 0 0.05rem;
|
|
81
81
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
82
82
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
83
83
|
display: flex;
|
|
@@ -88,22 +88,22 @@ const NotSelectedCircle = styled_components_1.default.div `
|
|
|
88
88
|
color: ${(props) => props.theme.color.text.default};
|
|
89
89
|
background: ${(props) => props.theme.color.background.default};
|
|
90
90
|
border: ${(props) => props.theme.strokeWidth.thin} solid
|
|
91
|
-
|
|
91
|
+
${(props) => props.theme.color.border.default};
|
|
92
92
|
border-radius: ${(props) => props.theme.borderRadius.circle};
|
|
93
93
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
94
94
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
95
95
|
display: inline-flex;
|
|
96
96
|
justify-content: center;
|
|
97
97
|
align-items: start;
|
|
98
|
-
padding: 0 .1rem;
|
|
98
|
+
padding: 0 0.1rem;
|
|
99
99
|
`;
|
|
100
100
|
exports.SelectedIcon = (0, styled_components_1.default)(fa_1.FaCheck) `
|
|
101
101
|
color: ${(props) => props.theme.color.text.default};
|
|
102
|
-
width: .75rem;
|
|
102
|
+
width: 0.75rem;
|
|
103
103
|
`;
|
|
104
104
|
exports.NotSelectedIcon = (0, styled_components_1.default)(fa_1.FaTimes) `
|
|
105
105
|
color: ${(props) => props.theme.color.text.default};
|
|
106
|
-
width: .75rem;
|
|
106
|
+
width: 0.75rem;
|
|
107
107
|
`;
|
|
108
108
|
exports.BooleanFieldWrapper = styled_components_1.default.div `
|
|
109
109
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
@@ -128,7 +128,7 @@ const BooleanFieldValue = ({ name, className, value, label, }) => {
|
|
|
128
128
|
};
|
|
129
129
|
exports.BooleanFieldValue = BooleanFieldValue;
|
|
130
130
|
const MultipleChoiceFieldValue = ({ inputProps, name, className, style, selected, notSelected }) => {
|
|
131
|
-
return ((0, jsx_runtime_1.jsx)(exports.MultipleChoiceFieldWrapper, { children: (0, jsx_runtime_1.jsxs)(styledComponents_1.MultipleChoiceFieldContainer, { className: className, style: (0, getStyle_1.getStyle)(style ?? ""), children: [!selected && !notSelected && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {
|
|
131
|
+
return ((0, jsx_runtime_1.jsx)(exports.MultipleChoiceFieldWrapper, { children: (0, jsx_runtime_1.jsxs)(styledComponents_1.MultipleChoiceFieldContainer, { className: className, style: (0, getStyle_1.getStyle)(style ?? ""), children: [!selected && !notSelected && (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), selected &&
|
|
132
132
|
selected.length > 0 &&
|
|
133
133
|
selected.map((s) => ((0, jsx_runtime_1.jsx)(styledComponents_1.MultipleChoiceFieldElement, { "data-fjsf-enum-value-view": s.const, children: (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: s.title ?? "Hello" })] }) }, s.title ?? s))), notSelected &&
|
|
134
134
|
notSelected?.length > 0 &&
|
|
@@ -4,12 +4,12 @@ exports.setTitleValues = void 0;
|
|
|
4
4
|
const formik_1 = require("formik");
|
|
5
5
|
// Replaces template string variables with form data for CollapsibleObjectFieldTemplate titles
|
|
6
6
|
const setTitleValues = (name, title, defaultTitle, values) => {
|
|
7
|
-
const match = name.match(/^([a-zA-Z_$][\w
|
|
7
|
+
const match = name.match(/^([a-zA-Z_$][\w\[\]\.$]*)\[(\d+)\]$/);
|
|
8
8
|
if (match) {
|
|
9
9
|
name = match[1];
|
|
10
10
|
}
|
|
11
11
|
const index = match ? parseInt(match[2]) : -1;
|
|
12
|
-
const itemValues = match ? values
|
|
12
|
+
const itemValues = match ? (0, formik_1.getIn)(values, name)[index] : (0, formik_1.getIn)(values, name);
|
|
13
13
|
return title.replace(/\$\{([\w$.]+)\}/g, (match) => {
|
|
14
14
|
const keyMatch = match.match(/^\$\{([\w$.]+)\}$/);
|
|
15
15
|
const key = keyMatch ? keyMatch[1] : "";
|
|
@@ -12,10 +12,14 @@ function solveReferences(schema, definitions, uiSchema, uiSchemaDefinitions) {
|
|
|
12
12
|
throw new Error("Only references to definitions are supported");
|
|
13
13
|
}
|
|
14
14
|
const path = pathParts.slice(2).join(".");
|
|
15
|
+
const uiPath = pathParts
|
|
16
|
+
.slice(2)
|
|
17
|
+
.filter((part) => part !== "properties")
|
|
18
|
+
.join(".");
|
|
15
19
|
// TODO: Should we overwrite rather than merge? Maybe add a flag for choosing the behavior?
|
|
16
20
|
solvedSchema = (0, mergeSchemas_1.mergeSchemas)((0, formik_1.getIn)(definitions, path) ?? {}, schema ?? {});
|
|
17
21
|
delete solvedSchema.$ref;
|
|
18
|
-
solvedUiSchema = (0, mergeSchemas_1.mergeSchemas)((0, formik_1.getIn)(uiSchemaDefinitions,
|
|
22
|
+
solvedUiSchema = (0, mergeSchemas_1.mergeSchemas)((0, formik_1.getIn)(uiSchemaDefinitions, uiPath) ?? {}, uiSchema ?? {});
|
|
19
23
|
}
|
|
20
24
|
return { schema: solvedSchema, uiSchema: solvedUiSchema };
|
|
21
25
|
}
|
|
@@ -4,10 +4,10 @@ import * as formik from "formik";
|
|
|
4
4
|
export const FieldWrapper = styled.div `
|
|
5
5
|
display: flex;
|
|
6
6
|
flex-direction: column;
|
|
7
|
-
|
|
7
|
+
gap: ${(props) => props.theme.spacing.xs};
|
|
8
8
|
color: ${(props) => props.theme.color.text.default};
|
|
9
9
|
opacity: ${(props) => (props.$isDisabled ? 0.6 : 1)};
|
|
10
|
-
pointer-events: ${(props) => (props.$isDisabled ?
|
|
10
|
+
pointer-events: ${(props) => (props.$isDisabled ? "none" : "auto")};
|
|
11
11
|
`;
|
|
12
12
|
export const FieldTitleInfoWrapper = styled.div `
|
|
13
13
|
display: flex;
|
|
@@ -26,7 +26,9 @@ export const FieldDescription = styled.p `
|
|
|
26
26
|
margin: 0;
|
|
27
27
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
28
28
|
font-size: ${(props) => props.theme.typography.size.base};
|
|
29
|
-
font-weight: ${(props) =>
|
|
29
|
+
font-weight: ${(props) => props.$isReadOnly
|
|
30
|
+
? props.theme.typography.weight.bold
|
|
31
|
+
: props.theme.typography.weight.normal};
|
|
30
32
|
`;
|
|
31
33
|
export const FieldHelp = styled.p `
|
|
32
34
|
color: ${(props) => props.theme.color.text.default};
|
|
@@ -4,19 +4,21 @@ import { FaCloudUploadAlt, FaTrash } from "react-icons/fa";
|
|
|
4
4
|
import { Button } from "@nolwenture/component-library";
|
|
5
5
|
export const FileUploadFieldContainer = styled.div `
|
|
6
6
|
align-items: center;
|
|
7
|
-
background-color: ${(props) => props.$readOnly ?
|
|
8
|
-
border: ${(props) => props.$readOnly
|
|
7
|
+
background-color: ${(props) => props.$readOnly ? "transparent" : props.theme.color.background.input};
|
|
8
|
+
border: ${(props) => props.$readOnly
|
|
9
|
+
? "none"
|
|
10
|
+
: `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
|
|
9
11
|
display: flex;
|
|
10
12
|
flex-direction: column;
|
|
11
13
|
gap: ${(props) => props.theme.spacing.m};
|
|
12
14
|
justify-content: center;
|
|
13
|
-
padding: ${(props) => props.$readOnly ?
|
|
14
|
-
margin
|
|
15
|
+
padding: ${(props) => (props.$readOnly ? "0" : props.theme.spacing.xxl)};
|
|
16
|
+
margin: ${(props) => `${props.theme.spacing.s} 0 ${props.theme.spacing.l} 0`};
|
|
15
17
|
position: relative;
|
|
16
18
|
transition: 0.3s filter ease;
|
|
17
19
|
|
|
18
20
|
&:hover {
|
|
19
|
-
filter: ${(props) => props.$readOnly ?
|
|
21
|
+
filter: ${(props) => (props.$readOnly ? "none" : "brightness(110%)")};
|
|
20
22
|
}
|
|
21
23
|
`;
|
|
22
24
|
export const HiddenFileInput = styled.input `
|
|
@@ -38,7 +40,12 @@ export const InfoText = styled.p `
|
|
|
38
40
|
margin: 0;
|
|
39
41
|
`;
|
|
40
42
|
export const Divider = styled.div `
|
|
41
|
-
background: linear-gradient(
|
|
43
|
+
background: linear-gradient(
|
|
44
|
+
180deg,
|
|
45
|
+
transparent calc(50% - 2px),
|
|
46
|
+
${(props) => props.theme.color.palette.neutral[500]} calc(50%),
|
|
47
|
+
transparent 50%
|
|
48
|
+
);
|
|
42
49
|
color: ${(props) => props.theme.color.palette.neutral[500]};
|
|
43
50
|
display: flex;
|
|
44
51
|
flex-direction: row;
|
|
@@ -93,15 +100,19 @@ export const FileItemContainer = styled.div `
|
|
|
93
100
|
`;
|
|
94
101
|
export const UploadedFileItemContainer = styled.div `
|
|
95
102
|
align-items: center;
|
|
96
|
-
background-color: ${(props) => props.$readOnly ?
|
|
97
|
-
border: ${(props) => props.$readOnly
|
|
103
|
+
background-color: ${(props) => props.$readOnly ? "transparent" : props.theme.color.background.default};
|
|
104
|
+
border: ${(props) => props.$readOnly
|
|
105
|
+
? "none"
|
|
106
|
+
: `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
|
|
98
107
|
display: flex;
|
|
99
108
|
flex-direction: row;
|
|
100
109
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
101
110
|
gap: ${(props) => props.theme.spacing.m};
|
|
102
111
|
justify-content: space-between;
|
|
103
112
|
margin: 0;
|
|
104
|
-
padding: ${(props) => props.$readOnly
|
|
113
|
+
padding: ${(props) => props.$readOnly
|
|
114
|
+
? "0"
|
|
115
|
+
: `${props.theme.spacing.m} ${props.theme.spacing.l}`};
|
|
105
116
|
width: 100%;
|
|
106
117
|
`;
|
|
107
118
|
export const UploadedFileInfoContainer = styled.div `
|
|
@@ -184,9 +195,9 @@ export const DragOverlay = styled.div `
|
|
|
184
195
|
font-weight: ${(props) => props.theme.typography.weight.bold};
|
|
185
196
|
justify-content: center;
|
|
186
197
|
left: 0;
|
|
187
|
-
pointer-events: none;
|
|
198
|
+
pointer-events: none;
|
|
188
199
|
position: absolute;
|
|
189
200
|
right: 0;
|
|
190
201
|
top: 0;
|
|
191
|
-
z-index: 3;
|
|
202
|
+
z-index: 3;
|
|
192
203
|
`;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
import { RadioFieldContainer, RadioFieldElement, RadioFieldInputElement, RadioFieldLabel, } from "../RadioField/styledComponents";
|
|
3
3
|
export const MultipleChoiceFieldContainer = styled(RadioFieldContainer) `
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
5
|
+
flex-wrap: wrap;
|
|
6
|
+
justify-content: start;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: ${(props) => props.theme.spacing.l};
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
&:has(input[readonly]) {
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: ${(props) => props.theme.spacing.s};
|
|
13
|
+
}
|
|
12
14
|
`;
|
|
13
15
|
export const MultipleChoiceFieldElement = styled(RadioFieldElement) ``;
|
|
14
16
|
export const MultipleChoiceFieldInputElement = styled(RadioFieldInputElement) ``;
|
|
@@ -3,12 +3,16 @@ import { styled } from "styled-components";
|
|
|
3
3
|
export const ObjectFieldTemplateWrapper = styled.fieldset `
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
+
gap: ${(props) => props.theme.spacing.m};
|
|
6
7
|
color: ${(props) => props.theme.color.text.default};
|
|
7
8
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
8
9
|
margin-inline: 0;
|
|
9
10
|
margin-bottom: ${(props) => props.theme.spacing.xs};
|
|
10
11
|
|
|
11
|
-
&:has(input[disabled]),
|
|
12
|
+
&:has(input[disabled]),
|
|
13
|
+
&:has(option[disabled]),
|
|
14
|
+
&:has(select[disabled]),
|
|
15
|
+
&:has(textarea[disabled]) {
|
|
12
16
|
border-color: ${(props) => lighten(0.4, props.theme.color.border.default)};
|
|
13
17
|
|
|
14
18
|
legend {
|
|
@@ -19,7 +23,6 @@ export const ObjectFieldTemplateWrapper = styled.fieldset `
|
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
25
|
}
|
|
22
|
-
|
|
23
26
|
`;
|
|
24
27
|
export const ObjectFieldTemplateTitle = styled.legend `
|
|
25
28
|
color: ${(props) => props.theme.color.text.default};
|
|
@@ -6,7 +6,8 @@ import { FaCheck, FaTimes } from "react-icons/fa";
|
|
|
6
6
|
export const FieldWrapper = styled.div `
|
|
7
7
|
color: ${(props) => props.theme.color.text.default};
|
|
8
8
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
9
|
-
|
|
9
|
+
gap: ${(props) => props.theme.spacing.s};
|
|
10
|
+
margin-bottom: ${(props) => props.theme.spacing.s};
|
|
10
11
|
width: min(100%, 70rem);
|
|
11
12
|
`;
|
|
12
13
|
export const FieldTitle = styled.label `
|
|
@@ -15,7 +16,6 @@ export const FieldTitle = styled.label `
|
|
|
15
16
|
font-family: ${(props) => props.theme.typography.fontFamily.heading};
|
|
16
17
|
font-size: ${(props) => props.theme.typography.size.base};
|
|
17
18
|
font-weight: ${(props) => props.theme.typography.weight.bold};
|
|
18
|
-
margin: ${(props) => `${props.theme.spacing.xs} 0 ${props.theme.spacing.s} 0`};
|
|
19
19
|
width: 100%;
|
|
20
20
|
`;
|
|
21
21
|
export const FieldDescription = styled.div `
|
|
@@ -24,13 +24,12 @@ export const FieldDescription = styled.div `
|
|
|
24
24
|
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
25
25
|
font-style: italic;
|
|
26
26
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
27
|
-
margin-bottom: ${(props) => props.theme.spacing.s};
|
|
28
27
|
`;
|
|
29
28
|
export const StringFieldValue = styled.div `
|
|
30
29
|
color: ${(props) => props.theme.color.text.default};
|
|
31
30
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
32
31
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
33
|
-
|
|
32
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
34
33
|
padding-left: ${(props) => props.theme.spacing.l};
|
|
35
34
|
white-space: pre-line;
|
|
36
35
|
`;
|
|
@@ -38,7 +37,7 @@ export const TextAreaValue = styled.div `
|
|
|
38
37
|
color: ${(props) => props.theme.color.text.default};
|
|
39
38
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
40
39
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
41
|
-
|
|
40
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
42
41
|
padding-left: ${(props) => props.theme.spacing.l};
|
|
43
42
|
white-space: pre-line;
|
|
44
43
|
`;
|
|
@@ -46,15 +45,16 @@ export const ArrayFieldItem = styled.div `
|
|
|
46
45
|
color: ${(props) => props.theme.color.text.default};
|
|
47
46
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
48
47
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
48
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
49
49
|
background-color: ${(props) => props.theme.color.background.default};
|
|
50
50
|
padding: ${(props) => props.theme.spacing.l};
|
|
51
51
|
border: ${(props) => `${props.theme.strokeWidth.thin} solid ${props.theme.color.border.default}`};
|
|
52
|
-
margin-bottom: ${(props) => props.theme.spacing.s};
|
|
53
52
|
`;
|
|
54
53
|
export const EJSFieldValue = styled.div `
|
|
55
54
|
color: ${(props) => props.theme.color.text.default};
|
|
56
55
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
57
56
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
57
|
+
font-weight: ${(props) => props.theme.typography.weight.normal};
|
|
58
58
|
padding-left: ${(props) => props.theme.spacing.l};
|
|
59
59
|
width: 100%;
|
|
60
60
|
`;
|
|
@@ -70,8 +70,8 @@ const SelectedBox = styled.div `
|
|
|
70
70
|
color: ${(props) => props.theme.color.text.default};
|
|
71
71
|
background: ${(props) => props.theme.color.background.default};
|
|
72
72
|
border: ${(props) => props.theme.strokeWidth.thin} solid
|
|
73
|
-
|
|
74
|
-
padding: 0 .05rem;
|
|
73
|
+
${(props) => props.theme.color.border.default};
|
|
74
|
+
padding: 0 0.05rem;
|
|
75
75
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
76
76
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
77
77
|
display: flex;
|
|
@@ -82,22 +82,22 @@ const NotSelectedCircle = styled.div `
|
|
|
82
82
|
color: ${(props) => props.theme.color.text.default};
|
|
83
83
|
background: ${(props) => props.theme.color.background.default};
|
|
84
84
|
border: ${(props) => props.theme.strokeWidth.thin} solid
|
|
85
|
-
|
|
85
|
+
${(props) => props.theme.color.border.default};
|
|
86
86
|
border-radius: ${(props) => props.theme.borderRadius.circle};
|
|
87
87
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
88
88
|
font-size: ${(props) => props.theme.typography.size.small};
|
|
89
89
|
display: inline-flex;
|
|
90
90
|
justify-content: center;
|
|
91
91
|
align-items: start;
|
|
92
|
-
padding: 0 .1rem;
|
|
92
|
+
padding: 0 0.1rem;
|
|
93
93
|
`;
|
|
94
94
|
export const SelectedIcon = styled(FaCheck) `
|
|
95
95
|
color: ${(props) => props.theme.color.text.default};
|
|
96
|
-
width: .75rem;
|
|
96
|
+
width: 0.75rem;
|
|
97
97
|
`;
|
|
98
98
|
export const NotSelectedIcon = styled(FaTimes) `
|
|
99
99
|
color: ${(props) => props.theme.color.text.default};
|
|
100
|
-
width: .75rem;
|
|
100
|
+
width: 0.75rem;
|
|
101
101
|
`;
|
|
102
102
|
export const BooleanFieldWrapper = styled.div `
|
|
103
103
|
font-family: ${(props) => props.theme.typography.fontFamily.base};
|
|
@@ -121,7 +121,7 @@ export const BooleanFieldValue = ({ name, className, value, label, }) => {
|
|
|
121
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
|
-
return (_jsx(MultipleChoiceFieldWrapper, { children: _jsxs(MultipleChoiceFieldContainer, { className: className, style: getStyle(style ?? ""), children: [!selected && !notSelected && _jsx(_Fragment, {
|
|
124
|
+
return (_jsx(MultipleChoiceFieldWrapper, { children: _jsxs(MultipleChoiceFieldContainer, { className: className, style: getStyle(style ?? ""), children: [!selected && !notSelected && _jsx(_Fragment, {}), selected &&
|
|
125
125
|
selected.length > 0 &&
|
|
126
126
|
selected.map((s) => (_jsx(MultipleChoiceFieldElement, { "data-fjsf-enum-value-view": s.const, children: _jsxs(Selected, { children: [_jsx(SelectedBox, { children: _jsx(SelectedIcon, {}) }), _jsx(MultipleChoiceFieldLabel, { children: s.title ?? "Hello" })] }) }, s.title ?? s))), notSelected &&
|
|
127
127
|
notSelected?.length > 0 &&
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { getIn } from "formik";
|
|
2
2
|
// Replaces template string variables with form data for CollapsibleObjectFieldTemplate titles
|
|
3
3
|
export const setTitleValues = (name, title, defaultTitle, values) => {
|
|
4
|
-
const match = name.match(/^([a-zA-Z_$][\w
|
|
4
|
+
const match = name.match(/^([a-zA-Z_$][\w\[\]\.$]*)\[(\d+)\]$/);
|
|
5
5
|
if (match) {
|
|
6
6
|
name = match[1];
|
|
7
7
|
}
|
|
8
8
|
const index = match ? parseInt(match[2]) : -1;
|
|
9
|
-
const itemValues = match ? values
|
|
9
|
+
const itemValues = match ? getIn(values, name)[index] : getIn(values, name);
|
|
10
10
|
return title.replace(/\$\{([\w$.]+)\}/g, (match) => {
|
|
11
11
|
const keyMatch = match.match(/^\$\{([\w$.]+)\}$/);
|
|
12
12
|
const key = keyMatch ? keyMatch[1] : "";
|
|
@@ -9,10 +9,14 @@ export function solveReferences(schema, definitions, uiSchema, uiSchemaDefinitio
|
|
|
9
9
|
throw new Error("Only references to definitions are supported");
|
|
10
10
|
}
|
|
11
11
|
const path = pathParts.slice(2).join(".");
|
|
12
|
+
const uiPath = pathParts
|
|
13
|
+
.slice(2)
|
|
14
|
+
.filter((part) => part !== "properties")
|
|
15
|
+
.join(".");
|
|
12
16
|
// TODO: Should we overwrite rather than merge? Maybe add a flag for choosing the behavior?
|
|
13
17
|
solvedSchema = mergeSchemas(getIn(definitions, path) ?? {}, schema ?? {});
|
|
14
18
|
delete solvedSchema.$ref;
|
|
15
|
-
solvedUiSchema = mergeSchemas(getIn(uiSchemaDefinitions,
|
|
19
|
+
solvedUiSchema = mergeSchemas(getIn(uiSchemaDefinitions, uiPath) ?? {}, uiSchema ?? {});
|
|
16
20
|
}
|
|
17
21
|
return { schema: solvedSchema, uiSchema: solvedUiSchema };
|
|
18
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nolwenture/formik-jsonschema-form",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Formik form generation from json schema",
|
|
5
5
|
"author": "anttivikman <antti.vikman@nolwenture.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -125,4 +125,4 @@
|
|
|
125
125
|
"last 1 safari version"
|
|
126
126
|
]
|
|
127
127
|
}
|
|
128
|
-
}
|
|
128
|
+
}
|