@cocreate/render 1.15.11 → 1.16.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 CHANGED
@@ -1,3 +1,19 @@
1
+ ## [1.16.1](https://github.com/CoCreate-app/CoCreate-render/compare/v1.16.0...v1.16.1) (2022-11-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * data.document._id ([b416a9c](https://github.com/CoCreate-app/CoCreate-render/commit/b416a9cfe975d8454a34d176a60c326a4dbf82c4))
7
+ * improved handling of data structure, added @cocreate/element-prototype ([e458cfc](https://github.com/CoCreate-app/CoCreate-render/commit/e458cfc7fbf034701cc7e90bacc625d6705c4259))
8
+ * renamed {{data.key}} to {{document.key}} ([f108b83](https://github.com/CoCreate-app/CoCreate-render/commit/f108b8324f80f22b3b784f02738949e7b357912f))
9
+
10
+ # [1.16.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.15.11...v1.16.0) (2022-10-03)
11
+
12
+
13
+ ### Features
14
+
15
+ * render Array will convert an object to array ([85bc9bd](https://github.com/CoCreate-app/CoCreate-render/commit/85bc9bd21040f5e75f63cc16f7002796a53f114a))
16
+
1
17
  ## [1.15.11](https://github.com/CoCreate-app/CoCreate-render/compare/v1.15.10...v1.15.11) (2022-10-02)
2
18
 
3
19
 
@@ -12,8 +12,8 @@
12
12
 
13
13
  <cocreate-select name="current_org" template_id="abc1">
14
14
  <selected class="template" template_id="abc1" render-array="data">
15
- <cc-option class="template" value="{{data.current_org}}">
16
- <h3>{{data.current_org}}</h3>
15
+ <cc-option class="template" value="{{document.current_org}}">
16
+ <h3>{{document.current_org}}</h3>
17
17
  </cc-option>
18
18
  </selected>
19
19
  </cocreate-select>
package/demo/render.html CHANGED
@@ -13,8 +13,8 @@
13
13
  <body>
14
14
 
15
15
  <div class="template" template_id="abc1">
16
- <h3>{{collection}}</h3>
17
- <h3>{{data._id}}</h3>
16
+ <h3>{{document.collection}}</h3>
17
+ <h3>{{document._id}}</h3>
18
18
  </div>
19
19
 
20
20
  <pre>
@@ -12,7 +12,7 @@
12
12
 
13
13
  <div class="template" template_id="abc1">
14
14
  <!-- <div>{{data}}</div>
15
- <h1> {{data.collection}} {{data._id}}</h1> -->
15
+ <h1> {{document.collection}} {{document._id}}</h1> -->
16
16
  <div class="template" render-object="" render-key="one">
17
17
  <h5>{{one.key}}: {{one.value}}</h5>
18
18
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/render",
3
- "version": "1.15.11",
3
+ "version": "1.16.1",
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",
@@ -64,6 +64,7 @@
64
64
  "@cocreate/actions": "^1.5.12",
65
65
  "@cocreate/api": "^1.4.12",
66
66
  "@cocreate/docs": "^1.3.18",
67
+ "@cocreate/element-prototype": "^1.0.0",
67
68
  "@cocreate/utils": "^1.10.12"
68
69
  }
69
70
  }
package/src/index.js CHANGED
@@ -3,8 +3,8 @@ import action from '@cocreate/actions';
3
3
  import observer from '@cocreate/observer';
4
4
  import uuid from '@cocreate/uuid';
5
5
  import { queryDocumentSelector } from '@cocreate/utils';
6
+ import '@cocreate/element-prototype';
6
7
  import './index.css';
7
- // import { getValue } from '../../CoCreate-elements/src/getValue';
8
8
  // import api from '@cocreate/api';
9
9
 
10
10
  const CoCreateRender = {
@@ -70,11 +70,11 @@ const CoCreateRender = {
70
70
  variables.forEach((attr) => {
71
71
  let value;
72
72
 
73
- if (attr == "{{data._id}}" || attr == `{{${renderKey}._id}}` || attr == "{{document_id}}")
74
- value = this.document_id;
75
- else if (attr == "{{collection}" || attr == `{{${renderKey}.collection}}`)
76
- value = this.collection;
77
- else
73
+ // if (attr == "{{data._id}}" || attr == `{{${renderKey}._id}}` || attr == "{{document_id}}" || attr == "{{document._id}}")
74
+ // value = this.document_id;
75
+ // else if (attr == "{{collection}" || attr == `{{${renderKey}.collection}}`)
76
+ // value = this.collection;
77
+ // else
78
78
  value = self.__getValue(data, attr);
79
79
 
80
80
  if (value) {
@@ -163,6 +163,9 @@ const CoCreateRender = {
163
163
  template.insertAdjacentElement('beforebegin', cloneEl);
164
164
  }
165
165
 
166
+ if (!Array.isArray(arrayData))
167
+ arrayData = [arrayData]
168
+
166
169
  if(type && Array.isArray(arrayData)) {
167
170
  arrayData.forEach((item) => {
168
171
  if (!template.renderedKeys.has(item)){
@@ -231,11 +234,11 @@ const CoCreateRender = {
231
234
  if (data.renderKey)
232
235
  isRenderKey = true
233
236
 
234
- if (data.document_id || data.data && data.data._id)
235
- this.document_id = data.document_id || data.data._id;
237
+ // if (data.document._id)
238
+ // this.document_id = data.document._id;
236
239
 
237
- if (data.collection)
238
- this.collection = data.collection;
240
+ // if (data.collection)
241
+ // this.collection = data.collection;
239
242
 
240
243
  const that = this;
241
244
  Array.from(els).forEach(el => {