@cocreate/elements 1.13.30 → 1.14.0
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 +21 -0
- package/package.json +7 -7
- package/src/fetchSrc.js +19 -3
- package/src/setValue.js +1 -1
- package/demo/input-and-fetch.html +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
# [1.14.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.31...v1.14.0) (2022-12-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bump dependecies ([cd95cd1](https://github.com/CoCreate-app/CoCreate-elements/commit/cd95cd1c12582086f7776e880eb3e6b6c4f5b6fb))
|
|
7
|
+
* bump dependencies ([03b8e18](https://github.com/CoCreate-app/CoCreate-elements/commit/03b8e18f658ca84a2d274c112d4f0e983b8862e1))
|
|
8
|
+
* observer target setValue and setValue-closest ([85dec0d](https://github.com/CoCreate-app/CoCreate-elements/commit/85dec0d291164d70f6f0d4618757710a4f9fb1e4))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* fetch src will remove CoCreatejs, CoCreateCSS, and css-parser link as it already exists ([d4893f4](https://github.com/CoCreate-app/CoCreate-elements/commit/d4893f41d7ee34d76f5f57d24922e97b15938145))
|
|
14
|
+
|
|
15
|
+
## [1.13.31](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.30...v1.13.31) (2022-12-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* bump dependencies ([0164e32](https://github.com/CoCreate-app/CoCreate-elements/commit/0164e3253228be1e46542adfb24082ed1817c1a3))
|
|
21
|
+
|
|
1
22
|
## [1.13.30](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.13.29...v1.13.30) (2022-12-23)
|
|
2
23
|
|
|
3
24
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
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.
|
|
64
|
-
"@cocreate/crud-client": "^1.
|
|
65
|
-
"@cocreate/docs": "^1.4.
|
|
66
|
-
"@cocreate/element-prototype": "^1.2.
|
|
67
|
-
"@cocreate/observer": "^1.5.
|
|
68
|
-
"@cocreate/utils": "^1.17.
|
|
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"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/src/fetchSrc.js
CHANGED
|
@@ -19,17 +19,33 @@ async function initElement(element) {
|
|
|
19
19
|
let initialize = initializing.get(element)
|
|
20
20
|
if (!initialize || initialize.src != src){
|
|
21
21
|
initializing.set(element, {src});
|
|
22
|
-
if (src)
|
|
22
|
+
if (src) {
|
|
23
23
|
try {
|
|
24
24
|
let response = await fetch(src); // Gets a promise
|
|
25
25
|
let text = await response.text(); // Replaces body with response
|
|
26
|
-
if (text){
|
|
27
|
-
|
|
26
|
+
if (text) {
|
|
27
|
+
let dom = document.createElement('dom')
|
|
28
|
+
dom.innerHTML = text;
|
|
29
|
+
|
|
30
|
+
let CoCreateJS = dom.querySelector('script[src*="CoCreate.js"], script[src*="CoCreate.min.js"]')
|
|
31
|
+
if (CoCreateJS)
|
|
32
|
+
CoCreateJS.remove()
|
|
33
|
+
|
|
34
|
+
let CoCreateCSS = dom.querySelector('link[src*="CoCreate.css"], link[src*="CoCreate.min.css"]')
|
|
35
|
+
if (CoCreateCSS)
|
|
36
|
+
CoCreateCSS.remove()
|
|
37
|
+
|
|
38
|
+
let css = dom.querySelector('link[collection], link[document]')
|
|
39
|
+
if (css)
|
|
40
|
+
css.remove()
|
|
41
|
+
|
|
42
|
+
element.innerHTML = dom.innerHTML; // Replaces body with response
|
|
28
43
|
initializing.delete(element)
|
|
29
44
|
}
|
|
30
45
|
} catch (err) {
|
|
31
46
|
console.log('FetchSrc error:' + err); // Error handling
|
|
32
47
|
}
|
|
48
|
+
}
|
|
33
49
|
}
|
|
34
50
|
};
|
|
35
51
|
|
package/src/setValue.js
CHANGED
|
@@ -85,7 +85,7 @@ function setValueByFind(element){
|
|
|
85
85
|
observer.init({
|
|
86
86
|
name: 'set-value',
|
|
87
87
|
observe: ['addedNodes'],
|
|
88
|
-
target: '[
|
|
88
|
+
target: '[set-value], [set-value-closest]',
|
|
89
89
|
callback: function(mutation) {
|
|
90
90
|
initElement(mutation.target);
|
|
91
91
|
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<title>Inputs | CoCreateJS</title>
|
|
6
|
-
<!-- CoCreate Favicon -->
|
|
7
|
-
<link rel="icon" href="https://cdn.cocreate.app/favicon.ico" type="image/ico" sizes="16x16">
|
|
8
|
-
</head>
|
|
9
|
-
|
|
10
|
-
<body class="padding:20px">
|
|
11
|
-
|
|
12
|
-
<form collection="contacts" document_id="">
|
|
13
|
-
<input name="fullname" pass_id="form-fields" pass-refresh>
|
|
14
|
-
<button actions="save, reset" class="display:inline margin:10px">Save</button>
|
|
15
|
-
</form>
|
|
16
|
-
|
|
17
|
-
<div class="display:flex flex-wrap:wrap" fetch-collection="contacts" template_id="grid">
|
|
18
|
-
|
|
19
|
-
<div template_id="grid" class="template card margin:10px padding:20px background:gainsboro:hover">
|
|
20
|
-
<a pass_to="form-fields" pass-document_id="{{document._id}}">
|
|
21
|
-
<h4 collection="contacts" document_id="{{document._id}}" name="fullname">Name</h4>
|
|
22
|
-
<h4>{{document._id}}</h4>
|
|
23
|
-
</a>
|
|
24
|
-
</div>
|
|
25
|
-
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
<!--<script src="https://cdn.cocreate.app/latest/CoCreate.min.js" ></script>-->
|
|
29
|
-
|
|
30
|
-
</body>
|
|
31
|
-
|
|
32
|
-
</html>
|