@cocreate/element-prototype 1.20.0 → 1.21.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 +20 -0
- package/docs/index.html +0 -4
- package/package.json +1 -1
- package/src/getAttribute.js +47 -0
- package/src/index.js +2 -2
- package/src/setValue.js +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [1.21.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.20.1...v1.21.0) (2024-02-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* getAttribute crdt ([bea2bfb](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/bea2bfb611e23fbb90249f982502e5208fab57d3))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* getAttribute prototype to handle operator values ([fa3c83f](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/fa3c83f67ad96961e3e77dabd8d717b1dd57854a))
|
|
12
|
+
|
|
13
|
+
## [1.20.1](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.20.0...v1.20.1) (2024-02-05)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* insert select options from src file ([7b644e1](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/7b644e10368ca21f4e478c2b333759430b466ef2))
|
|
19
|
+
* Removed https://cdn.cocreate.app/latest/CoCreate.min.css ([144d3e0](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/144d3e0c0996f52022f89d404d785d08a1762cfc))
|
|
20
|
+
|
|
1
21
|
# [1.20.0](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.19.0...v1.20.0) (2024-02-03)
|
|
2
22
|
|
|
3
23
|
|
package/docs/index.html
CHANGED
|
@@ -19,10 +19,6 @@
|
|
|
19
19
|
<meta name="robots" content="index,follow" />
|
|
20
20
|
|
|
21
21
|
<!-- CoCreate CSS CDN -->
|
|
22
|
-
<link
|
|
23
|
-
rel="stylesheet"
|
|
24
|
-
href="https://cdn.cocreate.app/latest/CoCreate.min.css"
|
|
25
|
-
type="text/css" />
|
|
26
22
|
|
|
27
23
|
<link rel="manifest" href="/manifest.webmanifest" />
|
|
28
24
|
</head>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/element-prototype",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "A simple element-prototype component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"element-prototype",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Store a reference to the original getAttribute function
|
|
2
|
+
const originalGetAttribute = Element.prototype.getAttribute;
|
|
3
|
+
|
|
4
|
+
// Override the getAttribute function
|
|
5
|
+
Element.prototype.getAttribute = function (name) {
|
|
6
|
+
let value = originalGetAttribute.call(this, name);
|
|
7
|
+
|
|
8
|
+
if (value === '$organization_id')
|
|
9
|
+
value = localStorage.getItem('organization_id')
|
|
10
|
+
else if (value === '$user_id')
|
|
11
|
+
value = localStorage.getItem('user_id')
|
|
12
|
+
else if (value === '$clientId')
|
|
13
|
+
value = localStorage.getItem('clientId')
|
|
14
|
+
else if (value === '$session_id')
|
|
15
|
+
value = localStorage.getItem('session_id')
|
|
16
|
+
else if (typeof value === 'string') {
|
|
17
|
+
if (value.startsWith('$search')) {
|
|
18
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
19
|
+
if (value.includes('.')) {
|
|
20
|
+
value = searchParams.get(value.split('.')[1]);
|
|
21
|
+
} else {
|
|
22
|
+
const paramsObject = {};
|
|
23
|
+
|
|
24
|
+
// Iterate over all key-value pairs and add them to the object
|
|
25
|
+
for (const [key, value] of searchParams) {
|
|
26
|
+
paramsObject[key] = value;
|
|
27
|
+
}
|
|
28
|
+
value = paramsObject
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
} else if ([
|
|
32
|
+
'$href',
|
|
33
|
+
'$origin',
|
|
34
|
+
'$protocol',
|
|
35
|
+
'$host',
|
|
36
|
+
'$hostname',
|
|
37
|
+
'$port',
|
|
38
|
+
'$pathname',
|
|
39
|
+
'$hash'
|
|
40
|
+
].includes(value)) {
|
|
41
|
+
value = window.location[value.substring(1)]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return value;
|
|
46
|
+
};
|
|
47
|
+
|
package/src/index.js
CHANGED
package/src/setValue.js
CHANGED
|
@@ -33,10 +33,12 @@ const setValue = (el, value, dispatch) => {
|
|
|
33
33
|
if (suffix)
|
|
34
34
|
value = value.toString().replace(suffix, "");
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
// TODO: el.options vs rendenring options from src
|
|
37
|
+
if (el.tagName == 'INPUT' || el.tagName == 'TEXTAREA' || el.tagName == 'SELECT' && el.options.length) {
|
|
38
|
+
// TODO: attribute config undefined when used with onload-value
|
|
39
|
+
let isCrdt = el.getAttribute('crdt') // getAttributes(el)
|
|
40
|
+
// if (isCrdt == null || isCrdt == undefined)
|
|
41
|
+
// isCrdt = el.getAttribute('crdt')
|
|
40
42
|
if (isCrdt == "true" || el.type === 'file') return;
|
|
41
43
|
|
|
42
44
|
if (el.type == 'checkbox') {
|