@sanity/assist 5.0.1 → 5.0.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "type": "module",
5
5
  "description": "You create the instructions; Sanity AI Assist does the rest.",
6
6
  "keywords": [
@@ -91,9 +91,9 @@
91
91
  "vitest": "^3.1.4"
92
92
  },
93
93
  "peerDependencies": {
94
- "@sanity/mutator": "^3.36.4 || ^4.0.0-0",
94
+ "@sanity/mutator": "^3.36.4 || ^4.0.0-0 || ^5.0.0",
95
95
  "react": "^18 || ^19",
96
- "sanity": "^3.36.4 || ^4.0.0-0",
96
+ "sanity": "^3.36.4 || ^4.0.0-0 || ^5.0.0",
97
97
  "styled-components": "^6.1"
98
98
  },
99
99
  "engines": {
@@ -1,13 +1,10 @@
1
1
  import {Box, Flex} from '@sanity/ui'
2
- import {useContext, useMemo} from 'react'
3
- import {FieldProps, isArraySchemaType, pathToString} from 'sanity'
2
+ import {useMemo} from 'react'
3
+ import {FieldProps, isArraySchemaType} from 'sanity'
4
4
 
5
5
  import {assistFormId} from '../_lib/form/constants'
6
6
  import {isAssistSupported} from '../helpers/assistSupported'
7
7
  import {isPortableTextArray, isType} from '../helpers/typeUtils'
8
- import {AssistOnboardingPopover} from '../onboarding/FieldActionsOnboarding'
9
- import {FirstAssistedPathContext} from '../onboarding/FirstAssistedPathProvider'
10
- import {fieldOnboardingKey, useOnboardingFeature} from '../onboarding/onboardingStore'
11
8
  import {AiFieldPresence} from '../presence/AiFieldPresence'
12
9
  import {useAssistPresence} from '../presence/useAssistPresence'
13
10
  import {contextDocumentTypeName} from '../types'
@@ -36,22 +33,12 @@ export function AssistFieldWrapper(props: FieldProps) {
36
33
  }
37
34
 
38
35
  export function AssistField(props: FieldProps) {
39
- const {path} = props
40
-
41
36
  const isPortableText = useMemo(
42
37
  () => !!(isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)),
43
38
  [props.schemaType],
44
39
  )
45
40
 
46
41
  const presence = useAssistPresence(props.path, isPortableText)
47
-
48
- const firstAssistedPath = useContext(FirstAssistedPathContext)
49
- const isFirstAssisted = useMemo(
50
- () => pathToString(path) === firstAssistedPath,
51
- [path, firstAssistedPath],
52
- )
53
-
54
- const {showOnboarding, dismissOnboarding} = useOnboardingFeature(fieldOnboardingKey)
55
42
  const singlePresence = presence[0]
56
43
 
57
44
  const actions = (
@@ -61,18 +48,15 @@ export function AssistField(props: FieldProps) {
61
48
  <AiFieldPresence presence={singlePresence} />
62
49
  </Box>
63
50
  )}
64
-
65
- {isFirstAssisted && showOnboarding && <AssistOnboardingPopover dismiss={dismissOnboarding} />}
66
51
  </Flex>
67
52
  )
68
53
 
69
54
  return props.renderDefault({
70
55
  ...props,
71
56
 
72
- // When showing the onboarding, prevent default field actions from being rendered
73
- actions: isFirstAssisted && showOnboarding ? [] : props.actions,
57
+ actions: props.actions,
74
58
 
75
- // Render presence (and possibly onboarding) in the internal slot (between presence and the field actions)
59
+ // Render presence in the internal slot (between presence and the field actions)
76
60
  // eslint-disable-next-line camelcase
77
61
  __internal_slot: actions,
78
62
  })
@@ -24,7 +24,6 @@ import {giveFeedbackUrl, pluginTitle, releaseAnnouncementUrl, salesUrl} from '..
24
24
  import {getConditionalMembers} from '../helpers/conditionalMembers'
25
25
  import {assistDocumentId} from '../helpers/ids'
26
26
  import {InspectorOnboarding} from '../onboarding/InspectorOnboarding'
27
- import {inspectorOnboardingKey, useOnboardingFeature} from '../onboarding/onboardingStore'
28
27
  import {assistDocumentTypeName, fieldPathParam, instructionParam} from '../types'
29
28
  import {FieldTitle} from './FieldAutocomplete'
30
29
  import {
@@ -35,6 +34,7 @@ import {
35
34
  useTypePath,
36
35
  } from './helpers'
37
36
  import {InstructionTaskHistoryButton} from './InstructionTaskHistoryButton'
37
+ import {inspectorOnboardingKey, useOnboardingFeature} from '../onboarding/onboardingStore'
38
38
 
39
39
  const CardWithShadowBelow = styled(Card)`
40
40
  position: relative;
@@ -1,7 +1,6 @@
1
1
  import {useCallback, useState} from 'react'
2
2
 
3
3
  export const inspectorOnboardingKey = 'sanityStudio:assist:inspector:onboarding:dismissed'
4
- export const fieldOnboardingKey = 'sanityStudio:assist:field:onboarding:dismissed'
5
4
 
6
5
  export function isFeatureOnboardingDismissed(featureKey: string): boolean {
7
6
  if (typeof localStorage === 'undefined') {
@@ -1,68 +0,0 @@
1
- import {ArrowRightIcon, CheckmarkIcon, SparklesIcon} from '@sanity/icons'
2
- import {Button, Card, Flex, Popover, Stack, Text} from '@sanity/ui'
3
- import {useRef} from 'react'
4
-
5
- import {AssistFeatureBadge} from '../components/AssistFeatureBadge'
6
- import {pluginTitle, releaseAnnouncementUrl} from '../constants'
7
-
8
- export interface FieldActionsOnboardingProps {
9
- dismiss: () => void
10
- }
11
-
12
- export function AssistOnboardingPopover(props: FieldActionsOnboardingProps) {
13
- const {dismiss} = props
14
-
15
- return (
16
- <Popover
17
- content={<AssistIntroCard dismiss={dismiss} />}
18
- open
19
- portal
20
- placeholder="bottom"
21
- tone="default"
22
- width={0}
23
- >
24
- <Card radius={2} shadow={2} style={{padding: 2, lineHeight: 0}}>
25
- <Button disabled fontSize={1} icon={SparklesIcon} mode="bleed" padding={2} />
26
- </Card>
27
- </Popover>
28
- )
29
- }
30
-
31
- function AssistIntroCard(props: {dismiss: () => void}) {
32
- const buttonRef = useRef<HTMLButtonElement>(null)
33
-
34
- return (
35
- <Stack as="section" padding={3} space={3}>
36
- <Stack padding={2} space={4}>
37
- <Flex gap={2} align="center">
38
- <Text as="h1" size={1} weight="semibold">
39
- {pluginTitle}
40
- </Text>
41
- <div aria-hidden style={{margin: '-3px 0', lineHeight: 0}}>
42
- <AssistFeatureBadge />
43
- </div>
44
- </Flex>
45
-
46
- <Stack space={3}>
47
- <Text as="p" muted size={1}>
48
- Manage reusable AI instructions to boost your content creation and reduce amount of
49
- repetitive chores.{' '}
50
- <a href={releaseAnnouncementUrl} target="_blank" rel="noreferrer">
51
- Learn more <ArrowRightIcon />
52
- </a>
53
- </Text>
54
- </Stack>
55
- </Stack>
56
-
57
- <Button
58
- fontSize={1}
59
- icon={CheckmarkIcon}
60
- onClick={props.dismiss}
61
- padding={3}
62
- ref={buttonRef}
63
- text="Ok, good to know!"
64
- tone="primary"
65
- />
66
- </Stack>
67
- )
68
- }