@json-layout/core 1.15.8 → 1.15.9
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/compile/index.js
CHANGED
|
@@ -71,6 +71,27 @@ export function compile (_schema, partialOptions = {}) {
|
|
|
71
71
|
'main'
|
|
72
72
|
)
|
|
73
73
|
|
|
74
|
+
while (true) {
|
|
75
|
+
let updatedPropertyKeys = false
|
|
76
|
+
for (const skeletonNode of Object.values(skeletonNodes)) {
|
|
77
|
+
for (const propertyKey of [...skeletonNode.propertyKeys]) {
|
|
78
|
+
if (propertyKey.startsWith('$')) {
|
|
79
|
+
const referencedNode = skeletonNodes[propertyKey.replace('$', '')]
|
|
80
|
+
skeletonNode.propertyKeys = [...new Set(skeletonNode.propertyKeys.filter(p => p !== propertyKey).concat(referencedNode.propertyKeys))]
|
|
81
|
+
updatedPropertyKeys = true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
for (const roPropertyKey of [...skeletonNode.roPropertyKeys]) {
|
|
85
|
+
if (roPropertyKey.startsWith('$')) {
|
|
86
|
+
const referencedNode = skeletonNodes[roPropertyKey.replace('$', '')]
|
|
87
|
+
skeletonNode.roPropertyKeys = [...new Set(skeletonNode.roPropertyKeys.filter(p => p !== roPropertyKey).concat(referencedNode.roPropertyKeys))]
|
|
88
|
+
updatedPropertyKeys = true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!updatedPropertyKeys) break
|
|
93
|
+
}
|
|
94
|
+
|
|
74
95
|
options.ajv.removeSchema(schema.$id) // just in case it was previously added
|
|
75
96
|
options.ajv.addSchema(schema)
|
|
76
97
|
|
|
@@ -258,7 +258,8 @@ export function makeSkeletonNode (
|
|
|
258
258
|
'object'
|
|
259
259
|
)
|
|
260
260
|
}
|
|
261
|
-
node.propertyKeys
|
|
261
|
+
node.propertyKeys.push('$' + dependentPointer)
|
|
262
|
+
node.roPropertyKeys.push('$' + dependentPointer)
|
|
262
263
|
node.children.push(dependentPointer)
|
|
263
264
|
}
|
|
264
265
|
}
|
|
@@ -288,8 +289,8 @@ export function makeSkeletonNode (
|
|
|
288
289
|
'object'
|
|
289
290
|
)
|
|
290
291
|
}
|
|
291
|
-
node.propertyKeys
|
|
292
|
-
node.roPropertyKeys
|
|
292
|
+
node.propertyKeys.push('$' + childPointer)
|
|
293
|
+
node.roPropertyKeys.push('$' + childPointer)
|
|
293
294
|
node.children = node.children ?? []
|
|
294
295
|
node.children.push(childPointer)
|
|
295
296
|
}
|
|
@@ -309,13 +310,14 @@ export function makeSkeletonNode (
|
|
|
309
310
|
type,
|
|
310
311
|
nullable
|
|
311
312
|
)
|
|
312
|
-
|
|
313
|
+
const compObjects = isSwitchStruct(normalizationResult.layout) ? normalizationResult.layout.switch : [normalizationResult.layout]
|
|
314
|
+
for (const compObject of compObjects) {
|
|
313
315
|
let defaultData
|
|
314
316
|
if ('default' in schema && (options.useDefault === 'data' || options.useDefault === true || required)) defaultData = schema.default
|
|
315
317
|
else defaultData = nullable ? null : {}
|
|
316
|
-
if (
|
|
317
|
-
if (
|
|
318
|
-
if (
|
|
318
|
+
if (compObject.defaultData === undefined) compObject.defaultData = defaultData
|
|
319
|
+
if (compObject.defaultData !== undefined && !compObject.getDefaultData) compObject.getDefaultData = { type: 'js-eval', expr: 'layout.defaultData', pure: true, dataAlias: 'value' }
|
|
320
|
+
if (compObject.getDefaultData) pushExpression(expressions, compObject.getDefaultData)
|
|
319
321
|
}
|
|
320
322
|
|
|
321
323
|
normalizedLayouts[oneOfPointer] = normalizationResult.layout
|
|
@@ -326,9 +328,9 @@ export function makeSkeletonNode (
|
|
|
326
328
|
/** @type {string[]} */
|
|
327
329
|
const childrenTrees = []
|
|
328
330
|
/** @type {string[]} */
|
|
329
|
-
|
|
331
|
+
const propertyKeys = []
|
|
330
332
|
/** @type {string[]} */
|
|
331
|
-
|
|
333
|
+
const roPropertyKeys = []
|
|
332
334
|
for (let i = 0; i < schema.oneOf.length; i++) {
|
|
333
335
|
if (!schema.oneOf[i].type) schema.oneOf[i].type = type
|
|
334
336
|
const childTreePointer = `${oneOfPointer}/${i}`
|
|
@@ -353,12 +355,8 @@ export function makeSkeletonNode (
|
|
|
353
355
|
)
|
|
354
356
|
}
|
|
355
357
|
childrenTrees.push(childTreePointer)
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
const rootSkeletonNode = skeletonNodes[skeletonTrees[childTreePointer].root]
|
|
359
|
-
propertyKeys = propertyKeys.concat(rootSkeletonNode.propertyKeys)
|
|
360
|
-
roPropertyKeys = roPropertyKeys.concat(rootSkeletonNode.roPropertyKeys)
|
|
361
|
-
}
|
|
358
|
+
propertyKeys.push('$' + childTreePointer)
|
|
359
|
+
roPropertyKeys.push('$' + childTreePointer)
|
|
362
360
|
}
|
|
363
361
|
if (!skeletonNodes[oneOfPointer]) {
|
|
364
362
|
skeletonNodes[oneOfPointer] = {
|
|
@@ -467,8 +465,8 @@ export function makeSkeletonNode (
|
|
|
467
465
|
)
|
|
468
466
|
}
|
|
469
467
|
node.children = node.children ?? []
|
|
470
|
-
node.propertyKeys
|
|
471
|
-
node.roPropertyKeys
|
|
468
|
+
node.propertyKeys.push('$' + childPointer)
|
|
469
|
+
node.roPropertyKeys.push('$' + childPointer)
|
|
472
470
|
node.children.push(childPointer)
|
|
473
471
|
}
|
|
474
472
|
if (schema.else) {
|
|
@@ -496,8 +494,8 @@ export function makeSkeletonNode (
|
|
|
496
494
|
)
|
|
497
495
|
}
|
|
498
496
|
node.children = node.children ?? []
|
|
499
|
-
node.propertyKeys
|
|
500
|
-
node.roPropertyKeys
|
|
497
|
+
node.propertyKeys.push('$' + childPointer)
|
|
498
|
+
node.roPropertyKeys.push('$' + childPointer)
|
|
501
499
|
node.children.push(childPointer)
|
|
502
500
|
}
|
|
503
501
|
}
|
package/src/state/state-node.js
CHANGED
|
@@ -776,8 +776,8 @@ export function createStateNode (
|
|
|
776
776
|
/** @type {unknown[]} */(nodeData ?? []),
|
|
777
777
|
children
|
|
778
778
|
)
|
|
779
|
-
} else if (Array.isArray(nodeData) &&
|
|
780
|
-
// case of
|
|
779
|
+
} else if (Array.isArray(nodeData) && isItemsLayout(layout, compiledLayout.components)) {
|
|
780
|
+
// case of a multi-valued select of objects
|
|
781
781
|
const itemsSkeletonTree = skeleton.childrenTrees?.[0] && compiledLayout.skeletonTrees[skeleton.childrenTrees?.[0]]
|
|
782
782
|
const itemsSkeletonNode = (itemsSkeletonTree && compiledLayout.skeletonNodes[itemsSkeletonTree.root]) || null
|
|
783
783
|
nodeData = produceStateNodeDataArray(
|
|
@@ -787,8 +787,8 @@ export function createStateNode (
|
|
|
787
787
|
itemsSkeletonNode?.propertyKeys.length ? itemsSkeletonNode?.propertyKeys : undefined,
|
|
788
788
|
options.readOnlyPropertiesMode === 'remove' ? itemsSkeletonNode?.roPropertyKeys : undefined
|
|
789
789
|
)
|
|
790
|
-
} else if (typeof nodeData === 'object' && !(nodeData instanceof File) &&
|
|
791
|
-
// case of
|
|
790
|
+
} else if (typeof nodeData === 'object' && !(nodeData instanceof File) && isItemsLayout(layout, compiledLayout.components)) {
|
|
791
|
+
// case of a select of objects
|
|
792
792
|
nodeData = cleanNodeData(
|
|
793
793
|
/** @type {Record<string, unknown>} */(nodeData ?? {}),
|
|
794
794
|
dataPath,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"AA4BA;;;;GAIG;AACH,iCAJW,MAAM,mBACN,qBAAqB,GACnB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compile/index.js"],"names":[],"mappings":"AA4BA;;;;GAIG;AACH,iCAJW,MAAM,mBACN,qBAAqB,GACnB,cAAc,CAuH1B;;;;2BAvIY,OAAO,YAAY,EAAE,YAAY;2BACjC,OAAO,YAAY,EAAE,YAAY;6BACjC,OAAO,YAAY,EAAE,cAAc;6BACnC,OAAO,YAAY,EAAE,cAAc;oCACnC,OAAO,YAAY,EAAE,qBAAqB;iCAC1C,OAAO,YAAY,EAAE,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AACH,4CAlBW,GAAG,kBACH,MAAM,WACN,OAAO,YAAY,EAAE,cAAc,cACnC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,iBACxD,MAAM,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,iBACjD,MAAM,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,oBACjD,MAAM,EAAE,oBACR,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,MAAM,CAAC,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO,yBAAyB,EAAE,UAAU,EAAE,OAC9C,MAAM,GAAG,MAAM,WACf,MAAM,YACN,OAAO,cACP,MAAM,cACN,OAAO,cACP,MAAM,GACJ,OAAO,YAAY,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"skeleton-node.d.ts","sourceRoot":"","sources":["../../src/compile/skeleton-node.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;GAkBG;AACH,4CAlBW,GAAG,kBACH,MAAM,WACN,OAAO,YAAY,EAAE,cAAc,cACnC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,iBACxD,MAAM,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,iBACjD,MAAM,CAAC,MAAM,EAAE,OAAO,YAAY,EAAE,YAAY,CAAC,oBACjD,MAAM,EAAE,oBACR,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,qBACxB,MAAM,CAAC,MAAM,EAAE,OAAO,yBAAyB,EAAE,gBAAgB,CAAC,eAClE,OAAO,yBAAyB,EAAE,UAAU,EAAE,OAC9C,MAAM,GAAG,MAAM,WACf,MAAM,YACN,OAAO,cACP,MAAM,cACN,OAAO,cACP,MAAM,GACJ,OAAO,YAAY,EAAE,YAAY,CA8iB7C"}
|