@cocreate/elements 1.11.1 → 1.12.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 +7 -0
- package/package.json +1 -1
- package/src/HTMLElement.js +24 -45
- package/src/getValue.js +1 -1
- package/src/index.js +2 -6
- package/src/setValue.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [1.12.0](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.11.1...v1.12.0) (2022-08-31)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add getValue() and setValue() to HTMLElement.prototype ([1fde509](https://github.com/CoCreate-app/CoCreate-elements/commit/1fde50918b279bb49103bf7bea1f24861615a0a9))
|
|
7
|
+
|
|
1
8
|
## [1.11.1](https://github.com/CoCreate-app/CoCreate-elements/compare/v1.11.0...v1.11.1) (2022-08-01)
|
|
2
9
|
|
|
3
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/elements",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.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",
|
package/src/HTMLElement.js
CHANGED
|
@@ -1,51 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
import { setValue } from './setValue';
|
|
2
|
+
import { getValue } from './getValue';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
HTMLInputElement.prototype.getValue = function() {
|
|
8
|
-
let value = this.value;
|
|
4
|
+
HTMLElement.prototype.getValue = function() {
|
|
5
|
+
let value = getValue(this)
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
HTMLElement.prototype.setValue = function(value) {
|
|
10
|
+
setValue(this, value)
|
|
11
|
+
};
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
value = [];
|
|
18
|
-
checkboxs.forEach(el => {
|
|
19
|
-
if (el.checked) value.push(el.value);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
value = this.checked;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else if (this.type === "number") {
|
|
27
|
-
value = Number(value);
|
|
28
|
-
}
|
|
29
|
-
else if (this.type === "password") {
|
|
30
|
-
value = this.__encryptPassword(value);
|
|
31
|
-
}
|
|
13
|
+
HTMLInputElement.prototype.getValue = function() {
|
|
14
|
+
let value = getValue(this)
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
32
17
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
18
|
+
HTMLInputElement.prototype.setValue = function(value) {
|
|
19
|
+
setValue(this, value)
|
|
20
|
+
};
|
|
36
21
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
HTMLHeadingElement.prototype.getValue = function() {
|
|
23
|
+
let value = getValue(this)
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
HTMLHeadingElement.prototype.setValue = function(value) {
|
|
28
|
+
setValue(this, value)
|
|
29
|
+
};
|
|
44
30
|
|
|
45
|
-
return value;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
HTMLHeadingElement.prototype.getValue = function() {
|
|
49
|
-
this.style.display = 'none';
|
|
50
|
-
};
|
|
51
|
-
|
package/src/getValue.js
CHANGED
|
@@ -62,7 +62,7 @@ function setValueByFind(valueEl, mutation) {
|
|
|
62
62
|
if (valueEl.hasAttribute('value'))
|
|
63
63
|
value = valueEl.getAttribute('value');
|
|
64
64
|
else if(valueEl.getValue)
|
|
65
|
-
value = valueEl.getValue(
|
|
65
|
+
value = valueEl.getValue();
|
|
66
66
|
else
|
|
67
67
|
value = getValue(valueEl);
|
|
68
68
|
if (!value) return;
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import crud from '@cocreate/crud-client';
|
|
|
4
4
|
import { initSetValues, setValue } from './setValue';
|
|
5
5
|
import { initGetValues, getValue } from './getValue';
|
|
6
6
|
import './fetchSrc';
|
|
7
|
+
import './HTMLElement';
|
|
7
8
|
|
|
8
9
|
const selector = "[collection][document_id][name]:not(cocreate-select, link), input, textarea, select, [contenteditable]";
|
|
9
10
|
const initializing = new Map();
|
|
@@ -33,11 +34,6 @@ function initElements(elements) {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
function initElement(el) {
|
|
36
|
-
if (el.tagName != 'DIV' || el.classList.contains('domEditor') || el.hasAttribute('contenteditable')){
|
|
37
|
-
el.getValue = getValue;
|
|
38
|
-
el.setValue = setValue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
__initEvents(el);
|
|
42
38
|
|
|
43
39
|
if (el.closest('.template')) return;
|
|
@@ -97,7 +93,7 @@ function setData(elements, data) {
|
|
|
97
93
|
} else
|
|
98
94
|
value = crud.getObjectValueByPath(data.data, name);
|
|
99
95
|
|
|
100
|
-
setValue(
|
|
96
|
+
el.setValue(value);
|
|
101
97
|
|
|
102
98
|
isRendered = true;
|
|
103
99
|
}
|