@sanity/assist 1.1.1 → 1.1.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/README.md CHANGED
@@ -40,7 +40,7 @@ In your Studio project folder, install the following plugin dependency:
40
40
  npm install @sanity/assist sanity@latest
41
41
  ```
42
42
 
43
- This plugin requires `sanity` version `3.14.5` or greater.
43
+ This plugin requires `sanity` version `3.16.0` or greater.
44
44
 
45
45
  ## Setup
46
46
 
@@ -227,6 +227,10 @@ defineField({
227
227
  This will add a "Generate caption" action to the configured field.
228
228
  "Generate caption" action will automatically run whenever the image changes.
229
229
 
230
+ ## Third party sub-processors
231
+
232
+ This version of the feature uses OpenAI.com as a third-party sub-processor. Their security posture has been vetted by Sanity's security team, and approved for use.
233
+
230
234
  ## License
231
235
 
232
236
  [MIT](LICENSE) © Sanity
package/dist/index.esm.js CHANGED
@@ -1962,20 +1962,6 @@ function AiFieldPresence(props) {
1962
1962
  })
1963
1963
  });
1964
1964
  }
1965
- const FirstAssistedPathContext = createContext(void 0);
1966
- function FirstAssistedPathProvider(props) {
1967
- const {
1968
- members
1969
- } = props;
1970
- const firstAssistedPath = useMemo(() => {
1971
- const firstAssisted = members.find(member => member.kind === "field" && isAssistSupported(member.field.schemaType));
1972
- return (firstAssisted == null ? void 0 : firstAssisted.field.path) ? pathToString(firstAssisted == null ? void 0 : firstAssisted.field.path) : void 0;
1973
- }, [members]);
1974
- return /* @__PURE__ */jsx(FirstAssistedPathContext.Provider, {
1975
- value: firstAssistedPath,
1976
- children: props.children
1977
- });
1978
- }
1979
1965
  function AssistFeatureBadge() {
1980
1966
  return /* @__PURE__ */jsx(Badge, {
1981
1967
  fontSize: 0,
@@ -1986,48 +1972,31 @@ function AssistFeatureBadge() {
1986
1972
  children: "Beta"
1987
1973
  });
1988
1974
  }
1989
- function FieldActionsOnboarding(props) {
1990
- const {
1991
- path,
1992
- children
1993
- } = props;
1994
- const firstAssistedPath = useContext(FirstAssistedPathContext);
1995
- const isFirstAssisted = useMemo(() => pathToString(path) === firstAssistedPath, [path, firstAssistedPath]);
1996
- if (!isFirstAssisted) {
1997
- return /* @__PURE__ */jsx(Fragment, {
1998
- children
1999
- });
2000
- }
2001
- return /* @__PURE__ */jsx(AssistOnboardingPopover, {
2002
- ...props
2003
- });
2004
- }
2005
1975
  function AssistOnboardingPopover(props) {
2006
1976
  const {
2007
- showOnboarding,
2008
- dismissOnboarding
2009
- } = useOnboardingFeature(fieldOnboardingKey);
2010
- if (!showOnboarding) {
2011
- return /* @__PURE__ */jsx(Fragment, {
2012
- children: props.children
2013
- });
2014
- }
1977
+ dismiss
1978
+ } = props;
2015
1979
  return /* @__PURE__ */jsx(Popover, {
2016
1980
  content: /* @__PURE__ */jsx(AssistIntroCard, {
2017
- path: props.path,
2018
- dismiss: dismissOnboarding
1981
+ dismiss
2019
1982
  }),
2020
1983
  open: true,
2021
1984
  portal: true,
2022
1985
  placeholder: "bottom",
2023
1986
  tone: "default",
2024
1987
  width: 0,
2025
- children: /* @__PURE__ */jsx("div", {
1988
+ children: /* @__PURE__ */jsx(Card, {
1989
+ radius: 2,
1990
+ shadow: 2,
1991
+ style: {
1992
+ padding: 2,
1993
+ lineHeight: 0
1994
+ },
2026
1995
  children: /* @__PURE__ */jsx(Button, {
2027
1996
  disabled: true,
2028
1997
  fontSize: 1,
2029
1998
  icon: SparklesIcon,
2030
- mode: "ghost",
1999
+ mode: "bleed",
2031
2000
  padding: 2
2032
2001
  })
2033
2002
  })
@@ -2083,6 +2052,20 @@ function AssistIntroCard(props) {
2083
2052
  })]
2084
2053
  });
2085
2054
  }
2055
+ const FirstAssistedPathContext = createContext(void 0);
2056
+ function FirstAssistedPathProvider(props) {
2057
+ const {
2058
+ members
2059
+ } = props;
2060
+ const firstAssistedPath = useMemo(() => {
2061
+ const firstAssisted = members.find(member => member.kind === "field" && isAssistSupported(member.field.schemaType));
2062
+ return (firstAssisted == null ? void 0 : firstAssisted.field.path) ? pathToString(firstAssisted == null ? void 0 : firstAssisted.field.path) : void 0;
2063
+ }, [members]);
2064
+ return /* @__PURE__ */jsx(FirstAssistedPathContext.Provider, {
2065
+ value: firstAssistedPath,
2066
+ children: props.children
2067
+ });
2068
+ }
2086
2069
  function AssistFieldWrapper(props) {
2087
2070
  const {
2088
2071
  schemaType
@@ -2100,8 +2083,17 @@ function AssistFieldWrapper(props) {
2100
2083
  return props.renderDefault(props);
2101
2084
  }
2102
2085
  function AssistField(props) {
2086
+ const {
2087
+ path
2088
+ } = props;
2103
2089
  const isPortableText = useMemo(() => !!(isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)), [props.schemaType]);
2104
2090
  const presence = useAssistPresence(props.path, isPortableText);
2091
+ const firstAssistedPath = useContext(FirstAssistedPathContext);
2092
+ const isFirstAssisted = useMemo(() => pathToString(path) === firstAssistedPath, [path, firstAssistedPath]);
2093
+ const {
2094
+ showOnboarding,
2095
+ dismissOnboarding
2096
+ } = useOnboardingFeature(fieldOnboardingKey);
2105
2097
  const actions = /* @__PURE__ */jsxs(Flex, {
2106
2098
  gap: 2,
2107
2099
  align: "center",
@@ -2110,14 +2102,17 @@ function AssistField(props) {
2110
2102
  children: /* @__PURE__ */jsx(AiFieldPresence, {
2111
2103
  presence: pre
2112
2104
  }, pre.lastActiveAt)
2113
- }, pre.user.id)), /* @__PURE__ */jsx(FieldActionsOnboarding, {
2114
- ...props,
2115
- children: props.actions
2105
+ }, pre.user.id)), isFirstAssisted && showOnboarding && /* @__PURE__ */jsx(AssistOnboardingPopover, {
2106
+ dismiss: dismissOnboarding
2116
2107
  })]
2117
2108
  });
2118
2109
  return props.renderDefault({
2119
2110
  ...props,
2120
- actions
2111
+ // When showing the onboarding, prevent default field actions from being rendered
2112
+ actions: isFirstAssisted && showOnboarding ? [] : props.actions,
2113
+ // Render presence (and possibly onboarding) in the internal slot (between presence and the field actions)
2114
+ // eslint-disable-next-line camelcase
2115
+ __internal_slot: actions
2121
2116
  });
2122
2117
  }
2123
2118
  const ConnectorsStoreContext = createContext(null);