@cocreate/state 1.24.4 → 1.24.6
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 +1 -9
- package/src/index.js +28 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.24.6](https://github.com/CoCreate-app/CoCreate-state/compare/v1.24.5...v1.24.6) (2025-11-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* correct method name for retrieving element value and enhance state attribute handling ([bda5c5a](https://github.com/CoCreate-app/CoCreate-state/commit/bda5c5a2ed26215b824b75052e4cf19f5f3c16b3))
|
|
7
|
+
|
|
8
|
+
## [1.24.5](https://github.com/CoCreate-app/CoCreate-state/compare/v1.24.4...v1.24.5) (2025-09-07)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* enhance attribute handling for elements with operator prefix ([9838a6e](https://github.com/CoCreate-app/CoCreate-state/commit/9838a6eb25dbe2c482d6c7e730039e175a2a1fc0))
|
|
14
|
+
|
|
1
15
|
## [1.24.4](https://github.com/CoCreate-app/CoCreate-state/compare/v1.24.3...v1.24.4) (2025-05-01)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/state",
|
|
3
|
-
"version": "1.24.
|
|
3
|
+
"version": "1.24.6",
|
|
4
4
|
"description": "Data attributes which can be used for components in CoCreate framework combined as a group of attributes that dynamically change attributes & fetch custom data.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"state",
|
|
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",
|
package/src/index.js
CHANGED
|
@@ -96,8 +96,19 @@ async function _setAttributeValue(element, attribute, value, isOverwrite) {
|
|
|
96
96
|
(element.hasAttribute("value") && !(await element.getValue()))
|
|
97
97
|
)
|
|
98
98
|
element.setValue(value);
|
|
99
|
-
} else if (element.hasAttribute(attribute) && (value || value === ""))
|
|
99
|
+
} else if (element.hasAttribute(attribute) && (value || value === "")) {
|
|
100
100
|
element.setAttribute(attribute, value);
|
|
101
|
+
} else if (attribute.startsWith("$")) {
|
|
102
|
+
// Handle using operators.js
|
|
103
|
+
const prop = attribute.substring(1);
|
|
104
|
+
if (element[prop]) {
|
|
105
|
+
if (typeof element[prop] === "function") {
|
|
106
|
+
element[prop](value);
|
|
107
|
+
} else {
|
|
108
|
+
element[prop] = value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
101
112
|
}
|
|
102
113
|
}
|
|
103
114
|
|
|
@@ -115,14 +126,21 @@ async function stateAttributes(element) {
|
|
|
115
126
|
}
|
|
116
127
|
let elements = [];
|
|
117
128
|
|
|
118
|
-
let form = element.closest("form");
|
|
119
|
-
if (form) {
|
|
120
|
-
|
|
121
|
-
} else {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
// let form = element.closest("form");
|
|
130
|
+
// if (form) {
|
|
131
|
+
// elements = form.querySelectorAll("[state_to]");
|
|
132
|
+
// } else {
|
|
133
|
+
if (element.hasAttribute("state_to")) elements.push(element);
|
|
134
|
+
let nestedElements = element.querySelectorAll("[state_to]");
|
|
135
|
+
elements.push(...nestedElements);
|
|
136
|
+
let current = element;
|
|
137
|
+
while (current) {
|
|
138
|
+
if (current.hasAttribute("state_to") && !elements.includes(current)) {
|
|
139
|
+
elements.push(current);
|
|
140
|
+
}
|
|
141
|
+
current = current.parentElement;
|
|
125
142
|
}
|
|
143
|
+
// }
|
|
126
144
|
|
|
127
145
|
let changeState = false;
|
|
128
146
|
for (let i = 0; i < elements.length; i++) {
|
|
@@ -176,7 +194,7 @@ async function _getAttributeValues(element) {
|
|
|
176
194
|
});
|
|
177
195
|
else if (attribute.name == "state-value" && !attribute.value)
|
|
178
196
|
Object.assign(attributeValues, {
|
|
179
|
-
value: await element.
|
|
197
|
+
value: await element.getValue()
|
|
180
198
|
});
|
|
181
199
|
else
|
|
182
200
|
Object.assign(attributeValues, {
|
|
@@ -189,7 +207,7 @@ async function _getAttributeValues(element) {
|
|
|
189
207
|
!element.hasAttribute("state-value") &&
|
|
190
208
|
element.getvalue
|
|
191
209
|
)
|
|
192
|
-
Object.assign(attributeValues, { value: await element.
|
|
210
|
+
Object.assign(attributeValues, { value: await element.getValue() });
|
|
193
211
|
|
|
194
212
|
return attributeValues;
|
|
195
213
|
}
|