@cocreate/elements 1.6.4 → 1.6.5

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,10 @@
1
+ ## [1.6.5](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.4...v1.6.5) (2022-01-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * getValue from element ([44fd22d](https://github.com/CoCreate-app/CoCreate-elements/commit/44fd22df7f5159a6f94e0bedfd381526d7b42a94))
7
+
1
8
  ## [1.6.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.3...v1.6.4) (2022-01-16)
2
9
 
3
10
 
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Value | CoCreateJS</title>
5
+
6
+ <!-- CoCreate Favicon -->
7
+ <link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
8
+ <!-- CoCreate CSS CDN -->
9
+ <link rel="stylesheet" href="https://cdn.cocreate.app/logic/latest/CoCreate-logic.min.css" type="text/css"/>
10
+ </head>
11
+ <body>
12
+ <!-- windows -->
13
+ <!--<ul get-value="##a123"> </ul>-->
14
+ <!--<ul id="a123"> hello </ul>-->
15
+
16
+ <cocreate-select class="floating-label" id="collection" placeholder="collection:" set-value="#document_id" set-value-key="setcollection" active>
17
+ <ul fetch-collections template_id="collection" class="options z-index:7 margin-top:5px">
18
+ <cc-option class="option template" template_id="collection" value="{{data.name}}">
19
+ <span>{{data.name}}</span>
20
+ </cc-option>
21
+ </ul>
22
+ </cocreate-select>
23
+
24
+ <cocreate-select class="floating-label" id="document_id" placeholder="document_id:" active>
25
+ <ul fetch-collection="{{setcollection}}" template_id="document_id" class="options z-index:7 margin-top:5px">
26
+ <cc-option class="option template" template_id="document_id" value="{{data._id}}">
27
+ <span>{{data._id}}</span>
28
+ </cc-option>
29
+ </ul>
30
+ </cocreate-select>
31
+
32
+ <input value="new" set-value="#testing" set-value-key="ty">
33
+ <h1 id="testing" class="{{ty}}" test="{{ty}}">{{ty}}</h1>
34
+
35
+
36
+
37
+ <!--<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>-->
38
+ <script src="../../../CoCreateJS/dist/CoCreate.js" ></script>
39
+
40
+ </body>
41
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/elements",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
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/getValue.js CHANGED
@@ -48,7 +48,7 @@ function initEvents(valueEl, element){
48
48
  }
49
49
 
50
50
  function setValueByFind(valueEl) {
51
- let value = getValue(valueEl);
51
+ let value = valueEl.getValue(valueEl);
52
52
  if (!value) return;
53
53
  let elements = valueEls.get(valueEl);
54
54
 
package/src/setValue.js CHANGED
@@ -27,11 +27,12 @@ function initEvents(element){
27
27
  });
28
28
  }
29
29
 
30
+ const setValueMap = new Map();
30
31
  function setValueByFind(element){
31
32
  let key = element.getAttribute('set-value-key');
32
33
  if (key)
33
34
  key = `{{${key}}}`;
34
- let value = getValue(element);
35
+ let value = element.getValue(element);
35
36
  if (!value) return;
36
37
  let selector = element.getAttribute('set-value');
37
38
  if(!selector) return;
@@ -39,6 +40,8 @@ function setValueByFind(element){
39
40
 
40
41
  for(let element of elements){
41
42
  if (key){
43
+ if (setValueMap.has(element))
44
+ key = setValueMap.get(element);
42
45
  const regex = new RegExp(key, "g");
43
46
  for (let attribute of element.attributes){
44
47
  let attrName = attribute.name;
@@ -61,6 +64,7 @@ function setValueByFind(element){
61
64
  html = html.replace(regex, value);
62
65
  element.innerHTML = html;
63
66
  }
67
+ setValueMap.set(element, value)
64
68
  }
65
69
  else
66
70
  setValue(element, value);