@sanity/assist 5.0.0 → 5.0.1
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.esm.js → index.cjs} +683 -691
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +691 -681
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
- package/src/_lib/form/DocumentForm.tsx +1 -0
- package/src/schemas/assistDocumentSchema.tsx +1 -1
- package/dist/index.esm.js.map +0 -1
- package/dist/index.mjs +0 -4328
- package/dist/index.mjs.map +0 -1
- /package/dist/{index.d.mts → index.d.cts} +0 -0
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import { extractWithPath } from "@sanity/mutator";
|
|
9
|
-
import { keyframes, styled } from "styled-components";
|
|
10
|
-
import { tap, mergeMap, share, take, filter, distinctUntilChanged, catchError } from "rxjs/operators";
|
|
11
|
-
import { get } from "lodash-es";
|
|
12
|
-
import isEqual from "react-fast-compare";
|
|
13
|
-
import { defer, throwError, of, partition, merge, switchMap, delay } from "rxjs";
|
|
14
|
-
import { exhaustMapToWithTrailing } from "rxjs-exhaustmap-with-trailing";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var jsxRuntime = require("react/jsx-runtime"), sanity = require("sanity"), ui = require("@sanity/ui"), react = require("react"), structure = require("sanity/structure"), dateFns = require("date-fns"), icons = require("@sanity/icons"), mutator = require("@sanity/mutator"), styledComponents = require("styled-components"), operators = require("rxjs/operators"), get = require("lodash/get.js"), isEqual = require("react-fast-compare"), rxjs = require("rxjs"), rxjsExhaustmapWithTrailing = require("rxjs-exhaustmap-with-trailing");
|
|
4
|
+
function _interopDefaultCompat(e) {
|
|
5
|
+
return e && typeof e == "object" && "default" in e ? e : { default: e };
|
|
6
|
+
}
|
|
7
|
+
var get__default = /* @__PURE__ */ _interopDefaultCompat(get), isEqual__default = /* @__PURE__ */ _interopDefaultCompat(isEqual);
|
|
15
8
|
function hasOverflowScroll(el) {
|
|
16
9
|
const overflow = getComputedStyle(el).overflow;
|
|
17
10
|
return overflow.includes("auto") || overflow.includes("hidden") || overflow.includes("scroll");
|
|
18
11
|
}
|
|
19
12
|
function useRegionRects() {
|
|
20
|
-
const ref = useRef(null), [relativeBoundsRect, setRelativeBoundsRect] = useState(null), [relativeElementRect, setRelativeElementRect] = useState(null), [boundsScroll, setBoundsScroll] = useState({ x: 0, y: 0 }), [scroll, setScroll] = useState({ x: 0, y: 0 }), boundsScrollXRef = useRef(0), boundsScrollYRef = useRef(0), elementScrollXRef = useRef(0), elementScrollYRef = useRef(0);
|
|
21
|
-
useEffect(() => {
|
|
13
|
+
const ref = react.useRef(null), [relativeBoundsRect, setRelativeBoundsRect] = react.useState(null), [relativeElementRect, setRelativeElementRect] = react.useState(null), [boundsScroll, setBoundsScroll] = react.useState({ x: 0, y: 0 }), [scroll, setScroll] = react.useState({ x: 0, y: 0 }), boundsScrollXRef = react.useRef(0), boundsScrollYRef = react.useRef(0), elementScrollXRef = react.useRef(0), elementScrollYRef = react.useRef(0);
|
|
14
|
+
react.useEffect(() => {
|
|
22
15
|
const el = ref.current;
|
|
23
16
|
if (!el) return;
|
|
24
17
|
const scrollParents = [];
|
|
@@ -66,7 +59,7 @@ function useRegionRects() {
|
|
|
66
59
|
ro.disconnect(), window.removeEventListener("scroll", handleScroll);
|
|
67
60
|
};
|
|
68
61
|
}, []);
|
|
69
|
-
const bounds = useMemo(
|
|
62
|
+
const bounds = react.useMemo(
|
|
70
63
|
() => relativeBoundsRect && {
|
|
71
64
|
x: relativeBoundsRect.x - boundsScroll.x,
|
|
72
65
|
y: relativeBoundsRect.y - boundsScroll.y,
|
|
@@ -74,7 +67,7 @@ function useRegionRects() {
|
|
|
74
67
|
h: relativeBoundsRect.h
|
|
75
68
|
},
|
|
76
69
|
[relativeBoundsRect, boundsScroll]
|
|
77
|
-
), element = useMemo(
|
|
70
|
+
), element = react.useMemo(
|
|
78
71
|
() => relativeElementRect && {
|
|
79
72
|
x: relativeElementRect.x - scroll.x,
|
|
80
73
|
y: relativeElementRect.y - scroll.y,
|
|
@@ -87,22 +80,22 @@ function useRegionRects() {
|
|
|
87
80
|
}
|
|
88
81
|
function ConnectorRegion(props) {
|
|
89
82
|
const { children, onRectsChange, ...restProps } = props, { bounds, element, ref } = useRegionRects();
|
|
90
|
-
return useEffect(() => {
|
|
83
|
+
return react.useEffect(() => {
|
|
91
84
|
onRectsChange?.(bounds && element ? { bounds, element } : null);
|
|
92
|
-
}, [bounds, element, onRectsChange]), /* @__PURE__ */ jsx("div", { ...restProps, ref, children });
|
|
85
|
+
}, [bounds, element, onRectsChange]), /* @__PURE__ */ jsxRuntime.jsx("div", { ...restProps, ref, children });
|
|
93
86
|
}
|
|
94
|
-
const ConnectorsStoreContext = createContext(null);
|
|
87
|
+
const ConnectorsStoreContext = react.createContext(null);
|
|
95
88
|
function useConnectorsStore() {
|
|
96
|
-
const store = useContext(ConnectorsStoreContext);
|
|
89
|
+
const store = react.useContext(ConnectorsStoreContext);
|
|
97
90
|
if (!store)
|
|
98
91
|
throw new Error("Missing connectors store context");
|
|
99
92
|
return store;
|
|
100
93
|
}
|
|
101
94
|
function ConnectFromRegion(props) {
|
|
102
|
-
const { children, _key: key, zIndex, ...restProps } = props, store = useConnectorsStore(), [rects, setRects] = useState(null);
|
|
103
|
-
return useEffect(() => store.from.subscribe(key, { zIndex }), [key, store, zIndex]), useEffect(() => {
|
|
95
|
+
const { children, _key: key, zIndex, ...restProps } = props, store = useConnectorsStore(), [rects, setRects] = react.useState(null);
|
|
96
|
+
return react.useEffect(() => store.from.subscribe(key, { zIndex }), [key, store, zIndex]), react.useEffect(() => {
|
|
104
97
|
rects && store.from.next(key, rects);
|
|
105
|
-
}, [key, rects, store]), /* @__PURE__ */ jsx(ConnectorRegion, { ...restProps, onRectsChange: setRects, children });
|
|
98
|
+
}, [key, rects, store]), /* @__PURE__ */ jsxRuntime.jsx(ConnectorRegion, { ...restProps, onRectsChange: setRects, children });
|
|
106
99
|
}
|
|
107
100
|
function createConnectorsStore() {
|
|
108
101
|
const configKeys = [], fieldKeys = [], channels = {
|
|
@@ -161,11 +154,11 @@ function createConnectorsStore() {
|
|
|
161
154
|
};
|
|
162
155
|
}
|
|
163
156
|
function ConnectorsProvider(props) {
|
|
164
|
-
const { children, onConnectorsChange } = props, store = useMemo(() => createConnectorsStore(), []);
|
|
165
|
-
return useEffect(
|
|
157
|
+
const { children, onConnectorsChange } = props, store = react.useMemo(() => createConnectorsStore(), []);
|
|
158
|
+
return react.useEffect(
|
|
166
159
|
() => onConnectorsChange && store.connectors.subscribe(onConnectorsChange),
|
|
167
160
|
[onConnectorsChange, store]
|
|
168
|
-
), /* @__PURE__ */ jsx(ConnectorsStoreContext.Provider, { value: store, children });
|
|
161
|
+
), /* @__PURE__ */ jsxRuntime.jsx(ConnectorsStoreContext.Provider, { value: store, children });
|
|
169
162
|
}
|
|
170
163
|
function getConnectorLinePoint(options2, rect, bounds) {
|
|
171
164
|
const centerY = rect.y + rect.h / 2, isAbove = rect.y + rect.h < bounds.y + options2.arrow.marginY, isBelow = rect.y > bounds.y + bounds.h - options2.arrow.marginY;
|
|
@@ -203,10 +196,10 @@ function mapConnectorToLine(options2, connector) {
|
|
|
203
196
|
}
|
|
204
197
|
const assistFormId = "assist", assistDocumentIdPrefix = "sanity.assist.schemaType.", assistDocumentStatusIdPrefix = "sanity.assist.status.", assistSchemaIdPrefix = "sanity.assist.schema.", assistDocumentTypeName = "sanity.assist.schemaType.annotations", assistFieldTypeName = "sanity.assist.schemaType.field", instructionTypeName = "sanity.assist.instruction", promptTypeName = "sanity.assist.instruction.prompt", userInputTypeName = "sanity.assist.instruction.userInput", instructionContextTypeName = "sanity.assist.instruction.context", fieldReferenceTypeName = "sanity.assist.instruction.fieldRef", contextDocumentTypeName = "assist.instruction.context", assistTasksStatusTypeName = "sanity.assist.task.status", instructionTaskTypeName = "sanity.assist.instructionTask", fieldPresenceTypeName = "sanity.assist.instructionTask.presence", assistSerializedTypeName = "sanity.assist.serialized.type", assistSerializedFieldTypeName = "sanity.assist.serialized.field", outputFieldTypeName = "sanity.assist.output.field", outputTypeTypeName = "sanity.assist.output.type", fieldPathParam = "pathKey", instructionParam = "instruction", documentRootKey = "<document>";
|
|
205
198
|
function usePathKey(path) {
|
|
206
|
-
return useMemo(() => getPathKey(path), [path]);
|
|
199
|
+
return react.useMemo(() => getPathKey(path), [path]);
|
|
207
200
|
}
|
|
208
201
|
function getPathKey(path) {
|
|
209
|
-
return path.length ? Array.isArray(path) ? pathToString(path) : path : documentRootKey;
|
|
202
|
+
return path.length ? Array.isArray(path) ? sanity.pathToString(path) : path : documentRootKey;
|
|
210
203
|
}
|
|
211
204
|
function getInstructionTitle(instruction2) {
|
|
212
205
|
return instruction2?.title ?? "Untitled";
|
|
@@ -251,25 +244,25 @@ function isDisabled(type) {
|
|
|
251
244
|
function isUnsupportedType(type) {
|
|
252
245
|
return type.name === "sanity.imageCrop" || type.name === "sanity.imageHotspot" || isType(type, "globalDocumentReference") || isType(type, "reference") && !type?.options?.aiAssist?.embeddingsIndex || isType(type, "crossDatasetReference") || isType(type, "file");
|
|
253
246
|
}
|
|
254
|
-
const FirstAssistedPathContext = createContext(void 0);
|
|
247
|
+
const FirstAssistedPathContext = react.createContext(void 0);
|
|
255
248
|
function FirstAssistedPathProvider(props) {
|
|
256
|
-
const { members } = props, firstAssistedPath = useMemo(() => {
|
|
249
|
+
const { members } = props, firstAssistedPath = react.useMemo(() => {
|
|
257
250
|
const firstAssisted = members.find(
|
|
258
251
|
(member) => member.kind === "field" && isAssistSupported(member.field.schemaType)
|
|
259
252
|
);
|
|
260
|
-
return firstAssisted?.field.path ? pathToString(firstAssisted?.field.path) : void 0;
|
|
253
|
+
return firstAssisted?.field.path ? sanity.pathToString(firstAssisted?.field.path) : void 0;
|
|
261
254
|
}, [members]);
|
|
262
|
-
return /* @__PURE__ */ jsx(FirstAssistedPathContext.Provider, { value: firstAssistedPath, children: props.children });
|
|
255
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FirstAssistedPathContext.Provider, { value: firstAssistedPath, children: props.children });
|
|
263
256
|
}
|
|
264
|
-
const releaseAnnouncementUrl = "https://www.sanity.io/blog/sanity-ai-assist-announcement?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", instructionGuideUrl = "https://sanity.io/guides/getting-started-with-ai-assist-instructions?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", giveFeedbackUrl = "https://forms.gle/Kwz7CThxGeA2GiEU8", salesUrl = "https://www.sanity.io/contact/sales?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", packageName = "@sanity/assist", pluginTitle = "Sanity AI Assist", pluginTitleShort = "AI Assist", maxHistoryVisibilityMs = minutesToMilliseconds(30), illegalIdChars = /[^a-zA-Z0-9._-]/g;
|
|
257
|
+
const releaseAnnouncementUrl = "https://www.sanity.io/blog/sanity-ai-assist-announcement?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", instructionGuideUrl = "https://sanity.io/guides/getting-started-with-ai-assist-instructions?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", giveFeedbackUrl = "https://forms.gle/Kwz7CThxGeA2GiEU8", salesUrl = "https://www.sanity.io/contact/sales?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", packageName = "@sanity/assist", pluginTitle = "Sanity AI Assist", pluginTitleShort = "AI Assist", maxHistoryVisibilityMs = dateFns.minutesToMilliseconds(30), illegalIdChars = /[^a-zA-Z0-9._-]/g;
|
|
265
258
|
function assistDocumentId(documentType) {
|
|
266
259
|
return `${assistDocumentIdPrefix}${documentType}`.replace(illegalIdChars, "_");
|
|
267
260
|
}
|
|
268
261
|
function assistTasksStatusId(documentId) {
|
|
269
|
-
return isVersionId(documentId) ? `${assistDocumentStatusIdPrefix}${getVersionFromId(documentId)}.${getPublishedId(documentId)}` : `${assistDocumentStatusIdPrefix}${getPublishedId(documentId)}`;
|
|
262
|
+
return sanity.isVersionId(documentId) ? `${assistDocumentStatusIdPrefix}${sanity.getVersionFromId(documentId)}.${sanity.getPublishedId(documentId)}` : `${assistDocumentStatusIdPrefix}${sanity.getPublishedId(documentId)}`;
|
|
270
263
|
}
|
|
271
264
|
function useDocumentState(id, docType) {
|
|
272
|
-
const state = useEditState(id, docType);
|
|
265
|
+
const state = sanity.useEditState(id, docType);
|
|
273
266
|
return state.draft || state.published;
|
|
274
267
|
}
|
|
275
268
|
function useStudioAssistDocument({
|
|
@@ -277,20 +270,20 @@ function useStudioAssistDocument({
|
|
|
277
270
|
schemaType,
|
|
278
271
|
initDoc
|
|
279
272
|
}) {
|
|
280
|
-
const documentTypeName = schemaType.name, currentUser = useCurrentUser(), assistDocument = useDocumentState(
|
|
273
|
+
const documentTypeName = schemaType.name, currentUser = sanity.useCurrentUser(), assistDocument = useDocumentState(
|
|
281
274
|
assistDocumentId(documentTypeName),
|
|
282
275
|
assistDocumentTypeName
|
|
283
276
|
), assistTasksStatus = useDocumentState(
|
|
284
277
|
assistTasksStatusId(documentId ?? ""),
|
|
285
278
|
assistTasksStatusTypeName
|
|
286
|
-
), client = useClient({ apiVersion: "2023-01-01" });
|
|
287
|
-
return useEffect(() => {
|
|
279
|
+
), client = sanity.useClient({ apiVersion: "2023-01-01" });
|
|
280
|
+
return react.useEffect(() => {
|
|
288
281
|
!assistDocument && initDoc && client.createIfNotExists({
|
|
289
282
|
_id: assistDocumentId(documentTypeName),
|
|
290
283
|
_type: assistDocumentTypeName
|
|
291
284
|
}).catch(() => {
|
|
292
285
|
});
|
|
293
|
-
}, [client, assistDocument, documentTypeName, initDoc]), useMemo(() => {
|
|
286
|
+
}, [client, assistDocument, documentTypeName, initDoc]), react.useMemo(() => {
|
|
294
287
|
if (!assistDocument)
|
|
295
288
|
return;
|
|
296
289
|
const tasks = assistTasksStatus?.tasks ?? [], fields = (assistDocument?.fields ?? []).map((assistField) => ({
|
|
@@ -298,7 +291,7 @@ function useStudioAssistDocument({
|
|
|
298
291
|
tasks: tasks.filter((task) => task.path === assistField.path),
|
|
299
292
|
instructions: assistField.instructions?.filter((p) => !p.userId || p.userId === currentUser?.id).map((instruction2) => asStudioInstruction(instruction2, tasks))
|
|
300
293
|
}));
|
|
301
|
-
return typed({
|
|
294
|
+
return sanity.typed({
|
|
302
295
|
...assistDocument,
|
|
303
296
|
tasks: tasks?.map((task) => {
|
|
304
297
|
const instruction2 = fields.find((f) => f.path === task.path)?.instructions?.find((i) => i._key === task.instructionKey);
|
|
@@ -321,8 +314,8 @@ function asStudioInstruction(instruction2, run) {
|
|
|
321
314
|
}
|
|
322
315
|
const NO_TASKS = [];
|
|
323
316
|
function useInstructionToaster(documentId, documentSchemaType) {
|
|
324
|
-
const assistDocument = useStudioAssistDocument({ documentId, schemaType: documentSchemaType }), assistDocLoaded = !!assistDocument, currentUser = useCurrentUser(), toast = useToast(), tasks = assistDocument?.tasks, previousTasks = useRef("initial");
|
|
325
|
-
useEffect(() => {
|
|
317
|
+
const assistDocument = useStudioAssistDocument({ documentId, schemaType: documentSchemaType }), assistDocLoaded = !!assistDocument, currentUser = sanity.useCurrentUser(), toast = ui.useToast(), tasks = assistDocument?.tasks, previousTasks = react.useRef("initial");
|
|
318
|
+
react.useEffect(() => {
|
|
326
319
|
if (assistDocLoaded) {
|
|
327
320
|
if (previousTasks.current !== "initial") {
|
|
328
321
|
const prevTaskByKey = Object.fromEntries(
|
|
@@ -331,7 +324,7 @@ function useInstructionToaster(documentId, documentSchemaType) {
|
|
|
331
324
|
tasks?.filter((task) => task.startedByUserId === currentUser?.id).filter((task) => {
|
|
332
325
|
const prevTask = prevTaskByKey[task._key];
|
|
333
326
|
return !prevTask && task.ended || !prevTask?.ended && task.ended;
|
|
334
|
-
}).filter((task) => task.ended && isAfter(addSeconds(new Date(task.ended), 30), /* @__PURE__ */ new Date()))?.forEach((task) => {
|
|
327
|
+
}).filter((task) => task.ended && dateFns.isAfter(dateFns.addSeconds(new Date(task.ended), 30), /* @__PURE__ */ new Date()))?.forEach((task) => {
|
|
335
328
|
const title = task.title ?? getInstructionTitle(task.instruction);
|
|
336
329
|
task.reason === "error" ? toast.push({
|
|
337
330
|
title: `Failed: ${title}`,
|
|
@@ -363,13 +356,13 @@ function useInstructionToaster(documentId, documentSchemaType) {
|
|
|
363
356
|
}
|
|
364
357
|
function AssistDocumentInputWrapper(props) {
|
|
365
358
|
if (!isType(props.schemaType, "document") && props.id !== "root" && props.id !== assistFormId)
|
|
366
|
-
return /* @__PURE__ */ jsx(AssistInput, { ...props });
|
|
359
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistInput, { ...props });
|
|
367
360
|
const documentId = props.value?._id;
|
|
368
|
-
return documentId ? /* @__PURE__ */ jsx(AssistDocumentInput, { ...props, documentId }) : props.renderDefault(props);
|
|
361
|
+
return documentId ? /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentInput, { ...props, documentId }) : props.renderDefault(props);
|
|
369
362
|
}
|
|
370
363
|
function AssistDocumentInput({ documentId, ...props }) {
|
|
371
364
|
useInstructionToaster(documentId, props.schemaType);
|
|
372
|
-
const schemaType = useMemo(() => props.schemaType.name !== assistDocumentTypeName ? props.schemaType : {
|
|
365
|
+
const schemaType = react.useMemo(() => props.schemaType.name !== assistDocumentTypeName ? props.schemaType : {
|
|
373
366
|
...props.schemaType,
|
|
374
367
|
type: {
|
|
375
368
|
...props.schemaType.type,
|
|
@@ -377,24 +370,24 @@ function AssistDocumentInput({ documentId, ...props }) {
|
|
|
377
370
|
name: "document"
|
|
378
371
|
}
|
|
379
372
|
}, [props.schemaType]);
|
|
380
|
-
return /* @__PURE__ */ jsx(FirstAssistedPathProvider, { members: props.members, children: props.renderDefault({ ...props, schemaType }) });
|
|
373
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FirstAssistedPathProvider, { members: props.members, children: props.renderDefault({ ...props, schemaType }) });
|
|
381
374
|
}
|
|
382
375
|
function AssistInput(props) {
|
|
383
|
-
const { zIndex } = useLayer(), { paneKey } = useDocumentPane(), pathKey = usePathKey(props.path);
|
|
384
|
-
return /* @__PURE__ */ jsx(ConnectFromRegion, { _key: `${paneKey}_${pathKey}`, zIndex, style: { minWidth: 0 }, children: props.renderDefault(props) });
|
|
376
|
+
const { zIndex } = ui.useLayer(), { paneKey } = structure.useDocumentPane(), pathKey = usePathKey(props.path);
|
|
377
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ConnectFromRegion, { _key: `${paneKey}_${pathKey}`, zIndex, style: { minWidth: 0 }, children: props.renderDefault(props) });
|
|
385
378
|
}
|
|
386
|
-
const AssistDocumentContext = createContext(
|
|
379
|
+
const AssistDocumentContext = react.createContext(
|
|
387
380
|
void 0
|
|
388
381
|
);
|
|
389
382
|
function useAssistDocumentContext() {
|
|
390
|
-
const context = useContext(AssistDocumentContext);
|
|
383
|
+
const context = react.useContext(AssistDocumentContext);
|
|
391
384
|
if (!context)
|
|
392
385
|
throw new Error("AssistDocumentContext value is missing");
|
|
393
386
|
return context;
|
|
394
387
|
}
|
|
395
|
-
const AiAssistanceConfigContext = createContext({});
|
|
388
|
+
const AiAssistanceConfigContext = react.createContext({});
|
|
396
389
|
function useAiAssistanceConfig() {
|
|
397
|
-
const context = useContext(AiAssistanceConfigContext);
|
|
390
|
+
const context = react.useContext(AiAssistanceConfigContext);
|
|
398
391
|
if (!context)
|
|
399
392
|
throw new Error("Missing AiAssistanceConfigContext");
|
|
400
393
|
return context;
|
|
@@ -407,14 +400,14 @@ function canUseAssist(status) {
|
|
|
407
400
|
return status?.enabled && status.initialized && status.validToken;
|
|
408
401
|
}
|
|
409
402
|
function useApiClient(customApiClient) {
|
|
410
|
-
const client = useClient({ apiVersion: API_VERSION_WITH_EXTENDED_TYPES });
|
|
411
|
-
return useMemo(
|
|
403
|
+
const client = sanity.useClient({ apiVersion: API_VERSION_WITH_EXTENDED_TYPES });
|
|
404
|
+
return react.useMemo(
|
|
412
405
|
() => customApiClient ? customApiClient(client) : client,
|
|
413
406
|
[client, customApiClient]
|
|
414
407
|
);
|
|
415
408
|
}
|
|
416
409
|
function useTranslate(apiClient) {
|
|
417
|
-
const [loading, setLoading] = useState(!1), user = useCurrentUser(), types = useSerializedTypes(), toast = useToast(), translate = useCallback(
|
|
410
|
+
const [loading, setLoading] = react.useState(!1), user = sanity.useCurrentUser(), types = useSerializedTypes(), toast = ui.useToast(), translate = react.useCallback(
|
|
418
411
|
({
|
|
419
412
|
documentId,
|
|
420
413
|
languagePath,
|
|
@@ -435,7 +428,7 @@ function useTranslate(apiClient) {
|
|
|
435
428
|
userStyleguide: await styleguide(),
|
|
436
429
|
fieldLanguageMap,
|
|
437
430
|
conditionalMembers,
|
|
438
|
-
translatePath: translatePath.length === 0 ? documentRootKey : pathToString(translatePath),
|
|
431
|
+
translatePath: translatePath.length === 0 ? documentRootKey : sanity.pathToString(translatePath),
|
|
439
432
|
userId: user?.id
|
|
440
433
|
}
|
|
441
434
|
});
|
|
@@ -454,7 +447,7 @@ function useTranslate(apiClient) {
|
|
|
454
447
|
},
|
|
455
448
|
[setLoading, apiClient, toast, user, types]
|
|
456
449
|
);
|
|
457
|
-
return useMemo(
|
|
450
|
+
return react.useMemo(
|
|
458
451
|
() => ({
|
|
459
452
|
translate,
|
|
460
453
|
loading
|
|
@@ -463,7 +456,7 @@ function useTranslate(apiClient) {
|
|
|
463
456
|
);
|
|
464
457
|
}
|
|
465
458
|
function useGenerateCaption(apiClient) {
|
|
466
|
-
const [loading, setLoading] = useState(!1), user = useCurrentUser(), types = useSerializedTypes(), toast = useToast(), generateCaption = useCallback(
|
|
459
|
+
const [loading, setLoading] = react.useState(!1), user = sanity.useCurrentUser(), types = useSerializedTypes(), toast = ui.useToast(), generateCaption = react.useCallback(
|
|
467
460
|
({ path, documentId }) => (setLoading(!0), apiClient.request({
|
|
468
461
|
method: "POST",
|
|
469
462
|
url: `/assist/tasks/generate-caption/${apiClient.config().dataset}?projectId=${apiClient.config().projectId}`,
|
|
@@ -486,7 +479,7 @@ function useGenerateCaption(apiClient) {
|
|
|
486
479
|
})),
|
|
487
480
|
[setLoading, apiClient, toast, user, types]
|
|
488
481
|
);
|
|
489
|
-
return useMemo(
|
|
482
|
+
return react.useMemo(
|
|
490
483
|
() => ({
|
|
491
484
|
generateCaption,
|
|
492
485
|
loading
|
|
@@ -495,7 +488,7 @@ function useGenerateCaption(apiClient) {
|
|
|
495
488
|
);
|
|
496
489
|
}
|
|
497
490
|
function useGenerateImage(apiClient) {
|
|
498
|
-
const [loading, setLoading] = useState(!1), user = useCurrentUser(), types = useSerializedTypes(), toast = useToast(), generateImage = useCallback(
|
|
491
|
+
const [loading, setLoading] = react.useState(!1), user = sanity.useCurrentUser(), types = useSerializedTypes(), toast = ui.useToast(), generateImage = react.useCallback(
|
|
499
492
|
({ path, documentId }) => (setLoading(!0), apiClient.request({
|
|
500
493
|
method: "POST",
|
|
501
494
|
url: `/assist/tasks/generate-image/${apiClient.config().dataset}?projectId=${apiClient.config().projectId}`,
|
|
@@ -518,7 +511,7 @@ function useGenerateImage(apiClient) {
|
|
|
518
511
|
})),
|
|
519
512
|
[setLoading, apiClient, toast, user, types]
|
|
520
513
|
);
|
|
521
|
-
return useMemo(
|
|
514
|
+
return react.useMemo(
|
|
522
515
|
() => ({
|
|
523
516
|
generateImage,
|
|
524
517
|
loading
|
|
@@ -527,7 +520,7 @@ function useGenerateImage(apiClient) {
|
|
|
527
520
|
);
|
|
528
521
|
}
|
|
529
522
|
function useGetInstructStatus(apiClient) {
|
|
530
|
-
const [loading, setLoading] = useState(!0), getInstructStatus = useCallback(async () => {
|
|
523
|
+
const [loading, setLoading] = react.useState(!0), getInstructStatus = react.useCallback(async () => {
|
|
531
524
|
setLoading(!0);
|
|
532
525
|
const projectId = apiClient.config().projectId;
|
|
533
526
|
try {
|
|
@@ -545,7 +538,7 @@ function useGetInstructStatus(apiClient) {
|
|
|
545
538
|
};
|
|
546
539
|
}
|
|
547
540
|
function useInitInstruct(apiClient) {
|
|
548
|
-
const [loading, setLoading] = useState(!1), initInstruct = useCallback(() => (setLoading(!0), apiClient.request({
|
|
541
|
+
const [loading, setLoading] = react.useState(!1), initInstruct = react.useCallback(() => (setLoading(!0), apiClient.request({
|
|
549
542
|
method: "GET",
|
|
550
543
|
url: `${basePath}/${apiClient.config().dataset}/init?projectId=${apiClient.config().projectId}`
|
|
551
544
|
}).finally(() => {
|
|
@@ -557,9 +550,9 @@ function useInitInstruct(apiClient) {
|
|
|
557
550
|
};
|
|
558
551
|
}
|
|
559
552
|
function useRunInstructionApi(apiClient) {
|
|
560
|
-
const toast = useToast(), [loading, setLoading] = useState(!1), user = useCurrentUser(), types = useSerializedTypes(), {
|
|
553
|
+
const toast = ui.useToast(), [loading, setLoading] = react.useState(!1), user = sanity.useCurrentUser(), types = useSerializedTypes(), {
|
|
561
554
|
config: { assist: assistConfig }
|
|
562
|
-
} = useAiAssistanceConfig(), runInstruction = useCallback(
|
|
555
|
+
} = useAiAssistanceConfig(), runInstruction = react.useCallback(
|
|
563
556
|
(request) => {
|
|
564
557
|
if (!user) {
|
|
565
558
|
toast.push({
|
|
@@ -592,7 +585,7 @@ function useRunInstructionApi(apiClient) {
|
|
|
592
585
|
},
|
|
593
586
|
[apiClient, types, user, toast, assistConfig]
|
|
594
587
|
);
|
|
595
|
-
return useMemo(
|
|
588
|
+
return react.useMemo(
|
|
596
589
|
() => ({
|
|
597
590
|
runInstruction,
|
|
598
591
|
loading
|
|
@@ -600,7 +593,7 @@ function useRunInstructionApi(apiClient) {
|
|
|
600
593
|
[runInstruction, loading]
|
|
601
594
|
);
|
|
602
595
|
}
|
|
603
|
-
const NO_INPUT = {}, RunInstructionContext = createContext({
|
|
596
|
+
const NO_INPUT = {}, RunInstructionContext = react.createContext({
|
|
604
597
|
runInstruction: () => {
|
|
605
598
|
},
|
|
606
599
|
getUserInput: async () => {
|
|
@@ -608,13 +601,13 @@ const NO_INPUT = {}, RunInstructionContext = createContext({
|
|
|
608
601
|
instructionLoading: !1
|
|
609
602
|
});
|
|
610
603
|
function useRunInstruction() {
|
|
611
|
-
return useContext(RunInstructionContext);
|
|
604
|
+
return react.useContext(RunInstructionContext);
|
|
612
605
|
}
|
|
613
606
|
function isUserInputBlock(block) {
|
|
614
607
|
return block._type === userInputTypeName;
|
|
615
608
|
}
|
|
616
609
|
function RunInstructionProvider(props) {
|
|
617
|
-
const { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { runInstruction: runInstructionRequest, loading } = useRunInstructionApi(apiClient), id = useId(), [inputs, setInputs] = useState(NO_INPUT), [runRequest, setRunRequest] = useState(), [resolveUserInput, setResolveUserInput] = useState(), getUserInput = useCallback(async ({ title, inputs: inputs2 }) => {
|
|
610
|
+
const { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { runInstruction: runInstructionRequest, loading } = useRunInstructionApi(apiClient), id = react.useId(), [inputs, setInputs] = react.useState(NO_INPUT), [runRequest, setRunRequest] = react.useState(), [resolveUserInput, setResolveUserInput] = react.useState(), getUserInput = react.useCallback(async ({ title, inputs: inputs2 }) => {
|
|
618
611
|
const userInputBlocks = inputs2.map((input, i) => ({
|
|
619
612
|
_type: userInputTypeName,
|
|
620
613
|
_key: input.id ?? `${i}`,
|
|
@@ -625,7 +618,7 @@ function RunInstructionProvider(props) {
|
|
|
625
618
|
return setRunRequest({ dialogTitle: title, userInputBlocks }), new Promise((resolve) => {
|
|
626
619
|
setResolveUserInput(() => resolve);
|
|
627
620
|
});
|
|
628
|
-
}, []), runInstruction = useCallback(
|
|
621
|
+
}, []), runInstruction = react.useCallback(
|
|
629
622
|
(req) => {
|
|
630
623
|
if (loading)
|
|
631
624
|
return;
|
|
@@ -646,9 +639,9 @@ function RunInstructionProvider(props) {
|
|
|
646
639
|
});
|
|
647
640
|
},
|
|
648
641
|
[runInstructionRequest, loading]
|
|
649
|
-
), close = useCallback(() => {
|
|
642
|
+
), close = react.useCallback(() => {
|
|
650
643
|
setRunRequest(void 0), setInputs(NO_INPUT), resolveUserInput && resolveUserInput(void 0), setResolveUserInput(void 0);
|
|
651
|
-
}, [resolveUserInput]), runWithInput = useCallback(() => {
|
|
644
|
+
}, [resolveUserInput]), runWithInput = react.useCallback(() => {
|
|
652
645
|
if (runRequest)
|
|
653
646
|
if ("instruction" in runRequest) {
|
|
654
647
|
const { instruction: instruction2, userTexts, ...request } = runRequest;
|
|
@@ -675,41 +668,41 @@ function RunInstructionProvider(props) {
|
|
|
675
668
|
resolveUserInput?.(userInputs), setResolveUserInput(void 0);
|
|
676
669
|
}
|
|
677
670
|
close();
|
|
678
|
-
}, [close, runInstructionRequest, runRequest, inputs, resolveUserInput]), open = !!runRequest, runDisabled = useMemo(
|
|
671
|
+
}, [close, runInstructionRequest, runRequest, inputs, resolveUserInput]), open = !!runRequest, runDisabled = react.useMemo(
|
|
679
672
|
() => (runRequest?.userInputBlocks?.length ?? 0) > Object.entries(inputs).filter(([, value]) => !!value).length,
|
|
680
673
|
[runRequest?.userInputBlocks, inputs]
|
|
681
|
-
), runButton = /* @__PURE__ */ jsx(
|
|
682
|
-
Button,
|
|
674
|
+
), runButton = /* @__PURE__ */ jsxRuntime.jsx(
|
|
675
|
+
ui.Button,
|
|
683
676
|
{
|
|
684
677
|
text: "Run instruction",
|
|
685
678
|
onClick: runWithInput,
|
|
686
679
|
tone: "primary",
|
|
687
|
-
icon: PlayIcon,
|
|
680
|
+
icon: icons.PlayIcon,
|
|
688
681
|
style: { width: "100%" },
|
|
689
682
|
disabled: runDisabled
|
|
690
683
|
}
|
|
691
|
-
), contextValue = useMemo(
|
|
684
|
+
), contextValue = react.useMemo(
|
|
692
685
|
() => ({ runInstruction, getUserInput, instructionLoading: loading }),
|
|
693
686
|
[runInstruction, loading]
|
|
694
687
|
);
|
|
695
|
-
return /* @__PURE__ */ jsxs(RunInstructionContext.Provider, { value: contextValue, children: [
|
|
696
|
-
open ? /* @__PURE__ */ jsx(
|
|
697
|
-
Dialog,
|
|
688
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RunInstructionContext.Provider, { value: contextValue, children: [
|
|
689
|
+
open ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
690
|
+
ui.Dialog,
|
|
698
691
|
{
|
|
699
692
|
id,
|
|
700
693
|
open,
|
|
701
694
|
onClose: close,
|
|
702
695
|
width: 1,
|
|
703
696
|
header: "dialogTitle" in runRequest ? runRequest.dialogTitle : getInstructionTitle(runRequest?.instruction),
|
|
704
|
-
footer: /* @__PURE__ */ jsx(Flex, { justify: "space-between", padding: 2, flex: 1, children: runDisabled ? /* @__PURE__ */ jsx(
|
|
705
|
-
Tooltip,
|
|
697
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "space-between", padding: 2, flex: 1, children: runDisabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
698
|
+
ui.Tooltip,
|
|
706
699
|
{
|
|
707
|
-
content: /* @__PURE__ */ jsx(Flex, { padding: 2, children: /* @__PURE__ */ jsx(Text, { children: "Unable to run instruction. All fields must have a value." }) }),
|
|
700
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Unable to run instruction. All fields must have a value." }) }),
|
|
708
701
|
placement: "top",
|
|
709
|
-
children: /* @__PURE__ */ jsx(Flex, { flex: 1, children: runButton })
|
|
702
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { flex: 1, children: runButton })
|
|
710
703
|
}
|
|
711
704
|
) : runButton }),
|
|
712
|
-
children: /* @__PURE__ */ jsx(Stack, { padding: 4, space: 2, children: runRequest?.userInputBlocks?.map((block, i) => /* @__PURE__ */ jsx(
|
|
705
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { padding: 4, space: 2, children: runRequest?.userInputBlocks?.map((block, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
713
706
|
UserInput,
|
|
714
707
|
{
|
|
715
708
|
block,
|
|
@@ -725,7 +718,7 @@ function RunInstructionProvider(props) {
|
|
|
725
718
|
] });
|
|
726
719
|
}
|
|
727
720
|
function UserInput(props) {
|
|
728
|
-
const { block, autoFocus, setInputs, inputs } = props, key = block._key, textAreaRef = useRef(null), onChange = useCallback(
|
|
721
|
+
const { block, autoFocus, setInputs, inputs } = props, key = block._key, textAreaRef = react.useRef(null), onChange = react.useCallback(
|
|
729
722
|
(e) => {
|
|
730
723
|
setInputs((current) => ({
|
|
731
724
|
...current,
|
|
@@ -733,19 +726,19 @@ function UserInput(props) {
|
|
|
733
726
|
}));
|
|
734
727
|
},
|
|
735
728
|
[key, setInputs]
|
|
736
|
-
), value = useMemo(() => inputs[key], [inputs, key]);
|
|
737
|
-
return useEffect(() => {
|
|
729
|
+
), value = react.useMemo(() => inputs[key], [inputs, key]);
|
|
730
|
+
return react.useEffect(() => {
|
|
738
731
|
autoFocus && setTimeout(() => textAreaRef.current?.focus(), 0);
|
|
739
|
-
}, [autoFocus]), /* @__PURE__ */ jsxs(Stack, { padding: 2, space: 3, children: [
|
|
740
|
-
/* @__PURE__ */ jsx(
|
|
741
|
-
FormFieldHeaderText,
|
|
732
|
+
}, [autoFocus]), /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { padding: 2, space: 3, children: [
|
|
733
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
734
|
+
sanity.FormFieldHeaderText,
|
|
742
735
|
{
|
|
743
736
|
title: block?.message ?? "Provide more context",
|
|
744
737
|
description: block.description
|
|
745
738
|
}
|
|
746
739
|
),
|
|
747
|
-
/* @__PURE__ */ jsx(
|
|
748
|
-
TextArea,
|
|
740
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
741
|
+
ui.TextArea,
|
|
749
742
|
{
|
|
750
743
|
ref: textAreaRef,
|
|
751
744
|
rows: 4,
|
|
@@ -770,12 +763,12 @@ function useRequestRunInstruction(args) {
|
|
|
770
763
|
};
|
|
771
764
|
}
|
|
772
765
|
function useDraftDelayedTask(args) {
|
|
773
|
-
const { documentOnChange, isDocAssistable: isDocAssistable2, task } = args, [queuedArgs, setQueuedArgs] = useState(void 0);
|
|
774
|
-
return useEffect(() => {
|
|
766
|
+
const { documentOnChange, isDocAssistable: isDocAssistable2, task } = args, [queuedArgs, setQueuedArgs] = react.useState(void 0);
|
|
767
|
+
return react.useEffect(() => {
|
|
775
768
|
queuedArgs && isDocAssistable2 && (task(queuedArgs), setQueuedArgs(void 0));
|
|
776
|
-
}, [queuedArgs, isDocAssistable2, task]), useCallback(
|
|
769
|
+
}, [queuedArgs, isDocAssistable2, task]), react.useCallback(
|
|
777
770
|
(taskArgs) => {
|
|
778
|
-
documentOnChange(PatchEvent.from([unset(["_force_document_creation"])])), setQueuedArgs(taskArgs);
|
|
771
|
+
documentOnChange(sanity.PatchEvent.from([sanity.unset(["_force_document_creation"])])), setQueuedArgs(taskArgs);
|
|
779
772
|
},
|
|
780
773
|
[setQueuedArgs, documentOnChange]
|
|
781
774
|
);
|
|
@@ -787,7 +780,7 @@ function getTypeIcon(schemaType) {
|
|
|
787
780
|
if (t.icon) return t.icon;
|
|
788
781
|
t = t.type;
|
|
789
782
|
}
|
|
790
|
-
return isType(schemaType, "slug") ? LinkIcon : isType(schemaType, "image") ? ImageIcon : schemaType.jsonType === "array" && isPortableTextArray(schemaType) ? BlockContentIcon : schemaType.jsonType === "array" ? OlistIcon : schemaType.jsonType === "object" ? BlockquoteIcon : schemaType.jsonType === "string" ? StringIcon : DocumentIcon;
|
|
783
|
+
return isType(schemaType, "slug") ? icons.LinkIcon : isType(schemaType, "image") ? icons.ImageIcon : schemaType.jsonType === "array" && isPortableTextArray(schemaType) ? icons.BlockContentIcon : schemaType.jsonType === "array" ? icons.OlistIcon : schemaType.jsonType === "object" ? icons.BlockquoteIcon : schemaType.jsonType === "string" ? icons.StringIcon : icons.DocumentIcon;
|
|
791
784
|
}
|
|
792
785
|
function asFieldRefsByTypePath(fieldRefs) {
|
|
793
786
|
return fieldRefs.reduce(
|
|
@@ -798,7 +791,7 @@ function asFieldRefsByTypePath(fieldRefs) {
|
|
|
798
791
|
function getDocumentFieldRef(schemaType) {
|
|
799
792
|
return {
|
|
800
793
|
key: documentRootKey,
|
|
801
|
-
icon: schemaType.icon ?? DocumentIcon,
|
|
794
|
+
icon: schemaType.icon ?? icons.DocumentIcon,
|
|
802
795
|
title: "The entire document",
|
|
803
796
|
path: [],
|
|
804
797
|
schemaType
|
|
@@ -807,7 +800,7 @@ function getDocumentFieldRef(schemaType) {
|
|
|
807
800
|
function getFieldRefs(schemaType, parent, depth = 0) {
|
|
808
801
|
return depth >= maxDepth ? [] : schemaType.fields.filter((f) => !f.name.startsWith("_")).flatMap((field) => {
|
|
809
802
|
const path = parent ? [...parent.path, field.name] : [field.name], title = field.type.title ?? field.name, fieldRef = {
|
|
810
|
-
key: patchableKey(pathToString(path)),
|
|
803
|
+
key: patchableKey(sanity.pathToString(path)),
|
|
811
804
|
path,
|
|
812
805
|
title: parent ? [parent.title, title].join(" / ") : title,
|
|
813
806
|
schemaType: field.type,
|
|
@@ -819,7 +812,7 @@ function getFieldRefs(schemaType, parent, depth = 0) {
|
|
|
819
812
|
function getSyntheticFields(schemaType, parent, depth = 0) {
|
|
820
813
|
return depth >= maxDepth ? [] : schemaType.of.filter((itemType) => !isType(itemType, "block")).flatMap((itemType) => {
|
|
821
814
|
const segment = { _key: itemType.name }, title = itemType.title ?? itemType.name, path = parent ? [...parent.path, segment] : [segment], fieldRef = {
|
|
822
|
-
key: patchableKey(pathToString(path)),
|
|
815
|
+
key: patchableKey(sanity.pathToString(path)),
|
|
823
816
|
path,
|
|
824
817
|
title: parent ? [parent.title, title].join(" / ") : title,
|
|
825
818
|
schemaType: itemType,
|
|
@@ -832,50 +825,50 @@ function getSyntheticFields(schemaType, parent, depth = 0) {
|
|
|
832
825
|
function getTypePath(doc, pathString) {
|
|
833
826
|
if (!pathString)
|
|
834
827
|
return;
|
|
835
|
-
const path = stringToPath(pathString), currentPath = [];
|
|
828
|
+
const path = sanity.stringToPath(pathString), currentPath = [];
|
|
836
829
|
let valid = !0;
|
|
837
830
|
const syntheticPath = path.map((segment) => {
|
|
838
|
-
if (currentPath.push(segment), isKeySegment(segment)) {
|
|
839
|
-
const match = extractWithPath(pathToString(currentPath), doc)[0], value = match?.value;
|
|
831
|
+
if (currentPath.push(segment), sanity.isKeySegment(segment)) {
|
|
832
|
+
const match = mutator.extractWithPath(sanity.pathToString(currentPath), doc)[0], value = match?.value;
|
|
840
833
|
if (match && value && typeof value == "object" && "_type" in value)
|
|
841
834
|
return { _key: value._type };
|
|
842
835
|
valid = !1;
|
|
843
836
|
}
|
|
844
837
|
return segment;
|
|
845
838
|
});
|
|
846
|
-
return valid ? patchableKey(pathToString(syntheticPath)) : void 0;
|
|
839
|
+
return valid ? patchableKey(sanity.pathToString(syntheticPath)) : void 0;
|
|
847
840
|
}
|
|
848
841
|
function patchableKey(pathKey) {
|
|
849
842
|
return pathKey.replace(/[=]=/g, ":").replace(/[[\]]/g, "|").replace(/"/g, "");
|
|
850
843
|
}
|
|
851
844
|
function useTypePath(doc, pathString) {
|
|
852
|
-
return useMemo(() => getTypePath(doc, pathString), [doc, pathString]);
|
|
845
|
+
return react.useMemo(() => getTypePath(doc, pathString), [doc, pathString]);
|
|
853
846
|
}
|
|
854
847
|
function useSelectedField(documentSchemaType, path) {
|
|
855
|
-
const { getFieldRefs: getFieldRefs2 } = useAiAssistanceConfig(), selectableFields = useMemo(
|
|
856
|
-
() => documentSchemaType && isObjectSchemaType(documentSchemaType) ? [getDocumentFieldRef(documentSchemaType), ...getFieldRefs2(documentSchemaType.name)] : [],
|
|
848
|
+
const { getFieldRefs: getFieldRefs2 } = useAiAssistanceConfig(), selectableFields = react.useMemo(
|
|
849
|
+
() => documentSchemaType && sanity.isObjectSchemaType(documentSchemaType) ? [getDocumentFieldRef(documentSchemaType), ...getFieldRefs2(documentSchemaType.name)] : [],
|
|
857
850
|
[documentSchemaType, getFieldRefs2]
|
|
858
851
|
);
|
|
859
|
-
return useMemo(() => path ? selectableFields?.find((f) => f.key === path) : void 0, [selectableFields, path]);
|
|
852
|
+
return react.useMemo(() => path ? selectableFields?.find((f) => f.key === path) : void 0, [selectableFields, path]);
|
|
860
853
|
}
|
|
861
854
|
function getFieldTitle(field) {
|
|
862
855
|
const schemaType = field?.schemaType;
|
|
863
856
|
return field?.title ?? schemaType?.title ?? schemaType?.name ?? "Untitled";
|
|
864
857
|
}
|
|
865
858
|
function useAiPaneRouter() {
|
|
866
|
-
const paneRouter = usePaneRouter();
|
|
867
|
-
return useMemo(
|
|
859
|
+
const paneRouter = structure.usePaneRouter();
|
|
860
|
+
return react.useMemo(
|
|
868
861
|
() => ({ ...paneRouter, params: paneRouter.params ?? {} }),
|
|
869
862
|
[paneRouter]
|
|
870
863
|
);
|
|
871
864
|
}
|
|
872
865
|
function useAssistDocumentContextValue(documentId, documentType) {
|
|
873
|
-
const schema = useSchema(), { getFieldRefs: getFieldRefs2, getFieldRefsByTypePath } = useAiAssistanceConfig(), documentSchemaType = useMemo(() => {
|
|
866
|
+
const schema = sanity.useSchema(), { getFieldRefs: getFieldRefs2, getFieldRefsByTypePath } = useAiAssistanceConfig(), documentSchemaType = react.useMemo(() => {
|
|
874
867
|
const schemaType = schema.get(documentType);
|
|
875
868
|
if (!schemaType)
|
|
876
869
|
throw new Error(`Schema type "${documentType}" not found`);
|
|
877
870
|
return schemaType;
|
|
878
|
-
}, [documentType, schema]), { fieldRefs, fieldRefsByTypePath } = useMemo(() => ({
|
|
871
|
+
}, [documentType, schema]), { fieldRefs, fieldRefsByTypePath } = react.useMemo(() => ({
|
|
879
872
|
fieldRefs: getFieldRefs2(documentType),
|
|
880
873
|
fieldRefsByTypePath: getFieldRefsByTypePath(documentType)
|
|
881
874
|
}), [getFieldRefs2, getFieldRefsByTypePath, documentType]), {
|
|
@@ -887,11 +880,11 @@ function useAssistDocumentContextValue(documentId, documentType) {
|
|
|
887
880
|
// @ts-ignore this is a valid option available in `corel` - Remove after corel is merged to next
|
|
888
881
|
selectedReleaseId,
|
|
889
882
|
editState
|
|
890
|
-
} = useDocumentPane(), { draft, published, version } = editState || {}, assistableDocumentId = selectedReleaseId ? getVersionId(documentId, selectedReleaseId) : documentSchemaType.liveEdit ? documentId : getDraftId(documentId), documentIsNew = selectedReleaseId ? !version?._id : !draft?._id && !published?._id, documentIsAssistable = selectedReleaseId ? !!version : isDocAssistable(documentSchemaType, published, draft), { params } = useAiPaneRouter(), selectedPath = params[fieldPathParam], assistDocument = useStudioAssistDocument({
|
|
883
|
+
} = structure.useDocumentPane(), { draft, published, version } = editState || {}, assistableDocumentId = selectedReleaseId ? sanity.getVersionId(documentId, selectedReleaseId) : documentSchemaType.liveEdit ? documentId : sanity.getDraftId(documentId), documentIsNew = selectedReleaseId ? !version?._id : !draft?._id && !published?._id, documentIsAssistable = selectedReleaseId ? !!version : isDocAssistable(documentSchemaType, published, draft), { params } = useAiPaneRouter(), selectedPath = params[fieldPathParam], assistDocument = useStudioAssistDocument({
|
|
891
884
|
documentId: assistableDocumentId,
|
|
892
885
|
schemaType: documentSchemaType
|
|
893
886
|
}), { syntheticTasks, addSyntheticTask, removeSyntheticTask } = useSyntheticTasks(assistableDocumentId);
|
|
894
|
-
return useMemo(() => {
|
|
887
|
+
return react.useMemo(() => {
|
|
895
888
|
const base = {
|
|
896
889
|
assistableDocumentId,
|
|
897
890
|
documentSchemaType,
|
|
@@ -932,12 +925,12 @@ function useAssistDocumentContextValue(documentId, documentType) {
|
|
|
932
925
|
]);
|
|
933
926
|
}
|
|
934
927
|
function useSyntheticTasks(assistableDocumentId) {
|
|
935
|
-
const [syntheticTasks, setSyntheticTasks] = useState(() => []), addSyntheticTask = useCallback((task) => {
|
|
928
|
+
const [syntheticTasks, setSyntheticTasks] = react.useState(() => []), addSyntheticTask = react.useCallback((task) => {
|
|
936
929
|
setSyntheticTasks((current) => [...current, task]);
|
|
937
|
-
}, []), removeSyntheticTask = useCallback((task) => {
|
|
930
|
+
}, []), removeSyntheticTask = react.useCallback((task) => {
|
|
938
931
|
setSyntheticTasks((current) => current.filter((t) => task._key !== t._key));
|
|
939
932
|
}, []);
|
|
940
|
-
return useEffect(() => {
|
|
933
|
+
return react.useEffect(() => {
|
|
941
934
|
setSyntheticTasks([]);
|
|
942
935
|
}, [assistableDocumentId]), {
|
|
943
936
|
syntheticTasks,
|
|
@@ -947,52 +940,52 @@ function useSyntheticTasks(assistableDocumentId) {
|
|
|
947
940
|
}
|
|
948
941
|
function AssistDocumentContextProvider(props) {
|
|
949
942
|
const { documentId, documentType } = props, value = useAssistDocumentContextValue(documentId, documentType);
|
|
950
|
-
return /* @__PURE__ */ jsx(AssistDocumentContext.Provider, { value, children: props.children });
|
|
943
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentContext.Provider, { value, children: props.children });
|
|
951
944
|
}
|
|
952
945
|
function AssistDocumentLayout(props) {
|
|
953
946
|
const { documentId, documentType } = props;
|
|
954
|
-
return /* @__PURE__ */ jsx(AssistDocumentContextProvider, { documentType, documentId, children: props.renderDefault(props) });
|
|
947
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentContextProvider, { documentType, documentId, children: props.renderDefault(props) });
|
|
955
948
|
}
|
|
956
949
|
function AssistFeatureBadge() {
|
|
957
|
-
return /* @__PURE__ */ jsx(Badge, { fontSize: 0, style: { margin: "-2px 0" }, tone: "primary", children: "Beta" });
|
|
950
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { fontSize: 0, style: { margin: "-2px 0" }, tone: "primary", children: "Beta" });
|
|
958
951
|
}
|
|
959
952
|
function AssistOnboardingPopover(props) {
|
|
960
953
|
const { dismiss } = props;
|
|
961
|
-
return /* @__PURE__ */ jsx(
|
|
962
|
-
Popover,
|
|
954
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
955
|
+
ui.Popover,
|
|
963
956
|
{
|
|
964
|
-
content: /* @__PURE__ */ jsx(AssistIntroCard, { dismiss }),
|
|
957
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(AssistIntroCard, { dismiss }),
|
|
965
958
|
open: !0,
|
|
966
959
|
portal: !0,
|
|
967
960
|
placeholder: "bottom",
|
|
968
961
|
tone: "default",
|
|
969
962
|
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 }) })
|
|
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 }) })
|
|
971
964
|
}
|
|
972
965
|
);
|
|
973
966
|
}
|
|
974
967
|
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, {}) })
|
|
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, {}) })
|
|
981
974
|
] }),
|
|
982
|
-
/* @__PURE__ */ jsx(Stack, { space: 3, children: /* @__PURE__ */ jsxs(Text, { as: "p", muted: !0, size: 1, children: [
|
|
975
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "p", muted: !0, size: 1, children: [
|
|
983
976
|
"Manage reusable AI instructions to boost your content creation and reduce amount of repetitive chores.",
|
|
984
977
|
" ",
|
|
985
|
-
/* @__PURE__ */ jsxs("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: [
|
|
978
|
+
/* @__PURE__ */ jsxRuntime.jsxs("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: [
|
|
986
979
|
"Learn more ",
|
|
987
|
-
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
980
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRightIcon, {})
|
|
988
981
|
] })
|
|
989
982
|
] }) })
|
|
990
983
|
] }),
|
|
991
|
-
/* @__PURE__ */ jsx(
|
|
992
|
-
Button,
|
|
984
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
985
|
+
ui.Button,
|
|
993
986
|
{
|
|
994
987
|
fontSize: 1,
|
|
995
|
-
icon: CheckmarkIcon,
|
|
988
|
+
icon: icons.CheckmarkIcon,
|
|
996
989
|
onClick: props.dismiss,
|
|
997
990
|
padding: 3,
|
|
998
991
|
ref: buttonRef,
|
|
@@ -1010,14 +1003,14 @@ function dismissFeatureOnboarding(featureKey) {
|
|
|
1010
1003
|
typeof localStorage > "u" || localStorage.setItem(featureKey, "true");
|
|
1011
1004
|
}
|
|
1012
1005
|
function useOnboardingFeature(featureKey) {
|
|
1013
|
-
const [showOnboarding, setShowOnboarding] = useState(
|
|
1006
|
+
const [showOnboarding, setShowOnboarding] = react.useState(
|
|
1014
1007
|
() => !isFeatureOnboardingDismissed(featureKey)
|
|
1015
|
-
), dismissOnboarding = useCallback(() => {
|
|
1008
|
+
), dismissOnboarding = react.useCallback(() => {
|
|
1016
1009
|
setShowOnboarding(!1), dismissFeatureOnboarding(featureKey);
|
|
1017
1010
|
}, [setShowOnboarding, featureKey]);
|
|
1018
1011
|
return { showOnboarding, dismissOnboarding };
|
|
1019
1012
|
}
|
|
1020
|
-
const fadeIn = keyframes`
|
|
1013
|
+
const fadeIn = styledComponents.keyframes`
|
|
1021
1014
|
0% {
|
|
1022
1015
|
opacity: 0;
|
|
1023
1016
|
transform: scale(0.75);
|
|
@@ -1030,14 +1023,14 @@ const fadeIn = keyframes`
|
|
|
1030
1023
|
opacity: 1;
|
|
1031
1024
|
transform: scale(1);
|
|
1032
1025
|
}
|
|
1033
|
-
`, FadeInDiv = styled.div`
|
|
1026
|
+
`, FadeInDiv = styledComponents.styled.div`
|
|
1034
1027
|
animation-name: ${fadeIn};
|
|
1035
1028
|
animation-timing-function: ease-in-out;
|
|
1036
|
-
`, FadeInContent = forwardRef(function({
|
|
1029
|
+
`, FadeInContent = react.forwardRef(function({
|
|
1037
1030
|
children,
|
|
1038
1031
|
durationMs = 250
|
|
1039
1032
|
}, ref) {
|
|
1040
|
-
return /* @__PURE__ */ jsx(FadeInDiv, { ref, style: { animationDuration: `${durationMs}ms` }, children });
|
|
1033
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FadeInDiv, { ref, style: { animationDuration: `${durationMs}ms` }, children });
|
|
1041
1034
|
}), purple = {
|
|
1042
1035
|
400: {
|
|
1043
1036
|
hex: "#b087f7"
|
|
@@ -1048,19 +1041,19 @@ const fadeIn = keyframes`
|
|
|
1048
1041
|
600: {
|
|
1049
1042
|
hex: "#721fe5"
|
|
1050
1043
|
}
|
|
1051
|
-
}, Root = styled.span`
|
|
1044
|
+
}, Root = styledComponents.styled.span`
|
|
1052
1045
|
display: block;
|
|
1053
1046
|
width: 25px;
|
|
1054
1047
|
height: 25px;
|
|
1055
1048
|
position: relative;
|
|
1056
|
-
`, dash = keyframes`
|
|
1049
|
+
`, dash = styledComponents.keyframes`
|
|
1057
1050
|
0% {
|
|
1058
1051
|
transform: rotate(0);
|
|
1059
1052
|
}
|
|
1060
1053
|
100% {
|
|
1061
1054
|
transform: rotate(43deg);
|
|
1062
1055
|
}
|
|
1063
|
-
`, Outline = styled.svg`
|
|
1056
|
+
`, Outline = styledComponents.styled.svg`
|
|
1064
1057
|
display: block;
|
|
1065
1058
|
position: absolute;
|
|
1066
1059
|
top: 0;
|
|
@@ -1080,7 +1073,7 @@ const fadeIn = keyframes`
|
|
|
1080
1073
|
stroke-dasharray: 2px 2.34px;
|
|
1081
1074
|
}
|
|
1082
1075
|
}
|
|
1083
|
-
`, IconDisc = styled.span`
|
|
1076
|
+
`, IconDisc = styledComponents.styled.span`
|
|
1084
1077
|
background: var(--ai-avatar-disc-color);
|
|
1085
1078
|
color: white;
|
|
1086
1079
|
width: 21px;
|
|
@@ -1094,15 +1087,15 @@ const fadeIn = keyframes`
|
|
|
1094
1087
|
left: 2px;
|
|
1095
1088
|
`;
|
|
1096
1089
|
function AssistAvatar(props) {
|
|
1097
|
-
const { state = "present" } = props, scheme = useColorSchemeValue(), style = useMemo(() => scheme === "dark" ? {
|
|
1090
|
+
const { state = "present" } = props, scheme = sanity.useColorSchemeValue(), style = react.useMemo(() => scheme === "dark" ? {
|
|
1098
1091
|
"--ai-avatar-stroke-color": purple[400].hex,
|
|
1099
1092
|
"--ai-avatar-disc-color": purple[600].hex
|
|
1100
1093
|
} : {
|
|
1101
1094
|
"--ai-avatar-stroke-color": purple[500].hex,
|
|
1102
1095
|
"--ai-avatar-disc-color": purple[600].hex
|
|
1103
1096
|
}, [scheme]);
|
|
1104
|
-
return /* @__PURE__ */ jsxs(Root, { "data-state": state, style, children: [
|
|
1105
|
-
/* @__PURE__ */ jsx(
|
|
1097
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Root, { "data-state": state, style, children: [
|
|
1098
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1106
1099
|
Outline,
|
|
1107
1100
|
{
|
|
1108
1101
|
width: "25",
|
|
@@ -1110,35 +1103,35 @@ function AssistAvatar(props) {
|
|
|
1110
1103
|
viewBox: "0 0 25 25",
|
|
1111
1104
|
fill: "none",
|
|
1112
1105
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1113
|
-
children: /* @__PURE__ */ jsx("circle", { cx: "12.5", cy: "12.5", r: "11.75" })
|
|
1106
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12.5", cy: "12.5", r: "11.75" })
|
|
1114
1107
|
}
|
|
1115
1108
|
),
|
|
1116
|
-
/* @__PURE__ */ jsx(IconDisc, { children: /* @__PURE__ */ jsx(Text, { as: "span", size: 0, style: { color: "inherit" }, children: /* @__PURE__ */ jsx(SparklesIcon, { style: { color: "inherit" } }) }) })
|
|
1109
|
+
/* @__PURE__ */ jsxRuntime.jsx(IconDisc, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "span", size: 0, style: { color: "inherit" }, children: /* @__PURE__ */ jsxRuntime.jsx(icons.SparklesIcon, { style: { color: "inherit" } }) }) })
|
|
1117
1110
|
] });
|
|
1118
1111
|
}
|
|
1119
1112
|
function AiFieldPresence(props) {
|
|
1120
|
-
return /* @__PURE__ */ jsx(Card, { style: { position: "relative", background: "transparent" }, contentEditable: !1, children: /* @__PURE__ */ jsx(
|
|
1121
|
-
Tooltip,
|
|
1113
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { style: { position: "relative", background: "transparent" }, contentEditable: !1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1114
|
+
ui.Tooltip,
|
|
1122
1115
|
{
|
|
1123
1116
|
placement: "left",
|
|
1124
|
-
content: /* @__PURE__ */ jsx(Card, { padding: 3, border: !0, children: /* @__PURE__ */ jsx(Flex, { align: "center", children: /* @__PURE__ */ jsx(Text, { size: 1, children: "Running instruction..." }) }) }),
|
|
1125
|
-
children: /* @__PURE__ */ jsx(FadeInContent, { durationMs: 300, children: /* @__PURE__ */ jsx(AssistAvatar, { state: "active" }) })
|
|
1117
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 3, border: !0, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Running instruction..." }) }) }),
|
|
1118
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(FadeInContent, { durationMs: 300, children: /* @__PURE__ */ jsxRuntime.jsx(AssistAvatar, { state: "active" }) })
|
|
1126
1119
|
}
|
|
1127
1120
|
) });
|
|
1128
1121
|
}
|
|
1129
1122
|
const NO_PRESENCE = [];
|
|
1130
1123
|
function useAssistPresence(path, showFocusWithin) {
|
|
1131
1124
|
const context = useAssistDocumentContext(), tasks = (context && "assistDocument" in context ? context.assistDocument : void 0)?.tasks;
|
|
1132
|
-
return useMemo(() => {
|
|
1125
|
+
return react.useMemo(() => {
|
|
1133
1126
|
const activePresence = tasks?.filter((task) => !task.ended)?.flatMap((task) => task.presence ?? [])?.filter(
|
|
1134
1127
|
(p) => p.started && (/* @__PURE__ */ new Date()).getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs
|
|
1135
1128
|
).filter((presence) => {
|
|
1136
1129
|
if (!presence.path || !path.length)
|
|
1137
1130
|
return !1;
|
|
1138
|
-
const statusPath = stringToPath(presence.path);
|
|
1131
|
+
const statusPath = sanity.stringToPath(presence.path);
|
|
1139
1132
|
return !showFocusWithin && statusPath.length !== path.length ? !1 : path.every((pathSegment, i) => {
|
|
1140
1133
|
const statusSegment = statusPath[i];
|
|
1141
|
-
return typeof pathSegment == "string" ? pathSegment === statusSegment : isKeySegment(pathSegment) && isKeySegment(statusSegment) ? pathSegment._key === statusSegment._key : !1;
|
|
1134
|
+
return typeof pathSegment == "string" ? pathSegment === statusSegment : sanity.isKeySegment(pathSegment) && sanity.isKeySegment(statusSegment) ? pathSegment._key === statusSegment._key : !1;
|
|
1142
1135
|
});
|
|
1143
1136
|
});
|
|
1144
1137
|
return activePresence?.length ? activePresence.map((status) => aiPresence(status, path)) : NO_PRESENCE;
|
|
@@ -1157,18 +1150,18 @@ function aiPresence(presence, path, title) {
|
|
|
1157
1150
|
}
|
|
1158
1151
|
function AssistFieldWrapper(props) {
|
|
1159
1152
|
const { schemaType } = props;
|
|
1160
|
-
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);
|
|
1153
|
+
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);
|
|
1161
1154
|
}
|
|
1162
1155
|
function AssistField(props) {
|
|
1163
|
-
const { path } = props, isPortableText = useMemo(
|
|
1164
|
-
() => !!(isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)),
|
|
1156
|
+
const { path } = props, isPortableText = react.useMemo(
|
|
1157
|
+
() => !!(sanity.isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)),
|
|
1165
1158
|
[props.schemaType]
|
|
1166
|
-
), presence = useAssistPresence(props.path, isPortableText), firstAssistedPath = useContext(FirstAssistedPathContext), isFirstAssisted = useMemo(
|
|
1167
|
-
() => pathToString(path) === firstAssistedPath,
|
|
1159
|
+
), presence = useAssistPresence(props.path, isPortableText), firstAssistedPath = react.useContext(FirstAssistedPathContext), isFirstAssisted = react.useMemo(
|
|
1160
|
+
() => sanity.pathToString(path) === firstAssistedPath,
|
|
1168
1161
|
[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 })
|
|
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 })
|
|
1172
1165
|
] });
|
|
1173
1166
|
return props.renderDefault({
|
|
1174
1167
|
...props,
|
|
@@ -1179,57 +1172,57 @@ function AssistField(props) {
|
|
|
1179
1172
|
__internal_slot: actions
|
|
1180
1173
|
});
|
|
1181
1174
|
}
|
|
1182
|
-
const WrapPreCard = styled(Card)`
|
|
1175
|
+
const WrapPreCard = styledComponents.styled(ui.Card)`
|
|
1183
1176
|
& pre {
|
|
1184
1177
|
white-space: pre-wrap !important;
|
|
1185
1178
|
}
|
|
1186
1179
|
`;
|
|
1187
1180
|
function SafeValueInput(props) {
|
|
1188
|
-
return /* @__PURE__ */ jsx(ErrorWrapper, { onChange: props.onChange, children: /* @__PURE__ */ jsx(PteValueFixer, { ...props }) });
|
|
1181
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ErrorWrapper, { onChange: props.onChange, children: /* @__PURE__ */ jsxRuntime.jsx(PteValueFixer, { ...props }) });
|
|
1189
1182
|
}
|
|
1190
1183
|
function ErrorWrapper(props) {
|
|
1191
|
-
const { onChange } = props, [error, setError] = useState(),
|
|
1184
|
+
const { onChange } = props, [error, setError] = react.useState(), catchError = react.useCallback((params) => {
|
|
1192
1185
|
setError(params.error);
|
|
1193
|
-
}, []), unsetValue = useCallback(() => {
|
|
1194
|
-
onChange(PatchEvent.from(unset())), setError(void 0);
|
|
1195
|
-
}, [onChange]), dismiss = useCallback(() => setError(void 0), []), catcher = /* @__PURE__ */ jsx(ErrorBoundary, { onCatch:
|
|
1196
|
-
return error ? /* @__PURE__ */ jsx(Card, { border: !0, tone: "critical", padding: 2, contentEditable: !1, children: /* @__PURE__ */ jsxs(Stack, { space: 3, children: [
|
|
1197
|
-
/* @__PURE__ */ jsx(Text, { muted: !0, weight: "semibold", children: "An error occurred." }),
|
|
1198
|
-
/* @__PURE__ */ jsx(WrapPreCard, { flex: 1, padding: 2, tone: "critical", border: !0, children: catcher }),
|
|
1199
|
-
/* @__PURE__ */ jsxs(Flex, { width: "fill", flex: 1, gap: 3, children: [
|
|
1200
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(Button, { text: "Dismiss", onClick: dismiss, tone: "primary" }) }),
|
|
1201
|
-
/* @__PURE__ */ jsx(Button, { text: "Unset value", onClick: unsetValue, tone: "critical" })
|
|
1186
|
+
}, []), unsetValue = react.useCallback(() => {
|
|
1187
|
+
onChange(sanity.PatchEvent.from(sanity.unset())), setError(void 0);
|
|
1188
|
+
}, [onChange]), dismiss = react.useCallback(() => setError(void 0), []), catcher = /* @__PURE__ */ jsxRuntime.jsx(ui.ErrorBoundary, { onCatch: catchError, children: props.children });
|
|
1189
|
+
return error ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, tone: "critical", padding: 2, contentEditable: !1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
1190
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, weight: "semibold", children: "An error occurred." }),
|
|
1191
|
+
/* @__PURE__ */ jsxRuntime.jsx(WrapPreCard, { flex: 1, padding: 2, tone: "critical", border: !0, children: catcher }),
|
|
1192
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "fill", flex: 1, gap: 3, children: [
|
|
1193
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Dismiss", onClick: dismiss, tone: "primary" }) }),
|
|
1194
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Unset value", onClick: unsetValue, tone: "critical" })
|
|
1202
1195
|
] })
|
|
1203
1196
|
] }) }) : catcher;
|
|
1204
1197
|
}
|
|
1205
1198
|
function PteValueFixer(props) {
|
|
1206
|
-
const isPortableText = useMemo(
|
|
1207
|
-
() => isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType),
|
|
1199
|
+
const isPortableText = react.useMemo(
|
|
1200
|
+
() => sanity.isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType),
|
|
1208
1201
|
[props.schemaType]
|
|
1209
1202
|
), value = props.value;
|
|
1210
1203
|
return isPortableText && value && !value.length ? props.renderDefault({ ...props, value: void 0 }) : props.renderDefault(props);
|
|
1211
1204
|
}
|
|
1212
1205
|
function AssistFormBlock(props) {
|
|
1213
|
-
const presence = useAssistPresence(props.path, !0), { onChange } = useFormCallbacks(), key = props.value._key, localOnChange = useCallback(
|
|
1206
|
+
const presence = useAssistPresence(props.path, !0), { onChange } = sanity.useFormCallbacks(), key = props.value._key, localOnChange = react.useCallback(
|
|
1214
1207
|
(patchEvent) => {
|
|
1215
|
-
key && onChange(PatchEvent.from(patchEvent).prefixAll({ _key: key }));
|
|
1208
|
+
key && onChange(sanity.PatchEvent.from(patchEvent).prefixAll({ _key: key }));
|
|
1216
1209
|
},
|
|
1217
1210
|
[onChange, key]
|
|
1218
1211
|
), singlePresence = presence[0];
|
|
1219
|
-
return /* @__PURE__ */ jsx(ErrorWrapper, { onChange: localOnChange, children: /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "space-between", children: [
|
|
1220
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, children: props.renderDefault(props) }),
|
|
1221
|
-
singlePresence && /* @__PURE__ */ jsx(AiFieldPresence, { presence: singlePresence })
|
|
1212
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ErrorWrapper, { onChange: localOnChange, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
|
|
1213
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: props.renderDefault(props) }),
|
|
1214
|
+
singlePresence && /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: singlePresence })
|
|
1222
1215
|
] }) });
|
|
1223
1216
|
}
|
|
1224
|
-
const InlineBlockValueContext = createContext(void 0);
|
|
1217
|
+
const InlineBlockValueContext = react.createContext(void 0);
|
|
1225
1218
|
function AssistInlineFormBlock(props) {
|
|
1226
|
-
return /* @__PURE__ */ jsx(InlineBlockValueContext.Provider, { value: props.value, children: /* @__PURE__ */ jsx(Fragment, { children: props.renderDefault(props) }) });
|
|
1219
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InlineBlockValueContext.Provider, { value: props.value, children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.renderDefault(props) }) });
|
|
1227
1220
|
}
|
|
1228
1221
|
function AssistItem(props) {
|
|
1229
1222
|
const { path } = props, presence = useAssistPresence(path, !0);
|
|
1230
|
-
return /* @__PURE__ */ jsxs(Flex, { align: "center", width: "fill", style: { position: "relative" }, children: [
|
|
1231
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, children: props.renderDefault({ ...props }) }),
|
|
1232
|
-
presence.map((pre) => /* @__PURE__ */ jsx(Box, { style: { position: "absolute", right: 35 }, children: /* @__PURE__ */ jsx(AiFieldPresence, { presence: pre }) }, pre.user.id))
|
|
1223
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", width: "fill", style: { position: "relative" }, children: [
|
|
1224
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: props.renderDefault({ ...props }) }),
|
|
1225
|
+
presence.map((pre) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { position: "absolute", right: 35 }, children: /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: pre }) }, pre.user.id))
|
|
1233
1226
|
] });
|
|
1234
1227
|
}
|
|
1235
1228
|
const preventDefault = (ev) => ev.preventDefault();
|
|
@@ -1251,10 +1244,10 @@ function DocumentForm(props) {
|
|
|
1251
1244
|
onSetCollapsedPath,
|
|
1252
1245
|
ready,
|
|
1253
1246
|
validation
|
|
1254
|
-
} = useDocumentPane(), documentStore = useDocumentStore(), presence = useDocumentPresence(documentId), patchChannel = useMemo(() => createPatchChannel(), []), isLocked = editState?.transactionSyncLock?.enabled;
|
|
1255
|
-
useEffect(() => {
|
|
1247
|
+
} = structure.useDocumentPane(), documentStore = sanity.useDocumentStore(), presence = sanity.useDocumentPresence(documentId), patchChannel = react.useMemo(() => sanity.createPatchChannel(), []), isLocked = editState?.transactionSyncLock?.enabled;
|
|
1248
|
+
react.useEffect(() => {
|
|
1256
1249
|
const sub = documentStore.pair.documentEvents(documentId, documentType).pipe(
|
|
1257
|
-
tap((event) => {
|
|
1250
|
+
operators.tap((event) => {
|
|
1258
1251
|
event.type === "mutation" && patchChannel.publish(prepareMutationEvent(event)), event.type === "rebase" && patchChannel.publish(prepareRebaseEvent(event));
|
|
1259
1252
|
})
|
|
1260
1253
|
).subscribe();
|
|
@@ -1263,18 +1256,18 @@ function DocumentForm(props) {
|
|
|
1263
1256
|
};
|
|
1264
1257
|
}, [documentId, documentStore, documentType, patchChannel]);
|
|
1265
1258
|
const hasRev = !!value?._rev;
|
|
1266
|
-
useEffect(() => {
|
|
1259
|
+
react.useEffect(() => {
|
|
1267
1260
|
hasRev && patchChannel.publish({
|
|
1268
1261
|
type: "mutation",
|
|
1269
1262
|
patches: [],
|
|
1270
1263
|
snapshot: value
|
|
1271
1264
|
});
|
|
1272
1265
|
}, [hasRev]);
|
|
1273
|
-
const formRef = useRef(null);
|
|
1274
|
-
return useEffect(() => {
|
|
1275
|
-
focusFirstDescendant(formRef.current);
|
|
1276
|
-
}, []), isLocked ? /* @__PURE__ */ jsx(Box, { as: "form", ...props, ref: formRef, children: /* @__PURE__ */ jsx(
|
|
1277
|
-
Flex,
|
|
1266
|
+
const formRef = react.useRef(null);
|
|
1267
|
+
return react.useEffect(() => {
|
|
1268
|
+
ui.focusFirstDescendant(formRef.current);
|
|
1269
|
+
}, []), isLocked ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { as: "form", ...props, ref: formRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1270
|
+
ui.Flex,
|
|
1278
1271
|
{
|
|
1279
1272
|
align: "center",
|
|
1280
1273
|
direction: "column",
|
|
@@ -1282,10 +1275,10 @@ function DocumentForm(props) {
|
|
|
1282
1275
|
justify: "center",
|
|
1283
1276
|
padding: 3,
|
|
1284
1277
|
sizing: "border",
|
|
1285
|
-
children: /* @__PURE__ */ jsx(Text, { size: 1, children: "Please hold tight while the document is synced. This usually happens right after the document has been published, and it shouldn\u2019t take more than a few seconds" })
|
|
1278
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Please hold tight while the document is synced. This usually happens right after the document has been published, and it shouldn\u2019t take more than a few seconds" })
|
|
1286
1279
|
}
|
|
1287
|
-
) }) : /* @__PURE__ */ jsx(Box, { as: "form", ...props, onSubmit: preventDefault, ref: formRef, children: ready ? formState === null ? /* @__PURE__ */ jsx(
|
|
1288
|
-
Flex,
|
|
1280
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { as: "form", ...props, onSubmit: preventDefault, ref: formRef, children: ready ? formState === null ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1281
|
+
ui.Flex,
|
|
1289
1282
|
{
|
|
1290
1283
|
align: "center",
|
|
1291
1284
|
direction: "column",
|
|
@@ -1293,10 +1286,10 @@ function DocumentForm(props) {
|
|
|
1293
1286
|
justify: "center",
|
|
1294
1287
|
padding: 3,
|
|
1295
1288
|
sizing: "border",
|
|
1296
|
-
children: /* @__PURE__ */ jsx(Text, { size: 1, children: "This form is hidden" })
|
|
1289
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "This form is hidden" })
|
|
1297
1290
|
}
|
|
1298
|
-
) : /* @__PURE__ */ jsx(
|
|
1299
|
-
FormBuilder,
|
|
1291
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1292
|
+
sanity.FormBuilder,
|
|
1300
1293
|
{
|
|
1301
1294
|
__internal_patchChannel: patchChannel,
|
|
1302
1295
|
collapsedFieldSets,
|
|
@@ -1318,10 +1311,11 @@ function DocumentForm(props) {
|
|
|
1318
1311
|
readOnly: formState.readOnly,
|
|
1319
1312
|
schemaType: formState.schemaType,
|
|
1320
1313
|
validation,
|
|
1321
|
-
value: formState.value
|
|
1314
|
+
value: formState.value,
|
|
1315
|
+
hasUpstreamVersion: !1
|
|
1322
1316
|
}
|
|
1323
|
-
) : /* @__PURE__ */ jsxs(
|
|
1324
|
-
Flex,
|
|
1317
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1318
|
+
ui.Flex,
|
|
1325
1319
|
{
|
|
1326
1320
|
align: "center",
|
|
1327
1321
|
direction: "column",
|
|
@@ -1330,8 +1324,8 @@ function DocumentForm(props) {
|
|
|
1330
1324
|
padding: 3,
|
|
1331
1325
|
sizing: "border",
|
|
1332
1326
|
children: [
|
|
1333
|
-
/* @__PURE__ */ jsx(Spinner, { muted: !0 }),
|
|
1334
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 3, children: /* @__PURE__ */ jsx(Text, { align: "center", muted: !0, size: 1, children: "Loading document" }) })
|
|
1327
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { muted: !0 }),
|
|
1328
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { align: "center", muted: !0, size: 1, children: "Loading document" }) })
|
|
1335
1329
|
]
|
|
1336
1330
|
}
|
|
1337
1331
|
) });
|
|
@@ -1341,7 +1335,7 @@ function prepareMutationEvent(event) {
|
|
|
1341
1335
|
return {
|
|
1342
1336
|
type: "mutation",
|
|
1343
1337
|
snapshot: event.document,
|
|
1344
|
-
patches: fromMutationPatches(event.origin, patches)
|
|
1338
|
+
patches: sanity.fromMutationPatches(event.origin, patches)
|
|
1345
1339
|
};
|
|
1346
1340
|
}
|
|
1347
1341
|
function prepareRebaseEvent(event) {
|
|
@@ -1349,12 +1343,12 @@ function prepareRebaseEvent(event) {
|
|
|
1349
1343
|
return {
|
|
1350
1344
|
type: "rebase",
|
|
1351
1345
|
snapshot: event.document,
|
|
1352
|
-
patches: fromMutationPatches("remote", remotePatches).concat(
|
|
1353
|
-
fromMutationPatches("local", localPatches)
|
|
1346
|
+
patches: sanity.fromMutationPatches("remote", remotePatches).concat(
|
|
1347
|
+
sanity.fromMutationPatches("local", localPatches)
|
|
1354
1348
|
)
|
|
1355
1349
|
};
|
|
1356
1350
|
}
|
|
1357
|
-
const AssistTypeContext = createContext({}), DEFAULT_MAX_DEPTH$1 = 8, ABSOLUTE_MAX_DEPTH$1 = 50;
|
|
1351
|
+
const AssistTypeContext = react.createContext({}), DEFAULT_MAX_DEPTH$1 = 8, ABSOLUTE_MAX_DEPTH$1 = 50;
|
|
1358
1352
|
function getConditionalMembers(docState, maxDepth2 = DEFAULT_MAX_DEPTH$1) {
|
|
1359
1353
|
return [{
|
|
1360
1354
|
path: "",
|
|
@@ -1368,7 +1362,7 @@ function isConditional(schemaType) {
|
|
|
1368
1362
|
}
|
|
1369
1363
|
function conditionalState(memberState) {
|
|
1370
1364
|
return {
|
|
1371
|
-
path: pathToString(memberState.path),
|
|
1365
|
+
path: sanity.pathToString(memberState.path),
|
|
1372
1366
|
readOnly: !!memberState.readOnly,
|
|
1373
1367
|
// Use actual form state readOnly value
|
|
1374
1368
|
hidden: !1,
|
|
@@ -1389,7 +1383,7 @@ function extractConditionalPaths(node, maxDepth2) {
|
|
|
1389
1383
|
const array = member.field;
|
|
1390
1384
|
let arrayPaths = [];
|
|
1391
1385
|
const isObjectsArray = array.members.some(
|
|
1392
|
-
(m) => m.kind === "item" && isObjectSchemaType(m.item.schemaType)
|
|
1386
|
+
(m) => m.kind === "item" && sanity.isObjectSchemaType(m.item.schemaType)
|
|
1393
1387
|
);
|
|
1394
1388
|
if (!array.readOnly)
|
|
1395
1389
|
for (const arrayMember of array.members) {
|
|
@@ -1414,7 +1408,7 @@ function extractConditionalPaths(node, maxDepth2) {
|
|
|
1414
1408
|
return acc;
|
|
1415
1409
|
}, []);
|
|
1416
1410
|
}
|
|
1417
|
-
const SparklesIllustration = styled(SparklesIcon)({
|
|
1411
|
+
const SparklesIllustration = styledComponents.styled(icons.SparklesIcon)({
|
|
1418
1412
|
fontSize: "3.125em",
|
|
1419
1413
|
"& path": {
|
|
1420
1414
|
strokeWidth: "0.6px !important"
|
|
@@ -1422,12 +1416,12 @@ const SparklesIllustration = styled(SparklesIcon)({
|
|
|
1422
1416
|
});
|
|
1423
1417
|
function InspectorOnboarding(props) {
|
|
1424
1418
|
const { onDismiss } = props;
|
|
1425
|
-
return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Container, { width: 0, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
1426
|
-
/* @__PURE__ */ jsx("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(SparklesIllustration, {}) }),
|
|
1427
|
-
/* @__PURE__ */ jsx(Text, { align: "center", size: 1, children: "Create reusable AI instructions that can be applied across all documents of a certain type." }),
|
|
1428
|
-
/* @__PURE__ */ jsxs(Flex, { align: "center", gap: 2, justify: "center", children: [
|
|
1429
|
-
/* @__PURE__ */ jsx(
|
|
1430
|
-
Button,
|
|
1419
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Container, { width: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
1420
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(SparklesIllustration, {}) }),
|
|
1421
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { align: "center", size: 1, children: "Create reusable AI instructions that can be applied across all documents of a certain type." }),
|
|
1422
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, justify: "center", children: [
|
|
1423
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1424
|
+
ui.Button,
|
|
1431
1425
|
{
|
|
1432
1426
|
as: "a",
|
|
1433
1427
|
href: releaseAnnouncementUrl,
|
|
@@ -1441,35 +1435,35 @@ function InspectorOnboarding(props) {
|
|
|
1441
1435
|
tone: "primary"
|
|
1442
1436
|
}
|
|
1443
1437
|
),
|
|
1444
|
-
/* @__PURE__ */ jsx(Button, { fontSize: 1, mode: "bleed", onClick: onDismiss, padding: 2, text: "Dismiss" })
|
|
1438
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { fontSize: 1, mode: "bleed", onClick: onDismiss, padding: 2, text: "Dismiss" })
|
|
1445
1439
|
] })
|
|
1446
1440
|
] }) }) });
|
|
1447
1441
|
}
|
|
1448
1442
|
function FieldAutocomplete(props) {
|
|
1449
|
-
const { id, schemaType, fieldPath, onSelect, includeDocument, filter
|
|
1443
|
+
const { id, schemaType, fieldPath, onSelect, includeDocument, filter } = props, { getFieldRefs: getFieldRefs2 } = useAiAssistanceConfig(), fieldRefs = react.useMemo(() => {
|
|
1450
1444
|
const refs = getFieldRefs2(schemaType.name);
|
|
1451
1445
|
return includeDocument ? [getDocumentFieldRef(schemaType), ...refs] : refs;
|
|
1452
|
-
}, [schemaType, includeDocument, getFieldRefs2]), currentField = useMemo(
|
|
1446
|
+
}, [schemaType, includeDocument, getFieldRefs2]), currentField = react.useMemo(
|
|
1453
1447
|
() => fieldRefs.find((f) => f.key === fieldPath),
|
|
1454
1448
|
[fieldPath, fieldRefs]
|
|
1455
|
-
), autocompleteOptions = useMemo(
|
|
1456
|
-
() => fieldRefs.filter((field) =>
|
|
1457
|
-
[fieldRefs,
|
|
1458
|
-
), renderOption = useCallback((option) => {
|
|
1449
|
+
), autocompleteOptions = react.useMemo(
|
|
1450
|
+
() => fieldRefs.filter((field) => filter ? filter(field) : !0).filter((f) => !isType(f.schemaType, "reference")).map((field) => ({ value: field.key, field })),
|
|
1451
|
+
[fieldRefs, filter]
|
|
1452
|
+
), renderOption = react.useCallback((option) => {
|
|
1459
1453
|
const { value, field } = option;
|
|
1460
|
-
return value ? isType(field.schemaType, "document") ? /* @__PURE__ */ jsx(Card, { as: "button", padding: 3, radius: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: "The entire document" }) }) : /* @__PURE__ */ jsx(Card, { as: "button", padding: 3, radius: 1, children: /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
|
|
1461
|
-
/* @__PURE__ */ jsx(Text, { size: 1, children: createElement(field.icon) }),
|
|
1462
|
-
/* @__PURE__ */ jsx(FieldTitle, { field })
|
|
1463
|
-
] }) }) : /* @__PURE__ */ jsx(Card, { as: "button", padding: 3, radius: 1, children: /* @__PURE__ */ jsx(Text, { accent: !0, size: 1, children: option.value }) });
|
|
1464
|
-
}, []), renderValue = useCallback((value, option) => option?.field.title ?? value, []), filterOption = useCallback((query, option) => {
|
|
1454
|
+
return value ? isType(field.schemaType, "document") ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: "button", padding: 3, radius: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: "The entire document" }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: "button", padding: 3, radius: 1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, children: [
|
|
1455
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: react.createElement(field.icon) }),
|
|
1456
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldTitle, { field })
|
|
1457
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: "button", padding: 3, radius: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { accent: !0, size: 1, children: option.value }) });
|
|
1458
|
+
}, []), renderValue = react.useCallback((value, option) => option?.field.title ?? value, []), filterOption = react.useCallback((query, option) => {
|
|
1465
1459
|
const lQuery = query.toLowerCase();
|
|
1466
1460
|
return option?.value?.toLowerCase().includes(lQuery) || option?.field?.title?.toLowerCase().includes(lQuery);
|
|
1467
1461
|
}, []);
|
|
1468
|
-
return /* @__PURE__ */ jsx(
|
|
1469
|
-
Autocomplete,
|
|
1462
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1463
|
+
ui.Autocomplete,
|
|
1470
1464
|
{
|
|
1471
1465
|
fontSize: 1,
|
|
1472
|
-
icon: currentField ? currentField.icon : SearchIcon,
|
|
1466
|
+
icon: currentField ? currentField.icon : icons.SearchIcon,
|
|
1473
1467
|
onChange: onSelect,
|
|
1474
1468
|
openButton: !0,
|
|
1475
1469
|
id,
|
|
@@ -1485,8 +1479,8 @@ function FieldAutocomplete(props) {
|
|
|
1485
1479
|
}
|
|
1486
1480
|
function FieldTitle(props) {
|
|
1487
1481
|
const splitTitle = props.field.title.split("/");
|
|
1488
|
-
return /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsxs(
|
|
1489
|
-
Breadcrumbs,
|
|
1482
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1483
|
+
ui.Breadcrumbs,
|
|
1490
1484
|
{
|
|
1491
1485
|
style: {
|
|
1492
1486
|
display: "flex",
|
|
@@ -1494,77 +1488,77 @@ function FieldTitle(props) {
|
|
|
1494
1488
|
alignItems: "center",
|
|
1495
1489
|
marginTop: "-4px"
|
|
1496
1490
|
},
|
|
1497
|
-
separator: /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "/" }) }),
|
|
1491
|
+
separator: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "/" }) }),
|
|
1498
1492
|
space: 1,
|
|
1499
1493
|
children: [
|
|
1500
1494
|
splitTitle.slice(0, splitTitle.length - 1).map((pt, i) => (
|
|
1501
1495
|
// eslint-disable-next-line react/no-array-index-key
|
|
1502
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: pt.trim() }) }, i)
|
|
1496
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: pt.trim() }) }, i)
|
|
1503
1497
|
)),
|
|
1504
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: splitTitle[splitTitle.length - 1] }) })
|
|
1498
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: splitTitle[splitTitle.length - 1] }) })
|
|
1505
1499
|
]
|
|
1506
1500
|
}
|
|
1507
1501
|
) });
|
|
1508
1502
|
}
|
|
1509
1503
|
function useInterval(ms) {
|
|
1510
|
-
const [tick, update] = useReducer((n) => n + 1, 0);
|
|
1511
|
-
return useEffect(() => {
|
|
1504
|
+
const [tick, update] = react.useReducer((n) => n + 1, 0);
|
|
1505
|
+
return react.useEffect(() => {
|
|
1512
1506
|
const i = setInterval(update, ms);
|
|
1513
1507
|
return () => clearInterval(i);
|
|
1514
1508
|
}, [ms]), tick;
|
|
1515
1509
|
}
|
|
1516
1510
|
function TimeAgo({ date }) {
|
|
1517
1511
|
useInterval(1e3);
|
|
1518
|
-
const timeSince = formatDistanceToNow(date ? new Date(date) : /* @__PURE__ */ new Date());
|
|
1519
|
-
return /* @__PURE__ */ jsxs("span", { title: timeSince, children: [
|
|
1512
|
+
const timeSince = dateFns.formatDistanceToNow(date ? new Date(date) : /* @__PURE__ */ new Date());
|
|
1513
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { title: timeSince, children: [
|
|
1520
1514
|
timeSince,
|
|
1521
1515
|
" ago"
|
|
1522
1516
|
] });
|
|
1523
1517
|
}
|
|
1524
|
-
const rotate = keyframes`
|
|
1518
|
+
const rotate = styledComponents.keyframes`
|
|
1525
1519
|
0% {
|
|
1526
1520
|
transform: rotate(0);
|
|
1527
1521
|
}
|
|
1528
1522
|
100% {
|
|
1529
1523
|
transform: rotate(360deg);
|
|
1530
1524
|
}
|
|
1531
|
-
`, SyncSpinningIcon = styled(SyncIcon)`
|
|
1525
|
+
`, SyncSpinningIcon = styledComponents.styled(icons.SyncIcon)`
|
|
1532
1526
|
animation: ${rotate} 1s linear infinite;
|
|
1533
1527
|
`, TASK_CONFIG = {
|
|
1534
1528
|
aborted: {
|
|
1535
1529
|
title: "Canceled",
|
|
1536
|
-
icon: CloseCircleIcon,
|
|
1530
|
+
icon: icons.CloseCircleIcon,
|
|
1537
1531
|
tone: "transparent"
|
|
1538
1532
|
},
|
|
1539
1533
|
error: {
|
|
1540
1534
|
title: "Error",
|
|
1541
|
-
icon: ErrorOutlineIcon,
|
|
1535
|
+
icon: icons.ErrorOutlineIcon,
|
|
1542
1536
|
tone: "critical"
|
|
1543
1537
|
},
|
|
1544
1538
|
success: {
|
|
1545
1539
|
title: "Completed",
|
|
1546
|
-
icon: CheckmarkCircleIcon,
|
|
1540
|
+
icon: icons.CheckmarkCircleIcon,
|
|
1547
1541
|
tone: "positive"
|
|
1548
1542
|
},
|
|
1549
1543
|
timeout: {
|
|
1550
1544
|
title: "Timeout",
|
|
1551
|
-
icon: ClockIcon,
|
|
1545
|
+
icon: icons.ClockIcon,
|
|
1552
1546
|
tone: "caution"
|
|
1553
1547
|
}
|
|
1554
1548
|
};
|
|
1555
1549
|
function InstructionTaskHistoryButton(props) {
|
|
1556
|
-
const { tasks, instructions, documentId, showTitles } = props, client = useClient({ apiVersion: "2023-01-01" }), cancelRun = useCallback(
|
|
1550
|
+
const { tasks, instructions, documentId, showTitles } = props, client = sanity.useClient({ apiVersion: "2023-01-01" }), cancelRun = react.useCallback(
|
|
1557
1551
|
(taskKey) => {
|
|
1558
1552
|
if (!documentId)
|
|
1559
1553
|
return;
|
|
1560
|
-
const statusDocId = assistTasksStatusId(documentId), basePath2 = `${typed("tasks")}[_key=="${taskKey}"]`;
|
|
1554
|
+
const statusDocId = assistTasksStatusId(documentId), basePath2 = `${sanity.typed("tasks")}[_key=="${taskKey}"]`;
|
|
1561
1555
|
client.patch(statusDocId).set({
|
|
1562
|
-
[`${basePath2}.${typed("ended")}`]: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1563
|
-
[`${basePath2}.${typed("reason")}`]: typed("aborted")
|
|
1556
|
+
[`${basePath2}.${sanity.typed("ended")}`]: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1557
|
+
[`${basePath2}.${sanity.typed("reason")}`]: sanity.typed("aborted")
|
|
1564
1558
|
}).commit().catch(console.error);
|
|
1565
1559
|
},
|
|
1566
1560
|
[client, documentId]
|
|
1567
|
-
), titledTasks = useMemo(() => {
|
|
1561
|
+
), titledTasks = react.useMemo(() => {
|
|
1568
1562
|
const t = tasks?.filter(
|
|
1569
1563
|
(task) => task.started && (/* @__PURE__ */ new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs
|
|
1570
1564
|
).map((task) => {
|
|
@@ -1576,27 +1570,27 @@ function InstructionTaskHistoryButton(props) {
|
|
|
1576
1570
|
};
|
|
1577
1571
|
}) ?? [];
|
|
1578
1572
|
return t.sort((a, b) => new Date(b.started ?? "").getTime() - new Date(a.started ?? "").getTime()), t;
|
|
1579
|
-
}, [tasks, instructions, cancelRun, showTitles]), isRunning = useMemo(() => titledTasks.some((r) => !r.ended), [titledTasks]), hasErrors = useMemo(
|
|
1573
|
+
}, [tasks, instructions, cancelRun, showTitles]), isRunning = react.useMemo(() => titledTasks.some((r) => !r.ended), [titledTasks]), hasErrors = react.useMemo(
|
|
1580
1574
|
() => titledTasks.some((r) => r.reason === "error" || r.reason === "timeout"),
|
|
1581
1575
|
[titledTasks]
|
|
1582
|
-
), [open, setOpen] = useState(!1), toggleOpen = useCallback(() => setOpen((v) => !v), []), [button, setButton] = useState(null), [popover, setPopover] = useState(null), handleClickOutside = useCallback(() => {
|
|
1576
|
+
), [open, setOpen] = react.useState(!1), toggleOpen = react.useCallback(() => setOpen((v) => !v), []), [button, setButton] = react.useState(null), [popover, setPopover] = react.useState(null), handleClickOutside = react.useCallback(() => {
|
|
1583
1577
|
setOpen(!1);
|
|
1584
1578
|
}, []);
|
|
1585
|
-
useClickOutside(handleClickOutside, [button, popover]);
|
|
1586
|
-
const handleEscape = useCallback(() => {
|
|
1579
|
+
ui.useClickOutside(handleClickOutside, [button, popover]);
|
|
1580
|
+
const handleEscape = react.useCallback(() => {
|
|
1587
1581
|
setOpen(!1), button?.focus();
|
|
1588
1582
|
}, [button]);
|
|
1589
|
-
return /* @__PURE__ */ jsx(
|
|
1590
|
-
Popover,
|
|
1583
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1584
|
+
ui.Popover,
|
|
1591
1585
|
{
|
|
1592
1586
|
constrainSize: !0,
|
|
1593
|
-
content: /* @__PURE__ */ jsx(TaskList, { onEscape: handleEscape, tasks: titledTasks }),
|
|
1587
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(TaskList, { onEscape: handleEscape, tasks: titledTasks }),
|
|
1594
1588
|
open: open && !!titledTasks?.length,
|
|
1595
1589
|
placement: "top",
|
|
1596
1590
|
portal: !0,
|
|
1597
1591
|
ref: setPopover,
|
|
1598
1592
|
width: 0,
|
|
1599
|
-
children: /* @__PURE__ */ jsx(
|
|
1593
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1600
1594
|
TaskStatusButton,
|
|
1601
1595
|
{
|
|
1602
1596
|
disabled: !titledTasks?.length,
|
|
@@ -1612,14 +1606,14 @@ function InstructionTaskHistoryButton(props) {
|
|
|
1612
1606
|
}
|
|
1613
1607
|
const TASK_STATUS_BUTTON_TOOLTIP_PROPS = {
|
|
1614
1608
|
placement: "top"
|
|
1615
|
-
}, TaskStatusButton = forwardRef(function(props, ref) {
|
|
1609
|
+
}, TaskStatusButton = react.forwardRef(function(props, ref) {
|
|
1616
1610
|
const { disabled, hasErrors, isRunning, onClick, selected } = props;
|
|
1617
|
-
return /* @__PURE__ */ jsx(
|
|
1618
|
-
StatusButton,
|
|
1611
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1612
|
+
sanity.StatusButton,
|
|
1619
1613
|
{
|
|
1620
1614
|
label: `${pluginTitle} status`,
|
|
1621
1615
|
"aria-label": `${pluginTitle} status`,
|
|
1622
|
-
icon: isRunning ? SyncSpinningIcon : hasErrors ? ErrorOutlineIcon : CheckmarkCircleIcon,
|
|
1616
|
+
icon: isRunning ? SyncSpinningIcon : hasErrors ? icons.ErrorOutlineIcon : icons.CheckmarkCircleIcon,
|
|
1623
1617
|
mode: "bleed",
|
|
1624
1618
|
onClick,
|
|
1625
1619
|
tone: hasErrors ? "critical" : void 0,
|
|
@@ -1631,40 +1625,40 @@ const TASK_STATUS_BUTTON_TOOLTIP_PROPS = {
|
|
|
1631
1625
|
);
|
|
1632
1626
|
});
|
|
1633
1627
|
function TaskList(props) {
|
|
1634
|
-
const { onEscape, tasks } = props, { isTopLayer } = useLayer();
|
|
1635
|
-
return useGlobalKeyDown(
|
|
1636
|
-
useCallback(
|
|
1628
|
+
const { onEscape, tasks } = props, { isTopLayer } = ui.useLayer();
|
|
1629
|
+
return ui.useGlobalKeyDown(
|
|
1630
|
+
react.useCallback(
|
|
1637
1631
|
(event) => {
|
|
1638
1632
|
isTopLayer && event.key === "Escape" && onEscape();
|
|
1639
1633
|
},
|
|
1640
1634
|
[isTopLayer, onEscape]
|
|
1641
1635
|
)
|
|
1642
|
-
), /* @__PURE__ */ jsx(Stack, { padding: 1, space: 1, children: tasks.map((task) => /* @__PURE__ */ jsx(TaskItem, { task }, task._key)) });
|
|
1636
|
+
), /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { padding: 1, space: 1, children: tasks.map((task) => /* @__PURE__ */ jsxRuntime.jsx(TaskItem, { task }, task._key)) });
|
|
1643
1637
|
}
|
|
1644
1638
|
function TaskItem(props) {
|
|
1645
1639
|
const { task } = props, taskType = task.reason && TASK_CONFIG[task.reason];
|
|
1646
|
-
return /* @__PURE__ */ jsx(Card, { radius: 2, tone: taskType && taskType?.tone, children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: 1, children: [
|
|
1647
|
-
/* @__PURE__ */ jsxs(Flex, { align: "flex-start", flex: 1, gap: 3, padding: 3, children: [
|
|
1648
|
-
/* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsxs(Text, { size: 1, children: [
|
|
1649
|
-
taskType && createElement(taskType.icon),
|
|
1650
|
-
!task.reason && /* @__PURE__ */ jsx(Spinner, {})
|
|
1640
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 2, tone: taskType && taskType?.tone, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 1, children: [
|
|
1641
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "flex-start", flex: 1, gap: 3, padding: 3, children: [
|
|
1642
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, children: [
|
|
1643
|
+
taskType && react.createElement(taskType.icon),
|
|
1644
|
+
!task.reason && /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {})
|
|
1651
1645
|
] }) }),
|
|
1652
|
-
/* @__PURE__ */ jsxs(Stack, { flex: 1, space: 2, children: [
|
|
1653
|
-
/* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [
|
|
1646
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { flex: 1, space: 2, children: [
|
|
1647
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "medium", children: [
|
|
1654
1648
|
taskType ? taskType.title : "Running",
|
|
1655
|
-
task.title && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1649
|
+
task.title && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1656
1650
|
": ",
|
|
1657
1651
|
task.title
|
|
1658
1652
|
] })
|
|
1659
1653
|
] }),
|
|
1660
|
-
task.message ? /* @__PURE__ */ jsx(Text, { size: 1, children: task.message }) : null,
|
|
1661
|
-
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsx(TimeAgo, { date: task.ended ?? task.started }) })
|
|
1654
|
+
task.message ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: task.message }) : null,
|
|
1655
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(TimeAgo, { date: task.ended ?? task.started }) })
|
|
1662
1656
|
] })
|
|
1663
1657
|
] }),
|
|
1664
|
-
!task.ended && /* @__PURE__ */ jsx(Box, { flex: "none", padding: 1, children: /* @__PURE__ */ jsx(Button, { fontSize: 1, mode: "bleed", onClick: task.cancel, text: "Cancel" }) })
|
|
1658
|
+
!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" }) })
|
|
1665
1659
|
] }) });
|
|
1666
1660
|
}
|
|
1667
|
-
const CardWithShadowBelow = styled(Card)`
|
|
1661
|
+
const CardWithShadowBelow = styledComponents.styled(ui.Card)`
|
|
1668
1662
|
position: relative;
|
|
1669
1663
|
|
|
1670
1664
|
&:after {
|
|
@@ -1678,7 +1672,7 @@ const CardWithShadowBelow = styled(Card)`
|
|
|
1678
1672
|
opacity: 0.5;
|
|
1679
1673
|
z-index: 100;
|
|
1680
1674
|
}
|
|
1681
|
-
`, CardWithShadowAbove = styled(Card)`
|
|
1675
|
+
`, CardWithShadowAbove = styledComponents.styled(ui.Card)`
|
|
1682
1676
|
position: relative;
|
|
1683
1677
|
|
|
1684
1678
|
&:after {
|
|
@@ -1696,48 +1690,48 @@ const CardWithShadowBelow = styled(Card)`
|
|
|
1696
1690
|
function AssistInspectorWrapper(props) {
|
|
1697
1691
|
const context = useAiAssistanceConfig();
|
|
1698
1692
|
if (context.statusLoading)
|
|
1699
|
-
return /* @__PURE__ */ jsx(Flex, { align: "center", height: "fill", justify: "center", padding: 4, sizing: "border", children: /* @__PURE__ */ jsxs(Stack, { space: 3, style: { textAlign: "center" }, children: [
|
|
1700
|
-
/* @__PURE__ */ jsx(Spinner, { muted: !0 }),
|
|
1701
|
-
/* @__PURE__ */ jsxs(Text, { muted: !0, size: 1, children: [
|
|
1693
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", height: "fill", justify: "center", padding: 4, sizing: "border", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, style: { textAlign: "center" }, children: [
|
|
1694
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { muted: !0 }),
|
|
1695
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, size: 1, children: [
|
|
1702
1696
|
"Loading ",
|
|
1703
1697
|
pluginTitle,
|
|
1704
1698
|
"..."
|
|
1705
1699
|
] })
|
|
1706
1700
|
] }) });
|
|
1707
1701
|
const status = context.status;
|
|
1708
|
-
return status?.enabled ? !status?.initialized || !status.validToken ? /* @__PURE__ */ jsxs(Flex, { direction: "column", height: "fill", children: [
|
|
1709
|
-
/* @__PURE__ */ jsx(
|
|
1710
|
-
DocumentInspectorHeader,
|
|
1702
|
+
return status?.enabled ? !status?.initialized || !status.validToken ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", height: "fill", children: [
|
|
1703
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1704
|
+
structure.DocumentInspectorHeader,
|
|
1711
1705
|
{
|
|
1712
1706
|
closeButtonLabel: "Close",
|
|
1713
1707
|
onClose: props.onClose,
|
|
1714
1708
|
title: pluginTitle
|
|
1715
1709
|
}
|
|
1716
1710
|
),
|
|
1717
|
-
/* @__PURE__ */ jsxs(Stack, { padding: 4, space: 3, children: [
|
|
1718
|
-
context.error ? /* @__PURE__ */ jsxs(Text, { size: 1, weight: "semibold", children: [
|
|
1711
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { padding: 4, space: 3, children: [
|
|
1712
|
+
context.error ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "semibold", children: [
|
|
1719
1713
|
"Failed to start ",
|
|
1720
1714
|
pluginTitle
|
|
1721
1715
|
] }) : null,
|
|
1722
|
-
!context.error && !status?.initialized ? /* @__PURE__ */ jsxs(Text, { size: 1, weight: "semibold", children: [
|
|
1716
|
+
!context.error && !status?.initialized ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "semibold", children: [
|
|
1723
1717
|
pluginTitle,
|
|
1724
1718
|
" is not enabled"
|
|
1725
1719
|
] }) : null,
|
|
1726
|
-
!context.error && status?.initialized && !status.validToken ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1727
|
-
/* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: "Invalid token" }),
|
|
1728
|
-
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "The token used by the AI Assistant is not valid and has to be regenerated." })
|
|
1720
|
+
!context.error && status?.initialized && !status.validToken ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1721
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: "Invalid token" }),
|
|
1722
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "The token used by the AI Assistant is not valid and has to be regenerated." })
|
|
1729
1723
|
] }) : null,
|
|
1730
|
-
context.error && /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "Something went wrong. See console for details." }),
|
|
1731
|
-
!context.error && !status?.initialized && /* @__PURE__ */ jsxs(Text, { size: 1, muted: !0, children: [
|
|
1724
|
+
context.error && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "Something went wrong. See console for details." }),
|
|
1725
|
+
!context.error && !status?.initialized && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, children: [
|
|
1732
1726
|
"Please enable ",
|
|
1733
1727
|
pluginTitle,
|
|
1734
1728
|
"."
|
|
1735
1729
|
] }),
|
|
1736
|
-
/* @__PURE__ */ jsx(
|
|
1737
|
-
Button,
|
|
1730
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1731
|
+
ui.Button,
|
|
1738
1732
|
{
|
|
1739
1733
|
fontSize: 1,
|
|
1740
|
-
icon: context.initLoading ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Spinner, {}) }) : context.error ? RetryIcon : void 0,
|
|
1734
|
+
icon: context.initLoading ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }) : context.error ? icons.RetryIcon : void 0,
|
|
1741
1735
|
text: context.error ? "Retry" : status?.initialized && !status.validToken ? `Restore ${pluginTitle}` : `Enable ${pluginTitle} now`,
|
|
1742
1736
|
tone: "primary",
|
|
1743
1737
|
onClick: context.init,
|
|
@@ -1745,59 +1739,59 @@ function AssistInspectorWrapper(props) {
|
|
|
1745
1739
|
}
|
|
1746
1740
|
)
|
|
1747
1741
|
] })
|
|
1748
|
-
] }) : /* @__PURE__ */ jsx(AssistInspector, { ...props }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", height: "fill", children: [
|
|
1749
|
-
/* @__PURE__ */ jsx(
|
|
1750
|
-
DocumentInspectorHeader,
|
|
1742
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(AssistInspector, { ...props }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", height: "fill", children: [
|
|
1743
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1744
|
+
structure.DocumentInspectorHeader,
|
|
1751
1745
|
{
|
|
1752
1746
|
closeButtonLabel: "Close",
|
|
1753
1747
|
onClose: props.onClose,
|
|
1754
1748
|
title: pluginTitle
|
|
1755
1749
|
}
|
|
1756
1750
|
),
|
|
1757
|
-
/* @__PURE__ */ jsxs(Stack, { flex: 1, overflow: "auto", padding: 4, space: 3, children: [
|
|
1758
|
-
/* @__PURE__ */ jsxs(Text, { as: "p", size: 1, weight: "semibold", children: [
|
|
1751
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { flex: 1, overflow: "auto", padding: 4, space: 3, children: [
|
|
1752
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "p", size: 1, weight: "semibold", children: [
|
|
1759
1753
|
pluginTitle,
|
|
1760
1754
|
" is not available"
|
|
1761
1755
|
] }),
|
|
1762
|
-
/* @__PURE__ */ jsxs(Text, { as: "p", muted: !0, size: 1, children: [
|
|
1756
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "p", muted: !0, size: 1, children: [
|
|
1763
1757
|
"Please get in touch with a Sanity account manager or",
|
|
1764
1758
|
" ",
|
|
1765
|
-
/* @__PURE__ */ jsx("a", { href: salesUrl, target: "_blank", rel: "noreferrer", children: "contact our sales team" }),
|
|
1759
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: salesUrl, target: "_blank", rel: "noreferrer", children: "contact our sales team" }),
|
|
1766
1760
|
" ",
|
|
1767
1761
|
"to get started with ",
|
|
1768
1762
|
pluginTitle,
|
|
1769
1763
|
".",
|
|
1770
1764
|
" ",
|
|
1771
|
-
/* @__PURE__ */ jsx("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: "Learn more \u2192" })
|
|
1765
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: "Learn more \u2192" })
|
|
1772
1766
|
] })
|
|
1773
1767
|
] })
|
|
1774
1768
|
] });
|
|
1775
1769
|
}
|
|
1776
1770
|
function AssistInspector(props) {
|
|
1777
|
-
const { params } = useAiPaneRouter(), boundary = useRef(null), pathKey = params?.[fieldPathParam], instructionKey = params?.[instructionParam], documentPane = useDocumentPane(), {
|
|
1771
|
+
const { params } = useAiPaneRouter(), boundary = react.useRef(null), pathKey = params?.[fieldPathParam], instructionKey = params?.[instructionParam], documentPane = structure.useDocumentPane(), {
|
|
1778
1772
|
documentId,
|
|
1779
1773
|
documentType,
|
|
1780
1774
|
value: docValue,
|
|
1781
1775
|
schemaType,
|
|
1782
1776
|
onChange: documentOnChange,
|
|
1783
1777
|
formState
|
|
1784
|
-
} = documentPane, { assistableDocumentId, documentIsAssistable } = useAssistDocumentContext(), formStateRef = useRef(formState);
|
|
1778
|
+
} = documentPane, { assistableDocumentId, documentIsAssistable } = useAssistDocumentContext(), formStateRef = react.useRef(formState);
|
|
1785
1779
|
formStateRef.current = formState;
|
|
1786
1780
|
const { instructionLoading, requestRunInstruction } = useRequestRunInstruction({
|
|
1787
1781
|
documentOnChange,
|
|
1788
1782
|
isDocAssistable: documentIsAssistable
|
|
1789
|
-
}), typePath = useTypePath(docValue, pathKey ?? ""), selectedField = useSelectedField(schemaType, typePath), aiDocId = assistDocumentId(documentType), assistDocument = useStudioAssistDocument({ documentId, schemaType, initDoc: !0 }), instruction2 = assistDocument?.fields?.find((f) => f.path === typePath)?.instructions?.find((i) => i._key === instructionKey), tasks = useMemo(
|
|
1783
|
+
}), typePath = useTypePath(docValue, pathKey ?? ""), selectedField = useSelectedField(schemaType, typePath), aiDocId = assistDocumentId(documentType), assistDocument = useStudioAssistDocument({ documentId, schemaType, initDoc: !0 }), instruction2 = assistDocument?.fields?.find((f) => f.path === typePath)?.instructions?.find((i) => i._key === instructionKey), tasks = react.useMemo(
|
|
1790
1784
|
() => assistDocument?.tasks?.filter((i) => !instructionKey || i.instructionKey === instructionKey),
|
|
1791
1785
|
[assistDocument?.tasks, instructionKey]
|
|
1792
|
-
), instructions = useMemo(
|
|
1786
|
+
), instructions = react.useMemo(
|
|
1793
1787
|
() => assistDocument?.fields?.flatMap((f) => f.instructions ?? []),
|
|
1794
1788
|
[assistDocument?.fields]
|
|
1795
|
-
), promptValue = instruction2?.prompt, isEmptyPrompt = useMemo(() => {
|
|
1789
|
+
), promptValue = instruction2?.prompt, isEmptyPrompt = react.useMemo(() => {
|
|
1796
1790
|
if (!promptValue?.length)
|
|
1797
1791
|
return !0;
|
|
1798
1792
|
const children = promptValue[0]?.children;
|
|
1799
1793
|
return promptValue.length == 1 && children?.length === 1 && !children?.[0]?.text?.length;
|
|
1800
|
-
}, [promptValue]), paneNode = useMemo(
|
|
1794
|
+
}, [promptValue]), paneNode = react.useMemo(
|
|
1801
1795
|
() => ({
|
|
1802
1796
|
type: "document",
|
|
1803
1797
|
id: aiDocId,
|
|
@@ -1808,7 +1802,7 @@ function AssistInspector(props) {
|
|
|
1808
1802
|
}
|
|
1809
1803
|
}),
|
|
1810
1804
|
[aiDocId]
|
|
1811
|
-
), runCurrentInstruction = useCallback(
|
|
1805
|
+
), runCurrentInstruction = react.useCallback(
|
|
1812
1806
|
() => instruction2 && pathKey && typePath && requestRunInstruction({
|
|
1813
1807
|
documentId: assistableDocumentId,
|
|
1814
1808
|
path: pathKey,
|
|
@@ -1818,9 +1812,9 @@ function AssistInspector(props) {
|
|
|
1818
1812
|
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
1819
1813
|
}),
|
|
1820
1814
|
[pathKey, instruction2, typePath, documentType, assistableDocumentId, requestRunInstruction]
|
|
1821
|
-
), Region = useCallback((_props) => /* @__PURE__ */ jsx("div", { ..._props, style: { height: "100%", flex: 1, overflow: "auto" } }), []), assistTypeContext = useMemo(() => ({ typePath, documentType }), [typePath, documentType]);
|
|
1822
|
-
return !documentId || !schemaType || schemaType.jsonType !== "object" ? /* @__PURE__ */ jsx(Card, { flex: 1, padding: 4, children: /* @__PURE__ */ jsx(Text, { children: "Document not ready yet." }) }) : /* @__PURE__ */ jsxs(
|
|
1823
|
-
Flex,
|
|
1815
|
+
), Region = react.useCallback((_props) => /* @__PURE__ */ jsxRuntime.jsx("div", { ..._props, style: { height: "100%", flex: 1, overflow: "auto" } }), []), assistTypeContext = react.useMemo(() => ({ typePath, documentType }), [typePath, documentType]);
|
|
1816
|
+
return !documentId || !schemaType || schemaType.jsonType !== "object" ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { flex: 1, padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Document not ready yet." }) }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1817
|
+
ui.Flex,
|
|
1824
1818
|
{
|
|
1825
1819
|
ref: boundary,
|
|
1826
1820
|
direction: "column",
|
|
@@ -1829,7 +1823,7 @@ function AssistInspector(props) {
|
|
|
1829
1823
|
sizing: "border",
|
|
1830
1824
|
style: { lineHeight: 0 },
|
|
1831
1825
|
children: [
|
|
1832
|
-
/* @__PURE__ */ jsx(
|
|
1826
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1833
1827
|
AiInspectorHeader,
|
|
1834
1828
|
{
|
|
1835
1829
|
onClose: props.onClose,
|
|
@@ -1837,14 +1831,14 @@ function AssistInspector(props) {
|
|
|
1837
1831
|
fieldTitle: getFieldTitle(selectedField)
|
|
1838
1832
|
}
|
|
1839
1833
|
),
|
|
1840
|
-
/* @__PURE__ */ jsx(Card, { as: Region, flex: 1, overflow: "auto", children: /* @__PURE__ */ jsxs(Flex, { direction: "column", style: { minHeight: "100%" }, children: [
|
|
1841
|
-
/* @__PURE__ */ jsx(Box, { flex: 1, children: /* @__PURE__ */ jsx(PresenceOverlay, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: selectedField && /* @__PURE__ */ jsx(AssistTypeContext.Provider, { value: assistTypeContext, children: /* @__PURE__ */ jsx(
|
|
1842
|
-
VirtualizerScrollInstanceProvider,
|
|
1834
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: Region, flex: 1, overflow: "auto", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", style: { minHeight: "100%" }, children: [
|
|
1835
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.PresenceOverlay, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { padding: 4, children: selectedField && /* @__PURE__ */ jsxRuntime.jsx(AssistTypeContext.Provider, { value: assistTypeContext, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1836
|
+
sanity.VirtualizerScrollInstanceProvider,
|
|
1843
1837
|
{
|
|
1844
1838
|
scrollElement: boundary.current,
|
|
1845
1839
|
containerElement: boundary,
|
|
1846
|
-
children: /* @__PURE__ */ jsx(
|
|
1847
|
-
DocumentPaneProvider,
|
|
1840
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1841
|
+
structure.DocumentPaneProvider,
|
|
1848
1842
|
{
|
|
1849
1843
|
paneKey: documentPane.paneKey,
|
|
1850
1844
|
index: documentPane.index,
|
|
@@ -1855,15 +1849,15 @@ function AssistInspector(props) {
|
|
|
1855
1849
|
selectedPerspectiveName: "published",
|
|
1856
1850
|
selectedReleaseId: void 0
|
|
1857
1851
|
},
|
|
1858
|
-
children: /* @__PURE__ */ jsx(DocumentForm, {})
|
|
1852
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DocumentForm, {})
|
|
1859
1853
|
}
|
|
1860
1854
|
)
|
|
1861
1855
|
}
|
|
1862
1856
|
) }) }) }) }),
|
|
1863
|
-
/* @__PURE__ */ jsx(Box, { flex: "none", padding: 4, children: /* @__PURE__ */ jsxs(Text, { muted: !0, size: 1, children: [
|
|
1857
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, size: 1, children: [
|
|
1864
1858
|
"How is Sanity AI Assist working for you?",
|
|
1865
1859
|
" ",
|
|
1866
|
-
/* @__PURE__ */ jsxs(
|
|
1860
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1867
1861
|
"a",
|
|
1868
1862
|
{
|
|
1869
1863
|
href: giveFeedbackUrl,
|
|
@@ -1872,26 +1866,26 @@ function AssistInspector(props) {
|
|
|
1872
1866
|
style: { whiteSpace: "nowrap" },
|
|
1873
1867
|
children: [
|
|
1874
1868
|
"Let us know ",
|
|
1875
|
-
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
1869
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRightIcon, {})
|
|
1876
1870
|
]
|
|
1877
1871
|
}
|
|
1878
1872
|
)
|
|
1879
1873
|
] }) })
|
|
1880
1874
|
] }) }),
|
|
1881
|
-
/* @__PURE__ */ jsx(CardWithShadowAbove, { flex: "none", paddingX: 4, paddingY: 3, style: { justifySelf: "flex-end" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 2, flex: 1, justify: "flex-end", children: [
|
|
1882
|
-
schemaType?.name && pathKey && instructionKey && /* @__PURE__ */ jsx(Stack, { flex: 1, children: /* @__PURE__ */ jsx(
|
|
1883
|
-
Button,
|
|
1875
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardWithShadowAbove, { flex: "none", paddingX: 4, paddingY: 3, style: { justifySelf: "flex-end" }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, flex: 1, justify: "flex-end", children: [
|
|
1876
|
+
schemaType?.name && pathKey && instructionKey && /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1877
|
+
ui.Button,
|
|
1884
1878
|
{
|
|
1885
1879
|
mode: "ghost",
|
|
1886
1880
|
disabled: isEmptyPrompt || instructionLoading,
|
|
1887
1881
|
fontSize: 1,
|
|
1888
|
-
icon: instructionLoading ? /* @__PURE__ */ jsx(Spinner, { style: { marginTop: 3 } }) : PlayIcon,
|
|
1882
|
+
icon: instructionLoading ? /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { marginTop: 3 } }) : icons.PlayIcon,
|
|
1889
1883
|
onClick: runCurrentInstruction,
|
|
1890
1884
|
padding: 3,
|
|
1891
1885
|
text: "Run instruction"
|
|
1892
1886
|
}
|
|
1893
1887
|
) }),
|
|
1894
|
-
/* @__PURE__ */ jsx(
|
|
1888
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1895
1889
|
InstructionTaskHistoryButton,
|
|
1896
1890
|
{
|
|
1897
1891
|
documentId: assistableDocumentId,
|
|
@@ -1907,21 +1901,21 @@ function AssistInspector(props) {
|
|
|
1907
1901
|
}
|
|
1908
1902
|
function AiInspectorHeader(props) {
|
|
1909
1903
|
const { onClose, field, fieldTitle } = props, { showOnboarding, dismissOnboarding } = useOnboardingFeature(inspectorOnboardingKey);
|
|
1910
|
-
return /* @__PURE__ */ jsxs(CardWithShadowBelow, { flex: "none", padding: 2, children: [
|
|
1911
|
-
/* @__PURE__ */ jsxs(Flex, { flex: 1, align: "center", children: [
|
|
1912
|
-
/* @__PURE__ */ jsx(Flex, { flex: 1, padding: 3, gap: 2, align: "center", children: /* @__PURE__ */ jsxs(Flex, { gap: 1, align: "center", wrap: "wrap", style: { marginTop: "-4px" }, children: [
|
|
1913
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: "AI instructions for" }) }),
|
|
1914
|
-
/* @__PURE__ */ jsx(Card, { radius: 2, border: !0, padding: 1, marginTop: 1, children: field ? /* @__PURE__ */ jsx(FieldTitle, { field }) : /* @__PURE__ */ jsx(Text, { size: 1, weight: "semibold", children: fieldTitle }) })
|
|
1904
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(CardWithShadowBelow, { flex: "none", padding: 2, children: [
|
|
1905
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { flex: 1, align: "center", children: [
|
|
1906
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { flex: 1, padding: 3, gap: 2, align: "center", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 1, align: "center", wrap: "wrap", style: { marginTop: "-4px" }, children: [
|
|
1907
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: "AI instructions for" }) }),
|
|
1908
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 2, border: !0, padding: 1, marginTop: 1, children: field ? /* @__PURE__ */ jsxRuntime.jsx(FieldTitle, { field }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: fieldTitle }) })
|
|
1915
1909
|
] }) }),
|
|
1916
|
-
/* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Button, { fontSize: 1, icon: CloseIcon, mode: "bleed", onClick: onClose }) })
|
|
1910
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { fontSize: 1, icon: icons.CloseIcon, mode: "bleed", onClick: onClose }) })
|
|
1917
1911
|
] }),
|
|
1918
|
-
showOnboarding && /* @__PURE__ */ jsx(InspectorOnboarding, { onDismiss: dismissOnboarding })
|
|
1912
|
+
showOnboarding && /* @__PURE__ */ jsxRuntime.jsx(InspectorOnboarding, { onDismiss: dismissOnboarding })
|
|
1919
1913
|
] });
|
|
1920
1914
|
}
|
|
1921
1915
|
const aiInspectorId = "ai-assistance", assistInspector = {
|
|
1922
1916
|
name: aiInspectorId,
|
|
1923
1917
|
useMenuItem: () => ({
|
|
1924
|
-
icon: SparklesIcon,
|
|
1918
|
+
icon: icons.SparklesIcon,
|
|
1925
1919
|
title: pluginTitle,
|
|
1926
1920
|
hidden: !0,
|
|
1927
1921
|
showAsAction: !1
|
|
@@ -1929,7 +1923,7 @@ const aiInspectorId = "ai-assistance", assistInspector = {
|
|
|
1929
1923
|
component: AssistInspectorWrapper,
|
|
1930
1924
|
onClose({ params }) {
|
|
1931
1925
|
return {
|
|
1932
|
-
params: typed({
|
|
1926
|
+
params: sanity.typed({
|
|
1933
1927
|
...params,
|
|
1934
1928
|
[fieldPathParam]: void 0,
|
|
1935
1929
|
[instructionParam]: void 0
|
|
@@ -2021,9 +2015,9 @@ function drawConnectorPath(options2, line) {
|
|
|
2021
2015
|
), join(cmds);
|
|
2022
2016
|
}
|
|
2023
2017
|
function ConnectorPath(props) {
|
|
2024
|
-
const { from, options: options2, to } = props, { strokeWidth } = options2.path, theme = useTheme(), line = useMemo(() => mapConnectorToLine(options2, { from, to }), [from, options2, to]);
|
|
2025
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2026
|
-
/* @__PURE__ */ jsx(
|
|
2018
|
+
const { from, options: options2, to } = props, { strokeWidth } = options2.path, theme = ui.useTheme(), line = react.useMemo(() => mapConnectorToLine(options2, { from, to }), [from, options2, to]);
|
|
2019
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2020
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2027
2021
|
"path",
|
|
2028
2022
|
{
|
|
2029
2023
|
d: drawConnectorPath(options2, line),
|
|
@@ -2031,15 +2025,15 @@ function ConnectorPath(props) {
|
|
|
2031
2025
|
strokeWidth: strokeWidth + 4
|
|
2032
2026
|
}
|
|
2033
2027
|
),
|
|
2034
|
-
/* @__PURE__ */ jsx(
|
|
2028
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2035
2029
|
"path",
|
|
2036
2030
|
{
|
|
2037
2031
|
d: drawConnectorPath(options2, line),
|
|
2038
|
-
stroke: rgba(theme.sanity.color.base.border, 0.5),
|
|
2032
|
+
stroke: ui.rgba(theme.sanity.color.base.border, 0.5),
|
|
2039
2033
|
strokeWidth
|
|
2040
2034
|
}
|
|
2041
2035
|
),
|
|
2042
|
-
line.from.isAbove && /* @__PURE__ */ jsx(
|
|
2036
|
+
line.from.isAbove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2043
2037
|
"path",
|
|
2044
2038
|
{
|
|
2045
2039
|
d: arrowPath(
|
|
@@ -2052,7 +2046,7 @@ function ConnectorPath(props) {
|
|
|
2052
2046
|
strokeWidth
|
|
2053
2047
|
}
|
|
2054
2048
|
),
|
|
2055
|
-
line.from.isBelow && /* @__PURE__ */ jsx(
|
|
2049
|
+
line.from.isBelow && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2056
2050
|
"path",
|
|
2057
2051
|
{
|
|
2058
2052
|
d: arrowPath(
|
|
@@ -2084,11 +2078,11 @@ const DEBUG = !1, options = {
|
|
|
2084
2078
|
}
|
|
2085
2079
|
};
|
|
2086
2080
|
function AssistConnectorsOverlay(props) {
|
|
2087
|
-
const { connectors } = props, [, setRedraw] = useState(!1);
|
|
2088
|
-
return useEffect(() => {
|
|
2081
|
+
const { connectors } = props, [, setRedraw] = react.useState(!1);
|
|
2082
|
+
return react.useEffect(() => {
|
|
2089
2083
|
setRedraw(!0);
|
|
2090
|
-
}, []), /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2091
|
-
/* @__PURE__ */ jsx(
|
|
2084
|
+
}, []), /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2085
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2092
2086
|
"svg",
|
|
2093
2087
|
{
|
|
2094
2088
|
fill: "none",
|
|
@@ -2104,7 +2098,7 @@ function AssistConnectorsOverlay(props) {
|
|
|
2104
2098
|
zIndex: 150
|
|
2105
2099
|
// zIndex,
|
|
2106
2100
|
},
|
|
2107
|
-
children: connectors.map((connector) => /* @__PURE__ */ jsx(
|
|
2101
|
+
children: connectors.map((connector) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2108
2102
|
ConnectorPath,
|
|
2109
2103
|
{
|
|
2110
2104
|
from: connector.from,
|
|
@@ -2138,7 +2132,7 @@ const getLanguageParams = (select, document2) => {
|
|
|
2138
2132
|
return {};
|
|
2139
2133
|
const selection = select || {}, selectedValue = {};
|
|
2140
2134
|
for (const [key, path] of Object.entries(selection)) {
|
|
2141
|
-
let value =
|
|
2135
|
+
let value = get__default.default(document2, path);
|
|
2142
2136
|
Array.isArray(value) && (value = value.filter(
|
|
2143
2137
|
(item) => typeof item == "object" ? item?._type !== "reference" || "_ref" in item : !0
|
|
2144
2138
|
)), selectedValue[key] = value;
|
|
@@ -2156,11 +2150,11 @@ function setPreferredToFieldLanguages(fromLanguageId, languageIds) {
|
|
|
2156
2150
|
}
|
|
2157
2151
|
const DEFAULT_MAX_DEPTH = 6, ABSOLUTE_MAX_DEPTH = 50;
|
|
2158
2152
|
function getDocumentMembersFlat(doc, schemaType, maxDepth2 = DEFAULT_MAX_DEPTH) {
|
|
2159
|
-
return isDocumentSchemaType(schemaType) ? extractPaths(doc, schemaType, [], Math.min(maxDepth2, ABSOLUTE_MAX_DEPTH)) : (console.error("Schema type is not a document"), []);
|
|
2153
|
+
return sanity.isDocumentSchemaType(schemaType) ? extractPaths(doc, schemaType, [], Math.min(maxDepth2, ABSOLUTE_MAX_DEPTH)) : (console.error("Schema type is not a document"), []);
|
|
2160
2154
|
}
|
|
2161
2155
|
function extractPaths(doc, schemaType, path, maxDepth2) {
|
|
2162
2156
|
return path.length >= maxDepth2 ? [] : schemaType.fields.reduce((acc, field) => {
|
|
2163
|
-
const fieldPath = [...path, field.name], fieldSchema = field.type, { value } = extractWithPath(pathToString(fieldPath), doc)[0] ?? {};
|
|
2157
|
+
const fieldPath = [...path, field.name], fieldSchema = field.type, { value } = mutator.extractWithPath(sanity.pathToString(fieldPath), doc)[0] ?? {};
|
|
2164
2158
|
if (!value)
|
|
2165
2159
|
return acc;
|
|
2166
2160
|
const thisFieldWithPath = {
|
|
@@ -2174,7 +2168,7 @@ function extractPaths(doc, schemaType, path, maxDepth2) {
|
|
|
2174
2168
|
return [...acc, thisFieldWithPath, ...innerFields];
|
|
2175
2169
|
} else if (fieldSchema.jsonType === "array" && fieldSchema.of.length && fieldSchema.of.some((item) => "fields" in item) && // no reason to drill into arrays if the item fields will be culled by maxDepth, ie we need 1 extra path headroom
|
|
2176
2170
|
path.length + 1 < maxDepth2) {
|
|
2177
|
-
const { value: arrayValue } = extractWithPath(pathToString(fieldPath), doc)[0] ?? {};
|
|
2171
|
+
const { value: arrayValue } = mutator.extractWithPath(sanity.pathToString(fieldPath), doc)[0] ?? {};
|
|
2178
2172
|
let arrayPaths = [];
|
|
2179
2173
|
if (arrayValue?.length)
|
|
2180
2174
|
for (const item of arrayValue) {
|
|
@@ -2210,7 +2204,7 @@ function extractPaths(doc, schemaType, path, maxDepth2) {
|
|
|
2210
2204
|
const defaultLanguageOutputs = function(member, enclosingType, translateFromLanguageId, translateToLanguageIds) {
|
|
2211
2205
|
if (member.schemaType.jsonType === "object" && member.schemaType.name.startsWith("internationalizedArray")) {
|
|
2212
2206
|
const pathEnd = member.path.slice(-1);
|
|
2213
|
-
return (isKeySegment(pathEnd[0]) ? pathEnd[0]._key : null) === translateFromLanguageId ? translateToLanguageIds.map((translateToId) => ({
|
|
2207
|
+
return (sanity.isKeySegment(pathEnd[0]) ? pathEnd[0]._key : null) === translateFromLanguageId ? translateToLanguageIds.map((translateToId) => ({
|
|
2214
2208
|
id: translateToId,
|
|
2215
2209
|
outputPath: [...member.path.slice(0, -1), { _key: translateToId }]
|
|
2216
2210
|
})) : void 0;
|
|
@@ -2224,7 +2218,7 @@ const defaultLanguageOutputs = function(member, enclosingType, translateFromLang
|
|
|
2224
2218
|
function getFieldLanguageMap(documentSchema, documentMembers, translateFromLanguageId, outputLanguageIds, langFn) {
|
|
2225
2219
|
const translationMaps = [];
|
|
2226
2220
|
for (const member of documentMembers) {
|
|
2227
|
-
const parentPath = member.path.slice(0, -1), enclosingType = documentMembers.find((m) => pathToString(m.path) === pathToString(parentPath))?.schemaType ?? documentSchema, translations = langFn(
|
|
2221
|
+
const parentPath = member.path.slice(0, -1), enclosingType = documentMembers.find((m) => sanity.pathToString(m.path) === sanity.pathToString(parentPath))?.schemaType ?? documentSchema, translations = langFn(
|
|
2228
2222
|
member,
|
|
2229
2223
|
enclosingType,
|
|
2230
2224
|
translateFromLanguageId,
|
|
@@ -2238,25 +2232,25 @@ function getFieldLanguageMap(documentSchema, documentMembers, translateFromLangu
|
|
|
2238
2232
|
}
|
|
2239
2233
|
return translationMaps;
|
|
2240
2234
|
}
|
|
2241
|
-
const FieldTranslationContext = createContext({
|
|
2235
|
+
const FieldTranslationContext = react.createContext({
|
|
2242
2236
|
openFieldTranslation: () => {
|
|
2243
2237
|
},
|
|
2244
2238
|
translationLoading: !1
|
|
2245
2239
|
});
|
|
2246
2240
|
function useFieldTranslation() {
|
|
2247
|
-
return useContext(FieldTranslationContext);
|
|
2241
|
+
return react.useContext(FieldTranslationContext);
|
|
2248
2242
|
}
|
|
2249
2243
|
function hasValuesToTranslate(fieldLanguageMaps, fromLanguage, basePath2) {
|
|
2250
2244
|
return fieldLanguageMaps?.some(
|
|
2251
|
-
(map) => map.inputLanguageId === fromLanguage?.id && map.inputPath && pathToString(map.inputPath).startsWith(pathToString(basePath2))
|
|
2245
|
+
(map) => map.inputLanguageId === fromLanguage?.id && map.inputPath && sanity.pathToString(map.inputPath).startsWith(sanity.pathToString(basePath2))
|
|
2252
2246
|
);
|
|
2253
2247
|
}
|
|
2254
2248
|
function FieldTranslationProvider(props) {
|
|
2255
|
-
const { config: assistConfig } = useAiAssistanceConfig(), apiClient = useApiClient(assistConfig.__customApiClient), styleguide = assistConfig.translate?.styleguide, config = assistConfig.translate?.field, { translate: runTranslate } = useTranslate(apiClient), [dialogOpen, setDialogOpen] = useState(!1), [fieldTranslationParams, setFieldTranslationParams] = useState(), [languages, setLanguages] = useState(), [fromLanguage, setFromLanguage] = useState(void 0), [toLanguages, setToLanguages] = useState(void 0), [fieldLanguageMaps, setFieldLanguageMaps] = useState(), close = useCallback(() => {
|
|
2249
|
+
const { config: assistConfig } = useAiAssistanceConfig(), apiClient = useApiClient(assistConfig.__customApiClient), styleguide = assistConfig.translate?.styleguide, config = assistConfig.translate?.field, { translate: runTranslate } = useTranslate(apiClient), [dialogOpen, setDialogOpen] = react.useState(!1), [fieldTranslationParams, setFieldTranslationParams] = react.useState(), [languages, setLanguages] = react.useState(), [fromLanguage, setFromLanguage] = react.useState(void 0), [toLanguages, setToLanguages] = react.useState(void 0), [fieldLanguageMaps, setFieldLanguageMaps] = react.useState(), close = react.useCallback(() => {
|
|
2256
2250
|
setDialogOpen(!1), setLanguages(void 0), setFieldTranslationParams(void 0);
|
|
2257
|
-
}, []), languageClient = useClient({
|
|
2251
|
+
}, []), languageClient = sanity.useClient({
|
|
2258
2252
|
apiVersion: config?.apiVersion ?? API_VERSION_WITH_EXTENDED_TYPES
|
|
2259
|
-
}), documentId = fieldTranslationParams?.document?._id, id = useId(), selectFromLanguage = useCallback(
|
|
2253
|
+
}), documentId = fieldTranslationParams?.document?._id, id = react.useId(), selectFromLanguage = react.useCallback(
|
|
2260
2254
|
(from, languages2, params) => {
|
|
2261
2255
|
const { document: document2, documentSchema } = params ?? {};
|
|
2262
2256
|
if (setFromLanguage(from), !document2 || !documentSchema || !params || !languages2) {
|
|
@@ -2281,7 +2275,7 @@ function FieldTranslationProvider(props) {
|
|
|
2281
2275
|
setFieldLanguageMaps(void 0);
|
|
2282
2276
|
},
|
|
2283
2277
|
[config]
|
|
2284
|
-
), toggleToLanguage = useCallback(
|
|
2278
|
+
), toggleToLanguage = react.useCallback(
|
|
2285
2279
|
(toggledLang, toLanguages2, languages2) => {
|
|
2286
2280
|
if (!languages2 || !fromLanguage)
|
|
2287
2281
|
return;
|
|
@@ -2296,7 +2290,7 @@ function FieldTranslationProvider(props) {
|
|
|
2296
2290
|
);
|
|
2297
2291
|
},
|
|
2298
2292
|
[fromLanguage]
|
|
2299
|
-
), openFieldTranslation = useCallback(
|
|
2293
|
+
), openFieldTranslation = react.useCallback(
|
|
2300
2294
|
async (params) => {
|
|
2301
2295
|
setDialogOpen(!0);
|
|
2302
2296
|
const languageParams = getLanguageParams(config?.selectLanguageParams, params.document), languages2 = await (typeof config?.languages == "function" ? config?.languages(languageClient, languageParams) : Promise.resolve(config?.languages));
|
|
@@ -2305,10 +2299,10 @@ function FieldTranslationProvider(props) {
|
|
|
2305
2299
|
fromLanguage2 ? selectFromLanguage(fromLanguage2, languages2, params) : console.error("No languages available for selected language params", languageParams);
|
|
2306
2300
|
},
|
|
2307
2301
|
[selectFromLanguage, config, languageClient]
|
|
2308
|
-
), contextValue = useMemo(() => ({
|
|
2302
|
+
), contextValue = react.useMemo(() => ({
|
|
2309
2303
|
openFieldTranslation,
|
|
2310
2304
|
translationLoading: !1
|
|
2311
|
-
}), [openFieldTranslation]), runDisabled = !fromLanguage || !toLanguages?.length || !fieldLanguageMaps?.length || !documentId || !hasValuesToTranslate(fieldLanguageMaps, fromLanguage, fieldTranslationParams.translatePath), onRunTranslation = useCallback(() => {
|
|
2305
|
+
}), [openFieldTranslation]), runDisabled = !fromLanguage || !toLanguages?.length || !fieldLanguageMaps?.length || !documentId || !hasValuesToTranslate(fieldLanguageMaps, fromLanguage, fieldTranslationParams.translatePath), onRunTranslation = react.useCallback(() => {
|
|
2312
2306
|
const translatePath = fieldTranslationParams?.translatePath;
|
|
2313
2307
|
fieldLanguageMaps && documentId && translatePath && runTranslate({
|
|
2314
2308
|
documentId,
|
|
@@ -2337,38 +2331,38 @@ function FieldTranslationProvider(props) {
|
|
|
2337
2331
|
fieldTranslationParams?.conditionalMembers,
|
|
2338
2332
|
fieldTranslationParams?.documentSchema,
|
|
2339
2333
|
languageClient
|
|
2340
|
-
]), runButton = /* @__PURE__ */ jsx(
|
|
2341
|
-
Button,
|
|
2334
|
+
]), runButton = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2335
|
+
ui.Button,
|
|
2342
2336
|
{
|
|
2343
2337
|
text: "Translate",
|
|
2344
2338
|
tone: "primary",
|
|
2345
|
-
icon: PlayIcon,
|
|
2339
|
+
icon: icons.PlayIcon,
|
|
2346
2340
|
style: { width: "100%" },
|
|
2347
2341
|
disabled: runDisabled,
|
|
2348
2342
|
onClick: onRunTranslation
|
|
2349
2343
|
}
|
|
2350
2344
|
);
|
|
2351
|
-
return /* @__PURE__ */ jsxs(FieldTranslationContext.Provider, { value: contextValue, children: [
|
|
2352
|
-
dialogOpen ? /* @__PURE__ */ jsx(
|
|
2353
|
-
Dialog,
|
|
2345
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FieldTranslationContext.Provider, { value: contextValue, children: [
|
|
2346
|
+
dialogOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2347
|
+
ui.Dialog,
|
|
2354
2348
|
{
|
|
2355
2349
|
id,
|
|
2356
2350
|
width: 1,
|
|
2357
2351
|
open: dialogOpen,
|
|
2358
2352
|
onClose: close,
|
|
2359
2353
|
header: "Translate fields",
|
|
2360
|
-
footer: /* @__PURE__ */ jsx(Flex, { justify: "space-between", padding: 2, flex: 1, children: runDisabled ? /* @__PURE__ */ jsx(
|
|
2361
|
-
Tooltip,
|
|
2354
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "space-between", padding: 2, flex: 1, children: runDisabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2355
|
+
ui.Tooltip,
|
|
2362
2356
|
{
|
|
2363
|
-
content: /* @__PURE__ */ jsx(Flex, { padding: 2, children: /* @__PURE__ */ jsx(Text, { children: "There is nothing to translate in the selected from-language." }) }),
|
|
2357
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "There is nothing to translate in the selected from-language." }) }),
|
|
2364
2358
|
placement: "top",
|
|
2365
|
-
children: /* @__PURE__ */ jsx(Flex, { flex: 1, children: runButton })
|
|
2359
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { flex: 1, children: runButton })
|
|
2366
2360
|
}
|
|
2367
2361
|
) : runButton }),
|
|
2368
|
-
children: languages ? /* @__PURE__ */ jsxs(Flex, { padding: 4, gap: 5, align: "flex-start", justify: "center", children: [
|
|
2369
|
-
/* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
2370
|
-
/* @__PURE__ */ jsx(Box, { marginBottom: 2, children: /* @__PURE__ */ jsx(Text, { weight: "semibold", children: "From" }) }),
|
|
2371
|
-
languages?.map((radioLanguage) => /* @__PURE__ */ jsx(
|
|
2362
|
+
children: languages ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { padding: 4, gap: 5, align: "flex-start", justify: "center", children: [
|
|
2363
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
2364
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", children: "From" }) }),
|
|
2365
|
+
languages?.map((radioLanguage) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2372
2366
|
FromLanguageRadio,
|
|
2373
2367
|
{
|
|
2374
2368
|
radioLanguage,
|
|
@@ -2380,9 +2374,9 @@ function FieldTranslationProvider(props) {
|
|
|
2380
2374
|
radioLanguage.id
|
|
2381
2375
|
))
|
|
2382
2376
|
] }),
|
|
2383
|
-
/* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
2384
|
-
/* @__PURE__ */ jsx(Box, { marginBottom: 2, children: /* @__PURE__ */ jsx(Text, { weight: "semibold", children: "To" }) }),
|
|
2385
|
-
languages.map((checkboxLanguage) => /* @__PURE__ */ jsx(
|
|
2377
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
2378
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", children: "To" }) }),
|
|
2379
|
+
languages.map((checkboxLanguage) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2386
2380
|
ToLanguageCheckbox,
|
|
2387
2381
|
{
|
|
2388
2382
|
checkboxLanguage,
|
|
@@ -2394,9 +2388,9 @@ function FieldTranslationProvider(props) {
|
|
|
2394
2388
|
checkboxLanguage.id
|
|
2395
2389
|
))
|
|
2396
2390
|
] })
|
|
2397
|
-
] }) : /* @__PURE__ */ jsxs(Flex, { padding: 4, gap: 2, align: "flex-start", justify: "center", children: [
|
|
2398
|
-
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Spinner, {}) }),
|
|
2399
|
-
/* @__PURE__ */ jsx(Text, { children: "Loading languages..." })
|
|
2391
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { padding: 4, gap: 2, align: "flex-start", justify: "center", children: [
|
|
2392
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }),
|
|
2393
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading languages..." })
|
|
2400
2394
|
] })
|
|
2401
2395
|
}
|
|
2402
2396
|
) : null,
|
|
@@ -2404,20 +2398,20 @@ function FieldTranslationProvider(props) {
|
|
|
2404
2398
|
] });
|
|
2405
2399
|
}
|
|
2406
2400
|
function ToLanguageCheckbox(props) {
|
|
2407
|
-
const { checkboxLanguage, fromLanguage, toLanguages, toggleToLanguage, languages } = props, langId = checkboxLanguage.id, onChange = useCallback(
|
|
2401
|
+
const { checkboxLanguage, fromLanguage, toLanguages, toggleToLanguage, languages } = props, langId = checkboxLanguage.id, onChange = react.useCallback(
|
|
2408
2402
|
() => toggleToLanguage(checkboxLanguage, toLanguages, languages),
|
|
2409
2403
|
[toggleToLanguage, checkboxLanguage, toLanguages, languages]
|
|
2410
2404
|
);
|
|
2411
|
-
return /* @__PURE__ */ jsxs(
|
|
2412
|
-
Flex,
|
|
2405
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2406
|
+
ui.Flex,
|
|
2413
2407
|
{
|
|
2414
2408
|
gap: 3,
|
|
2415
2409
|
align: "center",
|
|
2416
2410
|
as: "label",
|
|
2417
2411
|
style: langId === fromLanguage?.id ? { opacity: 0.5 } : void 0,
|
|
2418
2412
|
children: [
|
|
2419
|
-
/* @__PURE__ */ jsx(
|
|
2420
|
-
Checkbox,
|
|
2413
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2414
|
+
ui.Checkbox,
|
|
2421
2415
|
{
|
|
2422
2416
|
name: "toLang",
|
|
2423
2417
|
value: langId,
|
|
@@ -2426,20 +2420,20 @@ function ToLanguageCheckbox(props) {
|
|
|
2426
2420
|
disabled: langId === fromLanguage?.id
|
|
2427
2421
|
}
|
|
2428
2422
|
),
|
|
2429
|
-
/* @__PURE__ */ jsx(Text, { muted: langId === fromLanguage?.id, children: checkboxLanguage.title ?? langId })
|
|
2423
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: langId === fromLanguage?.id, children: checkboxLanguage.title ?? langId })
|
|
2430
2424
|
]
|
|
2431
2425
|
},
|
|
2432
2426
|
langId
|
|
2433
2427
|
);
|
|
2434
2428
|
}
|
|
2435
2429
|
function FromLanguageRadio(props) {
|
|
2436
|
-
const { languages, radioLanguage, selectFromLanguage, fromLanguage, fieldTranslationParams } = props, langId = radioLanguage.id, onChange = useCallback(
|
|
2430
|
+
const { languages, radioLanguage, selectFromLanguage, fromLanguage, fieldTranslationParams } = props, langId = radioLanguage.id, onChange = react.useCallback(
|
|
2437
2431
|
() => selectFromLanguage(radioLanguage, languages, fieldTranslationParams),
|
|
2438
2432
|
[selectFromLanguage, radioLanguage, languages, fieldTranslationParams]
|
|
2439
2433
|
);
|
|
2440
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", as: "label", children: [
|
|
2441
|
-
/* @__PURE__ */ jsx(
|
|
2442
|
-
Radio,
|
|
2434
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", as: "label", children: [
|
|
2435
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2436
|
+
ui.Radio,
|
|
2443
2437
|
{
|
|
2444
2438
|
name: "fromLang",
|
|
2445
2439
|
value: langId,
|
|
@@ -2447,7 +2441,7 @@ function FromLanguageRadio(props) {
|
|
|
2447
2441
|
onChange
|
|
2448
2442
|
}
|
|
2449
2443
|
),
|
|
2450
|
-
/* @__PURE__ */ jsx(Text, { children: radioLanguage.title ?? radioLanguage.id })
|
|
2444
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: radioLanguage.title ?? radioLanguage.id })
|
|
2451
2445
|
] }, langId);
|
|
2452
2446
|
}
|
|
2453
2447
|
const hiddenTypes = [
|
|
@@ -2547,7 +2541,7 @@ function serializeMember(schema, type, name, options2) {
|
|
|
2547
2541
|
}
|
|
2548
2542
|
function serializeInlineOf(blockSchemaType, schema, options2) {
|
|
2549
2543
|
const childrenType = blockSchemaType.fields.find((f) => f.name === "children")?.type;
|
|
2550
|
-
if (!(!childrenType || !isArraySchemaType(childrenType)))
|
|
2544
|
+
if (!(!childrenType || !sanity.isArraySchemaType(childrenType)))
|
|
2551
2545
|
return arrayOf(
|
|
2552
2546
|
{
|
|
2553
2547
|
of: childrenType.of.filter((t) => !isType(t, "span"))
|
|
@@ -2558,7 +2552,7 @@ function serializeInlineOf(blockSchemaType, schema, options2) {
|
|
|
2558
2552
|
}
|
|
2559
2553
|
function serializeAnnotations(blockSchemaType, schema, options2) {
|
|
2560
2554
|
const marksType = blockSchemaType.fields.find((f) => f.name === "markDefs")?.type;
|
|
2561
|
-
if (!(!marksType || !isArraySchemaType(marksType)))
|
|
2555
|
+
if (!(!marksType || !sanity.isArraySchemaType(marksType)))
|
|
2562
2556
|
return arrayOf(marksType, schema, options2);
|
|
2563
2557
|
}
|
|
2564
2558
|
function arrayOf(arrayType, schema, options2) {
|
|
@@ -2566,7 +2560,7 @@ function arrayOf(arrayType, schema, options2) {
|
|
|
2566
2560
|
}
|
|
2567
2561
|
function refToTypeNames(type) {
|
|
2568
2562
|
return type.to.map((t) => ({
|
|
2569
|
-
type: typed(t.name)
|
|
2563
|
+
type: sanity.typed(t.name)
|
|
2570
2564
|
}));
|
|
2571
2565
|
}
|
|
2572
2566
|
function removeUndef(obj) {
|
|
@@ -2586,13 +2580,13 @@ function createFieldRefCache() {
|
|
|
2586
2580
|
return getRefsForType;
|
|
2587
2581
|
}
|
|
2588
2582
|
function AiAssistanceConfigProvider(props) {
|
|
2589
|
-
const [status, setStatus] = useState(), [error, setError] = useState(), apiClient = useApiClient(props.config?.__customApiClient), { getInstructStatus, loading: statusLoading } = useGetInstructStatus(apiClient), { initInstruct, loading: initLoading } = useInitInstruct(apiClient), schema = useSchema(), serializedTypes = useMemo(() => serializeSchema(schema, { leanFormat: !0 }), [schema]), { getFieldRefs: getFieldRefs2, getFieldRefsByTypePath } = useFieldRefGetters(schema);
|
|
2590
|
-
useEffect(() => {
|
|
2583
|
+
const [status, setStatus] = react.useState(), [error, setError] = react.useState(), apiClient = useApiClient(props.config?.__customApiClient), { getInstructStatus, loading: statusLoading } = useGetInstructStatus(apiClient), { initInstruct, loading: initLoading } = useInitInstruct(apiClient), schema = sanity.useSchema(), serializedTypes = react.useMemo(() => serializeSchema(schema, { leanFormat: !0 }), [schema]), { getFieldRefs: getFieldRefs2, getFieldRefsByTypePath } = useFieldRefGetters(schema);
|
|
2584
|
+
react.useEffect(() => {
|
|
2591
2585
|
getInstructStatus().then((s) => setStatus(s)).catch((e) => {
|
|
2592
2586
|
console.error(e), setError(e);
|
|
2593
2587
|
});
|
|
2594
2588
|
}, [getInstructStatus]);
|
|
2595
|
-
const init = useCallback(async () => {
|
|
2589
|
+
const init = react.useCallback(async () => {
|
|
2596
2590
|
setError(void 0);
|
|
2597
2591
|
try {
|
|
2598
2592
|
await initInstruct();
|
|
@@ -2601,7 +2595,7 @@ function AiAssistanceConfigProvider(props) {
|
|
|
2601
2595
|
} catch (e) {
|
|
2602
2596
|
console.error("Failed to init ai assistance", e), setError(e);
|
|
2603
2597
|
}
|
|
2604
|
-
}, [initInstruct, getInstructStatus, setStatus]), { config, children } = props, context = useMemo(() => ({
|
|
2598
|
+
}, [initInstruct, getInstructStatus, setStatus]), { config, children } = props, context = react.useMemo(() => ({
|
|
2605
2599
|
config,
|
|
2606
2600
|
status,
|
|
2607
2601
|
statusLoading,
|
|
@@ -2622,10 +2616,10 @@ function AiAssistanceConfigProvider(props) {
|
|
|
2622
2616
|
getFieldRefs2,
|
|
2623
2617
|
getFieldRefsByTypePath
|
|
2624
2618
|
]);
|
|
2625
|
-
return /* @__PURE__ */ jsx(AiAssistanceConfigContext.Provider, { value: context, children });
|
|
2619
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AiAssistanceConfigContext.Provider, { value: context, children });
|
|
2626
2620
|
}
|
|
2627
2621
|
function useFieldRefGetters(schema) {
|
|
2628
|
-
return useMemo(() => {
|
|
2622
|
+
return react.useMemo(() => {
|
|
2629
2623
|
const getForSchemaType = createFieldRefCache();
|
|
2630
2624
|
function getRefsForType(documentType) {
|
|
2631
2625
|
const schemaType = schema.get(documentType);
|
|
@@ -2640,23 +2634,23 @@ function useFieldRefGetters(schema) {
|
|
|
2640
2634
|
}, [schema]);
|
|
2641
2635
|
}
|
|
2642
2636
|
function AssistLayout(props) {
|
|
2643
|
-
const [connectors, setConnectors] = useState([]);
|
|
2644
|
-
return /* @__PURE__ */ jsx(AiAssistanceConfigProvider, { config: props.config, children: /* @__PURE__ */ jsx(RunInstructionProvider, { children: /* @__PURE__ */ jsx(FieldTranslationProvider, { children: /* @__PURE__ */ jsxs(ConnectorsProvider, { onConnectorsChange: setConnectors, children: [
|
|
2637
|
+
const [connectors, setConnectors] = react.useState([]);
|
|
2638
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AiAssistanceConfigProvider, { config: props.config, children: /* @__PURE__ */ jsxRuntime.jsx(RunInstructionProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(FieldTranslationProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(ConnectorsProvider, { onConnectorsChange: setConnectors, children: [
|
|
2645
2639
|
props.renderDefault(props),
|
|
2646
|
-
/* @__PURE__ */ jsx(ThemeProvider, { tone: "default", children: /* @__PURE__ */ jsx(AssistConnectorsOverlay, { connectors }) })
|
|
2640
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.ThemeProvider, { tone: "default", children: /* @__PURE__ */ jsxRuntime.jsx(AssistConnectorsOverlay, { connectors }) })
|
|
2647
2641
|
] }) }) }) });
|
|
2648
2642
|
}
|
|
2649
|
-
const ImageContext = createContext({});
|
|
2643
|
+
const ImageContext = react.createContext({});
|
|
2650
2644
|
function ImageContextProvider(props) {
|
|
2651
|
-
const { schemaType, path, value, readOnly } = props, assetRef = value?.asset?._ref, { selectedReleaseId } = useDocumentPane(), [assetRefState, setAssetRefState] = useState(assetRef), { assistableDocumentId, documentSchemaType } = useAssistDocumentContext(), { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateCaption } = useGenerateCaption(apiClient), { isSyncing } = useSyncState(
|
|
2652
|
-
getPublishedId(assistableDocumentId),
|
|
2645
|
+
const { schemaType, path, value, readOnly } = props, assetRef = value?.asset?._ref, { selectedReleaseId } = structure.useDocumentPane(), [assetRefState, setAssetRefState] = react.useState(assetRef), { assistableDocumentId, documentSchemaType } = useAssistDocumentContext(), { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateCaption } = useGenerateCaption(apiClient), { isSyncing } = sanity.useSyncState(
|
|
2646
|
+
sanity.getPublishedId(assistableDocumentId),
|
|
2653
2647
|
documentSchemaType.name,
|
|
2654
2648
|
selectedReleaseId
|
|
2655
|
-
), isShowingOlderRevision = !!usePaneRouter().params?.rev;
|
|
2656
|
-
useEffect(() => {
|
|
2649
|
+
), isShowingOlderRevision = !!structure.usePaneRouter().params?.rev;
|
|
2650
|
+
react.useEffect(() => {
|
|
2657
2651
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
2658
2652
|
assetRef && assistableDocumentId && descriptionField?.updateOnImageChange && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly && (setAssetRefState(assetRef), canUseAssist(status) && generateCaption({
|
|
2659
|
-
path: pathToString([...path, descriptionField.path]),
|
|
2653
|
+
path: sanity.pathToString([...path, descriptionField.path]),
|
|
2660
2654
|
documentId: assistableDocumentId
|
|
2661
2655
|
}));
|
|
2662
2656
|
}, [
|
|
@@ -2671,27 +2665,27 @@ function ImageContextProvider(props) {
|
|
|
2671
2665
|
readOnly,
|
|
2672
2666
|
isShowingOlderRevision
|
|
2673
2667
|
]);
|
|
2674
|
-
const context = useMemo(() => {
|
|
2668
|
+
const context = react.useMemo(() => {
|
|
2675
2669
|
const descriptionField = getDescriptionFieldOption(schemaType), imageInstructionField = getImageInstructionFieldOption(schemaType);
|
|
2676
2670
|
return {
|
|
2677
|
-
imageDescriptionPath: descriptionField?.path ? pathToString([...path, descriptionField.path]) : void 0,
|
|
2678
|
-
imageInstructionPath: imageInstructionField ? pathToString([...path, imageInstructionField]) : void 0,
|
|
2671
|
+
imageDescriptionPath: descriptionField?.path ? sanity.pathToString([...path, descriptionField.path]) : void 0,
|
|
2672
|
+
imageInstructionPath: imageInstructionField ? sanity.pathToString([...path, imageInstructionField]) : void 0,
|
|
2679
2673
|
assetRef
|
|
2680
2674
|
};
|
|
2681
2675
|
}, [schemaType, path, assetRef]);
|
|
2682
|
-
return /* @__PURE__ */ jsx(ImageContext.Provider, { value: context, children: props.renderDefault(props) });
|
|
2676
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ImageContext.Provider, { value: context, children: props.renderDefault(props) });
|
|
2683
2677
|
}
|
|
2684
2678
|
function IconInput(props) {
|
|
2685
|
-
const { value, onChange } = props, id = useId(), items = useMemo(
|
|
2686
|
-
() => Object.entries(icons).map(([key, icon]) => /* @__PURE__ */ jsx(IconItem, { iconKey: key, icon, onChange }, key)),
|
|
2679
|
+
const { value, onChange } = props, id = react.useId(), items = react.useMemo(
|
|
2680
|
+
() => Object.entries(icons.icons).map(([key, icon]) => /* @__PURE__ */ jsxRuntime.jsx(IconItem, { iconKey: key, icon, onChange }, key)),
|
|
2687
2681
|
[onChange]
|
|
2688
|
-
), selectedIcon = useMemo(() => getIcon(value), [value]);
|
|
2689
|
-
return /* @__PURE__ */ jsx(
|
|
2690
|
-
MenuButton,
|
|
2682
|
+
), selectedIcon = react.useMemo(() => getIcon(value), [value]);
|
|
2683
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2684
|
+
ui.MenuButton,
|
|
2691
2685
|
{
|
|
2692
|
-
button: /* @__PURE__ */ jsx(Button, { icon: selectedIcon, title: "Select icon", padding: 3, mode: "ghost", radius: 1 }),
|
|
2686
|
+
button: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { icon: selectedIcon, title: "Select icon", padding: 3, mode: "ghost", radius: 1 }),
|
|
2693
2687
|
id,
|
|
2694
|
-
menu: /* @__PURE__ */ jsx(Menu, { style: { maxHeight: 300 }, children: items }),
|
|
2688
|
+
menu: /* @__PURE__ */ jsxRuntime.jsx(ui.Menu, { style: { maxHeight: 300 }, children: items }),
|
|
2695
2689
|
popover: { portal: !0 }
|
|
2696
2690
|
}
|
|
2697
2691
|
);
|
|
@@ -2701,19 +2695,19 @@ function IconItem({
|
|
|
2701
2695
|
iconKey: key,
|
|
2702
2696
|
onChange
|
|
2703
2697
|
}) {
|
|
2704
|
-
const onClick = useCallback(() => onChange(set(key)), [onChange, key]);
|
|
2705
|
-
return /* @__PURE__ */ jsx(MenuItem, { icon, title: key, text: key, onClick });
|
|
2698
|
+
const onClick = react.useCallback(() => onChange(sanity.set(key)), [onChange, key]);
|
|
2699
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.MenuItem, { icon, title: key, text: key, onClick });
|
|
2706
2700
|
}
|
|
2707
2701
|
function getIcon(iconName) {
|
|
2708
|
-
return Object.entries(icons).find(([key]) => key === iconName)?.[1] ?? icons.sparkles;
|
|
2702
|
+
return Object.entries(icons.icons).find(([key]) => key === iconName)?.[1] ?? icons.icons.sparkles;
|
|
2709
2703
|
}
|
|
2710
2704
|
function useAssistSupported(path, schemaType) {
|
|
2711
|
-
return useMemo(() => isAssistSupported(schemaType), [schemaType]);
|
|
2705
|
+
return react.useMemo(() => isAssistSupported(schemaType), [schemaType]);
|
|
2712
2706
|
}
|
|
2713
2707
|
const translateActions = {
|
|
2714
2708
|
name: "sanity-assist-translate",
|
|
2715
2709
|
useAction(props) {
|
|
2716
|
-
const { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), client = useClient({ apiVersion: API_VERSION_WITH_EXTENDED_TYPES }), {
|
|
2710
|
+
const { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), client = sanity.useClient({ apiVersion: API_VERSION_WITH_EXTENDED_TYPES }), {
|
|
2717
2711
|
schemaType: fieldSchemaType,
|
|
2718
2712
|
path,
|
|
2719
2713
|
documentId,
|
|
@@ -2721,21 +2715,21 @@ const translateActions = {
|
|
|
2721
2715
|
documentIsAssistable
|
|
2722
2716
|
} = props, isDocumentLevel = path.length === 0, readOnly = fieldSchemaType.readOnly === !0, docTransTypes = config.translate?.document?.documentTypes, options2 = fieldSchemaType?.options, addFieldAction = isDocumentLevel || options2?.aiAssist?.translateAction, fieldTransEnabled = addFieldAction && documentSchemaType && config.translate?.field?.documentTypes?.includes(documentSchemaType.name), documentTranslationEnabled = addFieldAction && documentSchemaType && (!docTransTypes && isAssistSupported(fieldSchemaType) || docTransTypes?.includes(documentSchemaType.name));
|
|
2723
2717
|
if (documentSchemaType && (documentTranslationEnabled || fieldTransEnabled)) {
|
|
2724
|
-
const { value: documentValue, onChange: documentOnChange, formState } = useDocumentPane(), docRef = useRef(documentValue);
|
|
2718
|
+
const { value: documentValue, onChange: documentOnChange, formState } = structure.useDocumentPane(), docRef = react.useRef(documentValue);
|
|
2725
2719
|
docRef.current = documentValue;
|
|
2726
|
-
const formStateRef = useRef(formState);
|
|
2720
|
+
const formStateRef = react.useRef(formState);
|
|
2727
2721
|
formStateRef.current = formState;
|
|
2728
2722
|
const translationApi = useTranslate(apiClient), translate = useDraftDelayedTask({
|
|
2729
2723
|
documentOnChange,
|
|
2730
2724
|
isDocAssistable: documentIsAssistable ?? !1,
|
|
2731
2725
|
task: translationApi.translate
|
|
2732
|
-
}), styleguide = config.translate?.styleguide, languagePath = config.translate?.document?.languageField, translateDocumentAction = useMemo(() => {
|
|
2726
|
+
}), styleguide = config.translate?.styleguide, languagePath = config.translate?.document?.languageField, translateDocumentAction = react.useMemo(() => {
|
|
2733
2727
|
if (!languagePath || !documentTranslationEnabled)
|
|
2734
2728
|
return;
|
|
2735
2729
|
const title = path.length ? "Translate" : "Translate document";
|
|
2736
2730
|
return {
|
|
2737
2731
|
type: "action",
|
|
2738
|
-
icon: translationApi.loading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : TranslateIcon,
|
|
2732
|
+
icon: translationApi.loading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.TranslateIcon,
|
|
2739
2733
|
title,
|
|
2740
2734
|
onAction: () => {
|
|
2741
2735
|
translationApi.loading || !languagePath || !documentId || translate({
|
|
@@ -2768,10 +2762,10 @@ const translateActions = {
|
|
|
2768
2762
|
documentOnChange,
|
|
2769
2763
|
isDocAssistable: documentIsAssistable ?? !1,
|
|
2770
2764
|
task: fieldTranslate.openFieldTranslation
|
|
2771
|
-
}), maxDepth2 = config.translate?.field?.maxPathDepth, translateFieldsAction = useMemo(
|
|
2765
|
+
}), maxDepth2 = config.translate?.field?.maxPathDepth, translateFieldsAction = react.useMemo(
|
|
2772
2766
|
() => fieldTransEnabled ? {
|
|
2773
2767
|
type: "action",
|
|
2774
|
-
icon: fieldTranslate.translationLoading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : TranslateIcon,
|
|
2768
|
+
icon: fieldTranslate.translationLoading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.TranslateIcon,
|
|
2775
2769
|
title: "Translate fields...",
|
|
2776
2770
|
onAction: () => {
|
|
2777
2771
|
fieldTranslate.translationLoading || !documentId || (formStateRef.current && getConditionalMembers(formStateRef.current), openFieldTranslation({
|
|
@@ -2798,7 +2792,7 @@ const translateActions = {
|
|
|
2798
2792
|
maxDepth2
|
|
2799
2793
|
]
|
|
2800
2794
|
);
|
|
2801
|
-
return useMemo(() => {
|
|
2795
|
+
return react.useMemo(() => {
|
|
2802
2796
|
if (status?.initialized)
|
|
2803
2797
|
return {
|
|
2804
2798
|
type: "group",
|
|
@@ -2815,12 +2809,12 @@ const translateActions = {
|
|
|
2815
2809
|
}, generateCaptionsActions = {
|
|
2816
2810
|
name: "sanity-assist-generate-captions",
|
|
2817
2811
|
useAction(props) {
|
|
2818
|
-
const pathKey = usePathKey(props.path), { openInspector } = useDocumentPane(), { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateCaption, loading } = useGenerateCaption(apiClient), imageContext = useContext(ImageContext);
|
|
2812
|
+
const pathKey = usePathKey(props.path), { openInspector } = structure.useDocumentPane(), { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateCaption, loading } = useGenerateCaption(apiClient), imageContext = react.useContext(ImageContext);
|
|
2819
2813
|
if (imageContext && pathKey === imageContext?.imageDescriptionPath) {
|
|
2820
2814
|
const { assistableDocumentId } = useAssistDocumentContext();
|
|
2821
|
-
return useMemo(() => ({
|
|
2815
|
+
return react.useMemo(() => ({
|
|
2822
2816
|
type: "action",
|
|
2823
|
-
icon: loading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : ImageIcon,
|
|
2817
|
+
icon: loading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.ImageIcon,
|
|
2824
2818
|
title: "Generate image description",
|
|
2825
2819
|
onAction: () => {
|
|
2826
2820
|
if (!loading) {
|
|
@@ -2851,12 +2845,12 @@ const translateActions = {
|
|
|
2851
2845
|
}, generateImagActions = {
|
|
2852
2846
|
name: "sanity-assist-generate-image",
|
|
2853
2847
|
useAction(props) {
|
|
2854
|
-
const pathKey = usePathKey(props.path), { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateImage, loading } = useGenerateImage(apiClient), imageContext = useContext(ImageContext);
|
|
2848
|
+
const pathKey = usePathKey(props.path), { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateImage, loading } = useGenerateImage(apiClient), imageContext = react.useContext(ImageContext);
|
|
2855
2849
|
if (imageContext && pathKey === imageContext?.imageInstructionPath) {
|
|
2856
2850
|
const { assistableDocumentId } = useAssistDocumentContext();
|
|
2857
|
-
return useMemo(() => ({
|
|
2851
|
+
return react.useMemo(() => ({
|
|
2858
2852
|
type: "action",
|
|
2859
|
-
icon: loading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : ImageIcon,
|
|
2853
|
+
icon: loading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.ImageIcon,
|
|
2860
2854
|
title: "Generate image from prompt",
|
|
2861
2855
|
onAction: () => {
|
|
2862
2856
|
loading || generateImage({ path: pathKey, documentId: assistableDocumentId });
|
|
@@ -2868,15 +2862,15 @@ const translateActions = {
|
|
|
2868
2862
|
}
|
|
2869
2863
|
};
|
|
2870
2864
|
function PrivateIcon() {
|
|
2871
|
-
return /* @__PURE__ */ jsx(
|
|
2872
|
-
Tooltip,
|
|
2865
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2866
|
+
ui.Tooltip,
|
|
2873
2867
|
{
|
|
2874
|
-
content: /* @__PURE__ */ jsx(Text, { size: 1, style: { whiteSpace: "nowrap" }, children: "Only visible to you" }),
|
|
2868
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { whiteSpace: "nowrap" }, children: "Only visible to you" }),
|
|
2875
2869
|
fallbackPlacements: ["bottom"],
|
|
2876
2870
|
padding: 2,
|
|
2877
2871
|
placement: "top",
|
|
2878
2872
|
portal: !0,
|
|
2879
|
-
children: /* @__PURE__ */ jsx(LockIcon, {})
|
|
2873
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.LockIcon, {})
|
|
2880
2874
|
}
|
|
2881
2875
|
);
|
|
2882
2876
|
}
|
|
@@ -2925,12 +2919,12 @@ function defineAssistFieldActionGroup(group) {
|
|
|
2925
2919
|
function useCustomFieldActions(props) {
|
|
2926
2920
|
const {
|
|
2927
2921
|
config: { fieldActions }
|
|
2928
|
-
} = useAiAssistanceConfig(), { addSyntheticTask, removeSyntheticTask } = useAssistDocumentContext(), schemaId = useWorkspaceSchemaId(), { push: pushToast } = useToast(), configActions = fieldActions?.useFieldActions?.({
|
|
2922
|
+
} = useAiAssistanceConfig(), { addSyntheticTask, removeSyntheticTask } = useAssistDocumentContext(), schemaId = sanity.useWorkspaceSchemaId(), { push: pushToast } = ui.useToast(), configActions = fieldActions?.useFieldActions?.({
|
|
2929
2923
|
...props,
|
|
2930
2924
|
schemaId,
|
|
2931
2925
|
path: props.path
|
|
2932
2926
|
});
|
|
2933
|
-
return useMemo(() => {
|
|
2927
|
+
return react.useMemo(() => {
|
|
2934
2928
|
const title = fieldActions?.title, customActions = configActions?.filter(isDefined).map((node) => createSafeNode({
|
|
2935
2929
|
node,
|
|
2936
2930
|
pushToast,
|
|
@@ -3019,30 +3013,30 @@ const assistFieldActions = {
|
|
|
3019
3013
|
selectedPath,
|
|
3020
3014
|
assistableDocumentId,
|
|
3021
3015
|
fieldRefsByTypePath
|
|
3022
|
-
} = useAssistDocumentContext(), { value: docValue, formState } = useDocumentPane(), docValueRef = useRef(docValue), formStateRef = useRef(formState);
|
|
3016
|
+
} = useAssistDocumentContext(), { value: docValue, formState } = structure.useDocumentPane(), docValueRef = react.useRef(docValue), formStateRef = react.useRef(formState);
|
|
3023
3017
|
formStateRef.current = formState;
|
|
3024
|
-
const currentUser = useCurrentUser(), isHidden = !assistDocument, pathKey = usePathKey(props.path), typePath = useTypePath(docValue, pathKey), assistDocumentId2 = assistDocument?._id, { requestRunInstruction } = useRequestRunInstruction({
|
|
3018
|
+
const currentUser = sanity.useCurrentUser(), isHidden = !assistDocument, pathKey = usePathKey(props.path), typePath = useTypePath(docValue, pathKey), assistDocumentId2 = assistDocument?._id, { requestRunInstruction } = useRequestRunInstruction({
|
|
3025
3019
|
documentOnChange,
|
|
3026
3020
|
isDocAssistable: documentIsAssistable ?? !1
|
|
3027
|
-
}), isSelectable = !!useSelectedField(documentSchemaType, typePath), assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType) && schemaType.readOnly !== !0, fieldAssist = useMemo(
|
|
3021
|
+
}), isSelectable = !!useSelectedField(documentSchemaType, typePath), assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType) && schemaType.readOnly !== !0, fieldAssist = react.useMemo(
|
|
3028
3022
|
() => (assistDocument?.fields ?? []).find(
|
|
3029
3023
|
(f) => f.path === typePath || pathKey === documentRootKey && f.path === pathKey
|
|
3030
3024
|
),
|
|
3031
3025
|
[assistDocument?.fields, pathKey, typePath]
|
|
3032
3026
|
), fieldAssistKey = fieldAssist?._key, isSelected = inspector?.name === aiInspectorId && pathKey === selectedPath, imageCaptionAction = generateCaptionsActions.useAction(props), imageGenAction = generateImagActions.useAction(props), translateAction = translateActions.useAction(
|
|
3033
|
-
typed({
|
|
3027
|
+
sanity.typed({
|
|
3034
3028
|
...props,
|
|
3035
3029
|
documentId: assistableDocumentId,
|
|
3036
3030
|
documentIsAssistable,
|
|
3037
3031
|
documentSchemaType
|
|
3038
3032
|
})
|
|
3039
|
-
), manageInstructions = useCallback(
|
|
3033
|
+
), manageInstructions = react.useCallback(
|
|
3040
3034
|
() => isSelected ? closeInspector(aiInspectorId) : openInspector(aiInspectorId, {
|
|
3041
3035
|
[fieldPathParam]: pathKey,
|
|
3042
3036
|
[instructionParam]: void 0
|
|
3043
3037
|
}),
|
|
3044
3038
|
[openInspector, closeInspector, isSelected, pathKey]
|
|
3045
|
-
), onInstructionAction = useCallback(
|
|
3039
|
+
), onInstructionAction = react.useCallback(
|
|
3046
3040
|
(instruction2) => {
|
|
3047
3041
|
!pathKey || !fieldAssistKey || !assistDocumentId2 || !assistableDocumentId || requestRunInstruction({
|
|
3048
3042
|
documentId: assistableDocumentId,
|
|
@@ -3061,16 +3055,16 @@ const assistFieldActions = {
|
|
|
3061
3055
|
assistDocumentId2,
|
|
3062
3056
|
fieldAssistKey
|
|
3063
3057
|
]
|
|
3064
|
-
), privateInstructions = useMemo(
|
|
3058
|
+
), privateInstructions = react.useMemo(
|
|
3065
3059
|
() => fieldAssist?.instructions?.filter((i) => i.userId && i.userId === currentUser?.id) || [],
|
|
3066
3060
|
[fieldAssist?.instructions, currentUser]
|
|
3067
|
-
), sharedInstructions = useMemo(
|
|
3061
|
+
), sharedInstructions = react.useMemo(
|
|
3068
3062
|
() => fieldAssist?.instructions?.filter((i) => !i.userId) || [],
|
|
3069
3063
|
[fieldAssist?.instructions]
|
|
3070
|
-
), instructions = useMemo(
|
|
3064
|
+
), instructions = react.useMemo(
|
|
3071
3065
|
() => [...privateInstructions, ...sharedInstructions],
|
|
3072
3066
|
[privateInstructions, sharedInstructions]
|
|
3073
|
-
), runInstructionsGroup = useMemo(() => instructions?.length || imageCaptionAction || translateAction || imageGenAction ? {
|
|
3067
|
+
), runInstructionsGroup = react.useMemo(() => instructions?.length || imageCaptionAction || translateAction || imageGenAction ? {
|
|
3074
3068
|
type: "group",
|
|
3075
3069
|
icon: () => null,
|
|
3076
3070
|
title: "Run instructions",
|
|
@@ -3098,20 +3092,20 @@ const assistFieldActions = {
|
|
|
3098
3092
|
imageCaptionAction,
|
|
3099
3093
|
translateAction,
|
|
3100
3094
|
imageGenAction
|
|
3101
|
-
]), getDocumentValue = useCallback(() => docValueRef.current, []), getConditionalPaths = useCallback(() => (formStateRef.current ? getConditionalMembers(formStateRef.current) : []).flatMap(
|
|
3095
|
+
]), getDocumentValue = react.useCallback(() => docValueRef.current, []), getConditionalPaths = react.useCallback(() => (formStateRef.current ? getConditionalMembers(formStateRef.current) : []).flatMap(
|
|
3102
3096
|
(cm) => {
|
|
3103
|
-
const path = stringToPath(cm.path);
|
|
3097
|
+
const path = sanity.stringToPath(cm.path);
|
|
3104
3098
|
return path.some((s) => typeof s == "number") ? [] : {
|
|
3105
3099
|
...cm,
|
|
3106
3100
|
path
|
|
3107
3101
|
};
|
|
3108
3102
|
}
|
|
3109
|
-
), []), parentSchemaType = useMemo(() => {
|
|
3103
|
+
), []), parentSchemaType = react.useMemo(() => {
|
|
3110
3104
|
if (props.path.length) {
|
|
3111
3105
|
if (props.path.length === 1)
|
|
3112
3106
|
return documentSchemaType;
|
|
3113
3107
|
} else return;
|
|
3114
|
-
const parentPath = props.path.slice(0, -1), typePath2 = getTypePath(docValueRef.current, pathToString(parentPath));
|
|
3108
|
+
const parentPath = props.path.slice(0, -1), typePath2 = getTypePath(docValueRef.current, sanity.pathToString(parentPath));
|
|
3115
3109
|
return typePath2 ? fieldRefsByTypePath[typePath2]?.schemaType : void 0;
|
|
3116
3110
|
}, [fieldRefsByTypePath, props.path, documentSchemaType]), customActions = useCustomFieldActions({
|
|
3117
3111
|
actionType: props.path.length ? "field" : "document",
|
|
@@ -3122,19 +3116,19 @@ const assistFieldActions = {
|
|
|
3122
3116
|
getDocumentValue,
|
|
3123
3117
|
getConditionalPaths,
|
|
3124
3118
|
parentSchemaType
|
|
3125
|
-
}), manageInstructionsItem = useMemo(
|
|
3119
|
+
}), manageInstructionsItem = react.useMemo(
|
|
3126
3120
|
() => ({
|
|
3127
3121
|
type: "action",
|
|
3128
|
-
icon: ControlsIcon,
|
|
3122
|
+
icon: icons.ControlsIcon,
|
|
3129
3123
|
title: "Manage instructions",
|
|
3130
3124
|
onAction: manageInstructions,
|
|
3131
3125
|
selected: isSelected
|
|
3132
3126
|
}),
|
|
3133
3127
|
[manageInstructions, isSelected]
|
|
3134
|
-
), group = useMemo(
|
|
3128
|
+
), group = react.useMemo(
|
|
3135
3129
|
() => ({
|
|
3136
3130
|
type: "group",
|
|
3137
|
-
icon: SparklesIcon,
|
|
3131
|
+
icon: icons.SparklesIcon,
|
|
3138
3132
|
title: pluginTitleShort,
|
|
3139
3133
|
children: [
|
|
3140
3134
|
runInstructionsGroup,
|
|
@@ -3156,11 +3150,11 @@ const assistFieldActions = {
|
|
|
3156
3150
|
imageGenAction,
|
|
3157
3151
|
customActions
|
|
3158
3152
|
]
|
|
3159
|
-
), emptyAction = useMemo(
|
|
3153
|
+
), emptyAction = react.useMemo(
|
|
3160
3154
|
() => ({
|
|
3161
3155
|
type: "action",
|
|
3162
3156
|
hidden: !assistSupported,
|
|
3163
|
-
icon: SparklesIcon,
|
|
3157
|
+
icon: icons.SparklesIcon,
|
|
3164
3158
|
onAction: manageInstructions,
|
|
3165
3159
|
renderAsButton: !0,
|
|
3166
3160
|
title: pluginTitleShort,
|
|
@@ -3185,11 +3179,11 @@ function instructionItem(props) {
|
|
|
3185
3179
|
}
|
|
3186
3180
|
function createAssistDocumentPresence(documentId) {
|
|
3187
3181
|
return function() {
|
|
3188
|
-
return documentId ? /* @__PURE__ */ jsx(AssistDocumentPresence, {}) : null;
|
|
3182
|
+
return documentId ? /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentPresence, {}) : null;
|
|
3189
3183
|
};
|
|
3190
3184
|
}
|
|
3191
3185
|
function AssistDocumentPresence() {
|
|
3192
|
-
const { assistDocument, syntheticTasks } = useAssistDocumentContext(), anyPresence = useMemo(() => {
|
|
3186
|
+
const { assistDocument, syntheticTasks } = useAssistDocumentContext(), anyPresence = react.useMemo(() => {
|
|
3193
3187
|
const anyPresence2 = [...assistDocument?.tasks ?? [], ...syntheticTasks ?? []].filter((run) => !run.ended && !run.reason)?.flatMap((run) => run.presence ?? []).find((f) => f.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f.started).getTime() < 3e4);
|
|
3194
3188
|
if (anyPresence2)
|
|
3195
3189
|
return aiPresence(anyPresence2, []);
|
|
@@ -3202,19 +3196,19 @@ function AssistDocumentPresence() {
|
|
|
3202
3196
|
[]
|
|
3203
3197
|
) : void 0;
|
|
3204
3198
|
}, [assistDocument?.tasks, syntheticTasks]);
|
|
3205
|
-
return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Flex, { flex: 1, justify: "flex-end", children: /* @__PURE__ */ jsx(Flex, { gap: 2, align: "center", children: anyPresence && /* @__PURE__ */ jsx(AiFieldPresence, { presence: anyPresence }) }) }) });
|
|
3199
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { flex: 1, justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 2, align: "center", children: anyPresence && /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: anyPresence }) }) }) });
|
|
3206
3200
|
}
|
|
3207
3201
|
function BackToInstructionListLink() {
|
|
3208
|
-
const { openInspector } = useDocumentPane(), goBack = useCallback(
|
|
3202
|
+
const { openInspector } = structure.useDocumentPane(), goBack = react.useCallback(
|
|
3209
3203
|
() => openInspector(aiInspectorId, { [instructionParam]: void 0 }),
|
|
3210
3204
|
[openInspector]
|
|
3211
3205
|
);
|
|
3212
|
-
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
3213
|
-
Button,
|
|
3206
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3207
|
+
ui.Button,
|
|
3214
3208
|
{
|
|
3215
3209
|
as: "a",
|
|
3216
3210
|
fontSize: 1,
|
|
3217
|
-
icon: ArrowLeftIcon,
|
|
3211
|
+
icon: icons.ArrowLeftIcon,
|
|
3218
3212
|
mode: "bleed",
|
|
3219
3213
|
padding: 1,
|
|
3220
3214
|
space: 2,
|
|
@@ -3224,38 +3218,38 @@ function BackToInstructionListLink() {
|
|
|
3224
3218
|
}
|
|
3225
3219
|
) });
|
|
3226
3220
|
}
|
|
3227
|
-
const SelectedFieldContext = createContext(void 0), SelectedFieldContextProvider = SelectedFieldContext.Provider, EMPTY_FIELDS = [];
|
|
3221
|
+
const SelectedFieldContext = react.createContext(void 0), SelectedFieldContextProvider = SelectedFieldContext.Provider, EMPTY_FIELDS = [];
|
|
3228
3222
|
function AssistDocumentForm(props) {
|
|
3229
|
-
return props.readOnly ? /* @__PURE__ */ jsx(Card, { border: !0, tone: "caution", padding: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, children: " You do not have sufficient permissions to manage instructions." }) }) : /* @__PURE__ */ jsx(AssistDocumentFormEditable, { ...props });
|
|
3223
|
+
return props.readOnly ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, tone: "caution", padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: " You do not have sufficient permissions to manage instructions." }) }) : /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentFormEditable, { ...props });
|
|
3230
3224
|
}
|
|
3231
3225
|
function AssistDocumentFormEditable(props) {
|
|
3232
|
-
const { onChange } = props, value = props.value, id = value?._id, fields = value?.fields, { params, setParams } = useAiPaneRouter(), pathKey = params[fieldPathParam], { typePath, documentType: targetDocumentType } = useContext(AssistTypeContext), instruction2 = params[instructionParam], activeKey = useMemo(() => {
|
|
3226
|
+
const { onChange } = props, value = props.value, id = value?._id, fields = value?.fields, { params, setParams } = useAiPaneRouter(), pathKey = params[fieldPathParam], { typePath, documentType: targetDocumentType } = react.useContext(AssistTypeContext), instruction2 = params[instructionParam], activeKey = react.useMemo(() => {
|
|
3233
3227
|
if (typePath)
|
|
3234
3228
|
return (fields ?? EMPTY_FIELDS).find((f) => f.path === typePath)?._key;
|
|
3235
|
-
}, [fields, typePath]), activePath = useMemo(() => {
|
|
3229
|
+
}, [fields, typePath]), activePath = react.useMemo(() => {
|
|
3236
3230
|
if (!activeKey)
|
|
3237
3231
|
return;
|
|
3238
3232
|
const base = ["fields", { _key: activeKey }];
|
|
3239
3233
|
return instruction2 ? [...base, "instructions", { _key: instruction2 }] : base;
|
|
3240
|
-
}, [activeKey, instruction2]), schema = useSchema(), documentSchema = useMemo(() => {
|
|
3234
|
+
}, [activeKey, instruction2]), schema = sanity.useSchema(), documentSchema = react.useMemo(() => {
|
|
3241
3235
|
if (targetDocumentType)
|
|
3242
3236
|
return schema.get(targetDocumentType);
|
|
3243
|
-
}, [schema, targetDocumentType]), fieldSchema = useSelectedSchema(pathKey, documentSchema), context = useMemo(
|
|
3237
|
+
}, [schema, targetDocumentType]), fieldSchema = useSelectedSchema(pathKey, documentSchema), context = react.useMemo(
|
|
3244
3238
|
() => ({
|
|
3245
3239
|
documentSchema,
|
|
3246
3240
|
fieldSchema: fieldSchema ?? documentSchema
|
|
3247
3241
|
}),
|
|
3248
3242
|
[fieldSchema, documentSchema]
|
|
3249
3243
|
), title = value?.title;
|
|
3250
|
-
useEffect(() => {
|
|
3251
|
-
!title && documentSchema && !id?.startsWith("drafts.") && onChange(set(documentSchema.title ?? documentSchema.name, ["title"]));
|
|
3244
|
+
react.useEffect(() => {
|
|
3245
|
+
!title && documentSchema && !id?.startsWith("drafts.") && onChange(sanity.set(documentSchema.title ?? documentSchema.name, ["title"]));
|
|
3252
3246
|
}, [title, documentSchema, onChange, id]);
|
|
3253
|
-
const { onPathOpen, ...formCallbacks } = useFormCallbacks(), newCallbacks = useMemo(
|
|
3247
|
+
const { onPathOpen, ...formCallbacks } = sanity.useFormCallbacks(), newCallbacks = react.useMemo(
|
|
3254
3248
|
() => ({
|
|
3255
3249
|
...formCallbacks,
|
|
3256
3250
|
onPathOpen: (path) => {
|
|
3257
3251
|
!instruction2 && path.length === 4 && path[2] === "instructions" ? (setParams(
|
|
3258
|
-
typed({
|
|
3252
|
+
sanity.typed({
|
|
3259
3253
|
...params,
|
|
3260
3254
|
[instructionParam]: path[3]?._key
|
|
3261
3255
|
})
|
|
@@ -3264,18 +3258,18 @@ function AssistDocumentFormEditable(props) {
|
|
|
3264
3258
|
}),
|
|
3265
3259
|
[formCallbacks, onPathOpen, params, setParams, instruction2]
|
|
3266
3260
|
);
|
|
3267
|
-
useEffect(() => {
|
|
3261
|
+
react.useEffect(() => {
|
|
3268
3262
|
activePath && !instruction2 && onPathOpen([]);
|
|
3269
3263
|
}, [activePath, instruction2, onPathOpen]);
|
|
3270
|
-
const fieldError = useMemo(() => {
|
|
3264
|
+
const fieldError = react.useMemo(() => {
|
|
3271
3265
|
const fieldError2 = props.members.find(
|
|
3272
3266
|
(m) => m.kind === "error" && m.fieldName === "fields"
|
|
3273
3267
|
);
|
|
3274
3268
|
if (fieldError2)
|
|
3275
|
-
return /* @__PURE__ */ jsx(MemberFieldError, { member: fieldError2 });
|
|
3269
|
+
return /* @__PURE__ */ jsxRuntime.jsx(sanity.MemberFieldError, { member: fieldError2 });
|
|
3276
3270
|
}, [props.members]);
|
|
3277
|
-
return /* @__PURE__ */ jsx(SelectedFieldContextProvider, { value: context, children: /* @__PURE__ */ jsxs(Stack, { space: 5, children: [
|
|
3278
|
-
/* @__PURE__ */ jsx(
|
|
3271
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedFieldContextProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 5, children: [
|
|
3272
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3279
3273
|
FieldsInitializer,
|
|
3280
3274
|
{
|
|
3281
3275
|
pathKey: typePath,
|
|
@@ -3286,19 +3280,19 @@ function AssistDocumentFormEditable(props) {
|
|
|
3286
3280
|
},
|
|
3287
3281
|
typePath
|
|
3288
3282
|
),
|
|
3289
|
-
instruction2 && /* @__PURE__ */ jsx(BackToInstructionListLink, {}),
|
|
3290
|
-
activePath && !fieldError && /* @__PURE__ */ jsx(FormCallbacksProvider, { ...newCallbacks, children: /* @__PURE__ */ jsx("div", { style: { lineHeight: "1.25em" }, children: /* @__PURE__ */ jsx(FormInput, { ...props, absolutePath: activePath }) }) }),
|
|
3283
|
+
instruction2 && /* @__PURE__ */ jsxRuntime.jsx(BackToInstructionListLink, {}),
|
|
3284
|
+
activePath && !fieldError && /* @__PURE__ */ jsxRuntime.jsx(sanity.FormCallbacksProvider, { ...newCallbacks, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { lineHeight: "1.25em" }, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.FormInput, { ...props, absolutePath: activePath }) }) }),
|
|
3291
3285
|
fieldError,
|
|
3292
3286
|
!activePath && props.renderDefault(props)
|
|
3293
3287
|
] }) });
|
|
3294
3288
|
}
|
|
3295
3289
|
function useSelectedSchema(fieldPath, documentSchema) {
|
|
3296
|
-
return useMemo(() => {
|
|
3290
|
+
return react.useMemo(() => {
|
|
3297
3291
|
if (!fieldPath)
|
|
3298
3292
|
return;
|
|
3299
3293
|
if (fieldPath === documentRootKey)
|
|
3300
3294
|
return documentSchema;
|
|
3301
|
-
const path = stringToPath(fieldPath);
|
|
3295
|
+
const path = sanity.stringToPath(fieldPath);
|
|
3302
3296
|
let currentSchema = documentSchema;
|
|
3303
3297
|
for (let i = 0; i < path.length; i++) {
|
|
3304
3298
|
const segment = path[i], field = currentSchema?.fields.find((f) => f.name === segment);
|
|
@@ -3322,22 +3316,22 @@ function FieldsInitializer({
|
|
|
3322
3316
|
}) {
|
|
3323
3317
|
const {
|
|
3324
3318
|
config: { __presets: presets }
|
|
3325
|
-
} = useAiAssistanceConfig(), existingField = fields?.find((f) => f._key === pathKey), documentPresets = !!documentSchema?.name && presets?.[documentSchema?.name], missingPresetInstructions = useMemo(() => {
|
|
3319
|
+
} = useAiAssistanceConfig(), existingField = fields?.find((f) => f._key === pathKey), documentPresets = !!documentSchema?.name && presets?.[documentSchema?.name], missingPresetInstructions = react.useMemo(() => {
|
|
3326
3320
|
if (!documentPresets || !pathKey)
|
|
3327
3321
|
return;
|
|
3328
3322
|
const existingInstructions = existingField?.instructions;
|
|
3329
3323
|
return documentPresets.fields?.find((f) => f.path === pathKey)?.instructions?.filter(
|
|
3330
3324
|
(i) => !existingInstructions?.some((ei) => ei._key === i._key)
|
|
3331
3325
|
);
|
|
3332
|
-
}, [documentPresets, pathKey, existingField]), initialized = useRef(!1);
|
|
3333
|
-
return useEffect(() => {
|
|
3326
|
+
}, [documentPresets, pathKey, existingField]), initialized = react.useRef(!1);
|
|
3327
|
+
return react.useEffect(() => {
|
|
3334
3328
|
if (initialized.current || !pathKey || existingField && !missingPresetInstructions?.length)
|
|
3335
3329
|
return;
|
|
3336
|
-
let event = PatchEvent.from([setIfMissing([], ["fields"])]);
|
|
3330
|
+
let event = sanity.PatchEvent.from([sanity.setIfMissing([], ["fields"])]);
|
|
3337
3331
|
existingField || (event = event.append(
|
|
3338
|
-
insert(
|
|
3332
|
+
sanity.insert(
|
|
3339
3333
|
[
|
|
3340
|
-
typed({
|
|
3334
|
+
sanity.typed({
|
|
3341
3335
|
_key: pathKey,
|
|
3342
3336
|
_type: assistFieldTypeName,
|
|
3343
3337
|
path: pathKey,
|
|
@@ -3347,8 +3341,8 @@ function FieldsInitializer({
|
|
|
3347
3341
|
"after",
|
|
3348
3342
|
["fields", -1]
|
|
3349
3343
|
)
|
|
3350
|
-
)), existingField?.instructions?.length || (event = event.append([setIfMissing([], ["fields", { _key: pathKey }, "instructions"])])), missingPresetInstructions?.length && (event = event.append(
|
|
3351
|
-
insert(
|
|
3344
|
+
)), existingField?.instructions?.length || (event = event.append([sanity.setIfMissing([], ["fields", { _key: pathKey }, "instructions"])])), missingPresetInstructions?.length && (event = event.append(
|
|
3345
|
+
sanity.insert(
|
|
3352
3346
|
missingPresetInstructions.map(
|
|
3353
3347
|
(preset) => ({
|
|
3354
3348
|
...preset,
|
|
@@ -3363,9 +3357,9 @@ function FieldsInitializer({
|
|
|
3363
3357
|
}, [activePath, onChange, pathKey, existingField, missingPresetInstructions]), null;
|
|
3364
3358
|
}
|
|
3365
3359
|
function FieldRefPreview(props) {
|
|
3366
|
-
const { actions } = props, documentSchema = useContext(SelectedFieldContext)?.documentSchema, path = useContext(InlineBlockValueContext)?.path ?? props.path, selectedField = useSelectedField(documentSchema, path);
|
|
3367
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", style: { width: "100%" }, children: [
|
|
3368
|
-
/* @__PURE__ */ jsx(Flex, { flex: 1, gap: 2, align: "center", paddingY: 3, paddingX: 1, children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { size: 1, textOverflow: "ellipsis", children: selectedField?.title ?? "Select field" }) }) }),
|
|
3360
|
+
const { actions } = props, documentSchema = react.useContext(SelectedFieldContext)?.documentSchema, path = react.useContext(InlineBlockValueContext)?.path ?? props.path, selectedField = useSelectedField(documentSchema, path);
|
|
3361
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", style: { width: "100%" }, children: [
|
|
3362
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { flex: 1, gap: 2, align: "center", paddingY: 3, paddingX: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, textOverflow: "ellipsis", children: selectedField?.title ?? "Select field" }) }) }),
|
|
3369
3363
|
actions
|
|
3370
3364
|
] });
|
|
3371
3365
|
}
|
|
@@ -3373,13 +3367,13 @@ function HiddenFieldTitle(props) {
|
|
|
3373
3367
|
return props.renderDefault({ ...props, title: "", level: props.level - 2, changed: !1 });
|
|
3374
3368
|
}
|
|
3375
3369
|
function InstructionVisibility(props) {
|
|
3376
|
-
const { value, onChange } = props, user = useCurrentUser(), handleChange = useCallback(() => {
|
|
3370
|
+
const { value, onChange } = props, user = sanity.useCurrentUser(), handleChange = react.useCallback(() => {
|
|
3377
3371
|
const newValue = value ? "" : user?.id ?? "";
|
|
3378
|
-
onChange(newValue ? set(newValue) : unset());
|
|
3379
|
-
}, [onChange, user, value]), id = useId();
|
|
3380
|
-
return /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "flex-start", children: [
|
|
3381
|
-
/* @__PURE__ */ jsx("div", { style: { margin: "-3px 0" }, children: /* @__PURE__ */ jsx(
|
|
3382
|
-
Switch,
|
|
3372
|
+
onChange(newValue ? sanity.set(newValue) : sanity.unset());
|
|
3373
|
+
}, [onChange, user, value]), id = react.useId();
|
|
3374
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "flex-start", children: [
|
|
3375
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { margin: "-3px 0" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3376
|
+
ui.Switch,
|
|
3383
3377
|
{
|
|
3384
3378
|
...props.elementProps,
|
|
3385
3379
|
id,
|
|
@@ -3389,15 +3383,15 @@ function InstructionVisibility(props) {
|
|
|
3389
3383
|
disabled: props.elementProps.readOnly
|
|
3390
3384
|
}
|
|
3391
3385
|
) }),
|
|
3392
|
-
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, weight: "medium", children: /* @__PURE__ */ jsx("label", { htmlFor: id, children: "Make visible to all Studio members" }) })
|
|
3386
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, weight: "medium", children: /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: id, children: "Make visible to all Studio members" }) })
|
|
3393
3387
|
] }) });
|
|
3394
3388
|
}
|
|
3395
3389
|
function FieldRefPathInput(props) {
|
|
3396
|
-
const documentSchema = useContext(SelectedFieldContext)?.documentSchema, { typePath } = useContext(AssistTypeContext), ref = useRef(null), id = useId(), { onChange } = props;
|
|
3397
|
-
useEffect(() => {
|
|
3390
|
+
const documentSchema = react.useContext(SelectedFieldContext)?.documentSchema, { typePath } = react.useContext(AssistTypeContext), ref = react.useRef(null), id = react.useId(), { onChange } = props;
|
|
3391
|
+
react.useEffect(() => {
|
|
3398
3392
|
ref.current?.querySelector("input")?.focus();
|
|
3399
3393
|
}, []);
|
|
3400
|
-
const onSelect = useCallback((path) => onChange(set(path)), [onChange]),
|
|
3394
|
+
const onSelect = react.useCallback((path) => onChange(sanity.set(path)), [onChange]), filter = react.useCallback(
|
|
3401
3395
|
(field) => {
|
|
3402
3396
|
if (!field.key.includes("|") || !typePath)
|
|
3403
3397
|
return !0;
|
|
@@ -3408,14 +3402,14 @@ function FieldRefPathInput(props) {
|
|
|
3408
3402
|
},
|
|
3409
3403
|
[typePath]
|
|
3410
3404
|
);
|
|
3411
|
-
return documentSchema ? /* @__PURE__ */ jsx(Box, { flex: 1, style: { minWidth: 300 }, ref, children: /* @__PURE__ */ jsx(
|
|
3405
|
+
return documentSchema ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, style: { minWidth: 300 }, ref, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3412
3406
|
FieldAutocomplete,
|
|
3413
3407
|
{
|
|
3414
3408
|
id,
|
|
3415
3409
|
schemaType: documentSchema,
|
|
3416
3410
|
onSelect,
|
|
3417
3411
|
fieldPath: props.value,
|
|
3418
|
-
filter
|
|
3412
|
+
filter
|
|
3419
3413
|
}
|
|
3420
3414
|
) }) : props.renderDefault(props);
|
|
3421
3415
|
}
|
|
@@ -3430,20 +3424,20 @@ function findFieldsetMember(members, fieldsetName) {
|
|
|
3430
3424
|
);
|
|
3431
3425
|
}
|
|
3432
3426
|
function InstructionInput(props) {
|
|
3433
|
-
return /* @__PURE__ */ jsxs(Stack, { space: [4, 4, 4, 5], children: [
|
|
3434
|
-
/* @__PURE__ */ jsx(NameField, { ...props }),
|
|
3435
|
-
/* @__PURE__ */ jsx(ShareField, { ...props }),
|
|
3436
|
-
/* @__PURE__ */ jsx(ObjectMember, { fieldName: "prompt", ...props }),
|
|
3437
|
-
/* @__PURE__ */ jsx(ObjectMember, { fieldName: "output", ...props })
|
|
3427
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: [4, 4, 4, 5], children: [
|
|
3428
|
+
/* @__PURE__ */ jsxRuntime.jsx(NameField, { ...props }),
|
|
3429
|
+
/* @__PURE__ */ jsxRuntime.jsx(ShareField, { ...props }),
|
|
3430
|
+
/* @__PURE__ */ jsxRuntime.jsx(ObjectMember, { fieldName: "prompt", ...props }),
|
|
3431
|
+
/* @__PURE__ */ jsxRuntime.jsx(ObjectMember, { fieldName: "output", ...props })
|
|
3438
3432
|
] });
|
|
3439
3433
|
}
|
|
3440
3434
|
function ObjectMember({ fieldName, ...props }) {
|
|
3441
3435
|
const member = findFieldMember(props.members, fieldName);
|
|
3442
|
-
return member ? /* @__PURE__ */ jsx(ObjectInputMember, { ...props, member }) : null;
|
|
3436
|
+
return member ? /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member }) : null;
|
|
3443
3437
|
}
|
|
3444
3438
|
const NONE = [];
|
|
3445
3439
|
function NameField(props) {
|
|
3446
|
-
const fieldsetMember = findFieldsetMember(props.members, "appearance"), titleId = useId(), members = fieldsetMember?.fieldSet.members ?? NONE, iconMember = findFieldMember(members, "icon"), titleMember = findFieldMember(members, "title"), titlePlaceholder = "Untitled", moddedTitleMember = useMemo(() => {
|
|
3440
|
+
const fieldsetMember = findFieldsetMember(props.members, "appearance"), titleId = react.useId(), members = fieldsetMember?.fieldSet.members ?? NONE, iconMember = findFieldMember(members, "icon"), titleMember = findFieldMember(members, "title"), titlePlaceholder = "Untitled", moddedTitleMember = react.useMemo(() => {
|
|
3447
3441
|
if (titleMember)
|
|
3448
3442
|
return titleMember.kind === "error" ? titleMember : {
|
|
3449
3443
|
...titleMember,
|
|
@@ -3456,28 +3450,28 @@ function NameField(props) {
|
|
|
3456
3450
|
}
|
|
3457
3451
|
};
|
|
3458
3452
|
}, [titleMember, titlePlaceholder]);
|
|
3459
|
-
return /* @__PURE__ */ jsx(Stack, { space: 5, children: /* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
3460
|
-
/* @__PURE__ */ jsx(Flex, { gap: 1, children: /* @__PURE__ */ jsx(Text, { as: "label", weight: "semibold", size: 1, htmlFor: titleId, children: "Name" }) }),
|
|
3461
|
-
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "How this instruction appears in menus" }),
|
|
3462
|
-
/* @__PURE__ */ jsxs(Flex, { align: "center", children: [
|
|
3463
|
-
iconMember && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(ObjectInputMember, { ...props, member: iconMember }) }),
|
|
3464
|
-
moddedTitleMember && /* @__PURE__ */ jsx(Box, { flex: 1, style: { marginLeft: -1 }, children: /* @__PURE__ */ jsx(ObjectInputMember, { ...props, member: moddedTitleMember }) })
|
|
3453
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
3454
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "label", weight: "semibold", size: 1, htmlFor: titleId, children: "Name" }) }),
|
|
3455
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "How this instruction appears in menus" }),
|
|
3456
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", children: [
|
|
3457
|
+
iconMember && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member: iconMember }) }),
|
|
3458
|
+
moddedTitleMember && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, style: { marginLeft: -1 }, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member: moddedTitleMember }) })
|
|
3465
3459
|
] })
|
|
3466
3460
|
] }) });
|
|
3467
3461
|
}
|
|
3468
3462
|
function ShareField(props) {
|
|
3469
3463
|
const members = findFieldsetMember(props.members, "appearance")?.fieldSet.members ?? NONE, visibilityMember = findFieldMember(members, "userId");
|
|
3470
|
-
return /* @__PURE__ */ jsx(Fragment, { children: visibilityMember && /* @__PURE__ */ jsx(ObjectInputMember, { ...props, member: visibilityMember }) });
|
|
3464
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: visibilityMember && /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member: visibilityMember }) });
|
|
3471
3465
|
}
|
|
3472
3466
|
function InstructionOutputField(props) {
|
|
3473
|
-
const { fieldSchema } = useContext(SelectedFieldContext) ?? {};
|
|
3474
|
-
return !fieldSchema || !(isObjectSchemaType(fieldSchema) || isArrayOfObjectsSchemaType(fieldSchema)) ? null : /* @__PURE__ */ jsx(EnabledOutputField, { ...props, fieldSchema, children: props.children });
|
|
3467
|
+
const { fieldSchema } = react.useContext(SelectedFieldContext) ?? {};
|
|
3468
|
+
return !fieldSchema || !(sanity.isObjectSchemaType(fieldSchema) || sanity.isArrayOfObjectsSchemaType(fieldSchema)) ? null : /* @__PURE__ */ jsxRuntime.jsx(EnabledOutputField, { ...props, fieldSchema, children: props.children });
|
|
3475
3469
|
}
|
|
3476
3470
|
function EnabledOutputField({
|
|
3477
3471
|
fieldSchema,
|
|
3478
3472
|
...props
|
|
3479
3473
|
}) {
|
|
3480
|
-
const [open, setOpen] = useState(!!props.value?.length), onExpand = useCallback(() => setOpen(!0), []), onCollapse = useCallback(() => setOpen(!1), []);
|
|
3474
|
+
const [open, setOpen] = react.useState(!!props.value?.length), onExpand = react.useCallback(() => setOpen(!0), []), onCollapse = react.useCallback(() => setOpen(!1), []);
|
|
3481
3475
|
return props.renderDefault({
|
|
3482
3476
|
...props,
|
|
3483
3477
|
collapsible: !0,
|
|
@@ -3485,46 +3479,46 @@ function EnabledOutputField({
|
|
|
3485
3479
|
onCollapse,
|
|
3486
3480
|
collapsed: !open,
|
|
3487
3481
|
level: 1,
|
|
3488
|
-
title: isObjectSchemaType(fieldSchema) ? "Allowed fields" : "Allowed types"
|
|
3482
|
+
title: sanity.isObjectSchemaType(fieldSchema) ? "Allowed fields" : "Allowed types"
|
|
3489
3483
|
});
|
|
3490
3484
|
}
|
|
3491
3485
|
function InstructionOutputInput(props) {
|
|
3492
|
-
const { fieldSchema } = useContext(SelectedFieldContext) ?? {};
|
|
3493
|
-
return fieldSchema ? isObjectSchemaType(fieldSchema) ? /* @__PURE__ */ jsx(ObjectOutputInput, { ...props, fieldSchema }) : isArrayOfObjectsSchemaType(fieldSchema) ? /* @__PURE__ */ jsx(ArrayOutputInput, { ...props, fieldSchema }) : null : null;
|
|
3486
|
+
const { fieldSchema } = react.useContext(SelectedFieldContext) ?? {};
|
|
3487
|
+
return fieldSchema ? sanity.isObjectSchemaType(fieldSchema) ? /* @__PURE__ */ jsxRuntime.jsx(ObjectOutputInput, { ...props, fieldSchema }) : sanity.isArrayOfObjectsSchemaType(fieldSchema) ? /* @__PURE__ */ jsxRuntime.jsx(ArrayOutputInput, { ...props, fieldSchema }) : null : null;
|
|
3494
3488
|
}
|
|
3495
3489
|
function useEmptySelectAllValue(value, allowedValues, onChange) {
|
|
3496
|
-
useEffect(() => {
|
|
3490
|
+
react.useEffect(() => {
|
|
3497
3491
|
const validValues = value?.filter(
|
|
3498
3492
|
(v) => allowedValues.find(
|
|
3499
3493
|
(f) => f.name === (v._type === outputFieldTypeName ? v.relativePath : v.type)
|
|
3500
3494
|
)
|
|
3501
3495
|
), valueLength = value?.length ?? 0, validLength = validValues?.length ?? 0;
|
|
3502
|
-
(!validLength && valueLength || validLength >= allowedValues.length) && onChange(PatchEvent.from([unset()]));
|
|
3496
|
+
(!validLength && valueLength || validLength >= allowedValues.length) && onChange(sanity.PatchEvent.from([sanity.unset()]));
|
|
3503
3497
|
}, [allowedValues, value, onChange]);
|
|
3504
3498
|
}
|
|
3505
3499
|
function ObjectOutputInput({
|
|
3506
3500
|
fieldSchema,
|
|
3507
3501
|
...props
|
|
3508
3502
|
}) {
|
|
3509
|
-
const { value, onChange } = props, fields = useMemo(
|
|
3503
|
+
const { value, onChange } = props, fields = react.useMemo(
|
|
3510
3504
|
() => fieldSchema.fields.filter((field) => isAssistSupported(field.type)),
|
|
3511
3505
|
[fieldSchema.fields]
|
|
3512
3506
|
);
|
|
3513
3507
|
useEmptySelectAllValue(value, fields, onChange);
|
|
3514
|
-
const onSelectChange = useCallback(
|
|
3508
|
+
const onSelectChange = react.useCallback(
|
|
3515
3509
|
(checked, selectedValue) => {
|
|
3516
3510
|
if (checked)
|
|
3517
3511
|
if (value?.length)
|
|
3518
|
-
onChange(PatchEvent.from(unset([{ _key: selectedValue }])));
|
|
3512
|
+
onChange(sanity.PatchEvent.from(sanity.unset([{ _key: selectedValue }])));
|
|
3519
3513
|
else {
|
|
3520
3514
|
const items = fields.filter((f) => f.name !== selectedValue).map(
|
|
3521
|
-
(field) => typed({
|
|
3515
|
+
(field) => sanity.typed({
|
|
3522
3516
|
_key: field.name,
|
|
3523
3517
|
_type: "sanity.assist.output.field",
|
|
3524
3518
|
relativePath: field.name
|
|
3525
3519
|
})
|
|
3526
3520
|
);
|
|
3527
|
-
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
3521
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert(items, "after", [-1])]));
|
|
3528
3522
|
}
|
|
3529
3523
|
else {
|
|
3530
3524
|
const patchValue = {
|
|
@@ -3532,12 +3526,12 @@ function ObjectOutputInput({
|
|
|
3532
3526
|
_type: "sanity.assist.output.field",
|
|
3533
3527
|
relativePath: selectedValue
|
|
3534
3528
|
};
|
|
3535
|
-
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
3529
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert([patchValue], "after", [-1])]));
|
|
3536
3530
|
}
|
|
3537
3531
|
},
|
|
3538
3532
|
[onChange, value, fields]
|
|
3539
3533
|
);
|
|
3540
|
-
return /* @__PURE__ */ jsx(Stack, { space: 2, children: fields.map((field) => /* @__PURE__ */ jsx(Flex, { align: "center", gap: 2, children: /* @__PURE__ */ jsx(
|
|
3534
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: fields.map((field) => /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { align: "center", gap: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3541
3535
|
Selectable,
|
|
3542
3536
|
{
|
|
3543
3537
|
value: field.name,
|
|
@@ -3551,25 +3545,25 @@ function ArrayOutputInput({
|
|
|
3551
3545
|
fieldSchema,
|
|
3552
3546
|
...props
|
|
3553
3547
|
}) {
|
|
3554
|
-
const { value, onChange } = props, ofItems = useMemo(
|
|
3548
|
+
const { value, onChange } = props, ofItems = react.useMemo(
|
|
3555
3549
|
() => fieldSchema.of.filter((itemType) => isAssistSupported(itemType)),
|
|
3556
3550
|
[fieldSchema.of]
|
|
3557
3551
|
);
|
|
3558
3552
|
useEmptySelectAllValue(value, ofItems, onChange);
|
|
3559
|
-
const onSelectChange = useCallback(
|
|
3553
|
+
const onSelectChange = react.useCallback(
|
|
3560
3554
|
(checked, selectedValue) => {
|
|
3561
3555
|
if (checked)
|
|
3562
3556
|
if (value?.length)
|
|
3563
|
-
onChange(PatchEvent.from(unset([{ _key: selectedValue }])));
|
|
3557
|
+
onChange(sanity.PatchEvent.from(sanity.unset([{ _key: selectedValue }])));
|
|
3564
3558
|
else {
|
|
3565
3559
|
const items = ofItems.filter((f) => f.name !== selectedValue).map(
|
|
3566
|
-
(field) => typed({
|
|
3560
|
+
(field) => sanity.typed({
|
|
3567
3561
|
_key: field.name,
|
|
3568
3562
|
_type: "sanity.assist.output.type",
|
|
3569
3563
|
type: field.name
|
|
3570
3564
|
})
|
|
3571
3565
|
);
|
|
3572
|
-
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
3566
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert(items, "after", [-1])]));
|
|
3573
3567
|
}
|
|
3574
3568
|
else {
|
|
3575
3569
|
const patchValue = {
|
|
@@ -3577,12 +3571,12 @@ function ArrayOutputInput({
|
|
|
3577
3571
|
_type: "sanity.assist.output.type",
|
|
3578
3572
|
type: selectedValue
|
|
3579
3573
|
};
|
|
3580
|
-
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
3574
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert([patchValue], "after", [-1])]));
|
|
3581
3575
|
}
|
|
3582
3576
|
},
|
|
3583
3577
|
[onChange, value, ofItems]
|
|
3584
3578
|
);
|
|
3585
|
-
return /* @__PURE__ */ jsx(Stack, { space: 2, children: ofItems.map((itemType) => /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
|
|
3579
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: ofItems.map((itemType) => /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3586
3580
|
Selectable,
|
|
3587
3581
|
{
|
|
3588
3582
|
value: itemType.name,
|
|
@@ -3598,13 +3592,13 @@ function Selectable({
|
|
|
3598
3592
|
value,
|
|
3599
3593
|
onChange
|
|
3600
3594
|
}) {
|
|
3601
|
-
const checked = !arrayValue?.length || !!arrayValue?.find((v) => v._key === value), handleChange = useCallback(() => onChange(checked, value), [onChange, checked, value]);
|
|
3602
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "flex-start", children: [
|
|
3603
|
-
/* @__PURE__ */ jsx(Checkbox, { checked, onChange: handleChange }),
|
|
3604
|
-
/* @__PURE__ */ jsx(Card, { marginTop: 1, onClick: handleChange, children: /* @__PURE__ */ jsx(Text, { style: { cursor: "default" }, size: 1, children: title }) })
|
|
3595
|
+
const checked = !arrayValue?.length || !!arrayValue?.find((v) => v._key === value), handleChange = react.useCallback(() => onChange(checked, value), [onChange, checked, value]);
|
|
3596
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "flex-start", children: [
|
|
3597
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { checked, onChange: handleChange }),
|
|
3598
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { marginTop: 1, onClick: handleChange, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { style: { cursor: "default" }, size: 1, children: title }) })
|
|
3605
3599
|
] });
|
|
3606
3600
|
}
|
|
3607
|
-
const PteMods = styled(Box)`
|
|
3601
|
+
const PteMods = styledComponents.styled(ui.Box)`
|
|
3608
3602
|
& [data-testid='pt-editor__toolbar-card'] > div > div:last-child {
|
|
3609
3603
|
display: none;
|
|
3610
3604
|
}
|
|
@@ -3616,12 +3610,12 @@ const PteMods = styled(Box)`
|
|
|
3616
3610
|
}
|
|
3617
3611
|
`;
|
|
3618
3612
|
function PromptInput(props) {
|
|
3619
|
-
return useOnlyInlineBlocks(props), /* @__PURE__ */ jsx(PteMods, { children: props.renderDefault(props) });
|
|
3613
|
+
return useOnlyInlineBlocks(props), /* @__PURE__ */ jsxRuntime.jsx(PteMods, { children: props.renderDefault(props) });
|
|
3620
3614
|
}
|
|
3621
3615
|
function useOnlyInlineBlocks(props) {
|
|
3622
|
-
useEffect(() => {
|
|
3616
|
+
react.useEffect(() => {
|
|
3623
3617
|
let needsFix = !1;
|
|
3624
|
-
const val = (props.value ?? []).map((block) => block._type === "block" ? block : (needsFix = !0, typed({
|
|
3618
|
+
const val = (props.value ?? []).map((block) => block._type === "block" ? block : (needsFix = !0, sanity.typed({
|
|
3625
3619
|
_key: randomKey(12),
|
|
3626
3620
|
_type: "block",
|
|
3627
3621
|
level: 0,
|
|
@@ -3629,7 +3623,7 @@ function useOnlyInlineBlocks(props) {
|
|
|
3629
3623
|
style: "normal",
|
|
3630
3624
|
children: [block]
|
|
3631
3625
|
})));
|
|
3632
|
-
needsFix && props.onChange(set(val));
|
|
3626
|
+
needsFix && props.onChange(sanity.set(val));
|
|
3633
3627
|
}, []);
|
|
3634
3628
|
}
|
|
3635
3629
|
function InstructionsArrayField(props) {
|
|
@@ -3639,10 +3633,10 @@ function InstructionsArrayField(props) {
|
|
|
3639
3633
|
});
|
|
3640
3634
|
}
|
|
3641
3635
|
function InstructionsArrayInput(props) {
|
|
3642
|
-
const user = useCurrentUser(), originalValue = props.value, originalMembers = props.members, value = useMemo(
|
|
3636
|
+
const user = sanity.useCurrentUser(), originalValue = props.value, originalMembers = props.members, value = react.useMemo(
|
|
3643
3637
|
() => (originalValue ?? []).filter((v) => !v.userId || v.userId === user?.id),
|
|
3644
3638
|
[originalValue, user]
|
|
3645
|
-
), members = useMemo(
|
|
3639
|
+
), members = react.useMemo(
|
|
3646
3640
|
() => (originalMembers ?? []).filter((v) => {
|
|
3647
3641
|
if (v.kind === "error")
|
|
3648
3642
|
return !0;
|
|
@@ -3654,8 +3648,8 @@ function InstructionsArrayInput(props) {
|
|
|
3654
3648
|
return props.renderDefault({ ...props, value, members });
|
|
3655
3649
|
}
|
|
3656
3650
|
function HideReferenceChangedBannerInput(props) {
|
|
3657
|
-
const ref = useRef(null);
|
|
3658
|
-
return useEffect(() => {
|
|
3651
|
+
const ref = react.useRef(null);
|
|
3652
|
+
return react.useEffect(() => {
|
|
3659
3653
|
const parent = ref.current?.closest('[data-testid="pane-content"]');
|
|
3660
3654
|
if (!parent)
|
|
3661
3655
|
return;
|
|
@@ -3663,29 +3657,29 @@ function HideReferenceChangedBannerInput(props) {
|
|
|
3663
3657
|
parent.id = parentId, style.innerText = `
|
|
3664
3658
|
#${parentId} [data-testid="reference-changed-banner"] { display: none; }
|
|
3665
3659
|
`, parent.prepend(style);
|
|
3666
|
-
}, [ref]), /* @__PURE__ */ jsx(Box, { ref, children: props.renderDefault(props) });
|
|
3660
|
+
}, [ref]), /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { ref, children: props.renderDefault(props) });
|
|
3667
3661
|
}
|
|
3668
|
-
const contextDocumentSchema = defineType({
|
|
3662
|
+
const contextDocumentSchema = sanity.defineType({
|
|
3669
3663
|
type: "document",
|
|
3670
3664
|
name: contextDocumentTypeName,
|
|
3671
3665
|
title: "AI context",
|
|
3672
3666
|
liveEdit: !0,
|
|
3673
|
-
icon: TokenIcon,
|
|
3667
|
+
icon: icons.TokenIcon,
|
|
3674
3668
|
components: {
|
|
3675
3669
|
input: HideReferenceChangedBannerInput
|
|
3676
3670
|
},
|
|
3677
3671
|
fields: [
|
|
3678
|
-
defineField({
|
|
3672
|
+
sanity.defineField({
|
|
3679
3673
|
type: "string",
|
|
3680
3674
|
name: "title",
|
|
3681
3675
|
title: "Title"
|
|
3682
3676
|
}),
|
|
3683
|
-
defineField({
|
|
3677
|
+
sanity.defineField({
|
|
3684
3678
|
name: "context",
|
|
3685
3679
|
type: "array",
|
|
3686
3680
|
title: "Context",
|
|
3687
3681
|
of: [
|
|
3688
|
-
defineArrayMember({
|
|
3682
|
+
sanity.defineArrayMember({
|
|
3689
3683
|
type: "block",
|
|
3690
3684
|
styles: [{ title: "Normal", value: "normal" }],
|
|
3691
3685
|
lists: [],
|
|
@@ -3707,17 +3701,17 @@ const contextDocumentSchema = defineType({
|
|
|
3707
3701
|
return {
|
|
3708
3702
|
title,
|
|
3709
3703
|
subtitle: `Words: ${words}`,
|
|
3710
|
-
media: DocumentTextIcon
|
|
3704
|
+
media: icons.DocumentTextIcon
|
|
3711
3705
|
};
|
|
3712
3706
|
}
|
|
3713
3707
|
}
|
|
3714
|
-
}), fieldReference = defineType({
|
|
3708
|
+
}), fieldReference = sanity.defineType({
|
|
3715
3709
|
type: "object",
|
|
3716
3710
|
name: fieldReferenceTypeName,
|
|
3717
3711
|
title: "Field",
|
|
3718
|
-
icon: ThListIcon,
|
|
3712
|
+
icon: icons.ThListIcon,
|
|
3719
3713
|
fields: [
|
|
3720
|
-
defineField({
|
|
3714
|
+
sanity.defineField({
|
|
3721
3715
|
type: "string",
|
|
3722
3716
|
name: "path",
|
|
3723
3717
|
title: "Field",
|
|
@@ -3753,7 +3747,7 @@ const contextDocumentSchema = defineType({
|
|
|
3753
3747
|
return {
|
|
3754
3748
|
title: path,
|
|
3755
3749
|
path,
|
|
3756
|
-
icon: CodeIcon
|
|
3750
|
+
icon: icons.CodeIcon
|
|
3757
3751
|
};
|
|
3758
3752
|
}
|
|
3759
3753
|
},
|
|
@@ -3765,13 +3759,13 @@ const contextDocumentSchema = defineType({
|
|
|
3765
3759
|
type: "popover"
|
|
3766
3760
|
}
|
|
3767
3761
|
}
|
|
3768
|
-
}), userInput = defineType({
|
|
3762
|
+
}), userInput = sanity.defineType({
|
|
3769
3763
|
type: "object",
|
|
3770
3764
|
name: userInputTypeName,
|
|
3771
3765
|
title: "User input",
|
|
3772
|
-
icon: ComposeIcon,
|
|
3766
|
+
icon: icons.ComposeIcon,
|
|
3773
3767
|
fields: [
|
|
3774
|
-
defineField({
|
|
3768
|
+
sanity.defineField({
|
|
3775
3769
|
type: "string",
|
|
3776
3770
|
name: "message",
|
|
3777
3771
|
title: "User input title",
|
|
@@ -3779,7 +3773,7 @@ const contextDocumentSchema = defineType({
|
|
|
3779
3773
|
description: "The header above the user input text field",
|
|
3780
3774
|
validation: (rule) => rule.required()
|
|
3781
3775
|
}),
|
|
3782
|
-
defineField({
|
|
3776
|
+
sanity.defineField({
|
|
3783
3777
|
type: "text",
|
|
3784
3778
|
rows: 3,
|
|
3785
3779
|
name: "description",
|
|
@@ -3798,13 +3792,13 @@ const contextDocumentSchema = defineType({
|
|
|
3798
3792
|
width: 1
|
|
3799
3793
|
}
|
|
3800
3794
|
}
|
|
3801
|
-
}), promptContext = defineType({
|
|
3795
|
+
}), promptContext = sanity.defineType({
|
|
3802
3796
|
type: "object",
|
|
3803
3797
|
name: instructionContextTypeName,
|
|
3804
3798
|
title: contextDocumentSchema.title,
|
|
3805
3799
|
icon: contextDocumentSchema.icon,
|
|
3806
3800
|
fields: [
|
|
3807
|
-
defineField({
|
|
3801
|
+
sanity.defineField({
|
|
3808
3802
|
type: "reference",
|
|
3809
3803
|
name: "reference",
|
|
3810
3804
|
to: [{ type: contextDocumentSchema.name }],
|
|
@@ -3813,14 +3807,14 @@ const contextDocumentSchema = defineType({
|
|
|
3813
3807
|
validation: (rule) => rule.required(),
|
|
3814
3808
|
components: {
|
|
3815
3809
|
input: function(props) {
|
|
3816
|
-
return /* @__PURE__ */ jsx(Box, { style: { maxWidth: 300 }, children: props.renderDefault(props) });
|
|
3810
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { maxWidth: 300 }, children: props.renderDefault(props) });
|
|
3817
3811
|
}
|
|
3818
3812
|
}
|
|
3819
3813
|
})
|
|
3820
3814
|
],
|
|
3821
3815
|
preview: {
|
|
3822
3816
|
select: {
|
|
3823
|
-
ref: "reference.
|
|
3817
|
+
ref: "reference._id",
|
|
3824
3818
|
title: "reference.title",
|
|
3825
3819
|
context: "reference.context"
|
|
3826
3820
|
},
|
|
@@ -3834,12 +3828,12 @@ const contextDocumentSchema = defineType({
|
|
|
3834
3828
|
width: "auto"
|
|
3835
3829
|
}
|
|
3836
3830
|
}
|
|
3837
|
-
}), prompt = defineType({
|
|
3831
|
+
}), prompt = sanity.defineType({
|
|
3838
3832
|
type: "array",
|
|
3839
3833
|
name: promptTypeName,
|
|
3840
3834
|
title: "Prompt",
|
|
3841
3835
|
of: [
|
|
3842
|
-
defineArrayMember({
|
|
3836
|
+
sanity.defineArrayMember({
|
|
3843
3837
|
type: "block",
|
|
3844
3838
|
styles: [{ title: "Normal", value: "normal" }],
|
|
3845
3839
|
lists: [],
|
|
@@ -3848,13 +3842,13 @@ const contextDocumentSchema = defineType({
|
|
|
3848
3842
|
annotations: []
|
|
3849
3843
|
},
|
|
3850
3844
|
of: [
|
|
3851
|
-
defineArrayMember({
|
|
3845
|
+
sanity.defineArrayMember({
|
|
3852
3846
|
type: fieldReference.name
|
|
3853
3847
|
}),
|
|
3854
|
-
defineArrayMember({
|
|
3848
|
+
sanity.defineArrayMember({
|
|
3855
3849
|
type: promptContext.name
|
|
3856
3850
|
}),
|
|
3857
|
-
defineArrayMember({
|
|
3851
|
+
sanity.defineArrayMember({
|
|
3858
3852
|
type: userInput.name
|
|
3859
3853
|
})
|
|
3860
3854
|
]
|
|
@@ -3869,29 +3863,29 @@ const contextDocumentSchema = defineType({
|
|
|
3869
3863
|
type: userInput.name,
|
|
3870
3864
|
}),*/
|
|
3871
3865
|
]
|
|
3872
|
-
}), outputFieldType = defineType({
|
|
3866
|
+
}), outputFieldType = sanity.defineType({
|
|
3873
3867
|
type: "object",
|
|
3874
3868
|
name: outputFieldTypeName,
|
|
3875
3869
|
title: "Output field",
|
|
3876
3870
|
fields: [
|
|
3877
|
-
defineField({
|
|
3871
|
+
sanity.defineField({
|
|
3878
3872
|
type: "string",
|
|
3879
3873
|
name: "path",
|
|
3880
3874
|
title: "Path"
|
|
3881
3875
|
})
|
|
3882
3876
|
]
|
|
3883
|
-
}), outputTypeType = defineType({
|
|
3877
|
+
}), outputTypeType = sanity.defineType({
|
|
3884
3878
|
type: "object",
|
|
3885
3879
|
name: outputTypeTypeName,
|
|
3886
3880
|
title: "Output type",
|
|
3887
3881
|
fields: [
|
|
3888
|
-
defineField({
|
|
3882
|
+
sanity.defineField({
|
|
3889
3883
|
type: "string",
|
|
3890
3884
|
name: "type",
|
|
3891
3885
|
title: "Type"
|
|
3892
3886
|
})
|
|
3893
3887
|
]
|
|
3894
|
-
}), instruction = defineType({
|
|
3888
|
+
}), instruction = sanity.defineType({
|
|
3895
3889
|
type: "object",
|
|
3896
3890
|
name: instructionTypeName,
|
|
3897
3891
|
title: "Instruction",
|
|
@@ -3906,45 +3900,45 @@ const contextDocumentSchema = defineType({
|
|
|
3906
3900
|
},
|
|
3907
3901
|
prepare: ({ icon, title, userId }) => ({
|
|
3908
3902
|
title,
|
|
3909
|
-
icon: icon ? icons[icon] : SparklesIcon,
|
|
3903
|
+
icon: icon ? icons.icons[icon] : icons.SparklesIcon,
|
|
3910
3904
|
userId
|
|
3911
3905
|
})
|
|
3912
3906
|
},
|
|
3913
3907
|
components: {
|
|
3914
3908
|
input: InstructionInput,
|
|
3915
|
-
preview: (props) => /* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", padding: 2, children: [
|
|
3916
|
-
props.icon && /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Text, { size: 1, children: createElement(props.icon) }) }),
|
|
3917
|
-
/* @__PURE__ */ jsx(Stack, { flex: 1, space: 2, children: /* @__PURE__ */ jsx(Text, { size: 1, textOverflow: "ellipsis", weight: "medium", children: getInstructionTitle(props) }) }),
|
|
3918
|
-
props.userId && /* @__PURE__ */ jsx(Text, { size: 1, children: /* @__PURE__ */ jsx(
|
|
3919
|
-
Tooltip,
|
|
3909
|
+
preview: (props) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", padding: 2, children: [
|
|
3910
|
+
props.icon && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: react.createElement(props.icon) }) }),
|
|
3911
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { flex: 1, space: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, textOverflow: "ellipsis", weight: "medium", children: getInstructionTitle(props) }) }),
|
|
3912
|
+
props.userId && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3913
|
+
ui.Tooltip,
|
|
3920
3914
|
{
|
|
3921
|
-
content: /* @__PURE__ */ jsx(Text, { size: 1, children: "Only visible to you" }),
|
|
3915
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Only visible to you" }),
|
|
3922
3916
|
padding: 2,
|
|
3923
3917
|
placement: "top",
|
|
3924
3918
|
portal: !0,
|
|
3925
|
-
children: /* @__PURE__ */ jsx(LockIcon, {})
|
|
3919
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.LockIcon, {})
|
|
3926
3920
|
}
|
|
3927
3921
|
) })
|
|
3928
3922
|
] })
|
|
3929
3923
|
},
|
|
3930
3924
|
fields: [
|
|
3931
|
-
defineField({
|
|
3925
|
+
sanity.defineField({
|
|
3932
3926
|
type: prompt.name,
|
|
3933
3927
|
name: "prompt",
|
|
3934
3928
|
title: "Instruction",
|
|
3935
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3929
|
+
description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3936
3930
|
"Learn from",
|
|
3937
3931
|
" ",
|
|
3938
|
-
/* @__PURE__ */ jsxs("a", { href: instructionGuideUrl, target: "_blank", rel: "noreferrer", children: [
|
|
3932
|
+
/* @__PURE__ */ jsxRuntime.jsxs("a", { href: instructionGuideUrl, target: "_blank", rel: "noreferrer", children: [
|
|
3939
3933
|
"our instruction guide ",
|
|
3940
|
-
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
3934
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRightIcon, {})
|
|
3941
3935
|
] })
|
|
3942
3936
|
] }),
|
|
3943
3937
|
components: {
|
|
3944
3938
|
input: PromptInput
|
|
3945
3939
|
}
|
|
3946
3940
|
}),
|
|
3947
|
-
defineField({
|
|
3941
|
+
sanity.defineField({
|
|
3948
3942
|
type: "string",
|
|
3949
3943
|
name: "icon",
|
|
3950
3944
|
title: "Icon",
|
|
@@ -3954,7 +3948,7 @@ const contextDocumentSchema = defineType({
|
|
|
3954
3948
|
input: IconInput
|
|
3955
3949
|
}
|
|
3956
3950
|
}),
|
|
3957
|
-
defineField({
|
|
3951
|
+
sanity.defineField({
|
|
3958
3952
|
type: "string",
|
|
3959
3953
|
name: "title",
|
|
3960
3954
|
title: "Title",
|
|
@@ -3963,7 +3957,7 @@ const contextDocumentSchema = defineType({
|
|
|
3963
3957
|
field: HiddenFieldTitle
|
|
3964
3958
|
}
|
|
3965
3959
|
}),
|
|
3966
|
-
defineField({
|
|
3960
|
+
sanity.defineField({
|
|
3967
3961
|
type: "string",
|
|
3968
3962
|
name: "userId",
|
|
3969
3963
|
title: "Visibility",
|
|
@@ -3975,7 +3969,7 @@ const contextDocumentSchema = defineType({
|
|
|
3975
3969
|
initialValue: (params, context) => context.currentUser?.id ?? "",
|
|
3976
3970
|
readOnly: (context) => !!(context.parent?.createdById && context.parent?.createdById !== context.currentUser?.id)
|
|
3977
3971
|
}),
|
|
3978
|
-
defineField({
|
|
3972
|
+
sanity.defineField({
|
|
3979
3973
|
type: "string",
|
|
3980
3974
|
name: "createdById",
|
|
3981
3975
|
title: "Created by",
|
|
@@ -3983,7 +3977,7 @@ const contextDocumentSchema = defineType({
|
|
|
3983
3977
|
fieldset: "appearance",
|
|
3984
3978
|
initialValue: (params, context) => context.currentUser?.id ?? ""
|
|
3985
3979
|
}),
|
|
3986
|
-
defineField({
|
|
3980
|
+
sanity.defineField({
|
|
3987
3981
|
type: "array",
|
|
3988
3982
|
name: "output",
|
|
3989
3983
|
title: "Output filter",
|
|
@@ -3992,12 +3986,12 @@ const contextDocumentSchema = defineType({
|
|
|
3992
3986
|
field: InstructionOutputField
|
|
3993
3987
|
},
|
|
3994
3988
|
of: [
|
|
3995
|
-
defineArrayMember({ type: outputFieldType.name }),
|
|
3996
|
-
defineArrayMember({ type: outputTypeType.name })
|
|
3989
|
+
sanity.defineArrayMember({ type: outputFieldType.name }),
|
|
3990
|
+
sanity.defineArrayMember({ type: outputTypeType.name })
|
|
3997
3991
|
]
|
|
3998
3992
|
})
|
|
3999
3993
|
]
|
|
4000
|
-
}), fieldInstructions = defineType({
|
|
3994
|
+
}), fieldInstructions = sanity.defineType({
|
|
4001
3995
|
type: "object",
|
|
4002
3996
|
name: assistFieldTypeName,
|
|
4003
3997
|
title: "Field prompt",
|
|
@@ -4005,14 +3999,14 @@ const contextDocumentSchema = defineType({
|
|
|
4005
3999
|
input: FieldPromptInput,
|
|
4006
4000
|
},*/
|
|
4007
4001
|
fields: [
|
|
4008
|
-
defineField({
|
|
4002
|
+
sanity.defineField({
|
|
4009
4003
|
type: "string",
|
|
4010
4004
|
name: "path",
|
|
4011
4005
|
title: "Path",
|
|
4012
4006
|
readOnly: !0,
|
|
4013
4007
|
hidden: !0
|
|
4014
4008
|
}),
|
|
4015
|
-
defineField({
|
|
4009
|
+
sanity.defineField({
|
|
4016
4010
|
type: "array",
|
|
4017
4011
|
name: "instructions",
|
|
4018
4012
|
title: "Instructions",
|
|
@@ -4028,7 +4022,7 @@ const contextDocumentSchema = defineType({
|
|
|
4028
4022
|
title: "path"
|
|
4029
4023
|
}
|
|
4030
4024
|
}
|
|
4031
|
-
}), assistDocumentSchema = defineType({
|
|
4025
|
+
}), assistDocumentSchema = sanity.defineType({
|
|
4032
4026
|
//NOTE: this is a document type. Using object here ensures it does not appear in structure menus
|
|
4033
4027
|
type: "object",
|
|
4034
4028
|
liveEdit: !0,
|
|
@@ -4039,12 +4033,12 @@ const contextDocumentSchema = defineType({
|
|
|
4039
4033
|
field: (props) => props.renderDefault({ ...props, title: "" })
|
|
4040
4034
|
},
|
|
4041
4035
|
fields: [
|
|
4042
|
-
defineField({
|
|
4036
|
+
sanity.defineField({
|
|
4043
4037
|
type: "string",
|
|
4044
4038
|
name: "title",
|
|
4045
4039
|
title: "Title"
|
|
4046
4040
|
}),
|
|
4047
|
-
defineField({
|
|
4041
|
+
sanity.defineField({
|
|
4048
4042
|
type: "array",
|
|
4049
4043
|
name: "fields",
|
|
4050
4044
|
title: "Fields",
|
|
@@ -4056,45 +4050,45 @@ const contextDocumentSchema = defineType({
|
|
|
4056
4050
|
title: "title"
|
|
4057
4051
|
}
|
|
4058
4052
|
}
|
|
4059
|
-
}), instructionTask = defineType({
|
|
4053
|
+
}), instructionTask = sanity.defineType({
|
|
4060
4054
|
type: "object",
|
|
4061
4055
|
name: instructionTaskTypeName,
|
|
4062
4056
|
title: "Instruction task",
|
|
4063
4057
|
fields: [
|
|
4064
|
-
defineField({
|
|
4058
|
+
sanity.defineField({
|
|
4065
4059
|
type: "string",
|
|
4066
4060
|
name: "path",
|
|
4067
4061
|
title: "Path"
|
|
4068
4062
|
}),
|
|
4069
|
-
defineField({
|
|
4063
|
+
sanity.defineField({
|
|
4070
4064
|
type: "string",
|
|
4071
4065
|
name: "instructionKey",
|
|
4072
4066
|
title: "Instruction key"
|
|
4073
4067
|
}),
|
|
4074
|
-
defineField({
|
|
4068
|
+
sanity.defineField({
|
|
4075
4069
|
type: "datetime",
|
|
4076
4070
|
name: "started",
|
|
4077
4071
|
title: "Started"
|
|
4078
4072
|
}),
|
|
4079
|
-
defineField({
|
|
4073
|
+
sanity.defineField({
|
|
4080
4074
|
type: "datetime",
|
|
4081
4075
|
name: "updated",
|
|
4082
4076
|
title: "Updated"
|
|
4083
4077
|
}),
|
|
4084
|
-
defineField({
|
|
4078
|
+
sanity.defineField({
|
|
4085
4079
|
type: "string",
|
|
4086
4080
|
name: "info",
|
|
4087
4081
|
title: "Info"
|
|
4088
4082
|
})
|
|
4089
4083
|
]
|
|
4090
|
-
}), documentInstructionStatus = defineType({
|
|
4084
|
+
}), documentInstructionStatus = sanity.defineType({
|
|
4091
4085
|
//NOTE: this is a document type. Using object here ensures it does not appear in structure menus
|
|
4092
4086
|
type: "object",
|
|
4093
4087
|
liveEdit: !0,
|
|
4094
4088
|
name: assistTasksStatusTypeName,
|
|
4095
4089
|
title: "Document instruction status",
|
|
4096
4090
|
fields: [
|
|
4097
|
-
defineField({
|
|
4091
|
+
sanity.defineField({
|
|
4098
4092
|
type: "array",
|
|
4099
4093
|
name: "tasks",
|
|
4100
4094
|
title: "Tasks",
|
|
@@ -4140,7 +4134,7 @@ const instructionForm = [
|
|
|
4140
4134
|
documentInstructionStatus,
|
|
4141
4135
|
instructionTask,
|
|
4142
4136
|
contextDocumentSchema
|
|
4143
|
-
], assist = definePlugin((config) => {
|
|
4137
|
+
], assist = sanity.definePlugin((config) => {
|
|
4144
4138
|
const configWithDefaults = config ?? {}, styleguide = configWithDefaults.translate?.styleguide || "", maxPathDepth = configWithDefaults.assist?.maxPathDepth, temperature = configWithDefaults.assist?.temperature;
|
|
4145
4139
|
if (typeof styleguide == "string" && validateStyleguide(styleguide), maxPathDepth !== void 0 && (maxPathDepth < 1 || maxPathDepth > 12))
|
|
4146
4140
|
throw new Error(
|
|
@@ -4174,7 +4168,7 @@ const instructionForm = [
|
|
|
4174
4168
|
if (schemaType === assistDocumentTypeName)
|
|
4175
4169
|
return [];
|
|
4176
4170
|
const docSchema = schema.get(schemaType);
|
|
4177
|
-
return docSchema && isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema) ? [...prev, createAssistDocumentPresence(documentId)] : prev;
|
|
4171
|
+
return docSchema && sanity.isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema) ? [...prev, createAssistDocumentPresence(documentId)] : prev;
|
|
4178
4172
|
},
|
|
4179
4173
|
components: {
|
|
4180
4174
|
unstable_layout: AssistDocumentLayout
|
|
@@ -4183,7 +4177,7 @@ const instructionForm = [
|
|
|
4183
4177
|
studio: {
|
|
4184
4178
|
components: {
|
|
4185
4179
|
layout: function(props) {
|
|
4186
|
-
return /* @__PURE__ */ jsx(AssistLayout, { ...props, config: configWithDefaults });
|
|
4180
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistLayout, { ...props, config: configWithDefaults });
|
|
4187
4181
|
}
|
|
4188
4182
|
}
|
|
4189
4183
|
},
|
|
@@ -4197,24 +4191,24 @@ const instructionForm = [
|
|
|
4197
4191
|
}
|
|
4198
4192
|
},
|
|
4199
4193
|
plugins: [
|
|
4200
|
-
definePlugin({
|
|
4194
|
+
sanity.definePlugin({
|
|
4201
4195
|
name: `${packageName}/safe-value-input`,
|
|
4202
4196
|
form: { components: { input: SafeValueInput } }
|
|
4203
4197
|
})(),
|
|
4204
|
-
definePlugin({
|
|
4198
|
+
sanity.definePlugin({
|
|
4205
4199
|
name: `${packageName}/generate-caption`,
|
|
4206
4200
|
form: {
|
|
4207
4201
|
components: {
|
|
4208
4202
|
input: (props) => {
|
|
4209
4203
|
const { schemaType } = props;
|
|
4210
|
-
return isImage(schemaType) ? /* @__PURE__ */ jsx(ImageContextProvider, { ...props }) : props.renderDefault(props);
|
|
4204
|
+
return isImage(schemaType) ? /* @__PURE__ */ jsxRuntime.jsx(ImageContextProvider, { ...props }) : props.renderDefault(props);
|
|
4211
4205
|
}
|
|
4212
4206
|
}
|
|
4213
4207
|
}
|
|
4214
4208
|
})()
|
|
4215
4209
|
]
|
|
4216
4210
|
};
|
|
4217
|
-
}), fetch = (client, query, params, options2) => defer(
|
|
4211
|
+
}), fetch = (client, query, params, options2) => rxjs.defer(
|
|
4218
4212
|
() => (
|
|
4219
4213
|
// getVersionedClient(options.apiVersion)
|
|
4220
4214
|
client.observable.fetch(query, params, {
|
|
@@ -4222,7 +4216,7 @@ const instructionForm = [
|
|
|
4222
4216
|
filterResponse: !0
|
|
4223
4217
|
})
|
|
4224
4218
|
)
|
|
4225
|
-
), listen = (client, query, params, options2) => defer(
|
|
4219
|
+
), listen = (client, query, params, options2) => rxjs.defer(
|
|
4226
4220
|
() => (
|
|
4227
4221
|
// getVersionedClient(options.apiVersion)
|
|
4228
4222
|
client.listen(query, params, {
|
|
@@ -4238,35 +4232,35 @@ function isWelcomeEvent(event) {
|
|
|
4238
4232
|
}
|
|
4239
4233
|
const listenQuery = (client, query, params = {}, options2 = {}) => {
|
|
4240
4234
|
const fetchQuery = query, listenerQuery = query, fetchOnce$ = fetch(client, fetchQuery, params, options2), events$ = listen(client, listenerQuery, params, options2).pipe(
|
|
4241
|
-
mergeMap((ev, i) => i === 0 && !isWelcomeEvent(ev) ? throwError(
|
|
4235
|
+
operators.mergeMap((ev, i) => i === 0 && !isWelcomeEvent(ev) ? rxjs.throwError(
|
|
4242
4236
|
new Error(
|
|
4243
4237
|
ev.type === "reconnect" ? "Could not establish EventSource connection" : `Received unexpected type of first event "${ev.type}"`
|
|
4244
4238
|
)
|
|
4245
|
-
) : of(ev)),
|
|
4246
|
-
share()
|
|
4247
|
-
), [welcome$, mutationAndReconnect$] = partition(events$, isWelcomeEvent), isRelevantEvent = (event) => !options2.transitions || event.type !== "mutation" ? !0 : options2.transitions.includes(event.transition);
|
|
4248
|
-
return merge(
|
|
4249
|
-
welcome$.pipe(take(1)),
|
|
4239
|
+
) : rxjs.of(ev)),
|
|
4240
|
+
operators.share()
|
|
4241
|
+
), [welcome$, mutationAndReconnect$] = rxjs.partition(events$, isWelcomeEvent), isRelevantEvent = (event) => !options2.transitions || event.type !== "mutation" ? !0 : options2.transitions.includes(event.transition);
|
|
4242
|
+
return rxjs.merge(
|
|
4243
|
+
welcome$.pipe(operators.take(1)),
|
|
4250
4244
|
mutationAndReconnect$.pipe(
|
|
4251
|
-
filter(isRelevantEvent),
|
|
4252
|
-
switchMap((event) => merge(of(event), of(event).pipe(delay(options2.throttleTime || 1e3))))
|
|
4245
|
+
operators.filter(isRelevantEvent),
|
|
4246
|
+
rxjs.switchMap((event) => rxjs.merge(rxjs.of(event), rxjs.of(event).pipe(rxjs.delay(options2.throttleTime || 1e3))))
|
|
4253
4247
|
)
|
|
4254
|
-
).pipe(exhaustMapToWithTrailing(fetchOnce$));
|
|
4248
|
+
).pipe(rxjsExhaustmapWithTrailing.exhaustMapToWithTrailing(fetchOnce$));
|
|
4255
4249
|
}, DEFAULT_PARAMS = {}, DEFAULT_OPTIONS = { apiVersion: "v2022-05-09" };
|
|
4256
4250
|
function useListeningQuery(query, params = DEFAULT_PARAMS, options2 = DEFAULT_OPTIONS) {
|
|
4257
|
-
const [loading, setLoading] = useState(!0), [error, setError] = useState(!1), [data, setData] = useState(null), subscription = useRef(null), client = useClient({ apiVersion: "v2022-05-09" });
|
|
4258
|
-
return useEffect(() => (subscription.current = listenQuery(client, query, params, options2).pipe(
|
|
4259
|
-
distinctUntilChanged(
|
|
4260
|
-
catchError((err) => (console.error(err), setError(err), setLoading(!1), setData(null), err))
|
|
4251
|
+
const [loading, setLoading] = react.useState(!0), [error, setError] = react.useState(!1), [data, setData] = react.useState(null), subscription = react.useRef(null), client = sanity.useClient({ apiVersion: "v2022-05-09" });
|
|
4252
|
+
return react.useEffect(() => (subscription.current = listenQuery(client, query, params, options2).pipe(
|
|
4253
|
+
operators.distinctUntilChanged(isEqual__default.default),
|
|
4254
|
+
operators.catchError((err) => (console.error(err), setError(err), setLoading(!1), setData(null), err))
|
|
4261
4255
|
).subscribe((documents) => {
|
|
4262
|
-
setData((current) =>
|
|
4256
|
+
setData((current) => isEqual__default.default(current, documents) ? current : documents), setLoading(!1), setError(!1);
|
|
4263
4257
|
}), () => subscription.current ? subscription.current.unsubscribe() : void 0), [query, params, options2, client]), { loading, error, data };
|
|
4264
4258
|
}
|
|
4265
4259
|
const NO_DATA = [], defaultTitle = "Sync schema";
|
|
4266
4260
|
function SchemaTypeTool() {
|
|
4267
|
-
const schema = useSchema(), client = useClient({ apiVersion: "2023-01-01" }), [saving, setSaving] = useState(!1), [syncTitle, setSyncTitle] = useState(defaultTitle), { data } = useListeningQuery("*[_type==$type] | order(_type)", {
|
|
4261
|
+
const schema = sanity.useSchema(), client = sanity.useClient({ apiVersion: "2023-01-01" }), [saving, setSaving] = react.useState(!1), [syncTitle, setSyncTitle] = react.useState(defaultTitle), { data } = useListeningQuery("*[_type==$type] | order(_type)", {
|
|
4268
4262
|
type: assistSerializedTypeName
|
|
4269
|
-
}), types = useMemo(() => serializeSchema(schema), [schema]), storeTypes = useCallback(() => {
|
|
4263
|
+
}), types = react.useMemo(() => serializeSchema(schema), [schema]), storeTypes = react.useCallback(() => {
|
|
4270
4264
|
setSaving(!0);
|
|
4271
4265
|
let canSave = !0;
|
|
4272
4266
|
async function store() {
|
|
@@ -4284,45 +4278,43 @@ function SchemaTypeTool() {
|
|
|
4284
4278
|
canSave = !1, setSaving(!1), setSyncTitle(defaultTitle);
|
|
4285
4279
|
};
|
|
4286
4280
|
}, [types, client, setSaving, setSyncTitle]);
|
|
4287
|
-
return /* @__PURE__ */ jsx(Card, { padding: 4, overflow: "auto", style: { height: "calc(100vh - 81px)" }, children: /* @__PURE__ */ jsxs(Stack, { space: 4, children: [
|
|
4288
|
-
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
|
|
4289
|
-
Button,
|
|
4281
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 4, overflow: "auto", style: { height: "calc(100vh - 81px)" }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
4282
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4283
|
+
ui.Button,
|
|
4290
4284
|
{
|
|
4291
|
-
icon: saving ? /* @__PURE__ */ jsx(Spinner, { style: { marginTop: 5 } }) : SyncIcon,
|
|
4285
|
+
icon: saving ? /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { marginTop: 5 } }) : icons.SyncIcon,
|
|
4292
4286
|
text: syncTitle,
|
|
4293
4287
|
disabled: saving,
|
|
4294
4288
|
onClick: storeTypes
|
|
4295
4289
|
}
|
|
4296
4290
|
) }),
|
|
4297
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
4298
|
-
/* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
4299
|
-
/* @__PURE__ */ jsx(Label, { children: "Studio schema" }),
|
|
4300
|
-
/* @__PURE__ */ jsx("ul", { children: types.map((type) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(SchemaEntry, { schemaStub: type }) }, type.name)) })
|
|
4291
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
4292
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
4293
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Studio schema" }),
|
|
4294
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: types.map((type) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(SchemaEntry, { schemaStub: type }) }, type.name)) })
|
|
4301
4295
|
] }),
|
|
4302
|
-
/* @__PURE__ */ jsxs(Stack, { space: 2, children: [
|
|
4303
|
-
/* @__PURE__ */ jsx(Label, { children: "Stored schema" }),
|
|
4304
|
-
/* @__PURE__ */ jsx("ul", { children: (data ?? NO_DATA).map((type) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(SchemaEntry, { schemaStub: type }) }, type.name)) })
|
|
4296
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
4297
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Stored schema" }),
|
|
4298
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: (data ?? NO_DATA).map((type) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(SchemaEntry, { schemaStub: type }) }, type.name)) })
|
|
4305
4299
|
] })
|
|
4306
4300
|
] })
|
|
4307
4301
|
] }) });
|
|
4308
4302
|
}
|
|
4309
4303
|
function SchemaEntry({ schemaStub }) {
|
|
4310
|
-
const out = useMemo(() => JSON.stringify(schemaStub, null, 2), [schemaStub]);
|
|
4311
|
-
return /* @__PURE__ */ jsx("pre", { children: out });
|
|
4304
|
+
const out = react.useMemo(() => JSON.stringify(schemaStub, null, 2), [schemaStub]);
|
|
4305
|
+
return /* @__PURE__ */ jsxRuntime.jsx("pre", { children: out });
|
|
4312
4306
|
}
|
|
4313
4307
|
function useUserInput() {
|
|
4314
4308
|
const { getUserInput } = useRunInstruction();
|
|
4315
4309
|
return getUserInput;
|
|
4316
4310
|
}
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
};
|
|
4328
|
-
//# sourceMappingURL=index.esm.js.map
|
|
4311
|
+
exports.SchemaTypeTool = SchemaTypeTool;
|
|
4312
|
+
exports.assist = assist;
|
|
4313
|
+
exports.contextDocumentTypeName = contextDocumentTypeName;
|
|
4314
|
+
exports.defaultLanguageOutputs = defaultLanguageOutputs;
|
|
4315
|
+
exports.defineAssistFieldAction = defineAssistFieldAction;
|
|
4316
|
+
exports.defineAssistFieldActionGroup = defineAssistFieldActionGroup;
|
|
4317
|
+
exports.defineFieldActionDivider = defineFieldActionDivider;
|
|
4318
|
+
exports.isType = isType;
|
|
4319
|
+
exports.useUserInput = useUserInput;
|
|
4320
|
+
//# sourceMappingURL=index.cjs.map
|