@cocreate/elements 1.6.1 → 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 +28 -0
- package/demo/input-and-fetch.html +2 -2
- package/demo/set-value.html +41 -0
- package/package.json +1 -1
- package/src/getValue.js +1 -1
- package/src/index.js +2 -2
- package/src/setValue.js +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
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
|
+
|
|
8
|
+
## [1.6.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.3...v1.6.4) (2022-01-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* updated saveDocument to save and createDocument replaced with save, reset ([749a02f](https://github.com/CoCreate-app/CoCreate-elements/commit/749a02f28f156eb36344863b9e77120eba8e08c1))
|
|
14
|
+
|
|
15
|
+
## [1.6.3](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.2...v1.6.3) (2022-01-16)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* update class overflow:overlay to overflow:auto ([111577e](https://github.com/CoCreate-app/CoCreate-elements/commit/111577e6c6642a85af1e33b67f0267e6471da4fb))
|
|
21
|
+
|
|
22
|
+
## [1.6.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.1...v1.6.2) (2022-01-11)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* if crdt = true but document_id is empty save ([cd69a43](https://github.com/CoCreate-app/CoCreate-elements/commit/cd69a434ec33ac7f32ded29f715154f22a1bd4e8))
|
|
28
|
+
|
|
1
29
|
## [1.6.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.0...v1.6.1) (2022-01-02)
|
|
2
30
|
|
|
3
31
|
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<!--<textarea type="text" placeholder="description" name="description"></textarea>-->
|
|
21
21
|
<!-- <cocreate-select class="floating-label" collection="apples3" name="industry" placeholder="Industry">-->
|
|
22
22
|
<!-- <input placeholder="Search" template_id="industries">-->
|
|
23
|
-
<!--<cc-options fetch-collection="apples3" template_id="industries" class="options overflow:
|
|
23
|
+
<!--<cc-options fetch-collection="apples3" template_id="industries" class="options overflow:auto">-->
|
|
24
24
|
<!-- <cc-option class="template" template_id="industries" value="{{data._id}}">-->
|
|
25
25
|
<!-- <h4 collection="apples3" document_id="{{data._id}}" name="name">industry name</h4>-->
|
|
26
26
|
<!-- </cc-option>-->
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<!-- </cc-option>-->
|
|
40
40
|
<!-- </cc-options>-->
|
|
41
41
|
<!--</cocreate-select>-->
|
|
42
|
-
<button class="position:fixed bottom:15px right:15px bg-blue grow-hover round opacity-08" actions="
|
|
42
|
+
<button class="position:fixed bottom:15px right:15px bg-blue grow-hover round opacity-08" actions="save"><i class="far fa-save"></i></button>
|
|
43
43
|
</form>
|
|
44
44
|
<!--<cocreate-select id="margin-right-unit" class="styleunit remove-none border:none padding:0 min-height:24px!important background:#eee" collection="builder" document_id="null" attributes="attributes_unit" attributes_target="#margin-right">-->
|
|
45
45
|
<!-- <ul class="options overflow:auto padding:0px z-index:7" fetch-collection="modules" filter-value="5ff747727005da1c27274193" filter-name="_id" filter-operator="$eq" fetch-name="units" template_id="units2">-->
|
|
@@ -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.
|
|
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
package/src/index.js
CHANGED
|
@@ -39,11 +39,11 @@ function initElement(el) {
|
|
|
39
39
|
if (el.closest('.template')) return;
|
|
40
40
|
|
|
41
41
|
const { collection, document_id, name, isRead } = crud.getAttr(el);
|
|
42
|
+
__initEvents(el);
|
|
42
43
|
if (!collection || !name) return;
|
|
43
44
|
if (!document_id.match(/^[0-9a-fA-F]{24}$/)) return;
|
|
44
45
|
if (!crud.checkAttrValue(collection) || !crud.checkAttrValue(name)) return;
|
|
45
46
|
|
|
46
|
-
__initEvents(el);
|
|
47
47
|
if (isRead == 'false') return;
|
|
48
48
|
return {collection, document_id};
|
|
49
49
|
}
|
|
@@ -119,7 +119,7 @@ function __initEvents(el) {
|
|
|
119
119
|
el.addEventListener('input', function(e) {
|
|
120
120
|
const {document_id, isRealtime, isCrdt} = crud.getAttr(el);
|
|
121
121
|
if (isCrdt == "true" && document_id || isRealtime == "false") return;
|
|
122
|
-
if (e.detail && e.detail.skip == true) return;
|
|
122
|
+
if (document_id && e.detail && e.detail.skip == true) return;
|
|
123
123
|
save(el);
|
|
124
124
|
});
|
|
125
125
|
|
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);
|