@cocreate/elements 1.6.4 → 1.6.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 +28 -0
- package/demo/set-value.html +41 -0
- package/docs/index.html +1 -1
- package/package.json +5 -5
- package/src/getValue.js +5 -5
- package/src/setValue.js +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [1.6.8](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.7...v1.6.8) (2022-02-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* removed tagName if condition for getValue and setValue events ([f0c6996](https://github.com/CoCreate-app/CoCreate-elements/commit/f0c699635cff3462415a06cf0ac138dc5802333a))
|
|
7
|
+
|
|
8
|
+
## [1.6.7](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.6...v1.6.7) (2022-02-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* replaced show and hide class hidden with attribute hidden ([2a10e9e](https://github.com/CoCreate-app/CoCreate-elements/commit/2a10e9e4a40fbc6a499d85409a59c4e624072865))
|
|
14
|
+
|
|
15
|
+
## [1.6.6](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.5...v1.6.6) (2022-02-01)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* update dependency versions ([00b9a75](https://github.com/CoCreate-app/CoCreate-elements/commit/00b9a7552ffa4650a28022d08a2d8aa442830bc6))
|
|
21
|
+
|
|
22
|
+
## [1.6.5](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.4...v1.6.5) (2022-01-27)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* getValue from element ([44fd22d](https://github.com/CoCreate-app/CoCreate-elements/commit/44fd22df7f5159a6f94e0bedfd381526d7b42a94))
|
|
28
|
+
|
|
1
29
|
## [1.6.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.3...v1.6.4) (2022-01-16)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -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/docs/index.html
CHANGED
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
<div class="container svColumn overflow:hidden card position:relative border-radius:2px width:auto height:100%" id="sandbox">
|
|
102
102
|
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
103
103
|
<a class="margin-right:10px" id="code" show="#preview" hide="#code, #view"><i class="far fa-eye"></i></a>
|
|
104
|
-
<a class="margin-right:10px
|
|
104
|
+
<a class="margin-right:10px" id="preview" show="#code, #view" hide="#preview" hidden><i class="fas fa-code"></i></a>
|
|
105
105
|
<a class="margin-right:5px" fullscreen target="#playground"><i class="fas fa-expand"></i></a>
|
|
106
106
|
</div>
|
|
107
107
|
<div class="svRow">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.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,9 +61,9 @@
|
|
|
61
61
|
"webpack-log": "^3.0.1"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@cocreate/actions": "^1.3.
|
|
65
|
-
"@cocreate/crud-client": "^1.4.
|
|
66
|
-
"@cocreate/docs": "^1.2.
|
|
67
|
-
"@cocreate/observer": "^1.
|
|
64
|
+
"@cocreate/actions": "^1.3.28",
|
|
65
|
+
"@cocreate/crud-client": "^1.4.43",
|
|
66
|
+
"@cocreate/docs": "^1.2.65",
|
|
67
|
+
"@cocreate/observer": "^1.4.0"
|
|
68
68
|
}
|
|
69
69
|
}
|
package/src/getValue.js
CHANGED
|
@@ -34,10 +34,10 @@ function initElement(element) {
|
|
|
34
34
|
function initEvents(valueEl, element){
|
|
35
35
|
if (!valueEls.has(valueEl)) {
|
|
36
36
|
valueEls.set(valueEl, [element]);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
|
|
38
|
+
valueEl.addEventListener('input', (e) => {
|
|
39
|
+
setValueByFind(e.target);
|
|
40
|
+
});
|
|
41
41
|
|
|
42
42
|
valueEl.addEventListener('updated_by_fetch', (e) => {
|
|
43
43
|
setValueByFind(e.target);
|
|
@@ -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
|
@@ -17,21 +17,21 @@ function initElement(element) {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function initEvents(element){
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
element.addEventListener('input', (e) => {
|
|
21
|
+
setValueByFind(e.target);
|
|
22
|
+
});
|
|
23
|
+
|
|
25
24
|
element.addEventListener('updated_by_fetch', (e) => {
|
|
26
25
|
setValueByFind(e.target);
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
|
|
29
|
+
const setValueMap = new Map();
|
|
30
30
|
function setValueByFind(element){
|
|
31
31
|
let key = element.getAttribute('set-value-key');
|
|
32
32
|
if (key)
|
|
33
33
|
key = `{{${key}}}`;
|
|
34
|
-
let value = getValue(element);
|
|
34
|
+
let value = element.getValue(element);
|
|
35
35
|
if (!value) return;
|
|
36
36
|
let selector = element.getAttribute('set-value');
|
|
37
37
|
if(!selector) return;
|
|
@@ -39,6 +39,8 @@ function setValueByFind(element){
|
|
|
39
39
|
|
|
40
40
|
for(let element of elements){
|
|
41
41
|
if (key){
|
|
42
|
+
if (setValueMap.has(element))
|
|
43
|
+
key = setValueMap.get(element);
|
|
42
44
|
const regex = new RegExp(key, "g");
|
|
43
45
|
for (let attribute of element.attributes){
|
|
44
46
|
let attrName = attribute.name;
|
|
@@ -61,6 +63,7 @@ function setValueByFind(element){
|
|
|
61
63
|
html = html.replace(regex, value);
|
|
62
64
|
element.innerHTML = html;
|
|
63
65
|
}
|
|
66
|
+
setValueMap.set(element, value)
|
|
64
67
|
}
|
|
65
68
|
else
|
|
66
69
|
setValue(element, value);
|