@sanity/assist 5.0.1 → 5.0.2
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 +19 -75
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -77
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/assistFormComponents/AssistField.tsx +4 -20
- package/src/assistInspector/AssistInspector.tsx +1 -1
- package/src/onboarding/onboardingStore.ts +0 -1
- package/src/onboarding/FieldActionsOnboarding.tsx +0 -68
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { pathToString, getVersionFromId, getPublishedId, isVersionId, useEditState, useCurrentUser, useClient, typed, FormFieldHeaderText, PatchEvent, unset, isObjectSchemaType, stringToPath, isKeySegment, useSchema, getVersionId, getDraftId, useColorSchemeValue, isArraySchemaType, useFormCallbacks, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, StatusButton, PresenceOverlay, VirtualizerScrollInstanceProvider, isDocumentSchemaType, useSyncState, set, useWorkspaceSchemaId, MemberFieldError, FormCallbacksProvider, FormInput, setIfMissing, insert, ObjectInputMember, isArrayOfObjectsSchemaType, defineType, defineField, defineArrayMember, definePlugin } from "sanity";
|
|
3
|
-
import { useToast, useLayer, Dialog, Stack, Flex, Tooltip, Text, TextArea, Button,
|
|
3
|
+
import { useToast, useLayer, Dialog, Stack, Flex, Tooltip, Text, TextArea, Button, Card, Box, ErrorBoundary, focusFirstDescendant, Spinner, Container, Autocomplete, Breadcrumbs, useClickOutside, Popover, useGlobalKeyDown, useTheme, rgba, Radio, Checkbox, ThemeProvider, MenuButton, Menu, MenuItem, Switch, Label } from "@sanity/ui";
|
|
4
4
|
import { useRef, useState, useEffect, useMemo, createContext, useContext, useCallback, useId, forwardRef, createElement, useReducer } from "react";
|
|
5
5
|
import { useDocumentPane, usePaneRouter, DocumentInspectorHeader, DocumentPaneProvider } from "sanity/structure";
|
|
6
6
|
import { minutesToMilliseconds, isAfter, addSeconds, formatDistanceToNow } from "date-fns";
|
|
7
|
-
import { PlayIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, SparklesIcon,
|
|
7
|
+
import { PlayIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, SparklesIcon, SearchIcon, SyncIcon, ErrorOutlineIcon, CheckmarkCircleIcon, ClockIcon, CloseCircleIcon, RetryIcon, ArrowRightIcon, CloseIcon, icons, TranslateIcon, LockIcon, ControlsIcon, ArrowLeftIcon, TokenIcon, DocumentTextIcon, ThListIcon, CodeIcon, ComposeIcon } from "@sanity/icons";
|
|
8
8
|
import { extractWithPath } from "@sanity/mutator";
|
|
9
9
|
import { keyframes, styled } from "styled-components";
|
|
10
10
|
import { tap, mergeMap, share, take, filter, distinctUntilChanged, catchError } from "rxjs/operators";
|
|
@@ -953,70 +953,6 @@ function AssistDocumentLayout(props) {
|
|
|
953
953
|
const { documentId, documentType } = props;
|
|
954
954
|
return /* @__PURE__ */ jsx(AssistDocumentContextProvider, { documentType, documentId, children: props.renderDefault(props) });
|
|
955
955
|
}
|
|
956
|
-
function AssistFeatureBadge() {
|
|
957
|
-
return /* @__PURE__ */ jsx(Badge, { fontSize: 0, style: { margin: "-2px 0" }, tone: "primary", children: "Beta" });
|
|
958
|
-
}
|
|
959
|
-
function AssistOnboardingPopover(props) {
|
|
960
|
-
const { dismiss } = props;
|
|
961
|
-
return /* @__PURE__ */ jsx(
|
|
962
|
-
Popover,
|
|
963
|
-
{
|
|
964
|
-
content: /* @__PURE__ */ jsx(AssistIntroCard, { dismiss }),
|
|
965
|
-
open: !0,
|
|
966
|
-
portal: !0,
|
|
967
|
-
placeholder: "bottom",
|
|
968
|
-
tone: "default",
|
|
969
|
-
width: 0,
|
|
970
|
-
children: /* @__PURE__ */ jsx(Card, { radius: 2, shadow: 2, style: { padding: 2, lineHeight: 0 }, children: /* @__PURE__ */ jsx(Button, { disabled: !0, fontSize: 1, icon: SparklesIcon, mode: "bleed", padding: 2 }) })
|
|
971
|
-
}
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
function AssistIntroCard(props) {
|
|
975
|
-
const buttonRef = useRef(null);
|
|
976
|
-
return /* @__PURE__ */ jsxs(Stack, { as: "section", padding: 3, space: 3, children: [
|
|
977
|
-
/* @__PURE__ */ jsxs(Stack, { padding: 2, space: 4, children: [
|
|
978
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
979
|
-
/* @__PURE__ */ jsx(Text, { as: "h1", size: 1, weight: "semibold", children: pluginTitle }),
|
|
980
|
-
/* @__PURE__ */ jsx("div", { "aria-hidden": !0, style: { margin: "-3px 0", lineHeight: 0 }, children: /* @__PURE__ */ jsx(AssistFeatureBadge, {}) })
|
|
981
|
-
] }),
|
|
982
|
-
/* @__PURE__ */ jsx(Stack, { space: 3, children: /* @__PURE__ */ jsxs(Text, { as: "p", muted: !0, size: 1, children: [
|
|
983
|
-
"Manage reusable AI instructions to boost your content creation and reduce amount of repetitive chores.",
|
|
984
|
-
" ",
|
|
985
|
-
/* @__PURE__ */ jsxs("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: [
|
|
986
|
-
"Learn more ",
|
|
987
|
-
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
988
|
-
] })
|
|
989
|
-
] }) })
|
|
990
|
-
] }),
|
|
991
|
-
/* @__PURE__ */ jsx(
|
|
992
|
-
Button,
|
|
993
|
-
{
|
|
994
|
-
fontSize: 1,
|
|
995
|
-
icon: CheckmarkIcon,
|
|
996
|
-
onClick: props.dismiss,
|
|
997
|
-
padding: 3,
|
|
998
|
-
ref: buttonRef,
|
|
999
|
-
text: "Ok, good to know!",
|
|
1000
|
-
tone: "primary"
|
|
1001
|
-
}
|
|
1002
|
-
)
|
|
1003
|
-
] });
|
|
1004
|
-
}
|
|
1005
|
-
const inspectorOnboardingKey = "sanityStudio:assist:inspector:onboarding:dismissed", fieldOnboardingKey = "sanityStudio:assist:field:onboarding:dismissed";
|
|
1006
|
-
function isFeatureOnboardingDismissed(featureKey) {
|
|
1007
|
-
return typeof localStorage > "u" ? !1 : localStorage.getItem(featureKey) === "true";
|
|
1008
|
-
}
|
|
1009
|
-
function dismissFeatureOnboarding(featureKey) {
|
|
1010
|
-
typeof localStorage > "u" || localStorage.setItem(featureKey, "true");
|
|
1011
|
-
}
|
|
1012
|
-
function useOnboardingFeature(featureKey) {
|
|
1013
|
-
const [showOnboarding, setShowOnboarding] = useState(
|
|
1014
|
-
() => !isFeatureOnboardingDismissed(featureKey)
|
|
1015
|
-
), dismissOnboarding = useCallback(() => {
|
|
1016
|
-
setShowOnboarding(!1), dismissFeatureOnboarding(featureKey);
|
|
1017
|
-
}, [setShowOnboarding, featureKey]);
|
|
1018
|
-
return { showOnboarding, dismissOnboarding };
|
|
1019
|
-
}
|
|
1020
956
|
const fadeIn = keyframes`
|
|
1021
957
|
0% {
|
|
1022
958
|
opacity: 0;
|
|
@@ -1160,21 +1096,14 @@ function AssistFieldWrapper(props) {
|
|
|
1160
1096
|
return !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__ */ jsx(AssistField, { ...props, children: props.children }) : props.renderDefault(props);
|
|
1161
1097
|
}
|
|
1162
1098
|
function AssistField(props) {
|
|
1163
|
-
const
|
|
1099
|
+
const isPortableText = useMemo(
|
|
1164
1100
|
() => !!(isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)),
|
|
1165
1101
|
[props.schemaType]
|
|
1166
|
-
),
|
|
1167
|
-
() => pathToString(path) === firstAssistedPath,
|
|
1168
|
-
[path, firstAssistedPath]
|
|
1169
|
-
), { showOnboarding, dismissOnboarding } = useOnboardingFeature(fieldOnboardingKey), singlePresence = presence[0], actions = /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", justify: "space-between", children: [
|
|
1170
|
-
singlePresence && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(AiFieldPresence, { presence: singlePresence }) }),
|
|
1171
|
-
isFirstAssisted && showOnboarding && /* @__PURE__ */ jsx(AssistOnboardingPopover, { dismiss: dismissOnboarding })
|
|
1172
|
-
] });
|
|
1102
|
+
), singlePresence = useAssistPresence(props.path, isPortableText)[0], actions = /* @__PURE__ */ jsx(Flex, { gap: 2, align: "center", justify: "space-between", children: singlePresence && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(AiFieldPresence, { presence: singlePresence }) }) });
|
|
1173
1103
|
return props.renderDefault({
|
|
1174
1104
|
...props,
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
// Render presence (and possibly onboarding) in the internal slot (between presence and the field actions)
|
|
1105
|
+
actions: props.actions,
|
|
1106
|
+
// Render presence in the internal slot (between presence and the field actions)
|
|
1178
1107
|
// eslint-disable-next-line camelcase
|
|
1179
1108
|
__internal_slot: actions
|
|
1180
1109
|
});
|
|
@@ -1665,6 +1594,21 @@ function TaskItem(props) {
|
|
|
1665
1594
|
!task.ended && /* @__PURE__ */ jsx(Box, { flex: "none", padding: 1, children: /* @__PURE__ */ jsx(Button, { fontSize: 1, mode: "bleed", onClick: task.cancel, text: "Cancel" }) })
|
|
1666
1595
|
] }) });
|
|
1667
1596
|
}
|
|
1597
|
+
const inspectorOnboardingKey = "sanityStudio:assist:inspector:onboarding:dismissed";
|
|
1598
|
+
function isFeatureOnboardingDismissed(featureKey) {
|
|
1599
|
+
return typeof localStorage > "u" ? !1 : localStorage.getItem(featureKey) === "true";
|
|
1600
|
+
}
|
|
1601
|
+
function dismissFeatureOnboarding(featureKey) {
|
|
1602
|
+
typeof localStorage > "u" || localStorage.setItem(featureKey, "true");
|
|
1603
|
+
}
|
|
1604
|
+
function useOnboardingFeature(featureKey) {
|
|
1605
|
+
const [showOnboarding, setShowOnboarding] = useState(
|
|
1606
|
+
() => !isFeatureOnboardingDismissed(featureKey)
|
|
1607
|
+
), dismissOnboarding = useCallback(() => {
|
|
1608
|
+
setShowOnboarding(!1), dismissFeatureOnboarding(featureKey);
|
|
1609
|
+
}, [setShowOnboarding, featureKey]);
|
|
1610
|
+
return { showOnboarding, dismissOnboarding };
|
|
1611
|
+
}
|
|
1668
1612
|
const CardWithShadowBelow = styled(Card)`
|
|
1669
1613
|
position: relative;
|
|
1670
1614
|
|