@sanity/assist 6.1.4 → 6.1.6
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.js +59 -24
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5,12 +5,39 @@ import { useToast, useLayer, Dialog, Stack, Flex, Tooltip, Text, Button, TextAre
|
|
|
5
5
|
import { useRef, useState, useEffect, createContext, useContext, useCallback, useId, useMemo, useEffectEvent, useReducer } from "react";
|
|
6
6
|
import { useDocumentPane, usePaneRouter, DocumentInspectorHeader, DocumentPaneProvider } from "sanity/structure";
|
|
7
7
|
import { minutesToMilliseconds, isAfter, addSeconds, formatDistanceToNow } from "date-fns";
|
|
8
|
-
import {
|
|
8
|
+
import { BlockContentIcon } from "@sanity/icons/BlockContent";
|
|
9
|
+
import { BlockquoteIcon } from "@sanity/icons/Blockquote";
|
|
10
|
+
import { DocumentIcon } from "@sanity/icons/Document";
|
|
11
|
+
import { ImageIcon } from "@sanity/icons/Image";
|
|
12
|
+
import { LinkIcon } from "@sanity/icons/Link";
|
|
13
|
+
import { OlistIcon } from "@sanity/icons/Olist";
|
|
14
|
+
import { StringIcon } from "@sanity/icons/String";
|
|
9
15
|
import { extractWithPath } from "@sanity/mutator";
|
|
16
|
+
import { PlayIcon } from "@sanity/icons/Play";
|
|
10
17
|
import { keyframes, styled } from "styled-components";
|
|
11
18
|
import { purple } from "@sanity/color";
|
|
19
|
+
import { SparklesIcon } from "@sanity/icons/Sparkles";
|
|
20
|
+
import { ArrowRightIcon } from "@sanity/icons/ArrowRight";
|
|
21
|
+
import { CloseIcon } from "@sanity/icons/Close";
|
|
22
|
+
import { RetryIcon } from "@sanity/icons/Retry";
|
|
12
23
|
import { tap, mergeMap, share, take, filter, distinctUntilChanged, catchError } from "rxjs/operators";
|
|
24
|
+
import { SearchIcon } from "@sanity/icons/Search";
|
|
25
|
+
import { CheckmarkCircleIcon } from "@sanity/icons/CheckmarkCircle";
|
|
26
|
+
import { ClockIcon } from "@sanity/icons/Clock";
|
|
27
|
+
import { CloseCircleIcon } from "@sanity/icons/CloseCircle";
|
|
28
|
+
import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
|
|
29
|
+
import { SyncIcon } from "@sanity/icons/Sync";
|
|
13
30
|
import get from "lodash-es/get.js";
|
|
31
|
+
import { icons, Icon } from "@sanity/icons";
|
|
32
|
+
import { ControlsIcon } from "@sanity/icons/Controls";
|
|
33
|
+
import { TranslateIcon } from "@sanity/icons/Translate";
|
|
34
|
+
import { LockIcon } from "@sanity/icons/Lock";
|
|
35
|
+
import { CodeIcon } from "@sanity/icons/Code";
|
|
36
|
+
import { ComposeIcon } from "@sanity/icons/Compose";
|
|
37
|
+
import { ThListIcon } from "@sanity/icons/ThList";
|
|
38
|
+
import { ArrowLeftIcon } from "@sanity/icons/ArrowLeft";
|
|
39
|
+
import { DocumentTextIcon } from "@sanity/icons/DocumentText";
|
|
40
|
+
import { TokenIcon } from "@sanity/icons/Token";
|
|
14
41
|
import isEqual from "react-fast-compare";
|
|
15
42
|
import { throwError, of, partition, merge, switchMap, delay, defer } from "rxjs";
|
|
16
43
|
import { exhaustMapToWithTrailing } from "rxjs-exhaustmap-with-trailing";
|
|
@@ -1242,10 +1269,10 @@ const fadeIn = keyframes`
|
|
|
1242
1269
|
opacity: 1;
|
|
1243
1270
|
transform: scale(1);
|
|
1244
1271
|
}
|
|
1245
|
-
`, FadeInDiv = styled.div.withConfig({
|
|
1272
|
+
`, FadeInDiv = /* @__PURE__ */ styled.div.withConfig({
|
|
1246
1273
|
displayName: "FadeInDiv",
|
|
1247
1274
|
componentId: "sc-1gsyaov-0"
|
|
1248
|
-
})
|
|
1275
|
+
})(["animation-name:", ";animation-timing-function:ease-in-out;"], fadeIn);
|
|
1249
1276
|
function FadeInContent(t0) {
|
|
1250
1277
|
const $ = c(6), {
|
|
1251
1278
|
children,
|
|
@@ -1259,23 +1286,23 @@ function FadeInContent(t0) {
|
|
|
1259
1286
|
let t4;
|
|
1260
1287
|
return $[2] !== children || $[3] !== ref || $[4] !== t3 ? (t4 = /* @__PURE__ */ jsx(FadeInDiv, { ref, style: t3, children }), $[2] = children, $[3] = ref, $[4] = t3, $[5] = t4) : t4 = $[5], t4;
|
|
1261
1288
|
}
|
|
1262
|
-
const Root = styled.span.withConfig({
|
|
1289
|
+
const Root = /* @__PURE__ */ styled.span.withConfig({
|
|
1263
1290
|
displayName: "Root",
|
|
1264
1291
|
componentId: "sc-5en2mb-0"
|
|
1265
|
-
})
|
|
1292
|
+
})(["display:block;width:25px;height:25px;position:relative;"]), dash = keyframes`
|
|
1266
1293
|
0% {
|
|
1267
1294
|
transform: rotate(0);
|
|
1268
1295
|
}
|
|
1269
1296
|
100% {
|
|
1270
1297
|
transform: rotate(43deg);
|
|
1271
1298
|
}
|
|
1272
|
-
`, Outline = styled.svg.withConfig({
|
|
1299
|
+
`, Outline = /* @__PURE__ */ styled.svg.withConfig({
|
|
1273
1300
|
displayName: "Outline",
|
|
1274
1301
|
componentId: "sc-5en2mb-1"
|
|
1275
|
-
})
|
|
1302
|
+
})(["display:block;position:absolute;top:0;left:0;& > circle{stroke:var(--ai-avatar-stroke-color);stroke-width:1.5px;stroke-linecap:round;transform-origin:center;animation:", " 500ms ease-in-out infinite;transition:stroke-dasharray 200ms ease-in-out;stroke-dasharray:2.34px 0;[data-state='active'] > &{stroke-dasharray:2px 2.34px;}}"], dash), IconDisc = /* @__PURE__ */ styled.span.withConfig({
|
|
1276
1303
|
displayName: "IconDisc",
|
|
1277
1304
|
componentId: "sc-5en2mb-2"
|
|
1278
|
-
})
|
|
1305
|
+
})(["background:var(--ai-avatar-disc-color);color:white;width:21px;height:21px;display:flex;align-items:center;justify-content:center;border-radius:10.5px;position:absolute;top:2px;left:2px;"]);
|
|
1279
1306
|
function AssistAvatar(props) {
|
|
1280
1307
|
const {
|
|
1281
1308
|
state = "present"
|
|
@@ -1386,10 +1413,10 @@ function AssistField(props) {
|
|
|
1386
1413
|
__internal_slot: actions
|
|
1387
1414
|
}), $[6] = actions, $[7] = props, $[8] = t3) : t3 = $[8], t3;
|
|
1388
1415
|
}
|
|
1389
|
-
const WrapPreCard = styled(Card).withConfig({
|
|
1416
|
+
const WrapPreCard = /* @__PURE__ */ styled(Card).withConfig({
|
|
1390
1417
|
displayName: "WrapPreCard",
|
|
1391
1418
|
componentId: "sc-q2jw3a-0"
|
|
1392
|
-
})
|
|
1419
|
+
})(["& pre{white-space:pre-wrap !important;}"]);
|
|
1393
1420
|
function SafeValueInput(props) {
|
|
1394
1421
|
const $ = c(5);
|
|
1395
1422
|
let t0;
|
|
@@ -1827,10 +1854,10 @@ const rotate = keyframes`
|
|
|
1827
1854
|
100% {
|
|
1828
1855
|
transform: rotate(360deg);
|
|
1829
1856
|
}
|
|
1830
|
-
`, SyncSpinningIcon = styled(SyncIcon).withConfig({
|
|
1857
|
+
`, SyncSpinningIcon = /* @__PURE__ */ styled(SyncIcon).withConfig({
|
|
1831
1858
|
displayName: "SyncSpinningIcon",
|
|
1832
1859
|
componentId: "sc-13pmxy-0"
|
|
1833
|
-
})
|
|
1860
|
+
})(["animation:", " 1s linear infinite;"], rotate), TASK_CONFIG = {
|
|
1834
1861
|
aborted: {
|
|
1835
1862
|
title: "Canceled",
|
|
1836
1863
|
icon: CloseCircleIcon,
|
|
@@ -1971,13 +1998,13 @@ function TaskItem(props) {
|
|
|
1971
1998
|
let t14;
|
|
1972
1999
|
return $[29] !== t0 || $[30] !== t13 ? (t14 = /* @__PURE__ */ jsx(Card, { radius: 2, tone: t0, children: t13 }), $[29] = t0, $[30] = t13, $[31] = t14) : t14 = $[31], t14;
|
|
1973
2000
|
}
|
|
1974
|
-
const CardWithShadowBelow = styled(Card).withConfig({
|
|
2001
|
+
const CardWithShadowBelow = /* @__PURE__ */ styled(Card).withConfig({
|
|
1975
2002
|
displayName: "CardWithShadowBelow",
|
|
1976
2003
|
componentId: "sc-yws49l-0"
|
|
1977
|
-
})
|
|
2004
|
+
})(["position:relative;&:after{content:'';display:block;position:absolute;left:0;right:0;bottom:-1px;border-bottom:1px solid var(--card-border-color);opacity:0.5;z-index:100;}"]), CardWithShadowAbove = /* @__PURE__ */ styled(Card).withConfig({
|
|
1978
2005
|
displayName: "CardWithShadowAbove",
|
|
1979
2006
|
componentId: "sc-yws49l-1"
|
|
1980
|
-
})
|
|
2007
|
+
})(["position:relative;&:after{content:'';display:block;position:absolute;left:0;right:0;top:-1px;border-top:1px solid var(--card-border-color);opacity:0.5;z-index:100;}"]);
|
|
1981
2008
|
function AssistInspectorWrapper(props) {
|
|
1982
2009
|
const $ = c(43), context = useAiAssistanceConfig();
|
|
1983
2010
|
if (context.statusLoading) {
|
|
@@ -2924,9 +2951,9 @@ function IconInput(props) {
|
|
|
2924
2951
|
const items = t1;
|
|
2925
2952
|
let t2;
|
|
2926
2953
|
$[3] !== value ? (t2 = getIcon(value), $[3] = value, $[4] = t2) : t2 = $[4];
|
|
2927
|
-
const
|
|
2954
|
+
const selectedSymbol = t2;
|
|
2928
2955
|
let t3;
|
|
2929
|
-
$[5] !==
|
|
2956
|
+
$[5] !== selectedSymbol ? (t3 = /* @__PURE__ */ jsx(Button, { icon: /* @__PURE__ */ jsx(Icon, { symbol: selectedSymbol }), title: "Select icon", padding: 3, mode: "ghost", radius: 1 }), $[5] = selectedSymbol, $[6] = t3) : t3 = $[6];
|
|
2930
2957
|
let t4;
|
|
2931
2958
|
$[7] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t4 = {
|
|
2932
2959
|
maxHeight: 300
|
|
@@ -2953,7 +2980,10 @@ function IconItem(t0) {
|
|
|
2953
2980
|
return $[3] !== icon || $[4] !== key || $[5] !== onClick ? (t2 = /* @__PURE__ */ jsx(MenuItem, { icon, title: key, text: key, onClick }), $[3] = icon, $[4] = key, $[5] = onClick, $[6] = t2) : t2 = $[6], t2;
|
|
2954
2981
|
}
|
|
2955
2982
|
function getIcon(iconName) {
|
|
2956
|
-
return
|
|
2983
|
+
return iconName && isIconSymbol(iconName) ? iconName : "sparkles";
|
|
2984
|
+
}
|
|
2985
|
+
function isIconSymbol(iconName) {
|
|
2986
|
+
return iconName in icons;
|
|
2957
2987
|
}
|
|
2958
2988
|
function useAssistSupported(_path, schemaType) {
|
|
2959
2989
|
const $ = c(2);
|
|
@@ -3379,9 +3409,14 @@ function instructionItem(props) {
|
|
|
3379
3409
|
assistSupported,
|
|
3380
3410
|
instruction: instruction2
|
|
3381
3411
|
} = props;
|
|
3412
|
+
function IconLeft() {
|
|
3413
|
+
const $ = c(1);
|
|
3414
|
+
let t0;
|
|
3415
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx(Icon, { symbol: getIcon(instruction2.icon) }), $[0] = t0) : t0 = $[0], t0;
|
|
3416
|
+
}
|
|
3382
3417
|
return {
|
|
3383
3418
|
type: "action",
|
|
3384
|
-
icon:
|
|
3419
|
+
icon: IconLeft,
|
|
3385
3420
|
iconRight: isPrivate ? PrivateIcon : void 0,
|
|
3386
3421
|
title: getInstructionTitle(instruction2),
|
|
3387
3422
|
onAction: () => onInstructionAction(instruction2),
|
|
@@ -4025,10 +4060,10 @@ function Selectable(t0) {
|
|
|
4025
4060
|
t6
|
|
4026
4061
|
] }), $[16] = t3, $[17] = t6, $[18] = t7) : t7 = $[18], t7;
|
|
4027
4062
|
}
|
|
4028
|
-
const PteMods = styled(Box).withConfig({
|
|
4063
|
+
const PteMods = /* @__PURE__ */ styled(Box).withConfig({
|
|
4029
4064
|
displayName: "PteMods",
|
|
4030
4065
|
componentId: "sc-grsj10-0"
|
|
4031
|
-
})
|
|
4066
|
+
})(["& [data-testid='pt-editor__toolbar-card'] > div > div:last-child{display:none;}& [data-testid='pt-editor']{min-height:300px;}& [data-testid='pt-editor'] .pt-inline-object *{max-width:400px;}"]);
|
|
4032
4067
|
function PromptInput(props) {
|
|
4033
4068
|
const $ = c(5);
|
|
4034
4069
|
useOnlyInlineBlocks(props);
|
|
@@ -4373,16 +4408,16 @@ const contextDocumentSchema = defineType({
|
|
|
4373
4408
|
}) => ({
|
|
4374
4409
|
title,
|
|
4375
4410
|
// oxlint-disable-next-line no-unsafe-type-assertion
|
|
4376
|
-
icon: icon ?
|
|
4411
|
+
icon: icon ? /* @__PURE__ */ jsx(Icon, { symbol: icon }) : SparklesIcon,
|
|
4377
4412
|
userId
|
|
4378
4413
|
})
|
|
4379
4414
|
},
|
|
4380
4415
|
components: {
|
|
4381
4416
|
input: InstructionInput,
|
|
4382
4417
|
preview: (props) => {
|
|
4383
|
-
const
|
|
4418
|
+
const Icon2 = props.icon;
|
|
4384
4419
|
return /* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", padding: 2, children: [
|
|
4385
|
-
|
|
4420
|
+
Icon2 && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Icon2, {}) }) }),
|
|
4386
4421
|
/* @__PURE__ */ jsx(Stack, { flex: 1, gap: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, textOverflow: "ellipsis", weight: "medium", children: getInstructionTitle(props) }) }),
|
|
4387
4422
|
props.userId && /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(Text, { size: 1, children: "Only visible to you" }), padding: 2, placement: "top", portal: !0, children: /* @__PURE__ */ jsx(LockIcon, {}) }) })
|
|
4388
4423
|
] });
|