@koumoul/vjsf 3.15.2 → 3.15.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 +1 -1
- package/src/compat/v2.js +30 -1
- package/types/compat/v2.d.ts.map +1 -1
package/package.json
CHANGED
package/src/compat/v2.js
CHANGED
|
@@ -96,7 +96,23 @@ const processFragment = (schema, getJSONRef, schemaId, processed) => {
|
|
|
96
96
|
if (display === 'checkbox' && schema.type !== 'boolean') display = 'checkbox-group'
|
|
97
97
|
if (display === 'switch' && schema.type !== 'boolean') display = 'switch-group'
|
|
98
98
|
if (display === 'hidden') display = 'none'
|
|
99
|
-
|
|
99
|
+
if (schema.allOf && schema.properties) {
|
|
100
|
+
const children = []
|
|
101
|
+
for (const key of Object.keys(schema.properties)) {
|
|
102
|
+
children.push(key)
|
|
103
|
+
}
|
|
104
|
+
const allOfChild = {
|
|
105
|
+
comp: display,
|
|
106
|
+
children: /** @type string[] */([])
|
|
107
|
+
}
|
|
108
|
+
for (let i = 0; i < schema.allOf.length; i++) {
|
|
109
|
+
allOfChild.children.push('$allOf-' + i)
|
|
110
|
+
}
|
|
111
|
+
children.push(allOfChild)
|
|
112
|
+
layout.children = children
|
|
113
|
+
} else {
|
|
114
|
+
layout.comp = display
|
|
115
|
+
}
|
|
100
116
|
delete schema['x-display']
|
|
101
117
|
}
|
|
102
118
|
|
|
@@ -147,6 +163,19 @@ const processFragment = (schema, getJSONRef, schemaId, processed) => {
|
|
|
147
163
|
layout.if = '!summary'
|
|
148
164
|
}
|
|
149
165
|
|
|
166
|
+
if (schema.type === 'array' && schema.items) {
|
|
167
|
+
if (!Array.isArray(schema.items)) {
|
|
168
|
+
layout.comp = 'list'
|
|
169
|
+
if (schema['x-itemTitle']) layout.itemTitle = `data["${schema['x-itemTitle']}"]`
|
|
170
|
+
else {
|
|
171
|
+
// vjsf 2 implicitly used a title property as an item title in lists
|
|
172
|
+
if (schema.items.properties?.title || schema.items.allOf?.some((/** @type {any} */ ao) => ao.properties?.title)) {
|
|
173
|
+
layout.itemTitle = 'data.title'
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
150
179
|
// compact the layout keyword if possible
|
|
151
180
|
if (Object.keys(layout).length === 1 && 'comp' in layout) {
|
|
152
181
|
schema.layout = layout.comp
|
package/types/compat/v2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/compat/v2.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/compat/v2.js"],"names":[],"mappings":"AAyOA;;;;;;GAMG;AACH,kCALW,MAAM,2CAEN,MAAM,0BAoBhB;sBAjQqB,KAAK"}
|