@cocreate/elements 1.42.1 → 1.42.3
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 +15 -0
- package/package.json +8 -16
- package/src/fetchSrc.js +7 -1
- package/src/index.js +25 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.42.3](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.42.2...v1.42.3) (2025-09-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* handle trailing slashes in relative path replacement and improve mutation parent check ([b2f559a](https://github.com/CoCreate-app/CoCreate-elements/commit/b2f559a583e41a88b196f62395ba3f1759fe10f2))
|
|
7
|
+
* improve value checks and handling in getData and save functions ([d8fd81d](https://github.com/CoCreate-app/CoCreate-elements/commit/d8fd81d89ecdf1feb3d7e1074fe8afe21adcfba4))
|
|
8
|
+
|
|
9
|
+
## [1.42.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.42.1...v1.42.2) (2025-05-01)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* update [@cocreate](https://github.com/cocreate) dependencies ([d0bb4ee](https://github.com/CoCreate-app/CoCreate-elements/commit/d0bb4ee9485f2125f9b46c0ea3787900d05463a1))
|
|
15
|
+
|
|
1
16
|
## [1.42.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.42.0...v1.42.1) (2025-04-30)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.42.
|
|
3
|
+
"version": "1.42.3",
|
|
4
4
|
"description": "Fetch content into any html element by using html5 attributes to query data stored in CoCreate headless CMS. If data is changed it will instantly reflect in html tags as changes are broadcasted in realtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"elements",
|
|
7
|
-
"cocreate",
|
|
8
|
-
"low-code-framework",
|
|
9
|
-
"no-code-framework",
|
|
10
|
-
"cocreatejs",
|
|
11
|
-
"cocreatejs-component",
|
|
12
|
-
"cocreate-framework",
|
|
13
|
-
"no-code",
|
|
14
7
|
"low-code",
|
|
15
|
-
"collaborative-framework",
|
|
16
8
|
"realtime",
|
|
17
9
|
"realtime-framework",
|
|
18
10
|
"collaboration",
|
|
@@ -54,12 +46,12 @@
|
|
|
54
46
|
"webpack-log": "^3.0.1"
|
|
55
47
|
},
|
|
56
48
|
"dependencies": {
|
|
57
|
-
"@cocreate/actions": "^1.21.
|
|
58
|
-
"@cocreate/crud-client": "^1.34.
|
|
59
|
-
"@cocreate/element-prototype": "^1.29.
|
|
60
|
-
"@cocreate/filter": "^1.33.
|
|
61
|
-
"@cocreate/observer": "^1.18.
|
|
62
|
-
"@cocreate/render": "^1.45.
|
|
63
|
-
"@cocreate/utils": "^1.
|
|
49
|
+
"@cocreate/actions": "^1.21.1",
|
|
50
|
+
"@cocreate/crud-client": "^1.34.2",
|
|
51
|
+
"@cocreate/element-prototype": "^1.29.1",
|
|
52
|
+
"@cocreate/filter": "^1.33.2",
|
|
53
|
+
"@cocreate/observer": "^1.18.1",
|
|
54
|
+
"@cocreate/render": "^1.45.2",
|
|
55
|
+
"@cocreate/utils": "^1.39.0"
|
|
64
56
|
}
|
|
65
57
|
}
|
package/src/fetchSrc.js
CHANGED
|
@@ -45,7 +45,13 @@ async function initElements(elements) {
|
|
|
45
45
|
if (pathElement) {
|
|
46
46
|
let path =
|
|
47
47
|
pathElement.getAttribute("path") || getPath();
|
|
48
|
-
if (path)
|
|
48
|
+
if (path) {
|
|
49
|
+
// Remove trailing slash if present
|
|
50
|
+
if (path.endsWith("/")) {
|
|
51
|
+
path = path.slice(0, -1);
|
|
52
|
+
}
|
|
53
|
+
text = text.replaceAll("$relativePath", path);
|
|
54
|
+
}
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
text = text.replaceAll("ObjectId()", () => {
|
package/src/index.js
CHANGED
|
@@ -856,7 +856,7 @@ async function getData(form) {
|
|
|
856
856
|
}
|
|
857
857
|
|
|
858
858
|
let value = await element.getValue();
|
|
859
|
-
if (
|
|
859
|
+
if (value === undefined) continue;
|
|
860
860
|
|
|
861
861
|
let Data = { ...data };
|
|
862
862
|
let dataKey = elements.get(element);
|
|
@@ -1014,7 +1014,7 @@ async function getData(form) {
|
|
|
1014
1014
|
|
|
1015
1015
|
async function save(element, action) {
|
|
1016
1016
|
if (!element) return;
|
|
1017
|
-
let data, value;
|
|
1017
|
+
let data, value, form;
|
|
1018
1018
|
let upsert = element.getAttribute("upsert");
|
|
1019
1019
|
if (upsert && upsert !== "false") upsert = true;
|
|
1020
1020
|
if (element.tagName === "FORM") {
|
|
@@ -1022,9 +1022,12 @@ async function save(element, action) {
|
|
|
1022
1022
|
} else {
|
|
1023
1023
|
let isSave = element.getAttribute("save");
|
|
1024
1024
|
if (isSave === "false") return;
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1025
|
+
if (action) {
|
|
1026
|
+
form = element.closest("form");
|
|
1027
|
+
if (form) {
|
|
1028
|
+
return save(form);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1028
1031
|
|
|
1029
1032
|
let dataKey = elements.get(element);
|
|
1030
1033
|
data = { ...keys.get(dataKey).dataKey.object };
|
|
@@ -1064,21 +1067,25 @@ async function save(element, action) {
|
|
|
1064
1067
|
let Data = [];
|
|
1065
1068
|
for (let i = 0; i < data.length; i++) {
|
|
1066
1069
|
if (data[i].type === "object") {
|
|
1067
|
-
if (
|
|
1070
|
+
if (!data[i].object) {
|
|
1071
|
+
data[i].method = "object.create";
|
|
1072
|
+
} else if (typeof data[i].object === "string") {
|
|
1068
1073
|
if (!data[i]._id) data[i].method = "object.create";
|
|
1069
1074
|
else {
|
|
1070
1075
|
data[i].method = "object.update";
|
|
1071
1076
|
if (upsert) data[i].upsert = true;
|
|
1072
1077
|
}
|
|
1073
1078
|
} else if (Array.isArray(data[i].object)) {
|
|
1074
|
-
if (!data[i].object[0]._id)
|
|
1075
|
-
|
|
1079
|
+
if (!data[i].object[0]._id) {
|
|
1080
|
+
data[i].method = "object.create";
|
|
1081
|
+
} else {
|
|
1076
1082
|
data[i].method = "object.update";
|
|
1077
1083
|
if (upsert) data[i].upsert = true;
|
|
1078
1084
|
}
|
|
1079
1085
|
} else if (typeof data[i].object === "object") {
|
|
1080
|
-
if (!data[i].object._id)
|
|
1081
|
-
|
|
1086
|
+
if (!data[i].object._id) {
|
|
1087
|
+
data[i].method = "object.create";
|
|
1088
|
+
} else {
|
|
1082
1089
|
data[i].method = "object.update";
|
|
1083
1090
|
if (upsert) data[i].upsert = true;
|
|
1084
1091
|
}
|
|
@@ -1151,7 +1158,9 @@ function setTypeValue(element, data, action) {
|
|
|
1151
1158
|
|
|
1152
1159
|
if (!form) {
|
|
1153
1160
|
if (data.type === "object") {
|
|
1154
|
-
|
|
1161
|
+
if (data.object && data.object[0] && data.object[0]._id) {
|
|
1162
|
+
element.setAttribute("object", data.object[0]._id);
|
|
1163
|
+
}
|
|
1155
1164
|
} else {
|
|
1156
1165
|
element.setAttribute(data.type, data[data.type].name);
|
|
1157
1166
|
}
|
|
@@ -1310,9 +1319,6 @@ function initSocket() {
|
|
|
1310
1319
|
if (data.rendered) return;
|
|
1311
1320
|
|
|
1312
1321
|
data.rendered = true;
|
|
1313
|
-
if (data && data.key === "answers") {
|
|
1314
|
-
console.log("test");
|
|
1315
|
-
}
|
|
1316
1322
|
|
|
1317
1323
|
setData(null, data);
|
|
1318
1324
|
});
|
|
@@ -1325,7 +1331,11 @@ Observer.init({
|
|
|
1325
1331
|
types: ["addedNodes"],
|
|
1326
1332
|
selector: "[render-clone]",
|
|
1327
1333
|
callback: function (mutation) {
|
|
1328
|
-
if (
|
|
1334
|
+
if (
|
|
1335
|
+
mutation.parentElement &&
|
|
1336
|
+
!mutation.parentElement.hasAttribute("dnd")
|
|
1337
|
+
)
|
|
1338
|
+
return;
|
|
1329
1339
|
let delayTimer = debounce.get(mutation);
|
|
1330
1340
|
clearTimeout(delayTimer);
|
|
1331
1341
|
debounce.delete(mutation.target);
|