@sanity/assist 5.0.2 → 5.0.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/LICENSE +1 -1
- package/dist/index.cjs +15 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +11 -34
- package/dist/index.js.map +1 -1
- package/package.json +15 -11
- package/src/_lib/usePrevious.ts +1 -1
- package/src/assistDocument/components/AssistDocumentForm.tsx +3 -2
- package/src/assistDocument/hooks/useAssistDocumentContextValue.tsx +2 -4
- package/src/assistInspector/AssistInspector.tsx +11 -15
- package/src/assistInspector/helpers.ts +2 -2
- package/src/components/ImageContext.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/assist",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "You create the instructions; Sanity AI Assist does the rest.",
|
|
6
6
|
"keywords": [
|
|
@@ -50,10 +50,14 @@
|
|
|
50
50
|
"release": "semantic-release"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@portabletext/types": "^4.0.1",
|
|
54
|
+
"@sanity/client": "^7.14.0",
|
|
55
|
+
"@sanity/color": "^3.0.6",
|
|
53
56
|
"@sanity/icons": "^3.7.4",
|
|
54
57
|
"@sanity/incompatible-plugin": "^1.0.4",
|
|
55
58
|
"@sanity/ui": "^3.1.11",
|
|
56
59
|
"date-fns": "^3.6.0",
|
|
60
|
+
"get-random-values-esm": "^1.0.2",
|
|
57
61
|
"lodash": "^4.17.21",
|
|
58
62
|
"lodash-es": "^4.17.21",
|
|
59
63
|
"react-fast-compare": "^3.2.2",
|
|
@@ -64,36 +68,36 @@
|
|
|
64
68
|
"@commitlint/cli": "^19.2.1",
|
|
65
69
|
"@commitlint/config-conventional": "^19.1.0",
|
|
66
70
|
"@rollup/plugin-image": "^3.0.3",
|
|
67
|
-
"@sanity/pkg-utils": "^
|
|
71
|
+
"@sanity/pkg-utils": "^10.3.2",
|
|
68
72
|
"@sanity/plugin-kit": "^4.0.20",
|
|
69
|
-
"@sanity/schema": "^4.
|
|
73
|
+
"@sanity/schema": "^5.4.0",
|
|
70
74
|
"@sanity/semantic-release-preset": "^4.1.7",
|
|
71
75
|
"@types/lodash": "^4.17.0",
|
|
72
76
|
"@types/lodash-es": "^4.17.12",
|
|
73
|
-
"@types/react": "^
|
|
77
|
+
"@types/react": "^19.2.8",
|
|
74
78
|
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
75
79
|
"@typescript-eslint/parser": "^7.6.0",
|
|
76
80
|
"eslint": "^8.57.0",
|
|
77
81
|
"eslint-config-prettier": "^9.1.0",
|
|
78
82
|
"eslint-config-sanity": "^7.1.2",
|
|
79
83
|
"eslint-plugin-prettier": "^5.1.3",
|
|
80
|
-
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
81
84
|
"eslint-plugin-react": "^7.34.1",
|
|
82
85
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
86
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
83
87
|
"npm-run-all2": "^5.0.2",
|
|
84
|
-
"react": "^
|
|
85
|
-
"react-dom": "^
|
|
88
|
+
"react": "^19.2.3",
|
|
89
|
+
"react-dom": "^19.2.3",
|
|
86
90
|
"rimraf": "^5.0.5",
|
|
87
|
-
"sanity": "^4.0
|
|
91
|
+
"sanity": "^5.4.0",
|
|
88
92
|
"semantic-release": "^23.0.8",
|
|
89
93
|
"styled-components": "^6.1.16",
|
|
90
|
-
"typescript": "^5.
|
|
94
|
+
"typescript": "^5.9.3",
|
|
91
95
|
"vitest": "^3.1.4"
|
|
92
96
|
},
|
|
93
97
|
"peerDependencies": {
|
|
94
|
-
"@sanity/mutator": "^3.36.4 || ^4.0.0-0",
|
|
98
|
+
"@sanity/mutator": "^3.36.4 || ^4.0.0-0 || ^5.0.0",
|
|
95
99
|
"react": "^18 || ^19",
|
|
96
|
-
"sanity": "^3.36.4 || ^4.0.0-0",
|
|
100
|
+
"sanity": "^3.36.4 || ^4.0.0-0 || ^5.0.0",
|
|
97
101
|
"styled-components": "^6.1"
|
|
98
102
|
},
|
|
99
103
|
"engines": {
|
package/src/_lib/usePrevious.ts
CHANGED
|
@@ -114,7 +114,6 @@ function AssistDocumentFormEditable(props: ObjectInputProps) {
|
|
|
114
114
|
[instructionParam]: (path[3] as KeyedSegment)?._key,
|
|
115
115
|
}) as Record<keyof AssistInspectorRouteParams, string | undefined>,
|
|
116
116
|
)
|
|
117
|
-
onPathOpen([])
|
|
118
117
|
} else {
|
|
119
118
|
setTimeout(() => onPathOpen(path), 0)
|
|
120
119
|
}
|
|
@@ -123,9 +122,11 @@ function AssistDocumentFormEditable(props: ObjectInputProps) {
|
|
|
123
122
|
[formCallbacks, onPathOpen, params, setParams, instruction],
|
|
124
123
|
)
|
|
125
124
|
|
|
125
|
+
// When showing the instruction list (no specific instruction selected),
|
|
126
|
+
// tell the form to focus on the field path to close any open modals
|
|
126
127
|
useEffect(() => {
|
|
127
128
|
if (activePath && !instruction) {
|
|
128
|
-
onPathOpen(
|
|
129
|
+
onPathOpen(activePath)
|
|
129
130
|
}
|
|
130
131
|
}, [activePath, instruction, onPathOpen])
|
|
131
132
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {useCallback, useEffect, useMemo, useState} from 'react'
|
|
2
|
-
import {getDraftId, getVersionId, type ObjectSchemaType, useSchema} from 'sanity'
|
|
2
|
+
import {getDraftId, getVersionId, type ObjectSchemaType, usePerspective, useSchema} from 'sanity'
|
|
3
3
|
import {useDocumentPane} from 'sanity/structure'
|
|
4
4
|
import {fieldPathParam, InstructionTask} from '../../types'
|
|
5
5
|
import {AssistDocumentContextValue} from '../AssistDocumentContext'
|
|
@@ -32,11 +32,9 @@ export function useAssistDocumentContextValue(documentId: string, documentType:
|
|
|
32
32
|
closeInspector,
|
|
33
33
|
inspector,
|
|
34
34
|
onChange: documentOnChange,
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
36
|
-
// @ts-ignore this is a valid option available in `corel` - Remove after corel is merged to next
|
|
37
|
-
selectedReleaseId,
|
|
38
35
|
editState,
|
|
39
36
|
} = useDocumentPane()
|
|
37
|
+
const {selectedReleaseId} = usePerspective()
|
|
40
38
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
41
39
|
// @ts-ignore this is a valid option available in `corel` - Remove after corel is merged to next
|
|
42
40
|
const {draft, published, version} = editState || {}
|
|
@@ -3,6 +3,7 @@ import {Box, Button, Card, Flex, Spinner, Stack, Text} from '@sanity/ui'
|
|
|
3
3
|
import {useCallback, useMemo, useRef} from 'react'
|
|
4
4
|
import {
|
|
5
5
|
type DocumentInspectorProps,
|
|
6
|
+
PerspectiveProvider,
|
|
6
7
|
PresenceOverlay,
|
|
7
8
|
VirtualizerScrollInstanceProvider,
|
|
8
9
|
} from 'sanity'
|
|
@@ -322,21 +323,16 @@ export function AssistInspector(props: DocumentInspectorProps) {
|
|
|
322
323
|
scrollElement={boundary.current}
|
|
323
324
|
containerElement={boundary}
|
|
324
325
|
>
|
|
325
|
-
<
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
selectedReleaseId: undefined,
|
|
336
|
-
}}
|
|
337
|
-
>
|
|
338
|
-
<DocumentForm />
|
|
339
|
-
</DocumentPaneProvider>
|
|
326
|
+
<PerspectiveProvider selectedPerspectiveName={undefined}>
|
|
327
|
+
<DocumentPaneProvider
|
|
328
|
+
paneKey={documentPane.paneKey}
|
|
329
|
+
index={documentPane.index}
|
|
330
|
+
itemId="ai"
|
|
331
|
+
pane={paneNode}
|
|
332
|
+
>
|
|
333
|
+
<DocumentForm />
|
|
334
|
+
</DocumentPaneProvider>
|
|
335
|
+
</PerspectiveProvider>
|
|
340
336
|
</VirtualizerScrollInstanceProvider>
|
|
341
337
|
</AssistTypeContext.Provider>
|
|
342
338
|
)}
|
|
@@ -37,7 +37,7 @@ export interface FieldRef {
|
|
|
37
37
|
|
|
38
38
|
const maxDepth = 6
|
|
39
39
|
|
|
40
|
-
export function getTypeIcon(schemaType: SchemaType) {
|
|
40
|
+
export function getTypeIcon(schemaType: SchemaType): ComponentType {
|
|
41
41
|
let t: SchemaType | undefined = schemaType
|
|
42
42
|
|
|
43
43
|
while (t) {
|
|
@@ -64,7 +64,7 @@ export function asFieldRefsByTypePath(fieldRefs: FieldRef[]): Record<string, Fie
|
|
|
64
64
|
return lookup
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export function getDocumentFieldRef(schemaType: ObjectSchemaType) {
|
|
67
|
+
export function getDocumentFieldRef(schemaType: ObjectSchemaType): FieldRef {
|
|
68
68
|
return {
|
|
69
69
|
key: documentRootKey,
|
|
70
70
|
icon: schemaType.icon ?? DocumentIcon,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {createContext, useEffect, useMemo, useState} from 'react'
|
|
2
|
-
import {getPublishedId, type InputProps, pathToString, useSyncState} from 'sanity'
|
|
3
|
-
import {
|
|
2
|
+
import {getPublishedId, type InputProps, pathToString, usePerspective, useSyncState} from 'sanity'
|
|
3
|
+
import {usePaneRouter} from 'sanity/structure'
|
|
4
4
|
|
|
5
5
|
import {useAssistDocumentContext} from '../assistDocument/AssistDocumentContext'
|
|
6
6
|
import {useAiAssistanceConfig} from '../assistLayout/AiAssistanceConfigContext'
|
|
@@ -18,7 +18,7 @@ export const ImageContext = createContext<ImageContextValue>({})
|
|
|
18
18
|
export function ImageContextProvider(props: InputProps) {
|
|
19
19
|
const {schemaType, path, value, readOnly} = props
|
|
20
20
|
const assetRef = (value as any)?.asset?._ref
|
|
21
|
-
const {selectedReleaseId} =
|
|
21
|
+
const {selectedReleaseId} = usePerspective()
|
|
22
22
|
const [assetRefState, setAssetRefState] = useState<string | undefined>(assetRef)
|
|
23
23
|
|
|
24
24
|
const {assistableDocumentId, documentSchemaType} = useAssistDocumentContext()
|