@cocreate/element-prototype 1.29.2 → 1.29.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 CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.29.3](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.29.2...v1.29.3) (2025-07-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * improve handling of radio inputs and select elements in setValue function ([8fb0fba](https://github.com/CoCreate-app/CoCreate-element-prototype/commit/8fb0fbade7136dfd8eefd1109d30f3ec02bcc32a))
7
+
1
8
  ## [1.29.2](https://github.com/CoCreate-app/CoCreate-element-prototype/compare/v1.29.1...v1.29.2) (2025-05-01)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,18 +1,10 @@
1
1
  {
2
2
  "name": "@cocreate/element-prototype",
3
- "version": "1.29.2",
3
+ "version": "1.29.3",
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",
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/getValue.js CHANGED
@@ -56,7 +56,10 @@ const getValue = (element, valueType) => {
56
56
  case "radio":
57
57
  const key = element.getAttribute("key");
58
58
  // Handles radio inputs by selecting the checked radio's value in the group with the same key
59
- value = document.querySelector(`input[key="${key}"]:checked`).value;
59
+ let el = document.querySelector(`input[key="${key}"]:checked`);
60
+ if (el) {
61
+ value = el.value;
62
+ }
60
63
  break;
61
64
 
62
65
  case "number":
package/src/operators.js CHANGED
@@ -8,6 +8,8 @@ const customOperators = new Map(
8
8
  $clientId: () => localStorage.getItem("clientId"),
9
9
  $session_id: () => localStorage.getItem("session_id"),
10
10
  $value: (element) => element.getValue() || "",
11
+ // TODO: get length of value
12
+ // $length: (element) => {element.getValue() || ""},
11
13
  $innerWidth: () => window.innerWidth,
12
14
  $innerHeight: () => window.innerHeight,
13
15
  $href: () => window.location.href.replace(/\/$/, ""),
@@ -34,7 +36,19 @@ const customOperators = new Map(
34
36
  return path === "/" ? "" : path;
35
37
  },
36
38
  $param: (element, args) => args,
37
- $setValue: (element, args) => element.setValue(...args) || ""
39
+ $setValue: (element, args) => element.setValue(...args) || "",
40
+ $true: () => true,
41
+ $false: () => false,
42
+ // TODO: Handle uuid generation
43
+ // $uid: () => uid.generate(6),
44
+ $parse: (element, args) => {
45
+ let value = args || "";
46
+ try {
47
+ return JSON.parse(value);
48
+ } catch (e) {
49
+ return value;
50
+ }
51
+ }
38
52
  })
39
53
  );
40
54
 
@@ -49,7 +63,8 @@ const propertyOperators = new Set([
49
63
  "$className",
50
64
  "$textContent",
51
65
  "$innerHTML",
52
- "$getValue"
66
+ "$getValue",
67
+ "$reset"
53
68
  ]);
54
69
 
55
70
  // Combine all known operator keys for the main parsing regex
package/src/setValue.js CHANGED
@@ -52,7 +52,7 @@ const setValue = (el, value, dispatch) => {
52
52
  if (
53
53
  el.tagName == "INPUT" ||
54
54
  el.tagName == "TEXTAREA" ||
55
- (el.tagName == "SELECT" && el.options.length)
55
+ el.tagName == "SELECT"
56
56
  ) {
57
57
  // TODO: attribute config undefined when used with onload-value
58
58
  let isCrdt = el.getAttribute("crdt");
@@ -71,9 +71,11 @@ const setValue = (el, value, dispatch) => {
71
71
  if (inputs[i].value) {
72
72
  if (value === true || value === false)
73
73
  inputs[i].checked = value;
74
- else if (value.includes(inputValue))
74
+ else if (value.includes(inputValue) || value === "on") {
75
75
  inputs[i].checked = true;
76
- else inputs[i].checked = false;
76
+ } else {
77
+ inputs[i].checked = false;
78
+ }
77
79
  } else {
78
80
  if (
79
81
  value === "true" ||
@@ -88,11 +90,7 @@ const setValue = (el, value, dispatch) => {
88
90
  el.value == value ? (el.checked = true) : (el.checked = false);
89
91
  } else if (el.type === "password") {
90
92
  el.value = __decryptPassword(value);
91
- } else if (
92
- el.tagName == "SELECT" &&
93
- el.hasAttribute("multiple") &&
94
- Array.isArray(value)
95
- ) {
93
+ } else if (el.tagName == "SELECT") {
96
94
  let options = el.options;
97
95
  for (let i = 0; i < options.length; i++) {
98
96
  if (value.includes && value.includes(options[i].value)) {