sanity-plugin-internationalized-array 1.10.1 → 1.10.3
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
|
@@ -104,7 +104,7 @@ export default function InternationalizedArray(
|
|
|
104
104
|
// Create default fields if the document is not yet created
|
|
105
105
|
const documentCreatedAt = useFormValue(['_createdAt'])
|
|
106
106
|
const [hasAddedDefaultLanguages, setHasAddedDefaultLanguages] =
|
|
107
|
-
useState(
|
|
107
|
+
useState(Boolean(documentCreatedAt))
|
|
108
108
|
|
|
109
109
|
// Write default languages
|
|
110
110
|
useEffect(() => {
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isArraySchemaType,
|
|
3
|
-
isDocumentSchemaType,
|
|
4
|
-
ObjectField,
|
|
5
|
-
Path,
|
|
6
|
-
SchemaType,
|
|
7
|
-
} from 'sanity'
|
|
1
|
+
import {isDocumentSchemaType, ObjectField, Path, SchemaType} from 'sanity'
|
|
8
2
|
|
|
9
3
|
type ObjectFieldWithPath = ObjectField<SchemaType> & {path: Path}
|
|
10
4
|
|
|
@@ -42,11 +36,15 @@ function extractInnerFields(
|
|
|
42
36
|
)
|
|
43
37
|
|
|
44
38
|
return [...acc, thisFieldWithPath, ...innerFields]
|
|
45
|
-
} else if (
|
|
39
|
+
} else if (
|
|
40
|
+
field.type.jsonType === 'array' &&
|
|
41
|
+
field.type.of.length &&
|
|
42
|
+
field.type.of.some((item) => 'fields' in item)
|
|
43
|
+
) {
|
|
46
44
|
const innerFields = extractInnerFields(
|
|
47
45
|
// TODO: Fix TS assertion for array fields
|
|
48
46
|
// @ts-expect-error
|
|
49
|
-
field.type.of,
|
|
47
|
+
field.type.of[0].fields,
|
|
50
48
|
[...path, field.name],
|
|
51
49
|
maxDepth
|
|
52
50
|
)
|