@cocreate/render 1.16.16 → 1.16.18
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 +6 -6
- package/src/index.js +4 -30
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
## [1.16.18](https://github.com/CoCreate-app/CoCreate-render/compare/v1.16.17...v1.16.18) (2022-12-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump dependencies ([6d998ba](https://github.com/CoCreate-app/CoCreate-render/commit/6d998bad28e14b8349ba3787a8a2cd3bdbcba8c6))
|
|
7
|
+
|
|
8
|
+
## [1.16.17](https://github.com/CoCreate-app/CoCreate-render/compare/v1.16.16...v1.16.17) (2022-12-04)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* bump dependencies ([400bc8f](https://github.com/CoCreate-app/CoCreate-render/commit/400bc8fdde09ecf5e90386136dcb62671a164581))
|
|
14
|
+
* utis.getValueFromObject ([7f18477](https://github.com/CoCreate-app/CoCreate-render/commit/7f18477f4ee4f7debe7bd4dbc4b4befbe6fa837c))
|
|
15
|
+
|
|
1
16
|
## [1.16.16](https://github.com/CoCreate-app/CoCreate-render/compare/v1.16.15...v1.16.16) (2022-12-02)
|
|
2
17
|
|
|
3
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/render",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.18",
|
|
4
4
|
"description": "A simple render component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"render",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"webpack-log": "^3.0.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@cocreate/actions": "^1.5.
|
|
65
|
-
"@cocreate/api": "^1.5.
|
|
66
|
-
"@cocreate/docs": "^1.4.
|
|
67
|
-
"@cocreate/element-prototype": "^1.1.
|
|
68
|
-
"@cocreate/utils": "^1.
|
|
64
|
+
"@cocreate/actions": "^1.5.30",
|
|
65
|
+
"@cocreate/api": "^1.5.17",
|
|
66
|
+
"@cocreate/docs": "^1.4.13",
|
|
67
|
+
"@cocreate/element-prototype": "^1.1.18",
|
|
68
|
+
"@cocreate/utils": "^1.14.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/index.js
CHANGED
|
@@ -2,43 +2,17 @@
|
|
|
2
2
|
import action from '@cocreate/actions';
|
|
3
3
|
import observer from '@cocreate/observer';
|
|
4
4
|
import uuid from '@cocreate/uuid';
|
|
5
|
-
import { queryDocumentSelector } from '@cocreate/utils';
|
|
5
|
+
import { queryDocumentSelector, getValueFromObject } from '@cocreate/utils';
|
|
6
6
|
import '@cocreate/element-prototype';
|
|
7
7
|
import './index.css';
|
|
8
8
|
// import api from '@cocreate/api';
|
|
9
9
|
|
|
10
10
|
const CoCreateRender = {
|
|
11
|
-
// Can be called from utils getValueFromObject
|
|
12
|
-
__getValueFromObject: function(json, path) {
|
|
13
|
-
try {
|
|
14
|
-
if (typeof json == 'undefined' || !path)
|
|
15
|
-
return false;
|
|
16
|
-
if (path.indexOf('.') == -1 && path.includes('collection'))
|
|
17
|
-
json = this.dataOriginal
|
|
18
|
-
if (/\[([0-9]*)\]/g.test(path)) {
|
|
19
|
-
path = path.replace(/\[/g, '.');
|
|
20
|
-
if (path.endsWith(']'))
|
|
21
|
-
path = path.slice(0, -1)
|
|
22
|
-
path = path.replace(/\]./g, '.');
|
|
23
|
-
path = path.replace(/\]/g, '.');
|
|
24
|
-
}
|
|
25
|
-
let jsonData = json, subpath = path.split('.');
|
|
26
|
-
|
|
27
|
-
for (let i = 0; i < subpath.length; i++) {
|
|
28
|
-
jsonData = jsonData[subpath[i]];
|
|
29
|
-
if (!jsonData) return false;
|
|
30
|
-
}
|
|
31
|
-
return jsonData;
|
|
32
|
-
}catch(error){
|
|
33
|
-
console.log("Error in getValueFromObject", error);
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
11
|
|
|
38
12
|
__getValue: function(data, attrValue) {
|
|
39
13
|
let result = /{{\s*([\w\W]+)\s*}}/g.exec(attrValue);
|
|
40
14
|
if (result) {
|
|
41
|
-
return
|
|
15
|
+
return getValueFromObject(data, result[1].trim());
|
|
42
16
|
}
|
|
43
17
|
return false;
|
|
44
18
|
},
|
|
@@ -141,7 +115,7 @@ const CoCreateRender = {
|
|
|
141
115
|
template.renderedKeys = new Map()
|
|
142
116
|
|
|
143
117
|
if (isRenderObject && type) {
|
|
144
|
-
let Data = self.
|
|
118
|
+
let Data = self.getValueFromObject(arrayData, type);
|
|
145
119
|
let array = self.isRenderObject(Data, renderKey)
|
|
146
120
|
for (let item of array) {
|
|
147
121
|
if (!template.renderedKeys.has(item[renderKey].key)){
|
|
@@ -155,7 +129,7 @@ const CoCreateRender = {
|
|
|
155
129
|
} else {
|
|
156
130
|
|
|
157
131
|
if (!Array.isArray(arrayData))
|
|
158
|
-
arrayData =
|
|
132
|
+
arrayData = getValueFromObject(data, type);
|
|
159
133
|
|
|
160
134
|
if (!arrayData) {
|
|
161
135
|
let cloneEl = this.cloneEl(template);
|