@cocreate/events 1.27.1 → 1.27.3
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 +14 -0
- package/package.json +5 -13
- package/src/index.js +26 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.27.3](https://github.com/CoCreate-app/CoCreate-events/compare/v1.27.2...v1.27.3) (2025-09-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improve event handling and element manipulation in CoCreateEvents ([ae6b58a](https://github.com/CoCreate-app/CoCreate-events/commit/ae6b58a7c0dc313b426a2614b6cb141735dffbbb))
|
|
7
|
+
|
|
8
|
+
## [1.27.2](https://github.com/CoCreate-app/CoCreate-events/compare/v1.27.1...v1.27.2) (2025-05-01)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update [@cocreate](https://github.com/cocreate) dependencies ([7d405b5](https://github.com/CoCreate-app/CoCreate-events/commit/7d405b51a40165f9b1a30fdf6cc6279aaba2289b))
|
|
14
|
+
|
|
1
15
|
## [1.27.1](https://github.com/CoCreate-app/CoCreate-events/compare/v1.27.0...v1.27.1) (2025-04-30)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/events",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.3",
|
|
4
4
|
"description": "A simple events component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"events",
|
|
7
|
-
"cocreate",
|
|
8
|
-
"low-code-framework",
|
|
9
|
-
"no-code-framework",
|
|
10
|
-
"cocreatejs",
|
|
11
|
-
"cocreatejs-component",
|
|
12
|
-
"cocreate-framework",
|
|
13
|
-
"no-code",
|
|
14
7
|
"low-code",
|
|
15
|
-
"collaborative-framework",
|
|
16
8
|
"realtime",
|
|
17
9
|
"realtime-framework",
|
|
18
10
|
"collaboration",
|
|
@@ -54,9 +46,9 @@
|
|
|
54
46
|
"webpack-log": "^3.0.1"
|
|
55
47
|
},
|
|
56
48
|
"dependencies": {
|
|
57
|
-
"@cocreate/actions": "^1.21.
|
|
58
|
-
"@cocreate/element-prototype": "^1.29.
|
|
59
|
-
"@cocreate/observer": "^1.18.
|
|
60
|
-
"@cocreate/utils": "^1.
|
|
49
|
+
"@cocreate/actions": "^1.21.1",
|
|
50
|
+
"@cocreate/element-prototype": "^1.29.1",
|
|
51
|
+
"@cocreate/observer": "^1.18.1",
|
|
52
|
+
"@cocreate/utils": "^1.39.0"
|
|
61
53
|
}
|
|
62
54
|
}
|
package/src/index.js
CHANGED
|
@@ -28,8 +28,9 @@ import "@cocreate/element-prototype";
|
|
|
28
28
|
const CoCreateEvents = {
|
|
29
29
|
elements2: new Map(),
|
|
30
30
|
init: function (prefix, events) {
|
|
31
|
-
if (prefix && events)
|
|
32
|
-
|
|
31
|
+
if (prefix && events) {
|
|
32
|
+
this.initPrefix(prefix, events);
|
|
33
|
+
} else {
|
|
33
34
|
this.initPrefix("toggle", ["click"]);
|
|
34
35
|
this.initPrefix("click", ["click"]);
|
|
35
36
|
this.initPrefix("hover", ["mouseover", "mouseout"]);
|
|
@@ -385,11 +386,9 @@ const CoCreateEvents = {
|
|
|
385
386
|
let elements = [el];
|
|
386
387
|
let targetGroup = el.getAttribute(`${prefix}-group`);
|
|
387
388
|
if (targetGroup) {
|
|
388
|
-
document
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
if (element !== el) elements.push(element);
|
|
392
|
-
});
|
|
389
|
+
elements = document.querySelectorAll(
|
|
390
|
+
`[${prefix}-group="${targetGroup}"]`
|
|
391
|
+
);
|
|
393
392
|
}
|
|
394
393
|
|
|
395
394
|
for (let element of elements) {
|
|
@@ -583,8 +582,11 @@ const CoCreateEvents = {
|
|
|
583
582
|
if (el !== element) {
|
|
584
583
|
deactivate = true;
|
|
585
584
|
}
|
|
586
|
-
|
|
585
|
+
if (events && events.includes("click")) {
|
|
586
|
+
// TODO: handling of attributes that represent states aria-expanded, aria-selected etc.
|
|
587
|
+
}
|
|
587
588
|
|
|
589
|
+
// values = values.map(x => x.trim());
|
|
588
590
|
values = values.map((x) => {
|
|
589
591
|
if (typeof x === "string") x = x.trim(); // Update x with the trimmed value
|
|
590
592
|
let prop = element.getAttribute(`${prefix}-property`);
|
|
@@ -604,10 +606,14 @@ const CoCreateEvents = {
|
|
|
604
606
|
targetElements = [element];
|
|
605
607
|
}
|
|
606
608
|
|
|
607
|
-
let action =
|
|
609
|
+
let action =
|
|
610
|
+
element.getAttribute(`${prefix}-action`) ||
|
|
611
|
+
element.getAttribute(`${prefix}-method`);
|
|
608
612
|
for (let i = 0; i < targetElements.length; i++) {
|
|
609
613
|
if (action) {
|
|
610
|
-
targetElements[i][action]
|
|
614
|
+
if (targetElements[i][action]) {
|
|
615
|
+
targetElements[i][action]();
|
|
616
|
+
}
|
|
611
617
|
} else if (
|
|
612
618
|
!targetAttribute &&
|
|
613
619
|
targetAttribute !== "" &&
|
|
@@ -736,14 +742,18 @@ const CoCreateEvents = {
|
|
|
736
742
|
if (deactivate) newValue = "";
|
|
737
743
|
if (attrName === "class") {
|
|
738
744
|
if (oldValue) {
|
|
739
|
-
|
|
745
|
+
oldValue.split(" ").forEach((className) => {
|
|
746
|
+
element.classList.remove(className);
|
|
747
|
+
});
|
|
740
748
|
if (values.length === 1) {
|
|
741
749
|
return;
|
|
742
750
|
}
|
|
743
751
|
}
|
|
744
752
|
|
|
745
753
|
if (newValue) {
|
|
746
|
-
|
|
754
|
+
newValue.split(" ").forEach((className) => {
|
|
755
|
+
element.classList.add(className);
|
|
756
|
+
});
|
|
747
757
|
}
|
|
748
758
|
} else if (attrName === "value") {
|
|
749
759
|
element.setValue(newValue, false);
|
|
@@ -755,9 +765,11 @@ const CoCreateEvents = {
|
|
|
755
765
|
element[attrName.substring(1)]();
|
|
756
766
|
} else if (attrName) {
|
|
757
767
|
// TODO: removeAttribute vs setting empty value, how best to define. operator $remove ???
|
|
758
|
-
if (newValue === "" && element.hasAttribute(attrName))
|
|
768
|
+
if (newValue === "" && element.hasAttribute(attrName)) {
|
|
759
769
|
element.removeAttribute(attrName);
|
|
760
|
-
else
|
|
770
|
+
} else {
|
|
771
|
+
element.setAttribute(attrName, newValue);
|
|
772
|
+
}
|
|
761
773
|
} else if (targetPosition) {
|
|
762
774
|
if (domTextEditor) {
|
|
763
775
|
CoCreate.text.insertAdjacentElement({
|