@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/dist/index.cjs CHANGED
@@ -946,70 +946,6 @@ function AssistDocumentLayout(props) {
946
946
  const { documentId, documentType } = props;
947
947
  return /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentContextProvider, { documentType, documentId, children: props.renderDefault(props) });
948
948
  }
949
- function AssistFeatureBadge() {
950
- return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { fontSize: 0, style: { margin: "-2px 0" }, tone: "primary", children: "Beta" });
951
- }
952
- function AssistOnboardingPopover(props) {
953
- const { dismiss } = props;
954
- return /* @__PURE__ */ jsxRuntime.jsx(
955
- ui.Popover,
956
- {
957
- content: /* @__PURE__ */ jsxRuntime.jsx(AssistIntroCard, { dismiss }),
958
- open: !0,
959
- portal: !0,
960
- placeholder: "bottom",
961
- tone: "default",
962
- width: 0,
963
- children: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 2, shadow: 2, style: { padding: 2, lineHeight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { disabled: !0, fontSize: 1, icon: icons.SparklesIcon, mode: "bleed", padding: 2 }) })
964
- }
965
- );
966
- }
967
- function AssistIntroCard(props) {
968
- const buttonRef = react.useRef(null);
969
- return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { as: "section", padding: 3, space: 3, children: [
970
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { padding: 2, space: 4, children: [
971
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", children: [
972
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "h1", size: 1, weight: "semibold", children: pluginTitle }),
973
- /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": !0, style: { margin: "-3px 0", lineHeight: 0 }, children: /* @__PURE__ */ jsxRuntime.jsx(AssistFeatureBadge, {}) })
974
- ] }),
975
- /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "p", muted: !0, size: 1, children: [
976
- "Manage reusable AI instructions to boost your content creation and reduce amount of repetitive chores.",
977
- " ",
978
- /* @__PURE__ */ jsxRuntime.jsxs("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: [
979
- "Learn more ",
980
- /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRightIcon, {})
981
- ] })
982
- ] }) })
983
- ] }),
984
- /* @__PURE__ */ jsxRuntime.jsx(
985
- ui.Button,
986
- {
987
- fontSize: 1,
988
- icon: icons.CheckmarkIcon,
989
- onClick: props.dismiss,
990
- padding: 3,
991
- ref: buttonRef,
992
- text: "Ok, good to know!",
993
- tone: "primary"
994
- }
995
- )
996
- ] });
997
- }
998
- const inspectorOnboardingKey = "sanityStudio:assist:inspector:onboarding:dismissed", fieldOnboardingKey = "sanityStudio:assist:field:onboarding:dismissed";
999
- function isFeatureOnboardingDismissed(featureKey) {
1000
- return typeof localStorage > "u" ? !1 : localStorage.getItem(featureKey) === "true";
1001
- }
1002
- function dismissFeatureOnboarding(featureKey) {
1003
- typeof localStorage > "u" || localStorage.setItem(featureKey, "true");
1004
- }
1005
- function useOnboardingFeature(featureKey) {
1006
- const [showOnboarding, setShowOnboarding] = react.useState(
1007
- () => !isFeatureOnboardingDismissed(featureKey)
1008
- ), dismissOnboarding = react.useCallback(() => {
1009
- setShowOnboarding(!1), dismissFeatureOnboarding(featureKey);
1010
- }, [setShowOnboarding, featureKey]);
1011
- return { showOnboarding, dismissOnboarding };
1012
- }
1013
949
  const fadeIn = styledComponents.keyframes`
1014
950
  0% {
1015
951
  opacity: 0;
@@ -1153,21 +1089,14 @@ function AssistFieldWrapper(props) {
1153
1089
  return !react.useMemo(() => isAssistSupported(schemaType), [schemaType]) || schemaType.name.startsWith("sanity.") || schemaType.name === contextDocumentTypeName ? props.renderDefault(props) : !isType(props.schemaType, "document") && props.inputId !== "root" && props.inputId !== assistFormId ? /* @__PURE__ */ jsxRuntime.jsx(AssistField, { ...props, children: props.children }) : props.renderDefault(props);
1154
1090
  }
1155
1091
  function AssistField(props) {
1156
- const { path } = props, isPortableText = react.useMemo(
1092
+ const isPortableText = react.useMemo(
1157
1093
  () => !!(sanity.isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)),
1158
1094
  [props.schemaType]
1159
- ), presence = useAssistPresence(props.path, isPortableText), firstAssistedPath = react.useContext(FirstAssistedPathContext), isFirstAssisted = react.useMemo(
1160
- () => sanity.pathToString(path) === firstAssistedPath,
1161
- [path, firstAssistedPath]
1162
- ), { showOnboarding, dismissOnboarding } = useOnboardingFeature(fieldOnboardingKey), singlePresence = presence[0], actions = /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", justify: "space-between", children: [
1163
- singlePresence && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: singlePresence }) }),
1164
- isFirstAssisted && showOnboarding && /* @__PURE__ */ jsxRuntime.jsx(AssistOnboardingPopover, { dismiss: dismissOnboarding })
1165
- ] });
1095
+ ), singlePresence = useAssistPresence(props.path, isPortableText)[0], actions = /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 2, align: "center", justify: "space-between", children: singlePresence && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: singlePresence }) }) });
1166
1096
  return props.renderDefault({
1167
1097
  ...props,
1168
- // When showing the onboarding, prevent default field actions from being rendered
1169
- actions: isFirstAssisted && showOnboarding ? [] : props.actions,
1170
- // Render presence (and possibly onboarding) in the internal slot (between presence and the field actions)
1098
+ actions: props.actions,
1099
+ // Render presence in the internal slot (between presence and the field actions)
1171
1100
  // eslint-disable-next-line camelcase
1172
1101
  __internal_slot: actions
1173
1102
  });
@@ -1658,6 +1587,21 @@ function TaskItem(props) {
1658
1587
  !task.ended && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { fontSize: 1, mode: "bleed", onClick: task.cancel, text: "Cancel" }) })
1659
1588
  ] }) });
1660
1589
  }
1590
+ const inspectorOnboardingKey = "sanityStudio:assist:inspector:onboarding:dismissed";
1591
+ function isFeatureOnboardingDismissed(featureKey) {
1592
+ return typeof localStorage > "u" ? !1 : localStorage.getItem(featureKey) === "true";
1593
+ }
1594
+ function dismissFeatureOnboarding(featureKey) {
1595
+ typeof localStorage > "u" || localStorage.setItem(featureKey, "true");
1596
+ }
1597
+ function useOnboardingFeature(featureKey) {
1598
+ const [showOnboarding, setShowOnboarding] = react.useState(
1599
+ () => !isFeatureOnboardingDismissed(featureKey)
1600
+ ), dismissOnboarding = react.useCallback(() => {
1601
+ setShowOnboarding(!1), dismissFeatureOnboarding(featureKey);
1602
+ }, [setShowOnboarding, featureKey]);
1603
+ return { showOnboarding, dismissOnboarding };
1604
+ }
1661
1605
  const CardWithShadowBelow = styledComponents.styled(ui.Card)`
1662
1606
  position: relative;
1663
1607