native-document 1.0.267 → 1.0.268

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-document",
3
- "version": "1.0.267",
3
+ "version": "1.0.268",
4
4
  "description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
5
5
  "author": "AfroCodeur <https://github.com/afrocodeur>",
6
6
  "license": "MIT",
@@ -5,6 +5,7 @@ import PluginsManager from '../../core/utils/plugins-manager';
5
5
  import Validator from '../../core/utils/validator';
6
6
  import {deepClone} from '../utils/helpers';
7
7
  import {$getFromStorage, $saveToStorage} from '../utils/localstorage';
8
+ import {value} from 'happy-dom/lib/PropertySymbol';
8
9
 
9
10
  /**
10
11
  * Reactive primitive value container.
@@ -568,6 +569,19 @@ ObservableItem.prototype.reset = function() {
568
569
  this.set(resetValue);
569
570
  };
570
571
 
572
+ /**
573
+ *
574
+ * @param {*} value
575
+ * @return {void}
576
+ */
577
+ ObservableItem.prototype.setOrReset = function(value) {
578
+ if(value) {
579
+ this.set(value);
580
+ return;
581
+ }
582
+ this.reset();
583
+ };
584
+
571
585
  /**
572
586
  * Returns a string representation of the observable's current value.
573
587
  *
@@ -214,12 +214,12 @@ ObservableItem.prototype.isNotEmpty = function () {
214
214
  ObservableItem.prototype.isIncludes = function (value) {
215
215
  if (value?.__$Observable) {
216
216
  return $computed((a, b) => {
217
- if (Array.isArray(a)) return a.includes(b);
217
+ if (Array.isArray(a)) return this.includes(value);
218
218
  return String(a).includes(String(b));
219
219
  }, [this, value]);
220
220
  }
221
221
  return $checker(this, x => {
222
- if (Array.isArray(x)) return x.includes(value);
222
+ if (Array.isArray(this.val())) return this.includes(value);
223
223
  return String(x).includes(String(value));
224
224
  });
225
225
  };
@@ -236,7 +236,9 @@ ObservableItem.prototype.isIncludes = function (value) {
236
236
  */
237
237
  ObservableItem.prototype.isIncludedIn = function (array) {
238
238
  if (array?.__$Observable) {
239
- return $computed((a, b) => b.includes(a), [this, array]);
239
+ return $computed(() => {
240
+ return array.includes(this);
241
+ }, [this, array]);
240
242
  }
241
243
  return $checker(this, x => array.includes(x));
242
244
  };
@@ -76,8 +76,8 @@ const buildSearch = ($desc, instance) => {
76
76
  const content = item.content ?? item.label ?? item.label;
77
77
  const value = item.value;
78
78
 
79
- return content?.toLowerCase().includes(key.toLowerCase())
80
- || value?.toLowerCase().includes(key.toLowerCase());
79
+ return content?.valueOf().toLowerCase().includes(key.toLowerCase())
80
+ || value?.valueOf().toLowerCase().includes(key.toLowerCase());
81
81
  }
82
82
  return description.value?.toLowerCase().includes(key.toLowerCase())
83
83
  || description.content?.toLowerCase().includes(key.toLowerCase());
@@ -30,6 +30,8 @@ export default function ListItemRender($desc, instance) {
30
30
  const value = $desc.value ?? instance;
31
31
  const isChecked = selectedValues ? selectedValues.isIncludes(value) : null;
32
32
 
33
+ console.log({ isChecked })
34
+
33
35
  if($list.$description?.selectable || $desc.selected) {
34
36
  const selectedSource = $desc.selected ?? isChecked;
35
37
  props.class.add('is-selected', selectedSource);
@@ -264,6 +264,7 @@ export type ObservableObject<T extends Record<string, any>> = ObservableItem<T>
264
264
  $updateWith(values: Partial<T>): void;
265
265
  update(values: Partial<T>): void;
266
266
  reset(): void;
267
+ setOrReset(): void;
267
268
  clone(): ObservableObject<T>;
268
269
  $clone(): ObservableObject<T>;
269
270
  keys(): string[];