@cocreate/render 1.16.15 → 1.16.17

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
@@ -1,3 +1,18 @@
1
+ ## [1.16.17](https://github.com/CoCreate-app/CoCreate-render/compare/v1.16.16...v1.16.17) (2022-12-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump dependencies ([400bc8f](https://github.com/CoCreate-app/CoCreate-render/commit/400bc8fdde09ecf5e90386136dcb62671a164581))
7
+ * utis.getValueFromObject ([7f18477](https://github.com/CoCreate-app/CoCreate-render/commit/7f18477f4ee4f7debe7bd4dbc4b4befbe6fa837c))
8
+
9
+ ## [1.16.16](https://github.com/CoCreate-app/CoCreate-render/compare/v1.16.15...v1.16.16) (2022-12-02)
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * docs ([29ccd85](https://github.com/CoCreate-app/CoCreate-render/commit/29ccd85eda9c38febbf9e2e7ac36d6a4c266f830))
15
+
1
16
  ## [1.16.15](https://github.com/CoCreate-app/CoCreate-render/compare/v1.16.14...v1.16.15) (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.15",
3
+ "version": "1.16.17",
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.27",
65
- "@cocreate/api": "^1.5.14",
66
- "@cocreate/docs": "^1.4.10",
67
- "@cocreate/element-prototype": "^1.1.15",
68
- "@cocreate/utils": "^1.13.0"
64
+ "@cocreate/actions": "^1.5.29",
65
+ "@cocreate/api": "^1.5.16",
66
+ "@cocreate/docs": "^1.4.13",
67
+ "@cocreate/element-prototype": "^1.1.16",
68
+ "@cocreate/utils": "^1.13.1"
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 this.__getValueFromObject(data, result[1].trim());
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.__getValueFromObject(arrayData, type);
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 = this.__getValueFromObject(data, type);
132
+ arrayData = getValueFromObject(data, type);
159
133
 
160
134
  if (!arrayData) {
161
135
  let cloneEl = this.cloneEl(template);