@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "5.0.2",
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": "^8.1.25",
71
+ "@sanity/pkg-utils": "^10.3.2",
68
72
  "@sanity/plugin-kit": "^4.0.20",
69
- "@sanity/schema": "^4.11.0",
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": "^18.2.75",
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": "^18.2.0",
85
- "react-dom": "^18.2.0",
88
+ "react": "^19.2.3",
89
+ "react-dom": "^19.2.3",
86
90
  "rimraf": "^5.0.5",
87
- "sanity": "^4.0.0",
91
+ "sanity": "^5.4.0",
88
92
  "semantic-release": "^23.0.8",
89
93
  "styled-components": "^6.1.16",
90
- "typescript": "^5.7.2",
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": {
@@ -1,7 +1,7 @@
1
1
  import {useEffect, useRef} from 'react'
2
2
 
3
3
  export function usePrevious<T>(value: T) {
4
- const ref = useRef<T>()
4
+ const ref = useRef<T>(undefined)
5
5
  useEffect(() => {
6
6
  ref.current = value
7
7
  }, [value])
@@ -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
- <DocumentPaneProvider
326
- paneKey={documentPane.paneKey}
327
- index={documentPane.index}
328
- itemId="ai"
329
- pane={paneNode}
330
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
331
- //@ts-ignore this is a valid option available in `corel` - Remove after corel is merged to next
332
- forcedVersion={{
333
- isReleaseLocked: false,
334
- selectedPerspectiveName: 'published',
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 {useDocumentPane, usePaneRouter} from 'sanity/structure'
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} = useDocumentPane()
21
+ const {selectedReleaseId} = usePerspective()
22
22
  const [assetRefState, setAssetRefState] = useState<string | undefined>(assetRef)
23
23
 
24
24
  const {assistableDocumentId, documentSchemaType} = useAssistDocumentContext()