@cocreate/elements 1.13.6 → 1.13.8
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 +14 -0
- package/package.json +7 -7
- package/src/getValue.js +5 -5
- package/src/index.js +3 -3
- package/src/setValue.js +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.13.8](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.7...v1.13.8) (2022-11-23)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bumped [@cocreate](https://github.com/cocreate) dependencies ([83c091b](https://github.com/CoCreate-app/CoCreate-elements/commit/83c091bb6fb3e733d5682ca7661687f772770db6))
|
|
7
|
+
|
|
8
|
+
## [1.13.7](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.6...v1.13.7) (2022-11-22)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* workflow docs ([56d2c11](https://github.com/CoCreate-app/CoCreate-elements/commit/56d2c11e05c687dbf43159de343ac540f82045b6))
|
|
14
|
+
|
|
1
15
|
## [1.13.6](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.5...v1.13.6) (2022-11-22)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.8",
|
|
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",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"webpack-log": "^3.0.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@cocreate/actions": "^1.5.
|
|
65
|
-
"@cocreate/crud-client": "^1.
|
|
66
|
-
"@cocreate/docs": "^1.
|
|
67
|
-
"@cocreate/element-prototype": "^1.1.
|
|
68
|
-
"@cocreate/observer": "^1.5.
|
|
69
|
-
"@cocreate/utils": "^1.10.
|
|
64
|
+
"@cocreate/actions": "^1.5.20",
|
|
65
|
+
"@cocreate/crud-client": "^1.14.0",
|
|
66
|
+
"@cocreate/docs": "^1.4.2",
|
|
67
|
+
"@cocreate/element-prototype": "^1.1.5",
|
|
68
|
+
"@cocreate/observer": "^1.5.25",
|
|
69
|
+
"@cocreate/utils": "^1.10.21"
|
|
70
70
|
}
|
|
71
71
|
}
|
package/src/getValue.js
CHANGED
|
@@ -17,15 +17,15 @@ function initElements(elements) {
|
|
|
17
17
|
|
|
18
18
|
function initElement(element, mutation) {
|
|
19
19
|
let selector = element.getAttribute('get-value') || element.getAttribute('get-value-closest');
|
|
20
|
-
if(!selector) return;
|
|
21
|
-
if(/{{\s*([\w\W]+)\s*}}/g.test(selector)) return;
|
|
20
|
+
if (!selector) return;
|
|
21
|
+
if (/{{\s*([\w\W]+)\s*}}/g.test(selector)) return;
|
|
22
22
|
|
|
23
23
|
let valueEl
|
|
24
24
|
if (element.hasAttribute('get-value-closest'))
|
|
25
25
|
valueEl = element.closest(selector);
|
|
26
26
|
else
|
|
27
27
|
valueEl = document.querySelector(selector);
|
|
28
|
-
if(!valueEl) return;
|
|
28
|
+
if (!valueEl) return;
|
|
29
29
|
|
|
30
30
|
initEvents(valueEl, element, mutation);
|
|
31
31
|
|
|
@@ -61,7 +61,7 @@ function setValueByFind(valueEl, mutation) {
|
|
|
61
61
|
// todo can be removed if all elements have getValue using prototype
|
|
62
62
|
if (valueEl.hasAttribute('value'))
|
|
63
63
|
value = valueEl.getAttribute('value');
|
|
64
|
-
else if(valueEl.getValue)
|
|
64
|
+
else if (valueEl.getValue)
|
|
65
65
|
value = valueEl.getValue();
|
|
66
66
|
// else
|
|
67
67
|
// value = getValue(valueEl);
|
|
@@ -87,7 +87,7 @@ function setValueByFind(valueEl, mutation) {
|
|
|
87
87
|
attrName = attrName.replace(regex, value);
|
|
88
88
|
setAttr = true;
|
|
89
89
|
}
|
|
90
|
-
if(setAttr)
|
|
90
|
+
if (setAttr)
|
|
91
91
|
element.setAttribute(attrName, attrValue);
|
|
92
92
|
}
|
|
93
93
|
let html = element.innerHTML;
|
package/src/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { initGetValues} from './getValue';
|
|
|
8
8
|
import './fetchSrc';
|
|
9
9
|
|
|
10
10
|
let crud
|
|
11
|
-
if(CRUD && CRUD.default)
|
|
11
|
+
if (CRUD && CRUD.default)
|
|
12
12
|
crud = CRUD.default
|
|
13
13
|
else
|
|
14
14
|
crud = CRUD
|
|
@@ -138,7 +138,7 @@ function setData(elements, data) {
|
|
|
138
138
|
// if (data.document[0]['collection'] == collection && data.document[0]['_id'] == document_id) {
|
|
139
139
|
let value;
|
|
140
140
|
let valueType = el.getAttribute('value-type');
|
|
141
|
-
if(valueType == 'object' || valueType == 'json'){
|
|
141
|
+
if (valueType == 'object' || valueType == 'json'){
|
|
142
142
|
// if (name == 'data')
|
|
143
143
|
// value = JSON.stringify(data[name])
|
|
144
144
|
// else
|
|
@@ -227,7 +227,7 @@ observer.init({
|
|
|
227
227
|
target: selector,
|
|
228
228
|
callback: function(mutation) {
|
|
229
229
|
let {collection, document_id, name} = crud.getAttributes(mutation.target);
|
|
230
|
-
if(collection && document_id && name)
|
|
230
|
+
if (collection && document_id && name)
|
|
231
231
|
initElements([mutation.target]);
|
|
232
232
|
}
|
|
233
233
|
});
|
package/src/setValue.js
CHANGED
|
@@ -4,7 +4,7 @@ import { queryDocumentSelectorAll } from '@cocreate/utils';
|
|
|
4
4
|
import '@cocreate/element-prototype';
|
|
5
5
|
|
|
6
6
|
let crud
|
|
7
|
-
if(CRUD && CRUD.default)
|
|
7
|
+
if (CRUD && CRUD.default)
|
|
8
8
|
crud = CRUD.default
|
|
9
9
|
else
|
|
10
10
|
crud = CRUD
|
|
@@ -42,12 +42,12 @@ function setValueByFind(element){
|
|
|
42
42
|
key = `{{${key}}}`;
|
|
43
43
|
|
|
44
44
|
let value
|
|
45
|
-
if(element.getValue)
|
|
45
|
+
if (element.getValue)
|
|
46
46
|
value = element.getValue();
|
|
47
47
|
if (!value) return;
|
|
48
48
|
|
|
49
49
|
let selector = element.getAttribute('set-value');
|
|
50
|
-
if(!selector) return;
|
|
50
|
+
if (!selector) return;
|
|
51
51
|
let elements;
|
|
52
52
|
if (element.hasAttribute('set-value-closest'))
|
|
53
53
|
elements = [element.closest(selector)];
|
|
@@ -72,7 +72,7 @@ function setValueByFind(element){
|
|
|
72
72
|
attrName = attrName.replace(regex, value);
|
|
73
73
|
setAttr = true;
|
|
74
74
|
}
|
|
75
|
-
if(setAttr)
|
|
75
|
+
if (setAttr)
|
|
76
76
|
element.setAttribute(attrName, attrValue);
|
|
77
77
|
}
|
|
78
78
|
let html = element.innerHTML;
|