@cocreate/events 1.21.0 → 1.22.1

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,17 @@
1
+ ## [1.22.1](https://github.com/CoCreate-app/CoCreate-events/compare/v1.22.0...v1.22.1) (2024-08-24)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * parse flag ([53ce700](https://github.com/CoCreate-app/CoCreate-events/commit/53ce700cca7d90919b933d102cda5f73fe3261c5))
7
+
8
+ # [1.22.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.21.0...v1.22.0) (2024-06-19)
9
+
10
+
11
+ ### Features
12
+
13
+ * $template condition checks for {{}} ([bd7219a](https://github.com/CoCreate-app/CoCreate-events/commit/bd7219a03b5d1b04772596872af15351bfd5f999))
14
+
1
15
  # [1.21.0](https://github.com/CoCreate-app/CoCreate-events/compare/v1.20.1...v1.21.0) (2024-06-12)
2
16
 
3
17
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/events",
3
- "version": "1.21.0",
3
+ "version": "1.22.1",
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",
package/src/index.js CHANGED
@@ -20,7 +20,7 @@
20
20
  // you must obtain a commercial license from CoCreate LLC.
21
21
  // For details, visit <https://cocreate.app/licenses/> or contact us at sales@cocreate.app.
22
22
 
23
- import { queryElements, checkMediaQueries, queryData } from '@cocreate/utils';
23
+ import { queryElements, queryData } from '@cocreate/utils';
24
24
  import action from '@cocreate/actions';
25
25
  import observer from '@cocreate/observer';
26
26
  import '@cocreate/element-prototype';
@@ -289,6 +289,7 @@ const CoCreateEvents = {
289
289
  //TODO: improved resize toggling of values
290
290
  // let hasCondition = this.elements2.get(element)
291
291
  if (ifCondition && evaluateCondition(ifCondition, ifValue)) {
292
+
292
293
  // if (hasCondition && hasCondition.condition === ifCondition) {
293
294
  // return
294
295
  // } else
@@ -577,18 +578,26 @@ function checkCondition(condition, value) {
577
578
  if (operatorMatch)
578
579
  condition = operatorMatch[2].trim()
579
580
 
581
+ let parse = true
580
582
  if (condition === 'true') {
581
583
  return !!value[0];
582
584
  } else if (condition === 'false') {
583
585
  return !value[0];
586
+ } else if (condition === '[]' && typeof value[0] === 'string') {
587
+ parse = false
584
588
  }
585
589
 
590
+
591
+
586
592
  // TODO: why parse updated conditin to boolean false
587
- if (condition !== 'false')
593
+ if (parse && condition !== 'false')
588
594
  condition = parseCondition(condition);
595
+
589
596
  let result;
590
597
 
591
- if (Array.isArray(value) && !(typeof condition === 'object')) {
598
+ if (condition === '$template') {
599
+ result = (/{{\s*([\w\W]+)\s*}}/g.test(value[0]))
600
+ } else if (Array.isArray(value) && !(typeof condition === 'object')) {
592
601
  if (operatorMatch) {
593
602
  condition = parseFloat(condition)
594
603
  result = value.some(v => {