@cocreate/elements 1.14.0 → 1.14.2

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.14.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.14.1...v1.14.2) (2022-12-30)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update config sources to use template braces with entry on src ([241c4bc](https://github.com/CoCreate-app/CoCreate-elements/commit/241c4bc229c4e8bf13e2d5dd7b4841e1f066a5e6))
7
+
8
+ ## [1.14.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.14.0...v1.14.1) (2022-12-29)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * bump dependencies ([d4637fa](https://github.com/CoCreate-app/CoCreate-elements/commit/d4637fa2089fbee92e3191704bcd65c9ac4d12fa))
14
+ * exclusively use element-prototype getValue and setValue ([5d4bc05](https://github.com/CoCreate-app/CoCreate-elements/commit/5d4bc05c27e5f83275547d2f32e6de363a6c744e))
15
+
1
16
  # [1.14.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.31...v1.14.0) (2022-12-27)
2
17
 
3
18
 
@@ -6,13 +6,12 @@ module.exports = {
6
6
  },
7
7
  "sources": [
8
8
  {
9
- "entry": "./docs/index.html",
10
9
  "collection": "files",
11
10
  "document": {
12
11
  "_id": "601f4b1c6b402c72efc07e0b",
13
12
  "name": "index.html",
14
13
  "path": "/docs/elements/index.html",
15
- "src": "{{source}}",
14
+ "src": "{{./docs/index.html}}",
16
15
  "domains": [
17
16
  "*",
18
17
  "general.cocreate.app"
@@ -1,28 +1,26 @@
1
1
  <!DOCTYPE html>
2
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
- <!--<ul get-value="#a123"> </ul>-->
13
- <!--<ul id="a123"> hello </ul>-->
14
-
15
- <input id="testing" value="new">
16
- <h1 get-value="#testing" get-value-key="ty" class="{{ty}}" test="{{ty}}">{{ty}}</h1>
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>
17
12
 
18
- <hr/>
13
+ <input id="testing" value="new">
14
+ <h1 get-value="#testing" get-value-key="ty" class="{{ty}}" test="{{ty}}">{{ty}}</h1>
19
15
 
20
- <input id="testing1" value="new1" />
21
- <input get-value="#testing1" />
22
- <input get-value="#testing1" />
23
-
24
- <script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
25
- <!--<script src="../dist/CoCreate-form.js"></script>-->
26
-
27
- </body>
16
+ <hr/>
17
+
18
+ <input id="testing1" value="new1" />
19
+ <input get-value="#testing1" />
20
+ <input get-value="#testing1" />
21
+
22
+ <script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
23
+ <!--<script src="../dist/CoCreate-form.js"></script>-->
24
+
25
+ </body>
28
26
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/elements",
3
- "version": "1.14.0",
3
+ "version": "1.14.2",
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",
@@ -60,11 +60,11 @@
60
60
  "webpack-log": "^3.0.1"
61
61
  },
62
62
  "dependencies": {
63
- "@cocreate/actions": "^1.5.44",
64
- "@cocreate/crud-client": "^1.17.3",
65
- "@cocreate/docs": "^1.4.26",
66
- "@cocreate/element-prototype": "^1.2.15",
67
- "@cocreate/observer": "^1.5.48",
68
- "@cocreate/utils": "^1.17.7"
63
+ "@cocreate/actions": "^1.5.45",
64
+ "@cocreate/crud-client": "^1.17.5",
65
+ "@cocreate/docs": "^1.4.27",
66
+ "@cocreate/element-prototype": "^1.2.17",
67
+ "@cocreate/observer": "^1.5.49",
68
+ "@cocreate/utils": "^1.17.9"
69
69
  }
70
70
  }
package/src/getValue.js CHANGED
@@ -57,47 +57,41 @@ function initEvents(valueEl, element, mutation){
57
57
  }
58
58
 
59
59
  function setValueByFind(valueEl, mutation) {
60
- let value;
61
- // todo can be removed if all elements have getValue using prototype
62
- if (valueEl.hasAttribute('value'))
63
- value = valueEl.getAttribute('value');
64
- else if (valueEl.getValue)
65
- value = valueEl.getValue();
66
- // else
67
- // value = getValue(valueEl);
60
+ let value = valueEl.getValue();
68
61
  if (!value) return;
62
+
69
63
  let elements = mutation || valueEls.get(valueEl);
70
-
71
- if (elements)
72
- for(let element of elements){
73
- let key = element.getAttribute('get-value-key');
74
- if (key){
75
- key = `{{${key}}}`;
76
- const regex = new RegExp(key, "g");
77
- for (let attribute of element.attributes){
78
- let attrName = attribute.name;
79
- let attrValue = attribute.value;
80
- let setAttr = false;
81
- if (attrValue.includes(key)){
82
- attrValue = attrValue.replace(regex, value);
83
- setAttr = true;
64
+ if (elements) {
65
+ for(let element of elements){
66
+ let key = element.getAttribute('get-value-key');
67
+ if (key){
68
+ key = `{{${key}}}`;
69
+ const regex = new RegExp(key, "g");
70
+ for (let attribute of element.attributes){
71
+ let attrName = attribute.name;
72
+ let attrValue = attribute.value;
73
+ let setAttr = false;
74
+ if (attrValue.includes(key)){
75
+ attrValue = attrValue.replace(regex, value);
76
+ setAttr = true;
77
+ }
78
+ if (attrName.includes(key)){
79
+ element.removeAttribute(key);
80
+ attrName = attrName.replace(regex, value);
81
+ setAttr = true;
82
+ }
83
+ if (setAttr)
84
+ element.setAttribute(attrName, attrValue);
84
85
  }
85
- if (attrName.includes(key)){
86
- element.removeAttribute(key);
87
- attrName = attrName.replace(regex, value);
88
- setAttr = true;
86
+ let html = element.innerHTML;
87
+ if (html.indexOf(key) !== -1){
88
+ html = html.replace(regex, value);
89
+ element.innerHTML = html;
89
90
  }
90
- if (setAttr)
91
- element.setAttribute(attrName, attrValue);
92
- }
93
- let html = element.innerHTML;
94
- if (html.indexOf(key) !== -1){
95
- html = html.replace(regex, value);
96
- element.innerHTML = html;
97
91
  }
92
+ else
93
+ element.setValue(value);
98
94
  }
99
- else
100
- element.setValue(value);
101
95
  }
102
96
  }
103
97
 
package/src/setValue.js CHANGED
@@ -35,9 +35,7 @@ function setValueByFind(element){
35
35
  if (key)
36
36
  key = `{{${key}}}`;
37
37
 
38
- let value
39
- if (element.getValue)
40
- value = element.getValue();
38
+ let value = element.getValue();
41
39
  if (!value) return;
42
40
 
43
41
  let selector = element.getAttribute('set-value');