@cocreate/elements 1.41.0 → 1.41.1
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 +8 -0
- package/package.json +1 -1
- package/src/fetchSrc.js +13 -9
- package/src/index.js +11 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## [1.41.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.41.0...v1.41.1) (2025-01-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* path handling ([1276f2d](https://github.com/CoCreate-app/CoCreate-elements/commit/1276f2d3988ec556ce95d3166596526d9d5851c3))
|
|
7
|
+
* sum handling ([86f1e74](https://github.com/CoCreate-app/CoCreate-elements/commit/86f1e74af2e14b51b925e36fd22b2935796073fa))
|
|
8
|
+
|
|
1
9
|
# [1.41.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.40.1...v1.41.0) (2025-01-02)
|
|
2
10
|
|
|
3
11
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.41.
|
|
3
|
+
"version": "1.41.1",
|
|
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",
|
package/src/fetchSrc.js
CHANGED
|
@@ -149,16 +149,20 @@ async function initElements(elements) {
|
|
|
149
149
|
// let blob = await response.json();
|
|
150
150
|
// URL.createObjectURL(blob);
|
|
151
151
|
}
|
|
152
|
-
}
|
|
152
|
+
}
|
|
153
|
+
// else if (element.hasAttribute("rendered")) {
|
|
154
|
+
// element.removeAttribute("rendered");
|
|
155
|
+
// // let path = element.getAttribute("path");
|
|
156
|
+
// // if (path) {
|
|
157
|
+
// // let elements = element.querySelectorAll("[src]");
|
|
158
|
+
// // for (let i = 0; i < elements.length; i++) {
|
|
159
|
+
// // text = text.replaceAll("{{path}}", path);
|
|
160
|
+
// // }
|
|
161
|
+
// // }
|
|
162
|
+
// }
|
|
163
|
+
else {
|
|
153
164
|
element.removeAttribute("rendered");
|
|
154
|
-
|
|
155
|
-
// if (path) {
|
|
156
|
-
// let elements = element.querySelectorAll("[src]");
|
|
157
|
-
// for (let i = 0; i < elements.length; i++) {
|
|
158
|
-
// text = text.replaceAll("{{path}}", path);
|
|
159
|
-
// }
|
|
160
|
-
// }
|
|
161
|
-
} else {
|
|
165
|
+
|
|
162
166
|
let text = await response.text();
|
|
163
167
|
if (text) {
|
|
164
168
|
let path = element.getAttribute("path");
|
package/src/index.js
CHANGED
|
@@ -480,8 +480,12 @@ async function filterData(element, data, type, key) {
|
|
|
480
480
|
}
|
|
481
481
|
let docValue = getValueFromObject(doc, property);
|
|
482
482
|
if (docValue) {
|
|
483
|
-
if (
|
|
484
|
-
|
|
483
|
+
if (operator === "$sum" && typeof docValue === "number") {
|
|
484
|
+
if (typeof value !== "number") value = 0;
|
|
485
|
+
value += docValue;
|
|
486
|
+
} else if (Array.isArray(docValue)) {
|
|
487
|
+
Data.push(...docValue);
|
|
488
|
+
} else {
|
|
485
489
|
isObject = true;
|
|
486
490
|
Data.push(docValue);
|
|
487
491
|
}
|
|
@@ -496,11 +500,11 @@ async function filterData(element, data, type, key) {
|
|
|
496
500
|
// data = { [property]: Data[0] }
|
|
497
501
|
// } else
|
|
498
502
|
if (!operator) data = Data;
|
|
499
|
-
else if (operator === "$sum") {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
503
|
+
// else if (operator === "$sum") {
|
|
504
|
+
// value = data[type].reduce((accumulator, currentValue) => {
|
|
505
|
+
// return accumulator + currentValue;
|
|
506
|
+
// }, 0);
|
|
507
|
+
// }
|
|
504
508
|
} else {
|
|
505
509
|
data = { [property]: data[type][property] };
|
|
506
510
|
}
|