@schukai/monster 4.91.1 → 4.92.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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.92.0"}
|
|
@@ -1043,34 +1043,32 @@ function syncOptionData() {
|
|
|
1043
1043
|
* @return {object}
|
|
1044
1044
|
*/
|
|
1045
1045
|
function resolveFormRecord(form, datasource) {
|
|
1046
|
-
|
|
1046
|
+
const { data, dataPath } = resolveDatasourceBasePath(form, datasource);
|
|
1047
1047
|
if (!isObject(data) && !isArray(data)) {
|
|
1048
1048
|
return {};
|
|
1049
1049
|
}
|
|
1050
1050
|
|
|
1051
|
-
|
|
1052
|
-
if (
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1051
|
+
let resolvedData = data;
|
|
1052
|
+
if (isObject(resolvedData) && !isArray(resolvedData)) {
|
|
1053
|
+
if (isArray(resolvedData.data)) {
|
|
1054
|
+
resolvedData = resolvedData.data;
|
|
1055
|
+
} else if (isArray(resolvedData.dataset)) {
|
|
1056
|
+
resolvedData = resolvedData.dataset;
|
|
1057
|
+
} else if (dataPath === "") {
|
|
1058
|
+
resolvedData = Object.values(resolvedData);
|
|
1057
1059
|
}
|
|
1058
1060
|
}
|
|
1059
1061
|
|
|
1060
|
-
if (isObject(data)) {
|
|
1061
|
-
data = Object.values(data);
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
1062
|
const mappingIndex = form.getOption?.("mapping.index");
|
|
1065
1063
|
if (mappingIndex !== null && mappingIndex !== undefined) {
|
|
1066
|
-
|
|
1064
|
+
resolvedData = resolvedData?.[mappingIndex];
|
|
1067
1065
|
}
|
|
1068
1066
|
|
|
1069
|
-
if (!isObject(
|
|
1067
|
+
if (!isObject(resolvedData) && !isArray(resolvedData)) {
|
|
1070
1068
|
return {};
|
|
1071
1069
|
}
|
|
1072
1070
|
|
|
1073
|
-
return
|
|
1071
|
+
return resolvedData;
|
|
1074
1072
|
}
|
|
1075
1073
|
|
|
1076
1074
|
/**
|
|
@@ -1085,14 +1083,14 @@ function getDatasourceContext() {
|
|
|
1085
1083
|
return null;
|
|
1086
1084
|
}
|
|
1087
1085
|
|
|
1088
|
-
const mappingData = form?.getOption?.("mapping.data");
|
|
1089
1086
|
const mappingIndex = form?.getOption?.("mapping.index");
|
|
1087
|
+
const { dataPath } = resolveDatasourceBasePath(form, datasource);
|
|
1090
1088
|
const record = resolveFormRecord(form, datasource);
|
|
1091
1089
|
const normalizedPath = normalizePathForRecord(path, record);
|
|
1092
1090
|
let basePath = "";
|
|
1093
1091
|
|
|
1094
|
-
if (isString(
|
|
1095
|
-
basePath =
|
|
1092
|
+
if (isString(dataPath) && dataPath.trim() !== "") {
|
|
1093
|
+
basePath = dataPath.trim();
|
|
1096
1094
|
}
|
|
1097
1095
|
|
|
1098
1096
|
if (mappingIndex !== null && mappingIndex !== undefined) {
|
|
@@ -1104,6 +1102,42 @@ function getDatasourceContext() {
|
|
|
1104
1102
|
return { target: datasource, path: finalPath };
|
|
1105
1103
|
}
|
|
1106
1104
|
|
|
1105
|
+
/**
|
|
1106
|
+
* @private
|
|
1107
|
+
* @param {HTMLElement} form
|
|
1108
|
+
* @param {HTMLElement} datasource
|
|
1109
|
+
* @return {{data: object|Array, dataPath: string}}
|
|
1110
|
+
*/
|
|
1111
|
+
function resolveDatasourceBasePath(form, datasource) {
|
|
1112
|
+
let data = datasource?.data;
|
|
1113
|
+
if (!isObject(data) && !isArray(data)) {
|
|
1114
|
+
return { data: {}, dataPath: "" };
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
let dataPath = "";
|
|
1118
|
+
const mappingData = form?.getOption?.("mapping.data");
|
|
1119
|
+
if (isString(mappingData) && mappingData.trim() !== "") {
|
|
1120
|
+
const trimmed = mappingData.trim();
|
|
1121
|
+
try {
|
|
1122
|
+
const mapped = new Pathfinder(data).getVia(trimmed);
|
|
1123
|
+
if (mapped !== undefined) {
|
|
1124
|
+
data = mapped;
|
|
1125
|
+
dataPath = trimmed;
|
|
1126
|
+
}
|
|
1127
|
+
} catch {}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
if (dataPath === "" && isObject(data) && !isArray(data)) {
|
|
1131
|
+
if (isArray(data.data)) {
|
|
1132
|
+
dataPath = "data";
|
|
1133
|
+
} else if (isArray(data.dataset)) {
|
|
1134
|
+
dataPath = "dataset";
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
return { data, dataPath };
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1107
1141
|
/**
|
|
1108
1142
|
* @private
|
|
1109
1143
|
* @return {string}
|