@rokkit/states 1.0.0-next.114 → 1.0.0-next.116

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": "@rokkit/states",
3
- "version": "1.0.0-next.114",
3
+ "version": "1.0.0-next.116",
4
4
  "description": "Contains generic data manipulation functions that can be used in various components.",
5
5
  "author": "Jerry Thomas <me@jerrythomas.name>",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@ export class Proxy {
17
17
  }
18
18
 
19
19
  #processChildren() {
20
+ if (!this.has('children')) return []
20
21
  const children = this.#value[this.fields.children] ?? []
21
22
  if (Array.isArray(children)) {
22
23
  const fields = getNestedFields(this.fields)
@@ -57,7 +58,7 @@ export class Proxy {
57
58
  delete this.#value[key]
58
59
  })
59
60
  } else {
60
- this.#value.text = value
61
+ this.#value = typeof value === 'object' ? value : { [this.fields.text]: value }
61
62
  this.#original = value
62
63
  }
63
64
  }
@@ -66,7 +67,7 @@ export class Proxy {
66
67
  * Gets a mapped attribute from the original item
67
68
  *
68
69
  * @param {string} fieldName - Name of the field to get
69
- * @param {any} defaultValue - Default value to return if not found
70
+ * @param {any} [defaultValue] - Default value to return if not found
70
71
  * @returns {any|undefined} - The attribute value or null if not found
71
72
  */
72
73
  get(fieldName, defaultValue) {
@@ -91,7 +92,7 @@ export class Proxy {
91
92
  * - No snippet key is configured for this item
92
93
  * - The configured snippet key doesn't exist in the snippets collection
93
94
  * @param {Object} snippets
94
- * @param {import('svelte').Snippet|undefined} defaultSnippet
95
+ * @param {import('svelte').Snippet|undefined} [defaultSnippet]
95
96
  * @returns {import('svelte').Snippet|undefined}
96
97
  */
97
98
  getSnippet(snippets, defaultSnippet) {