@json-layout/core 0.16.2 → 0.16.4

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": "@json-layout/core",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "description": "Compilation and state management utilities for JSON Layout.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -85,13 +85,12 @@ const produceStateNodeData = produce((draft, parentDataPath, children, additiona
85
85
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
86
86
  if (child.data === undefined) delete draft[child.key]
87
87
  else draft[child.key] = child.data
88
-
89
- if (Array.isArray(draft)) {
90
- // remove trailing undefined values from tuples
91
- while (draft.length && draft[draft.length - 1] === undefined) {
92
- draft.pop()
93
- }
94
- }
88
+ }
89
+ }
90
+ if (Array.isArray(draft)) {
91
+ // remove trailing undefined values from tuples
92
+ while (draft.length && draft[draft.length - 1] === undefined) {
93
+ draft.pop()
95
94
  }
96
95
  }
97
96
  }
@@ -253,7 +252,9 @@ export function createStateNode (
253
252
  // TODO: implement a cleaner way to filter context.errors while being able to reuse nodes with errors
254
253
  if (skeleton.pure && reusedNode && !reusedNode.error && !reusedNode.childError) {
255
254
  cacheKey = [parentOptions, compiledLayout, fullKey, skeleton, childDefinition, parentDisplay.width, validationState, context.activeItems, context.initial, data]
256
- if (context.cacheKeys[fullKey] && shallowEqualArray(context.cacheKeys[fullKey], cacheKey)) return reusedNode
255
+ if (context.cacheKeys[fullKey] && shallowEqualArray(context.cacheKeys[fullKey], cacheKey)) {
256
+ return reusedNode
257
+ }
257
258
  }
258
259
 
259
260
  const normalizedLayout = childDefinition && childIsCompObject(childDefinition)
@@ -324,7 +325,7 @@ export function createStateNode (
324
325
  // if an item was selected, remove the oneOf error
325
326
  if (originalError.schemaPath === skeleton.pointer && originalError.keyword === 'oneOf') return false
326
327
  // also remove the errors from other children of the oneOf
327
- if (!originalError.schemaPath.startsWith(skeleton.pointer + '/' + activeChildTreeIndex)) return false
328
+ if (originalError.schemaPath.startsWith(skeleton.pointer) && !originalError.schemaPath.startsWith(skeleton.pointer + '/' + activeChildTreeIndex)) return false
328
329
  return true
329
330
  })
330
331
  context.activeItems = produce(context.activeItems, draft => { draft[fullKey] = activeChildTreeIndex })
@@ -378,7 +379,7 @@ export function createStateNode (
378
379
  itemData,
379
380
  arrayData,
380
381
  validationState,
381
- reusedNode?.children?.[0]
382
+ reusedNode?.children?.[i]
382
383
  )
383
384
  if (child.autofocus || child.autofocusChild !== undefined) focusChild = false
384
385
  children.push(child)