@cocreate/elements 1.6.0 → 1.6.4
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 +29 -0
- package/demo/get-value.html +3 -1
- package/demo/input-and-fetch.html +2 -2
- package/package.json +1 -1
- package/src/getValue.js +6 -10
- package/src/index.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
## [1.6.4](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.3...v1.6.4) (2022-01-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* updated saveDocument to save and createDocument replaced with save, reset ([749a02f](https://github.com/CoCreate-app/CoCreate-elements/commit/749a02f28f156eb36344863b9e77120eba8e08c1))
|
|
7
|
+
|
|
8
|
+
## [1.6.3](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.2...v1.6.3) (2022-01-16)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update class overflow:overlay to overflow:auto ([111577e](https://github.com/CoCreate-app/CoCreate-elements/commit/111577e6c6642a85af1e33b67f0267e6471da4fb))
|
|
14
|
+
|
|
15
|
+
## [1.6.2](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.1...v1.6.2) (2022-01-11)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* if crdt = true but document_id is empty save ([cd69a43](https://github.com/CoCreate-app/CoCreate-elements/commit/cd69a434ec33ac7f32ded29f715154f22a1bd4e8))
|
|
21
|
+
|
|
22
|
+
## [1.6.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.6.0...v1.6.1) (2022-01-02)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* add input event listener to valueEl ([ea77493](https://github.com/CoCreate-app/CoCreate-elements/commit/ea77493fed7401b2ccd3d825b73198daf03f836c))
|
|
28
|
+
* check if document_id is a valid id if not return ([220151f](https://github.com/CoCreate-app/CoCreate-elements/commit/220151f9ee0b2c9ff8e4afc06cc24ad5b891b161))
|
|
29
|
+
|
|
1
30
|
# [1.6.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.5.0...v1.6.0) (2022-01-01)
|
|
2
31
|
|
|
3
32
|
|
package/demo/get-value.html
CHANGED
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
<input get-value="#testing1" />
|
|
25
25
|
<input get-value="#testing1" />
|
|
26
26
|
|
|
27
|
+
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
27
28
|
<!--<script src="../dist/CoCreate-form.js"></script>-->
|
|
28
|
-
|
|
29
|
+
<!--<script src="../../../CoCreateJS/dist/CoCreate.js" ></script>-->
|
|
30
|
+
|
|
29
31
|
</body>
|
|
30
32
|
</html>
|
|
@@ -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">-->
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.4",
|
|
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
|
@@ -18,14 +18,11 @@ function initElements(elements) {
|
|
|
18
18
|
function initElement(element) {
|
|
19
19
|
let selector = element.getAttribute('get-value');
|
|
20
20
|
if(!selector) return;
|
|
21
|
+
if(/{{\s*([\w\W]+)\s*}}/g.test(selector)) return;
|
|
21
22
|
|
|
22
23
|
let valueEl = document.querySelector(selector);
|
|
23
24
|
if(!valueEl) return;
|
|
24
|
-
|
|
25
|
-
// let value = getValue(valueEl);
|
|
26
|
-
// if (value)
|
|
27
|
-
// setValue(element, value);
|
|
28
|
-
|
|
25
|
+
|
|
29
26
|
initEvents(valueEl, element);
|
|
30
27
|
|
|
31
28
|
element.dispatchEvent(new Event("input", {
|
|
@@ -35,10 +32,8 @@ function initElement(element) {
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
function initEvents(valueEl, element){
|
|
38
|
-
if (!valueEls.has(valueEl))
|
|
35
|
+
if (!valueEls.has(valueEl)) {
|
|
39
36
|
valueEls.set(valueEl, [element]);
|
|
40
|
-
else {
|
|
41
|
-
valueEls.get(valueEl).push(element);
|
|
42
37
|
if (['INPUT', 'TEXTAREA', 'SELECT'].includes(valueEl.tagName) || valueEl.contentEditable)
|
|
43
38
|
valueEl.addEventListener('input', (e) => {
|
|
44
39
|
setValueByFind(e.target);
|
|
@@ -46,8 +41,10 @@ function initEvents(valueEl, element){
|
|
|
46
41
|
|
|
47
42
|
valueEl.addEventListener('updated_by_fetch', (e) => {
|
|
48
43
|
setValueByFind(e.target);
|
|
49
|
-
});
|
|
44
|
+
});
|
|
50
45
|
}
|
|
46
|
+
else
|
|
47
|
+
valueEls.get(valueEl).push(element);
|
|
51
48
|
}
|
|
52
49
|
|
|
53
50
|
function setValueByFind(valueEl) {
|
|
@@ -147,5 +144,4 @@ observer.init({
|
|
|
147
144
|
}
|
|
148
145
|
});
|
|
149
146
|
|
|
150
|
-
// initGetValues();
|
|
151
147
|
export { initGetValues, getValue };
|
package/src/index.js
CHANGED
|
@@ -39,10 +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;
|
|
44
|
+
if (!document_id.match(/^[0-9a-fA-F]{24}$/)) return;
|
|
43
45
|
if (!crud.checkAttrValue(collection) || !crud.checkAttrValue(name)) return;
|
|
44
46
|
|
|
45
|
-
__initEvents(el);
|
|
46
47
|
if (isRead == 'false') return;
|
|
47
48
|
return {collection, document_id};
|
|
48
49
|
}
|
|
@@ -118,7 +119,7 @@ function __initEvents(el) {
|
|
|
118
119
|
el.addEventListener('input', function(e) {
|
|
119
120
|
const {document_id, isRealtime, isCrdt} = crud.getAttr(el);
|
|
120
121
|
if (isCrdt == "true" && document_id || isRealtime == "false") return;
|
|
121
|
-
if (e.detail && e.detail.skip == true) return;
|
|
122
|
+
if (document_id && e.detail && e.detail.skip == true) return;
|
|
122
123
|
save(el);
|
|
123
124
|
});
|
|
124
125
|
|