@json-layout/core 1.10.9 → 1.10.10
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
package/src/state/state-node.js
CHANGED
|
@@ -114,9 +114,9 @@ const produceStateNodeData = produce((draft, parentDataPath, children, additiona
|
|
|
114
114
|
if (child.data === undefined || child.data === null) continue
|
|
115
115
|
if (children.length > 1) {
|
|
116
116
|
for (const key of Object.keys(child.data)) {
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
}
|
|
117
|
+
if (children.some(c => c.key === key)) continue
|
|
118
|
+
if (!child.skeleton.propertyKeys.includes(key) && children.some(c => c.key !== child.key && c.skeleton.propertyKeys.includes(key))) continue
|
|
119
|
+
draft[key] = /** @type {any} */(child.data)[key]
|
|
120
120
|
}
|
|
121
121
|
} else {
|
|
122
122
|
Object.assign(draft, child.data)
|
|
@@ -442,12 +442,12 @@ export function createStateNode (
|
|
|
442
442
|
|
|
443
443
|
if (key === '$oneOf' && skeleton.childrenTrees) {
|
|
444
444
|
// find the oneOf child that was either previously selected, if none were selected select the child that is valid with current data
|
|
445
|
-
const
|
|
445
|
+
const validChildTreeIndex = skeleton.childrenTrees?.findIndex((childTree) => compiledLayout.validates[compiledLayout.skeletonTrees[childTree].refPointer](data))
|
|
446
|
+
const activeChildTreeIndex = /** @type {number} */(fullKey in context.activatedItems ? context.activatedItems[fullKey] : validChildTreeIndex)
|
|
446
447
|
if (activeChildTreeIndex !== -1) {
|
|
447
448
|
if (!(fullKey in context.activatedItems)) context.autoActivatedItems[fullKey] = activeChildTreeIndex
|
|
448
449
|
context.errors = context.errors?.filter(error => {
|
|
449
450
|
const originalError = error.params?.errors?.[0] ?? error
|
|
450
|
-
// console.log(originalError.schemaPath, skeleton.pointer, skeleton.refPointer)
|
|
451
451
|
// if an item was selected, remove the oneOf error
|
|
452
452
|
if (matchError(error, skeleton, dataPath, parentDataPath)) return false
|
|
453
453
|
// also remove the errors from other children of the oneOf
|
|
@@ -457,7 +457,14 @@ export function createStateNode (
|
|
|
457
457
|
}
|
|
458
458
|
return true
|
|
459
459
|
})
|
|
460
|
-
|
|
460
|
+
if (context.additionalPropertiesErrors && validChildTreeIndex === -1) {
|
|
461
|
+
// remove additional properties errors if the oneOf has no valid children
|
|
462
|
+
context.additionalPropertiesErrors = context.additionalPropertiesErrors?.filter(error => {
|
|
463
|
+
const originalError = error.params?.errors?.[0] ?? error
|
|
464
|
+
if (originalError.instancePath === parentDataPath) return false
|
|
465
|
+
return true
|
|
466
|
+
})
|
|
467
|
+
}
|
|
461
468
|
const activeChildKey = `${fullKey}/${activeChildTreeIndex}`
|
|
462
469
|
if (context.autofocusTarget === fullKey) context.autofocusTarget = activeChildKey
|
|
463
470
|
const activeChildTree = compiledLayout.skeletonTrees[skeleton.childrenTrees[activeChildTreeIndex]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-node.d.ts","sourceRoot":"","sources":["../../src/state/state-node.js"],"names":[],"mappings":"AAiOA;;;;;;;;;;;GAWG;AACH,4CAXW,OAAO,aAAa,EAAE,kBAAkB,EAAE,cAC1C,OAAO,yBAAyB,EAAE,UAAU,QAC5C,GAAG,WACH,OAAO,YAAY,EAAE,gBAAgB,WACrC,OAAO,oBAAoB,EAAE,OAAO,UACpC,OAAO,yBAAyB,EAAE,cAAc,aAChD,MAAM,CAAC,MAAM,EAAE,OAAO,KAAK,EAAE,gBAAgB,CAAC,YAC9C,OAAO,iBACP,OAAO,qBAAqB,EAAE,uBAAuB,GAAG,IAAI,GAC1D,GAAG,CAsBf;AAiCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,yCAjBW,OAAO,YAAY,EAAE,sBAAsB,iBAC3C,OAAO,YAAY,EAAE,gBAAgB,kBACrC,OAAO,aAAa,EAAE,cAAc,OACpC,MAAM,GAAG,MAAM,WACf,MAAM,iBACN,MAAM,GAAG,IAAI,YACb,MAAM,kBACN,MAAM,GAAG,IAAI,YACb,O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