@sanity/assist 1.0.7 → 1.0.8
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/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/assistInspector/helpers.ts +12 -2
package/package.json
CHANGED
|
@@ -23,6 +23,8 @@ export interface FieldRef {
|
|
|
23
23
|
icon: ComponentType
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const maxDepth = 4
|
|
27
|
+
|
|
26
28
|
export function getTypeIcon(schemaType: SchemaType) {
|
|
27
29
|
let t: SchemaType | undefined = schemaType
|
|
28
30
|
|
|
@@ -57,7 +59,14 @@ export function getFieldRefsWithDocument(schemaType: ObjectSchemaType): FieldRef
|
|
|
57
59
|
]
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
export function getFieldRefs(
|
|
62
|
+
export function getFieldRefs(
|
|
63
|
+
schemaType: ObjectSchemaType,
|
|
64
|
+
parent?: FieldRef,
|
|
65
|
+
depth = 0
|
|
66
|
+
): FieldRef[] {
|
|
67
|
+
if (depth >= maxDepth) {
|
|
68
|
+
return []
|
|
69
|
+
}
|
|
61
70
|
return schemaType.fields
|
|
62
71
|
.filter((f) => !f.name.startsWith('_'))
|
|
63
72
|
.flatMap((field) => {
|
|
@@ -70,7 +79,8 @@ export function getFieldRefs(schemaType: ObjectSchemaType, parent?: FieldRef): F
|
|
|
70
79
|
schemaType: field.type,
|
|
71
80
|
icon: getTypeIcon(field.type),
|
|
72
81
|
}
|
|
73
|
-
const fields =
|
|
82
|
+
const fields =
|
|
83
|
+
field.type.jsonType === 'object' ? getFieldRefs(field.type, fieldRef, depth + 1) : []
|
|
74
84
|
|
|
75
85
|
if (!isAssistSupported(field.type)) {
|
|
76
86
|
return fields
|