@nolwenture/formik-jsonschema-form 1.3.6 → 1.3.7
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.
|
@@ -10,14 +10,16 @@ const setTitleValues = (name, title, defaultTitle, values) => {
|
|
|
10
10
|
}
|
|
11
11
|
const index = match ? parseInt(match[2]) : -1;
|
|
12
12
|
const itemValues = match ? (0, formik_1.getIn)(values, name)[index] : (0, formik_1.getIn)(values, name);
|
|
13
|
+
const fallbackName = name.split(".").slice(-1)[0];
|
|
13
14
|
return title.replace(/\$\{([\w$.:]+)\}/g, (match) => {
|
|
14
15
|
const keyMatch = match.match(/^\$\{([\w$.:]+)\}$/);
|
|
15
16
|
const key = keyMatch ? keyMatch[1] : "";
|
|
17
|
+
const value = itemValues ? (0, formik_1.getIn)(itemValues, key) : undefined;
|
|
16
18
|
return key === "index"
|
|
17
19
|
? (index + 1).toString()
|
|
18
|
-
:
|
|
19
|
-
?
|
|
20
|
-
: defaultTitle
|
|
20
|
+
: value
|
|
21
|
+
? value
|
|
22
|
+
: defaultTitle || fallbackName;
|
|
21
23
|
});
|
|
22
24
|
};
|
|
23
25
|
exports.setTitleValues = setTitleValues;
|
|
@@ -7,13 +7,15 @@ export const setTitleValues = (name, title, defaultTitle, values) => {
|
|
|
7
7
|
}
|
|
8
8
|
const index = match ? parseInt(match[2]) : -1;
|
|
9
9
|
const itemValues = match ? getIn(values, name)[index] : getIn(values, name);
|
|
10
|
+
const fallbackName = name.split(".").slice(-1)[0];
|
|
10
11
|
return title.replace(/\$\{([\w$.:]+)\}/g, (match) => {
|
|
11
12
|
const keyMatch = match.match(/^\$\{([\w$.:]+)\}$/);
|
|
12
13
|
const key = keyMatch ? keyMatch[1] : "";
|
|
14
|
+
const value = itemValues ? getIn(itemValues, key) : undefined;
|
|
13
15
|
return key === "index"
|
|
14
16
|
? (index + 1).toString()
|
|
15
|
-
:
|
|
16
|
-
?
|
|
17
|
-
: defaultTitle
|
|
17
|
+
: value
|
|
18
|
+
? value
|
|
19
|
+
: defaultTitle || fallbackName;
|
|
18
20
|
});
|
|
19
21
|
};
|