@sanity/assist 5.0.0 → 5.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index.esm.js → index.cjs} +677 -741
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +685 -731
- package/dist/index.js.map +1 -1
- package/package.json +12 -11
- package/src/_lib/form/DocumentForm.tsx +1 -0
- package/src/assistFormComponents/AssistField.tsx +4 -20
- package/src/assistInspector/AssistInspector.tsx +1 -1
- package/src/onboarding/onboardingStore.ts +0 -1
- 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/src/onboarding/FieldActionsOnboarding.tsx +0 -68
- /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,77 +940,13 @@ 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) });
|
|
955
|
-
}
|
|
956
|
-
function AssistFeatureBadge() {
|
|
957
|
-
return /* @__PURE__ */ jsx(Badge, { fontSize: 0, style: { margin: "-2px 0" }, tone: "primary", children: "Beta" });
|
|
958
|
-
}
|
|
959
|
-
function AssistOnboardingPopover(props) {
|
|
960
|
-
const { dismiss } = props;
|
|
961
|
-
return /* @__PURE__ */ jsx(
|
|
962
|
-
Popover,
|
|
963
|
-
{
|
|
964
|
-
content: /* @__PURE__ */ jsx(AssistIntroCard, { dismiss }),
|
|
965
|
-
open: !0,
|
|
966
|
-
portal: !0,
|
|
967
|
-
placeholder: "bottom",
|
|
968
|
-
tone: "default",
|
|
969
|
-
width: 0,
|
|
970
|
-
children: /* @__PURE__ */ jsx(Card, { radius: 2, shadow: 2, style: { padding: 2, lineHeight: 0 }, children: /* @__PURE__ */ jsx(Button, { disabled: !0, fontSize: 1, icon: SparklesIcon, mode: "bleed", padding: 2 }) })
|
|
971
|
-
}
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
function AssistIntroCard(props) {
|
|
975
|
-
const buttonRef = useRef(null);
|
|
976
|
-
return /* @__PURE__ */ jsxs(Stack, { as: "section", padding: 3, space: 3, children: [
|
|
977
|
-
/* @__PURE__ */ jsxs(Stack, { padding: 2, space: 4, children: [
|
|
978
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", children: [
|
|
979
|
-
/* @__PURE__ */ jsx(Text, { as: "h1", size: 1, weight: "semibold", children: pluginTitle }),
|
|
980
|
-
/* @__PURE__ */ jsx("div", { "aria-hidden": !0, style: { margin: "-3px 0", lineHeight: 0 }, children: /* @__PURE__ */ jsx(AssistFeatureBadge, {}) })
|
|
981
|
-
] }),
|
|
982
|
-
/* @__PURE__ */ jsx(Stack, { space: 3, children: /* @__PURE__ */ jsxs(Text, { as: "p", muted: !0, size: 1, children: [
|
|
983
|
-
"Manage reusable AI instructions to boost your content creation and reduce amount of repetitive chores.",
|
|
984
|
-
" ",
|
|
985
|
-
/* @__PURE__ */ jsxs("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: [
|
|
986
|
-
"Learn more ",
|
|
987
|
-
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
988
|
-
] })
|
|
989
|
-
] }) })
|
|
990
|
-
] }),
|
|
991
|
-
/* @__PURE__ */ jsx(
|
|
992
|
-
Button,
|
|
993
|
-
{
|
|
994
|
-
fontSize: 1,
|
|
995
|
-
icon: CheckmarkIcon,
|
|
996
|
-
onClick: props.dismiss,
|
|
997
|
-
padding: 3,
|
|
998
|
-
ref: buttonRef,
|
|
999
|
-
text: "Ok, good to know!",
|
|
1000
|
-
tone: "primary"
|
|
1001
|
-
}
|
|
1002
|
-
)
|
|
1003
|
-
] });
|
|
1004
|
-
}
|
|
1005
|
-
const inspectorOnboardingKey = "sanityStudio:assist:inspector:onboarding:dismissed", fieldOnboardingKey = "sanityStudio:assist:field:onboarding:dismissed";
|
|
1006
|
-
function isFeatureOnboardingDismissed(featureKey) {
|
|
1007
|
-
return typeof localStorage > "u" ? !1 : localStorage.getItem(featureKey) === "true";
|
|
1008
|
-
}
|
|
1009
|
-
function dismissFeatureOnboarding(featureKey) {
|
|
1010
|
-
typeof localStorage > "u" || localStorage.setItem(featureKey, "true");
|
|
947
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentContextProvider, { documentType, documentId, children: props.renderDefault(props) });
|
|
1011
948
|
}
|
|
1012
|
-
|
|
1013
|
-
const [showOnboarding, setShowOnboarding] = useState(
|
|
1014
|
-
() => !isFeatureOnboardingDismissed(featureKey)
|
|
1015
|
-
), dismissOnboarding = useCallback(() => {
|
|
1016
|
-
setShowOnboarding(!1), dismissFeatureOnboarding(featureKey);
|
|
1017
|
-
}, [setShowOnboarding, featureKey]);
|
|
1018
|
-
return { showOnboarding, dismissOnboarding };
|
|
1019
|
-
}
|
|
1020
|
-
const fadeIn = keyframes`
|
|
949
|
+
const fadeIn = styledComponents.keyframes`
|
|
1021
950
|
0% {
|
|
1022
951
|
opacity: 0;
|
|
1023
952
|
transform: scale(0.75);
|
|
@@ -1030,14 +959,14 @@ const fadeIn = keyframes`
|
|
|
1030
959
|
opacity: 1;
|
|
1031
960
|
transform: scale(1);
|
|
1032
961
|
}
|
|
1033
|
-
`, FadeInDiv = styled.div`
|
|
962
|
+
`, FadeInDiv = styledComponents.styled.div`
|
|
1034
963
|
animation-name: ${fadeIn};
|
|
1035
964
|
animation-timing-function: ease-in-out;
|
|
1036
|
-
`, FadeInContent = forwardRef(function({
|
|
965
|
+
`, FadeInContent = react.forwardRef(function({
|
|
1037
966
|
children,
|
|
1038
967
|
durationMs = 250
|
|
1039
968
|
}, ref) {
|
|
1040
|
-
return /* @__PURE__ */ jsx(FadeInDiv, { ref, style: { animationDuration: `${durationMs}ms` }, children });
|
|
969
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FadeInDiv, { ref, style: { animationDuration: `${durationMs}ms` }, children });
|
|
1041
970
|
}), purple = {
|
|
1042
971
|
400: {
|
|
1043
972
|
hex: "#b087f7"
|
|
@@ -1048,19 +977,19 @@ const fadeIn = keyframes`
|
|
|
1048
977
|
600: {
|
|
1049
978
|
hex: "#721fe5"
|
|
1050
979
|
}
|
|
1051
|
-
}, Root = styled.span`
|
|
980
|
+
}, Root = styledComponents.styled.span`
|
|
1052
981
|
display: block;
|
|
1053
982
|
width: 25px;
|
|
1054
983
|
height: 25px;
|
|
1055
984
|
position: relative;
|
|
1056
|
-
`, dash = keyframes`
|
|
985
|
+
`, dash = styledComponents.keyframes`
|
|
1057
986
|
0% {
|
|
1058
987
|
transform: rotate(0);
|
|
1059
988
|
}
|
|
1060
989
|
100% {
|
|
1061
990
|
transform: rotate(43deg);
|
|
1062
991
|
}
|
|
1063
|
-
`, Outline = styled.svg`
|
|
992
|
+
`, Outline = styledComponents.styled.svg`
|
|
1064
993
|
display: block;
|
|
1065
994
|
position: absolute;
|
|
1066
995
|
top: 0;
|
|
@@ -1080,7 +1009,7 @@ const fadeIn = keyframes`
|
|
|
1080
1009
|
stroke-dasharray: 2px 2.34px;
|
|
1081
1010
|
}
|
|
1082
1011
|
}
|
|
1083
|
-
`, IconDisc = styled.span`
|
|
1012
|
+
`, IconDisc = styledComponents.styled.span`
|
|
1084
1013
|
background: var(--ai-avatar-disc-color);
|
|
1085
1014
|
color: white;
|
|
1086
1015
|
width: 21px;
|
|
@@ -1094,15 +1023,15 @@ const fadeIn = keyframes`
|
|
|
1094
1023
|
left: 2px;
|
|
1095
1024
|
`;
|
|
1096
1025
|
function AssistAvatar(props) {
|
|
1097
|
-
const { state = "present" } = props, scheme = useColorSchemeValue(), style = useMemo(() => scheme === "dark" ? {
|
|
1026
|
+
const { state = "present" } = props, scheme = sanity.useColorSchemeValue(), style = react.useMemo(() => scheme === "dark" ? {
|
|
1098
1027
|
"--ai-avatar-stroke-color": purple[400].hex,
|
|
1099
1028
|
"--ai-avatar-disc-color": purple[600].hex
|
|
1100
1029
|
} : {
|
|
1101
1030
|
"--ai-avatar-stroke-color": purple[500].hex,
|
|
1102
1031
|
"--ai-avatar-disc-color": purple[600].hex
|
|
1103
1032
|
}, [scheme]);
|
|
1104
|
-
return /* @__PURE__ */ jsxs(Root, { "data-state": state, style, children: [
|
|
1105
|
-
/* @__PURE__ */ jsx(
|
|
1033
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Root, { "data-state": state, style, children: [
|
|
1034
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1106
1035
|
Outline,
|
|
1107
1036
|
{
|
|
1108
1037
|
width: "25",
|
|
@@ -1110,35 +1039,35 @@ function AssistAvatar(props) {
|
|
|
1110
1039
|
viewBox: "0 0 25 25",
|
|
1111
1040
|
fill: "none",
|
|
1112
1041
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1113
|
-
children: /* @__PURE__ */ jsx("circle", { cx: "12.5", cy: "12.5", r: "11.75" })
|
|
1042
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12.5", cy: "12.5", r: "11.75" })
|
|
1114
1043
|
}
|
|
1115
1044
|
),
|
|
1116
|
-
/* @__PURE__ */ jsx(IconDisc, { children: /* @__PURE__ */ jsx(Text, { as: "span", size: 0, style: { color: "inherit" }, children: /* @__PURE__ */ jsx(SparklesIcon, { style: { color: "inherit" } }) }) })
|
|
1045
|
+
/* @__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
1046
|
] });
|
|
1118
1047
|
}
|
|
1119
1048
|
function AiFieldPresence(props) {
|
|
1120
|
-
return /* @__PURE__ */ jsx(Card, { style: { position: "relative", background: "transparent" }, contentEditable: !1, children: /* @__PURE__ */ jsx(
|
|
1121
|
-
Tooltip,
|
|
1049
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { style: { position: "relative", background: "transparent" }, contentEditable: !1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1050
|
+
ui.Tooltip,
|
|
1122
1051
|
{
|
|
1123
1052
|
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" }) })
|
|
1053
|
+
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..." }) }) }),
|
|
1054
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(FadeInContent, { durationMs: 300, children: /* @__PURE__ */ jsxRuntime.jsx(AssistAvatar, { state: "active" }) })
|
|
1126
1055
|
}
|
|
1127
1056
|
) });
|
|
1128
1057
|
}
|
|
1129
1058
|
const NO_PRESENCE = [];
|
|
1130
1059
|
function useAssistPresence(path, showFocusWithin) {
|
|
1131
1060
|
const context = useAssistDocumentContext(), tasks = (context && "assistDocument" in context ? context.assistDocument : void 0)?.tasks;
|
|
1132
|
-
return useMemo(() => {
|
|
1061
|
+
return react.useMemo(() => {
|
|
1133
1062
|
const activePresence = tasks?.filter((task) => !task.ended)?.flatMap((task) => task.presence ?? [])?.filter(
|
|
1134
1063
|
(p) => p.started && (/* @__PURE__ */ new Date()).getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs
|
|
1135
1064
|
).filter((presence) => {
|
|
1136
1065
|
if (!presence.path || !path.length)
|
|
1137
1066
|
return !1;
|
|
1138
|
-
const statusPath = stringToPath(presence.path);
|
|
1067
|
+
const statusPath = sanity.stringToPath(presence.path);
|
|
1139
1068
|
return !showFocusWithin && statusPath.length !== path.length ? !1 : path.every((pathSegment, i) => {
|
|
1140
1069
|
const statusSegment = statusPath[i];
|
|
1141
|
-
return typeof pathSegment == "string" ? pathSegment === statusSegment : isKeySegment(pathSegment) && isKeySegment(statusSegment) ? pathSegment._key === statusSegment._key : !1;
|
|
1070
|
+
return typeof pathSegment == "string" ? pathSegment === statusSegment : sanity.isKeySegment(pathSegment) && sanity.isKeySegment(statusSegment) ? pathSegment._key === statusSegment._key : !1;
|
|
1142
1071
|
});
|
|
1143
1072
|
});
|
|
1144
1073
|
return activePresence?.length ? activePresence.map((status) => aiPresence(status, path)) : NO_PRESENCE;
|
|
@@ -1157,79 +1086,72 @@ function aiPresence(presence, path, title) {
|
|
|
1157
1086
|
}
|
|
1158
1087
|
function AssistFieldWrapper(props) {
|
|
1159
1088
|
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);
|
|
1089
|
+
return !react.useMemo(() => isAssistSupported(schemaType), [schemaType]) || schemaType.name.startsWith("sanity.") || schemaType.name === contextDocumentTypeName ? props.renderDefault(props) : !isType(props.schemaType, "document") && props.inputId !== "root" && props.inputId !== assistFormId ? /* @__PURE__ */ jsxRuntime.jsx(AssistField, { ...props, children: props.children }) : props.renderDefault(props);
|
|
1161
1090
|
}
|
|
1162
1091
|
function AssistField(props) {
|
|
1163
|
-
const
|
|
1164
|
-
() => !!(isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)),
|
|
1092
|
+
const isPortableText = react.useMemo(
|
|
1093
|
+
() => !!(sanity.isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType)),
|
|
1165
1094
|
[props.schemaType]
|
|
1166
|
-
),
|
|
1167
|
-
() => pathToString(path) === firstAssistedPath,
|
|
1168
|
-
[path, firstAssistedPath]
|
|
1169
|
-
), { showOnboarding, dismissOnboarding } = useOnboardingFeature(fieldOnboardingKey), singlePresence = presence[0], actions = /* @__PURE__ */ jsxs(Flex, { gap: 2, align: "center", justify: "space-between", children: [
|
|
1170
|
-
singlePresence && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(AiFieldPresence, { presence: singlePresence }) }),
|
|
1171
|
-
isFirstAssisted && showOnboarding && /* @__PURE__ */ jsx(AssistOnboardingPopover, { dismiss: dismissOnboarding })
|
|
1172
|
-
] });
|
|
1095
|
+
), singlePresence = useAssistPresence(props.path, isPortableText)[0], actions = /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 2, align: "center", justify: "space-between", children: singlePresence && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: singlePresence }) }) });
|
|
1173
1096
|
return props.renderDefault({
|
|
1174
1097
|
...props,
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
// Render presence (and possibly onboarding) in the internal slot (between presence and the field actions)
|
|
1098
|
+
actions: props.actions,
|
|
1099
|
+
// Render presence in the internal slot (between presence and the field actions)
|
|
1178
1100
|
// eslint-disable-next-line camelcase
|
|
1179
1101
|
__internal_slot: actions
|
|
1180
1102
|
});
|
|
1181
1103
|
}
|
|
1182
|
-
const WrapPreCard = styled(Card)`
|
|
1104
|
+
const WrapPreCard = styledComponents.styled(ui.Card)`
|
|
1183
1105
|
& pre {
|
|
1184
1106
|
white-space: pre-wrap !important;
|
|
1185
1107
|
}
|
|
1186
1108
|
`;
|
|
1187
1109
|
function SafeValueInput(props) {
|
|
1188
|
-
return /* @__PURE__ */ jsx(ErrorWrapper, { onChange: props.onChange, children: /* @__PURE__ */ jsx(PteValueFixer, { ...props }) });
|
|
1110
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ErrorWrapper, { onChange: props.onChange, children: /* @__PURE__ */ jsxRuntime.jsx(PteValueFixer, { ...props }) });
|
|
1189
1111
|
}
|
|
1190
1112
|
function ErrorWrapper(props) {
|
|
1191
|
-
const { onChange } = props, [error, setError] = useState(),
|
|
1113
|
+
const { onChange } = props, [error, setError] = react.useState(), catchError = react.useCallback((params) => {
|
|
1192
1114
|
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" })
|
|
1115
|
+
}, []), unsetValue = react.useCallback(() => {
|
|
1116
|
+
onChange(sanity.PatchEvent.from(sanity.unset())), setError(void 0);
|
|
1117
|
+
}, [onChange]), dismiss = react.useCallback(() => setError(void 0), []), catcher = /* @__PURE__ */ jsxRuntime.jsx(ui.ErrorBoundary, { onCatch: catchError, children: props.children });
|
|
1118
|
+
return error ? /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { border: !0, tone: "critical", padding: 2, contentEditable: !1, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 3, children: [
|
|
1119
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, weight: "semibold", children: "An error occurred." }),
|
|
1120
|
+
/* @__PURE__ */ jsxRuntime.jsx(WrapPreCard, { flex: 1, padding: 2, tone: "critical", border: !0, children: catcher }),
|
|
1121
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { width: "fill", flex: 1, gap: 3, children: [
|
|
1122
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Dismiss", onClick: dismiss, tone: "primary" }) }),
|
|
1123
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { text: "Unset value", onClick: unsetValue, tone: "critical" })
|
|
1202
1124
|
] })
|
|
1203
1125
|
] }) }) : catcher;
|
|
1204
1126
|
}
|
|
1205
1127
|
function PteValueFixer(props) {
|
|
1206
|
-
const isPortableText = useMemo(
|
|
1207
|
-
() => isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType),
|
|
1128
|
+
const isPortableText = react.useMemo(
|
|
1129
|
+
() => sanity.isArraySchemaType(props.schemaType) && isPortableTextArray(props.schemaType),
|
|
1208
1130
|
[props.schemaType]
|
|
1209
1131
|
), value = props.value;
|
|
1210
1132
|
return isPortableText && value && !value.length ? props.renderDefault({ ...props, value: void 0 }) : props.renderDefault(props);
|
|
1211
1133
|
}
|
|
1212
1134
|
function AssistFormBlock(props) {
|
|
1213
|
-
const presence = useAssistPresence(props.path, !0), { onChange } = useFormCallbacks(), key = props.value._key, localOnChange = useCallback(
|
|
1135
|
+
const presence = useAssistPresence(props.path, !0), { onChange } = sanity.useFormCallbacks(), key = props.value._key, localOnChange = react.useCallback(
|
|
1214
1136
|
(patchEvent) => {
|
|
1215
|
-
key && onChange(PatchEvent.from(patchEvent).prefixAll({ _key: key }));
|
|
1137
|
+
key && onChange(sanity.PatchEvent.from(patchEvent).prefixAll({ _key: key }));
|
|
1216
1138
|
},
|
|
1217
1139
|
[onChange, key]
|
|
1218
1140
|
), 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 })
|
|
1141
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ErrorWrapper, { onChange: localOnChange, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", justify: "space-between", children: [
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: props.renderDefault(props) }),
|
|
1143
|
+
singlePresence && /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: singlePresence })
|
|
1222
1144
|
] }) });
|
|
1223
1145
|
}
|
|
1224
|
-
const InlineBlockValueContext = createContext(void 0);
|
|
1146
|
+
const InlineBlockValueContext = react.createContext(void 0);
|
|
1225
1147
|
function AssistInlineFormBlock(props) {
|
|
1226
|
-
return /* @__PURE__ */ jsx(InlineBlockValueContext.Provider, { value: props.value, children: /* @__PURE__ */ jsx(Fragment, { children: props.renderDefault(props) }) });
|
|
1148
|
+
return /* @__PURE__ */ jsxRuntime.jsx(InlineBlockValueContext.Provider, { value: props.value, children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: props.renderDefault(props) }) });
|
|
1227
1149
|
}
|
|
1228
1150
|
function AssistItem(props) {
|
|
1229
1151
|
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))
|
|
1152
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", width: "fill", style: { position: "relative" }, children: [
|
|
1153
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, children: props.renderDefault({ ...props }) }),
|
|
1154
|
+
presence.map((pre) => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { position: "absolute", right: 35 }, children: /* @__PURE__ */ jsxRuntime.jsx(AiFieldPresence, { presence: pre }) }, pre.user.id))
|
|
1233
1155
|
] });
|
|
1234
1156
|
}
|
|
1235
1157
|
const preventDefault = (ev) => ev.preventDefault();
|
|
@@ -1251,10 +1173,10 @@ function DocumentForm(props) {
|
|
|
1251
1173
|
onSetCollapsedPath,
|
|
1252
1174
|
ready,
|
|
1253
1175
|
validation
|
|
1254
|
-
} = useDocumentPane(), documentStore = useDocumentStore(), presence = useDocumentPresence(documentId), patchChannel = useMemo(() => createPatchChannel(), []), isLocked = editState?.transactionSyncLock?.enabled;
|
|
1255
|
-
useEffect(() => {
|
|
1176
|
+
} = structure.useDocumentPane(), documentStore = sanity.useDocumentStore(), presence = sanity.useDocumentPresence(documentId), patchChannel = react.useMemo(() => sanity.createPatchChannel(), []), isLocked = editState?.transactionSyncLock?.enabled;
|
|
1177
|
+
react.useEffect(() => {
|
|
1256
1178
|
const sub = documentStore.pair.documentEvents(documentId, documentType).pipe(
|
|
1257
|
-
tap((event) => {
|
|
1179
|
+
operators.tap((event) => {
|
|
1258
1180
|
event.type === "mutation" && patchChannel.publish(prepareMutationEvent(event)), event.type === "rebase" && patchChannel.publish(prepareRebaseEvent(event));
|
|
1259
1181
|
})
|
|
1260
1182
|
).subscribe();
|
|
@@ -1263,18 +1185,18 @@ function DocumentForm(props) {
|
|
|
1263
1185
|
};
|
|
1264
1186
|
}, [documentId, documentStore, documentType, patchChannel]);
|
|
1265
1187
|
const hasRev = !!value?._rev;
|
|
1266
|
-
useEffect(() => {
|
|
1188
|
+
react.useEffect(() => {
|
|
1267
1189
|
hasRev && patchChannel.publish({
|
|
1268
1190
|
type: "mutation",
|
|
1269
1191
|
patches: [],
|
|
1270
1192
|
snapshot: value
|
|
1271
1193
|
});
|
|
1272
1194
|
}, [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,
|
|
1195
|
+
const formRef = react.useRef(null);
|
|
1196
|
+
return react.useEffect(() => {
|
|
1197
|
+
ui.focusFirstDescendant(formRef.current);
|
|
1198
|
+
}, []), isLocked ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { as: "form", ...props, ref: formRef, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1199
|
+
ui.Flex,
|
|
1278
1200
|
{
|
|
1279
1201
|
align: "center",
|
|
1280
1202
|
direction: "column",
|
|
@@ -1282,10 +1204,10 @@ function DocumentForm(props) {
|
|
|
1282
1204
|
justify: "center",
|
|
1283
1205
|
padding: 3,
|
|
1284
1206
|
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" })
|
|
1207
|
+
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
1208
|
}
|
|
1287
|
-
) }) : /* @__PURE__ */ jsx(Box, { as: "form", ...props, onSubmit: preventDefault, ref: formRef, children: ready ? formState === null ? /* @__PURE__ */ jsx(
|
|
1288
|
-
Flex,
|
|
1209
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { as: "form", ...props, onSubmit: preventDefault, ref: formRef, children: ready ? formState === null ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1210
|
+
ui.Flex,
|
|
1289
1211
|
{
|
|
1290
1212
|
align: "center",
|
|
1291
1213
|
direction: "column",
|
|
@@ -1293,10 +1215,10 @@ function DocumentForm(props) {
|
|
|
1293
1215
|
justify: "center",
|
|
1294
1216
|
padding: 3,
|
|
1295
1217
|
sizing: "border",
|
|
1296
|
-
children: /* @__PURE__ */ jsx(Text, { size: 1, children: "This form is hidden" })
|
|
1218
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "This form is hidden" })
|
|
1297
1219
|
}
|
|
1298
|
-
) : /* @__PURE__ */ jsx(
|
|
1299
|
-
FormBuilder,
|
|
1220
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1221
|
+
sanity.FormBuilder,
|
|
1300
1222
|
{
|
|
1301
1223
|
__internal_patchChannel: patchChannel,
|
|
1302
1224
|
collapsedFieldSets,
|
|
@@ -1318,10 +1240,11 @@ function DocumentForm(props) {
|
|
|
1318
1240
|
readOnly: formState.readOnly,
|
|
1319
1241
|
schemaType: formState.schemaType,
|
|
1320
1242
|
validation,
|
|
1321
|
-
value: formState.value
|
|
1243
|
+
value: formState.value,
|
|
1244
|
+
hasUpstreamVersion: !1
|
|
1322
1245
|
}
|
|
1323
|
-
) : /* @__PURE__ */ jsxs(
|
|
1324
|
-
Flex,
|
|
1246
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1247
|
+
ui.Flex,
|
|
1325
1248
|
{
|
|
1326
1249
|
align: "center",
|
|
1327
1250
|
direction: "column",
|
|
@@ -1330,8 +1253,8 @@ function DocumentForm(props) {
|
|
|
1330
1253
|
padding: 3,
|
|
1331
1254
|
sizing: "border",
|
|
1332
1255
|
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" }) })
|
|
1256
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { muted: !0 }),
|
|
1257
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 3, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { align: "center", muted: !0, size: 1, children: "Loading document" }) })
|
|
1335
1258
|
]
|
|
1336
1259
|
}
|
|
1337
1260
|
) });
|
|
@@ -1341,7 +1264,7 @@ function prepareMutationEvent(event) {
|
|
|
1341
1264
|
return {
|
|
1342
1265
|
type: "mutation",
|
|
1343
1266
|
snapshot: event.document,
|
|
1344
|
-
patches: fromMutationPatches(event.origin, patches)
|
|
1267
|
+
patches: sanity.fromMutationPatches(event.origin, patches)
|
|
1345
1268
|
};
|
|
1346
1269
|
}
|
|
1347
1270
|
function prepareRebaseEvent(event) {
|
|
@@ -1349,12 +1272,12 @@ function prepareRebaseEvent(event) {
|
|
|
1349
1272
|
return {
|
|
1350
1273
|
type: "rebase",
|
|
1351
1274
|
snapshot: event.document,
|
|
1352
|
-
patches: fromMutationPatches("remote", remotePatches).concat(
|
|
1353
|
-
fromMutationPatches("local", localPatches)
|
|
1275
|
+
patches: sanity.fromMutationPatches("remote", remotePatches).concat(
|
|
1276
|
+
sanity.fromMutationPatches("local", localPatches)
|
|
1354
1277
|
)
|
|
1355
1278
|
};
|
|
1356
1279
|
}
|
|
1357
|
-
const AssistTypeContext = createContext({}), DEFAULT_MAX_DEPTH$1 = 8, ABSOLUTE_MAX_DEPTH$1 = 50;
|
|
1280
|
+
const AssistTypeContext = react.createContext({}), DEFAULT_MAX_DEPTH$1 = 8, ABSOLUTE_MAX_DEPTH$1 = 50;
|
|
1358
1281
|
function getConditionalMembers(docState, maxDepth2 = DEFAULT_MAX_DEPTH$1) {
|
|
1359
1282
|
return [{
|
|
1360
1283
|
path: "",
|
|
@@ -1368,7 +1291,7 @@ function isConditional(schemaType) {
|
|
|
1368
1291
|
}
|
|
1369
1292
|
function conditionalState(memberState) {
|
|
1370
1293
|
return {
|
|
1371
|
-
path: pathToString(memberState.path),
|
|
1294
|
+
path: sanity.pathToString(memberState.path),
|
|
1372
1295
|
readOnly: !!memberState.readOnly,
|
|
1373
1296
|
// Use actual form state readOnly value
|
|
1374
1297
|
hidden: !1,
|
|
@@ -1389,7 +1312,7 @@ function extractConditionalPaths(node, maxDepth2) {
|
|
|
1389
1312
|
const array = member.field;
|
|
1390
1313
|
let arrayPaths = [];
|
|
1391
1314
|
const isObjectsArray = array.members.some(
|
|
1392
|
-
(m) => m.kind === "item" && isObjectSchemaType(m.item.schemaType)
|
|
1315
|
+
(m) => m.kind === "item" && sanity.isObjectSchemaType(m.item.schemaType)
|
|
1393
1316
|
);
|
|
1394
1317
|
if (!array.readOnly)
|
|
1395
1318
|
for (const arrayMember of array.members) {
|
|
@@ -1414,7 +1337,7 @@ function extractConditionalPaths(node, maxDepth2) {
|
|
|
1414
1337
|
return acc;
|
|
1415
1338
|
}, []);
|
|
1416
1339
|
}
|
|
1417
|
-
const SparklesIllustration = styled(SparklesIcon)({
|
|
1340
|
+
const SparklesIllustration = styledComponents.styled(icons.SparklesIcon)({
|
|
1418
1341
|
fontSize: "3.125em",
|
|
1419
1342
|
"& path": {
|
|
1420
1343
|
strokeWidth: "0.6px !important"
|
|
@@ -1422,12 +1345,12 @@ const SparklesIllustration = styled(SparklesIcon)({
|
|
|
1422
1345
|
});
|
|
1423
1346
|
function InspectorOnboarding(props) {
|
|
1424
1347
|
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,
|
|
1348
|
+
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: [
|
|
1349
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(SparklesIllustration, {}) }),
|
|
1350
|
+
/* @__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." }),
|
|
1351
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 2, justify: "center", children: [
|
|
1352
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1353
|
+
ui.Button,
|
|
1431
1354
|
{
|
|
1432
1355
|
as: "a",
|
|
1433
1356
|
href: releaseAnnouncementUrl,
|
|
@@ -1441,35 +1364,35 @@ function InspectorOnboarding(props) {
|
|
|
1441
1364
|
tone: "primary"
|
|
1442
1365
|
}
|
|
1443
1366
|
),
|
|
1444
|
-
/* @__PURE__ */ jsx(Button, { fontSize: 1, mode: "bleed", onClick: onDismiss, padding: 2, text: "Dismiss" })
|
|
1367
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Button, { fontSize: 1, mode: "bleed", onClick: onDismiss, padding: 2, text: "Dismiss" })
|
|
1445
1368
|
] })
|
|
1446
1369
|
] }) }) });
|
|
1447
1370
|
}
|
|
1448
1371
|
function FieldAutocomplete(props) {
|
|
1449
|
-
const { id, schemaType, fieldPath, onSelect, includeDocument, filter
|
|
1372
|
+
const { id, schemaType, fieldPath, onSelect, includeDocument, filter } = props, { getFieldRefs: getFieldRefs2 } = useAiAssistanceConfig(), fieldRefs = react.useMemo(() => {
|
|
1450
1373
|
const refs = getFieldRefs2(schemaType.name);
|
|
1451
1374
|
return includeDocument ? [getDocumentFieldRef(schemaType), ...refs] : refs;
|
|
1452
|
-
}, [schemaType, includeDocument, getFieldRefs2]), currentField = useMemo(
|
|
1375
|
+
}, [schemaType, includeDocument, getFieldRefs2]), currentField = react.useMemo(
|
|
1453
1376
|
() => fieldRefs.find((f) => f.key === fieldPath),
|
|
1454
1377
|
[fieldPath, fieldRefs]
|
|
1455
|
-
), autocompleteOptions = useMemo(
|
|
1456
|
-
() => fieldRefs.filter((field) =>
|
|
1457
|
-
[fieldRefs,
|
|
1458
|
-
), renderOption = useCallback((option) => {
|
|
1378
|
+
), autocompleteOptions = react.useMemo(
|
|
1379
|
+
() => fieldRefs.filter((field) => filter ? filter(field) : !0).filter((f) => !isType(f.schemaType, "reference")).map((field) => ({ value: field.key, field })),
|
|
1380
|
+
[fieldRefs, filter]
|
|
1381
|
+
), renderOption = react.useCallback((option) => {
|
|
1459
1382
|
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) => {
|
|
1383
|
+
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: [
|
|
1384
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: react.createElement(field.icon) }),
|
|
1385
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldTitle, { field })
|
|
1386
|
+
] }) }) : /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: "button", padding: 3, radius: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { accent: !0, size: 1, children: option.value }) });
|
|
1387
|
+
}, []), renderValue = react.useCallback((value, option) => option?.field.title ?? value, []), filterOption = react.useCallback((query, option) => {
|
|
1465
1388
|
const lQuery = query.toLowerCase();
|
|
1466
1389
|
return option?.value?.toLowerCase().includes(lQuery) || option?.field?.title?.toLowerCase().includes(lQuery);
|
|
1467
1390
|
}, []);
|
|
1468
|
-
return /* @__PURE__ */ jsx(
|
|
1469
|
-
Autocomplete,
|
|
1391
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1392
|
+
ui.Autocomplete,
|
|
1470
1393
|
{
|
|
1471
1394
|
fontSize: 1,
|
|
1472
|
-
icon: currentField ? currentField.icon : SearchIcon,
|
|
1395
|
+
icon: currentField ? currentField.icon : icons.SearchIcon,
|
|
1473
1396
|
onChange: onSelect,
|
|
1474
1397
|
openButton: !0,
|
|
1475
1398
|
id,
|
|
@@ -1485,8 +1408,8 @@ function FieldAutocomplete(props) {
|
|
|
1485
1408
|
}
|
|
1486
1409
|
function FieldTitle(props) {
|
|
1487
1410
|
const splitTitle = props.field.title.split("/");
|
|
1488
|
-
return /* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsxs(
|
|
1489
|
-
Breadcrumbs,
|
|
1411
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1412
|
+
ui.Breadcrumbs,
|
|
1490
1413
|
{
|
|
1491
1414
|
style: {
|
|
1492
1415
|
display: "flex",
|
|
@@ -1494,77 +1417,77 @@ function FieldTitle(props) {
|
|
|
1494
1417
|
alignItems: "center",
|
|
1495
1418
|
marginTop: "-4px"
|
|
1496
1419
|
},
|
|
1497
|
-
separator: /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { muted: !0, size: 1, children: "/" }) }),
|
|
1420
|
+
separator: /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "/" }) }),
|
|
1498
1421
|
space: 1,
|
|
1499
1422
|
children: [
|
|
1500
1423
|
splitTitle.slice(0, splitTitle.length - 1).map((pt, i) => (
|
|
1501
1424
|
// 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)
|
|
1425
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: pt.trim() }) }, i)
|
|
1503
1426
|
)),
|
|
1504
|
-
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { size: 1, weight: "medium", children: splitTitle[splitTitle.length - 1] }) })
|
|
1427
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "medium", children: splitTitle[splitTitle.length - 1] }) })
|
|
1505
1428
|
]
|
|
1506
1429
|
}
|
|
1507
1430
|
) });
|
|
1508
1431
|
}
|
|
1509
1432
|
function useInterval(ms) {
|
|
1510
|
-
const [tick, update] = useReducer((n) => n + 1, 0);
|
|
1511
|
-
return useEffect(() => {
|
|
1433
|
+
const [tick, update] = react.useReducer((n) => n + 1, 0);
|
|
1434
|
+
return react.useEffect(() => {
|
|
1512
1435
|
const i = setInterval(update, ms);
|
|
1513
1436
|
return () => clearInterval(i);
|
|
1514
1437
|
}, [ms]), tick;
|
|
1515
1438
|
}
|
|
1516
1439
|
function TimeAgo({ date }) {
|
|
1517
1440
|
useInterval(1e3);
|
|
1518
|
-
const timeSince = formatDistanceToNow(date ? new Date(date) : /* @__PURE__ */ new Date());
|
|
1519
|
-
return /* @__PURE__ */ jsxs("span", { title: timeSince, children: [
|
|
1441
|
+
const timeSince = dateFns.formatDistanceToNow(date ? new Date(date) : /* @__PURE__ */ new Date());
|
|
1442
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { title: timeSince, children: [
|
|
1520
1443
|
timeSince,
|
|
1521
1444
|
" ago"
|
|
1522
1445
|
] });
|
|
1523
1446
|
}
|
|
1524
|
-
const rotate = keyframes`
|
|
1447
|
+
const rotate = styledComponents.keyframes`
|
|
1525
1448
|
0% {
|
|
1526
1449
|
transform: rotate(0);
|
|
1527
1450
|
}
|
|
1528
1451
|
100% {
|
|
1529
1452
|
transform: rotate(360deg);
|
|
1530
1453
|
}
|
|
1531
|
-
`, SyncSpinningIcon = styled(SyncIcon)`
|
|
1454
|
+
`, SyncSpinningIcon = styledComponents.styled(icons.SyncIcon)`
|
|
1532
1455
|
animation: ${rotate} 1s linear infinite;
|
|
1533
1456
|
`, TASK_CONFIG = {
|
|
1534
1457
|
aborted: {
|
|
1535
1458
|
title: "Canceled",
|
|
1536
|
-
icon: CloseCircleIcon,
|
|
1459
|
+
icon: icons.CloseCircleIcon,
|
|
1537
1460
|
tone: "transparent"
|
|
1538
1461
|
},
|
|
1539
1462
|
error: {
|
|
1540
1463
|
title: "Error",
|
|
1541
|
-
icon: ErrorOutlineIcon,
|
|
1464
|
+
icon: icons.ErrorOutlineIcon,
|
|
1542
1465
|
tone: "critical"
|
|
1543
1466
|
},
|
|
1544
1467
|
success: {
|
|
1545
1468
|
title: "Completed",
|
|
1546
|
-
icon: CheckmarkCircleIcon,
|
|
1469
|
+
icon: icons.CheckmarkCircleIcon,
|
|
1547
1470
|
tone: "positive"
|
|
1548
1471
|
},
|
|
1549
1472
|
timeout: {
|
|
1550
1473
|
title: "Timeout",
|
|
1551
|
-
icon: ClockIcon,
|
|
1474
|
+
icon: icons.ClockIcon,
|
|
1552
1475
|
tone: "caution"
|
|
1553
1476
|
}
|
|
1554
1477
|
};
|
|
1555
1478
|
function InstructionTaskHistoryButton(props) {
|
|
1556
|
-
const { tasks, instructions, documentId, showTitles } = props, client = useClient({ apiVersion: "2023-01-01" }), cancelRun = useCallback(
|
|
1479
|
+
const { tasks, instructions, documentId, showTitles } = props, client = sanity.useClient({ apiVersion: "2023-01-01" }), cancelRun = react.useCallback(
|
|
1557
1480
|
(taskKey) => {
|
|
1558
1481
|
if (!documentId)
|
|
1559
1482
|
return;
|
|
1560
|
-
const statusDocId = assistTasksStatusId(documentId), basePath2 = `${typed("tasks")}[_key=="${taskKey}"]`;
|
|
1483
|
+
const statusDocId = assistTasksStatusId(documentId), basePath2 = `${sanity.typed("tasks")}[_key=="${taskKey}"]`;
|
|
1561
1484
|
client.patch(statusDocId).set({
|
|
1562
|
-
[`${basePath2}.${typed("ended")}`]: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1563
|
-
[`${basePath2}.${typed("reason")}`]: typed("aborted")
|
|
1485
|
+
[`${basePath2}.${sanity.typed("ended")}`]: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1486
|
+
[`${basePath2}.${sanity.typed("reason")}`]: sanity.typed("aborted")
|
|
1564
1487
|
}).commit().catch(console.error);
|
|
1565
1488
|
},
|
|
1566
1489
|
[client, documentId]
|
|
1567
|
-
), titledTasks = useMemo(() => {
|
|
1490
|
+
), titledTasks = react.useMemo(() => {
|
|
1568
1491
|
const t = tasks?.filter(
|
|
1569
1492
|
(task) => task.started && (/* @__PURE__ */ new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs
|
|
1570
1493
|
).map((task) => {
|
|
@@ -1576,27 +1499,27 @@ function InstructionTaskHistoryButton(props) {
|
|
|
1576
1499
|
};
|
|
1577
1500
|
}) ?? [];
|
|
1578
1501
|
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(
|
|
1502
|
+
}, [tasks, instructions, cancelRun, showTitles]), isRunning = react.useMemo(() => titledTasks.some((r) => !r.ended), [titledTasks]), hasErrors = react.useMemo(
|
|
1580
1503
|
() => titledTasks.some((r) => r.reason === "error" || r.reason === "timeout"),
|
|
1581
1504
|
[titledTasks]
|
|
1582
|
-
), [open, setOpen] = useState(!1), toggleOpen = useCallback(() => setOpen((v) => !v), []), [button, setButton] = useState(null), [popover, setPopover] = useState(null), handleClickOutside = useCallback(() => {
|
|
1505
|
+
), [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
1506
|
setOpen(!1);
|
|
1584
1507
|
}, []);
|
|
1585
|
-
useClickOutside(handleClickOutside, [button, popover]);
|
|
1586
|
-
const handleEscape = useCallback(() => {
|
|
1508
|
+
ui.useClickOutside(handleClickOutside, [button, popover]);
|
|
1509
|
+
const handleEscape = react.useCallback(() => {
|
|
1587
1510
|
setOpen(!1), button?.focus();
|
|
1588
1511
|
}, [button]);
|
|
1589
|
-
return /* @__PURE__ */ jsx(
|
|
1590
|
-
Popover,
|
|
1512
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1513
|
+
ui.Popover,
|
|
1591
1514
|
{
|
|
1592
1515
|
constrainSize: !0,
|
|
1593
|
-
content: /* @__PURE__ */ jsx(TaskList, { onEscape: handleEscape, tasks: titledTasks }),
|
|
1516
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(TaskList, { onEscape: handleEscape, tasks: titledTasks }),
|
|
1594
1517
|
open: open && !!titledTasks?.length,
|
|
1595
1518
|
placement: "top",
|
|
1596
1519
|
portal: !0,
|
|
1597
1520
|
ref: setPopover,
|
|
1598
1521
|
width: 0,
|
|
1599
|
-
children: /* @__PURE__ */ jsx(
|
|
1522
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1600
1523
|
TaskStatusButton,
|
|
1601
1524
|
{
|
|
1602
1525
|
disabled: !titledTasks?.length,
|
|
@@ -1612,14 +1535,14 @@ function InstructionTaskHistoryButton(props) {
|
|
|
1612
1535
|
}
|
|
1613
1536
|
const TASK_STATUS_BUTTON_TOOLTIP_PROPS = {
|
|
1614
1537
|
placement: "top"
|
|
1615
|
-
}, TaskStatusButton = forwardRef(function(props, ref) {
|
|
1538
|
+
}, TaskStatusButton = react.forwardRef(function(props, ref) {
|
|
1616
1539
|
const { disabled, hasErrors, isRunning, onClick, selected } = props;
|
|
1617
|
-
return /* @__PURE__ */ jsx(
|
|
1618
|
-
StatusButton,
|
|
1540
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1541
|
+
sanity.StatusButton,
|
|
1619
1542
|
{
|
|
1620
1543
|
label: `${pluginTitle} status`,
|
|
1621
1544
|
"aria-label": `${pluginTitle} status`,
|
|
1622
|
-
icon: isRunning ? SyncSpinningIcon : hasErrors ? ErrorOutlineIcon : CheckmarkCircleIcon,
|
|
1545
|
+
icon: isRunning ? SyncSpinningIcon : hasErrors ? icons.ErrorOutlineIcon : icons.CheckmarkCircleIcon,
|
|
1623
1546
|
mode: "bleed",
|
|
1624
1547
|
onClick,
|
|
1625
1548
|
tone: hasErrors ? "critical" : void 0,
|
|
@@ -1631,40 +1554,55 @@ const TASK_STATUS_BUTTON_TOOLTIP_PROPS = {
|
|
|
1631
1554
|
);
|
|
1632
1555
|
});
|
|
1633
1556
|
function TaskList(props) {
|
|
1634
|
-
const { onEscape, tasks } = props, { isTopLayer } = useLayer();
|
|
1635
|
-
return useGlobalKeyDown(
|
|
1636
|
-
useCallback(
|
|
1557
|
+
const { onEscape, tasks } = props, { isTopLayer } = ui.useLayer();
|
|
1558
|
+
return ui.useGlobalKeyDown(
|
|
1559
|
+
react.useCallback(
|
|
1637
1560
|
(event) => {
|
|
1638
1561
|
isTopLayer && event.key === "Escape" && onEscape();
|
|
1639
1562
|
},
|
|
1640
1563
|
[isTopLayer, onEscape]
|
|
1641
1564
|
)
|
|
1642
|
-
), /* @__PURE__ */ jsx(Stack, { padding: 1, space: 1, children: tasks.map((task) => /* @__PURE__ */ jsx(TaskItem, { task }, task._key)) });
|
|
1565
|
+
), /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { padding: 1, space: 1, children: tasks.map((task) => /* @__PURE__ */ jsxRuntime.jsx(TaskItem, { task }, task._key)) });
|
|
1643
1566
|
}
|
|
1644
1567
|
function TaskItem(props) {
|
|
1645
1568
|
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, {})
|
|
1569
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { radius: 2, tone: taskType && taskType?.tone, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", gap: 1, children: [
|
|
1570
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "flex-start", flex: 1, gap: 3, padding: 3, children: [
|
|
1571
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, children: [
|
|
1572
|
+
taskType && react.createElement(taskType.icon),
|
|
1573
|
+
!task.reason && /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {})
|
|
1651
1574
|
] }) }),
|
|
1652
|
-
/* @__PURE__ */ jsxs(Stack, { flex: 1, space: 2, children: [
|
|
1653
|
-
/* @__PURE__ */ jsxs(Text, { size: 1, weight: "medium", children: [
|
|
1575
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { flex: 1, space: 2, children: [
|
|
1576
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "medium", children: [
|
|
1654
1577
|
taskType ? taskType.title : "Running",
|
|
1655
|
-
task.title && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1578
|
+
task.title && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1656
1579
|
": ",
|
|
1657
1580
|
task.title
|
|
1658
1581
|
] })
|
|
1659
1582
|
] }),
|
|
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 }) })
|
|
1583
|
+
task.message ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: task.message }) : null,
|
|
1584
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(TimeAgo, { date: task.ended ?? task.started }) })
|
|
1662
1585
|
] })
|
|
1663
1586
|
] }),
|
|
1664
|
-
!task.ended && /* @__PURE__ */ jsx(Box, { flex: "none", padding: 1, children: /* @__PURE__ */ jsx(Button, { fontSize: 1, mode: "bleed", onClick: task.cancel, text: "Cancel" }) })
|
|
1587
|
+
!task.ended && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", padding: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { fontSize: 1, mode: "bleed", onClick: task.cancel, text: "Cancel" }) })
|
|
1665
1588
|
] }) });
|
|
1666
1589
|
}
|
|
1667
|
-
const
|
|
1590
|
+
const inspectorOnboardingKey = "sanityStudio:assist:inspector:onboarding:dismissed";
|
|
1591
|
+
function isFeatureOnboardingDismissed(featureKey) {
|
|
1592
|
+
return typeof localStorage > "u" ? !1 : localStorage.getItem(featureKey) === "true";
|
|
1593
|
+
}
|
|
1594
|
+
function dismissFeatureOnboarding(featureKey) {
|
|
1595
|
+
typeof localStorage > "u" || localStorage.setItem(featureKey, "true");
|
|
1596
|
+
}
|
|
1597
|
+
function useOnboardingFeature(featureKey) {
|
|
1598
|
+
const [showOnboarding, setShowOnboarding] = react.useState(
|
|
1599
|
+
() => !isFeatureOnboardingDismissed(featureKey)
|
|
1600
|
+
), dismissOnboarding = react.useCallback(() => {
|
|
1601
|
+
setShowOnboarding(!1), dismissFeatureOnboarding(featureKey);
|
|
1602
|
+
}, [setShowOnboarding, featureKey]);
|
|
1603
|
+
return { showOnboarding, dismissOnboarding };
|
|
1604
|
+
}
|
|
1605
|
+
const CardWithShadowBelow = styledComponents.styled(ui.Card)`
|
|
1668
1606
|
position: relative;
|
|
1669
1607
|
|
|
1670
1608
|
&:after {
|
|
@@ -1678,7 +1616,7 @@ const CardWithShadowBelow = styled(Card)`
|
|
|
1678
1616
|
opacity: 0.5;
|
|
1679
1617
|
z-index: 100;
|
|
1680
1618
|
}
|
|
1681
|
-
`, CardWithShadowAbove = styled(Card)`
|
|
1619
|
+
`, CardWithShadowAbove = styledComponents.styled(ui.Card)`
|
|
1682
1620
|
position: relative;
|
|
1683
1621
|
|
|
1684
1622
|
&:after {
|
|
@@ -1696,48 +1634,48 @@ const CardWithShadowBelow = styled(Card)`
|
|
|
1696
1634
|
function AssistInspectorWrapper(props) {
|
|
1697
1635
|
const context = useAiAssistanceConfig();
|
|
1698
1636
|
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: [
|
|
1637
|
+
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: [
|
|
1638
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { muted: !0 }),
|
|
1639
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, size: 1, children: [
|
|
1702
1640
|
"Loading ",
|
|
1703
1641
|
pluginTitle,
|
|
1704
1642
|
"..."
|
|
1705
1643
|
] })
|
|
1706
1644
|
] }) });
|
|
1707
1645
|
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,
|
|
1646
|
+
return status?.enabled ? !status?.initialized || !status.validToken ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", height: "fill", children: [
|
|
1647
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1648
|
+
structure.DocumentInspectorHeader,
|
|
1711
1649
|
{
|
|
1712
1650
|
closeButtonLabel: "Close",
|
|
1713
1651
|
onClose: props.onClose,
|
|
1714
1652
|
title: pluginTitle
|
|
1715
1653
|
}
|
|
1716
1654
|
),
|
|
1717
|
-
/* @__PURE__ */ jsxs(Stack, { padding: 4, space: 3, children: [
|
|
1718
|
-
context.error ? /* @__PURE__ */ jsxs(Text, { size: 1, weight: "semibold", children: [
|
|
1655
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { padding: 4, space: 3, children: [
|
|
1656
|
+
context.error ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "semibold", children: [
|
|
1719
1657
|
"Failed to start ",
|
|
1720
1658
|
pluginTitle
|
|
1721
1659
|
] }) : null,
|
|
1722
|
-
!context.error && !status?.initialized ? /* @__PURE__ */ jsxs(Text, { size: 1, weight: "semibold", children: [
|
|
1660
|
+
!context.error && !status?.initialized ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, weight: "semibold", children: [
|
|
1723
1661
|
pluginTitle,
|
|
1724
1662
|
" is not enabled"
|
|
1725
1663
|
] }) : 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." })
|
|
1664
|
+
!context.error && status?.initialized && !status.validToken ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1665
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: "Invalid token" }),
|
|
1666
|
+
/* @__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
1667
|
] }) : 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: [
|
|
1668
|
+
context.error && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "Something went wrong. See console for details." }),
|
|
1669
|
+
!context.error && !status?.initialized && /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { size: 1, muted: !0, children: [
|
|
1732
1670
|
"Please enable ",
|
|
1733
1671
|
pluginTitle,
|
|
1734
1672
|
"."
|
|
1735
1673
|
] }),
|
|
1736
|
-
/* @__PURE__ */ jsx(
|
|
1737
|
-
Button,
|
|
1674
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1675
|
+
ui.Button,
|
|
1738
1676
|
{
|
|
1739
1677
|
fontSize: 1,
|
|
1740
|
-
icon: context.initLoading ? /* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Spinner, {}) }) : context.error ? RetryIcon : void 0,
|
|
1678
|
+
icon: context.initLoading ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }) : context.error ? icons.RetryIcon : void 0,
|
|
1741
1679
|
text: context.error ? "Retry" : status?.initialized && !status.validToken ? `Restore ${pluginTitle}` : `Enable ${pluginTitle} now`,
|
|
1742
1680
|
tone: "primary",
|
|
1743
1681
|
onClick: context.init,
|
|
@@ -1745,59 +1683,59 @@ function AssistInspectorWrapper(props) {
|
|
|
1745
1683
|
}
|
|
1746
1684
|
)
|
|
1747
1685
|
] })
|
|
1748
|
-
] }) : /* @__PURE__ */ jsx(AssistInspector, { ...props }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", height: "fill", children: [
|
|
1749
|
-
/* @__PURE__ */ jsx(
|
|
1750
|
-
DocumentInspectorHeader,
|
|
1686
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(AssistInspector, { ...props }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", height: "fill", children: [
|
|
1687
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1688
|
+
structure.DocumentInspectorHeader,
|
|
1751
1689
|
{
|
|
1752
1690
|
closeButtonLabel: "Close",
|
|
1753
1691
|
onClose: props.onClose,
|
|
1754
1692
|
title: pluginTitle
|
|
1755
1693
|
}
|
|
1756
1694
|
),
|
|
1757
|
-
/* @__PURE__ */ jsxs(Stack, { flex: 1, overflow: "auto", padding: 4, space: 3, children: [
|
|
1758
|
-
/* @__PURE__ */ jsxs(Text, { as: "p", size: 1, weight: "semibold", children: [
|
|
1695
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { flex: 1, overflow: "auto", padding: 4, space: 3, children: [
|
|
1696
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "p", size: 1, weight: "semibold", children: [
|
|
1759
1697
|
pluginTitle,
|
|
1760
1698
|
" is not available"
|
|
1761
1699
|
] }),
|
|
1762
|
-
/* @__PURE__ */ jsxs(Text, { as: "p", muted: !0, size: 1, children: [
|
|
1700
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { as: "p", muted: !0, size: 1, children: [
|
|
1763
1701
|
"Please get in touch with a Sanity account manager or",
|
|
1764
1702
|
" ",
|
|
1765
|
-
/* @__PURE__ */ jsx("a", { href: salesUrl, target: "_blank", rel: "noreferrer", children: "contact our sales team" }),
|
|
1703
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: salesUrl, target: "_blank", rel: "noreferrer", children: "contact our sales team" }),
|
|
1766
1704
|
" ",
|
|
1767
1705
|
"to get started with ",
|
|
1768
1706
|
pluginTitle,
|
|
1769
1707
|
".",
|
|
1770
1708
|
" ",
|
|
1771
|
-
/* @__PURE__ */ jsx("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: "Learn more \u2192" })
|
|
1709
|
+
/* @__PURE__ */ jsxRuntime.jsx("a", { href: releaseAnnouncementUrl, target: "_blank", rel: "noreferrer", children: "Learn more \u2192" })
|
|
1772
1710
|
] })
|
|
1773
1711
|
] })
|
|
1774
1712
|
] });
|
|
1775
1713
|
}
|
|
1776
1714
|
function AssistInspector(props) {
|
|
1777
|
-
const { params } = useAiPaneRouter(), boundary = useRef(null), pathKey = params?.[fieldPathParam], instructionKey = params?.[instructionParam], documentPane = useDocumentPane(), {
|
|
1715
|
+
const { params } = useAiPaneRouter(), boundary = react.useRef(null), pathKey = params?.[fieldPathParam], instructionKey = params?.[instructionParam], documentPane = structure.useDocumentPane(), {
|
|
1778
1716
|
documentId,
|
|
1779
1717
|
documentType,
|
|
1780
1718
|
value: docValue,
|
|
1781
1719
|
schemaType,
|
|
1782
1720
|
onChange: documentOnChange,
|
|
1783
1721
|
formState
|
|
1784
|
-
} = documentPane, { assistableDocumentId, documentIsAssistable } = useAssistDocumentContext(), formStateRef = useRef(formState);
|
|
1722
|
+
} = documentPane, { assistableDocumentId, documentIsAssistable } = useAssistDocumentContext(), formStateRef = react.useRef(formState);
|
|
1785
1723
|
formStateRef.current = formState;
|
|
1786
1724
|
const { instructionLoading, requestRunInstruction } = useRequestRunInstruction({
|
|
1787
1725
|
documentOnChange,
|
|
1788
1726
|
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(
|
|
1727
|
+
}), 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
1728
|
() => assistDocument?.tasks?.filter((i) => !instructionKey || i.instructionKey === instructionKey),
|
|
1791
1729
|
[assistDocument?.tasks, instructionKey]
|
|
1792
|
-
), instructions = useMemo(
|
|
1730
|
+
), instructions = react.useMemo(
|
|
1793
1731
|
() => assistDocument?.fields?.flatMap((f) => f.instructions ?? []),
|
|
1794
1732
|
[assistDocument?.fields]
|
|
1795
|
-
), promptValue = instruction2?.prompt, isEmptyPrompt = useMemo(() => {
|
|
1733
|
+
), promptValue = instruction2?.prompt, isEmptyPrompt = react.useMemo(() => {
|
|
1796
1734
|
if (!promptValue?.length)
|
|
1797
1735
|
return !0;
|
|
1798
1736
|
const children = promptValue[0]?.children;
|
|
1799
1737
|
return promptValue.length == 1 && children?.length === 1 && !children?.[0]?.text?.length;
|
|
1800
|
-
}, [promptValue]), paneNode = useMemo(
|
|
1738
|
+
}, [promptValue]), paneNode = react.useMemo(
|
|
1801
1739
|
() => ({
|
|
1802
1740
|
type: "document",
|
|
1803
1741
|
id: aiDocId,
|
|
@@ -1808,7 +1746,7 @@ function AssistInspector(props) {
|
|
|
1808
1746
|
}
|
|
1809
1747
|
}),
|
|
1810
1748
|
[aiDocId]
|
|
1811
|
-
), runCurrentInstruction = useCallback(
|
|
1749
|
+
), runCurrentInstruction = react.useCallback(
|
|
1812
1750
|
() => instruction2 && pathKey && typePath && requestRunInstruction({
|
|
1813
1751
|
documentId: assistableDocumentId,
|
|
1814
1752
|
path: pathKey,
|
|
@@ -1818,9 +1756,9 @@ function AssistInspector(props) {
|
|
|
1818
1756
|
conditionalMembers: formStateRef.current ? getConditionalMembers(formStateRef.current) : []
|
|
1819
1757
|
}),
|
|
1820
1758
|
[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,
|
|
1759
|
+
), Region = react.useCallback((_props) => /* @__PURE__ */ jsxRuntime.jsx("div", { ..._props, style: { height: "100%", flex: 1, overflow: "auto" } }), []), assistTypeContext = react.useMemo(() => ({ typePath, documentType }), [typePath, documentType]);
|
|
1760
|
+
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(
|
|
1761
|
+
ui.Flex,
|
|
1824
1762
|
{
|
|
1825
1763
|
ref: boundary,
|
|
1826
1764
|
direction: "column",
|
|
@@ -1829,7 +1767,7 @@ function AssistInspector(props) {
|
|
|
1829
1767
|
sizing: "border",
|
|
1830
1768
|
style: { lineHeight: 0 },
|
|
1831
1769
|
children: [
|
|
1832
|
-
/* @__PURE__ */ jsx(
|
|
1770
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1833
1771
|
AiInspectorHeader,
|
|
1834
1772
|
{
|
|
1835
1773
|
onClose: props.onClose,
|
|
@@ -1837,14 +1775,14 @@ function AssistInspector(props) {
|
|
|
1837
1775
|
fieldTitle: getFieldTitle(selectedField)
|
|
1838
1776
|
}
|
|
1839
1777
|
),
|
|
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,
|
|
1778
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { as: Region, flex: 1, overflow: "auto", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { direction: "column", style: { minHeight: "100%" }, children: [
|
|
1779
|
+
/* @__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(
|
|
1780
|
+
sanity.VirtualizerScrollInstanceProvider,
|
|
1843
1781
|
{
|
|
1844
1782
|
scrollElement: boundary.current,
|
|
1845
1783
|
containerElement: boundary,
|
|
1846
|
-
children: /* @__PURE__ */ jsx(
|
|
1847
|
-
DocumentPaneProvider,
|
|
1784
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1785
|
+
structure.DocumentPaneProvider,
|
|
1848
1786
|
{
|
|
1849
1787
|
paneKey: documentPane.paneKey,
|
|
1850
1788
|
index: documentPane.index,
|
|
@@ -1855,15 +1793,15 @@ function AssistInspector(props) {
|
|
|
1855
1793
|
selectedPerspectiveName: "published",
|
|
1856
1794
|
selectedReleaseId: void 0
|
|
1857
1795
|
},
|
|
1858
|
-
children: /* @__PURE__ */ jsx(DocumentForm, {})
|
|
1796
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DocumentForm, {})
|
|
1859
1797
|
}
|
|
1860
1798
|
)
|
|
1861
1799
|
}
|
|
1862
1800
|
) }) }) }) }),
|
|
1863
|
-
/* @__PURE__ */ jsx(Box, { flex: "none", padding: 4, children: /* @__PURE__ */ jsxs(Text, { muted: !0, size: 1, children: [
|
|
1801
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", padding: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Text, { muted: !0, size: 1, children: [
|
|
1864
1802
|
"How is Sanity AI Assist working for you?",
|
|
1865
1803
|
" ",
|
|
1866
|
-
/* @__PURE__ */ jsxs(
|
|
1804
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1867
1805
|
"a",
|
|
1868
1806
|
{
|
|
1869
1807
|
href: giveFeedbackUrl,
|
|
@@ -1872,26 +1810,26 @@ function AssistInspector(props) {
|
|
|
1872
1810
|
style: { whiteSpace: "nowrap" },
|
|
1873
1811
|
children: [
|
|
1874
1812
|
"Let us know ",
|
|
1875
|
-
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
1813
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRightIcon, {})
|
|
1876
1814
|
]
|
|
1877
1815
|
}
|
|
1878
1816
|
)
|
|
1879
1817
|
] }) })
|
|
1880
1818
|
] }) }),
|
|
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,
|
|
1819
|
+
/* @__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: [
|
|
1820
|
+
schemaType?.name && pathKey && instructionKey && /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { flex: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1821
|
+
ui.Button,
|
|
1884
1822
|
{
|
|
1885
1823
|
mode: "ghost",
|
|
1886
1824
|
disabled: isEmptyPrompt || instructionLoading,
|
|
1887
1825
|
fontSize: 1,
|
|
1888
|
-
icon: instructionLoading ? /* @__PURE__ */ jsx(Spinner, { style: { marginTop: 3 } }) : PlayIcon,
|
|
1826
|
+
icon: instructionLoading ? /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { marginTop: 3 } }) : icons.PlayIcon,
|
|
1889
1827
|
onClick: runCurrentInstruction,
|
|
1890
1828
|
padding: 3,
|
|
1891
1829
|
text: "Run instruction"
|
|
1892
1830
|
}
|
|
1893
1831
|
) }),
|
|
1894
|
-
/* @__PURE__ */ jsx(
|
|
1832
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1895
1833
|
InstructionTaskHistoryButton,
|
|
1896
1834
|
{
|
|
1897
1835
|
documentId: assistableDocumentId,
|
|
@@ -1907,21 +1845,21 @@ function AssistInspector(props) {
|
|
|
1907
1845
|
}
|
|
1908
1846
|
function AiInspectorHeader(props) {
|
|
1909
1847
|
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 }) })
|
|
1848
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(CardWithShadowBelow, { flex: "none", padding: 2, children: [
|
|
1849
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { flex: 1, align: "center", children: [
|
|
1850
|
+
/* @__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: [
|
|
1851
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginTop: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, weight: "semibold", children: "AI instructions for" }) }),
|
|
1852
|
+
/* @__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
1853
|
] }) }),
|
|
1916
|
-
/* @__PURE__ */ jsx(Box, { flex: "none", children: /* @__PURE__ */ jsx(Button, { fontSize: 1, icon: CloseIcon, mode: "bleed", onClick: onClose }) })
|
|
1854
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { fontSize: 1, icon: icons.CloseIcon, mode: "bleed", onClick: onClose }) })
|
|
1917
1855
|
] }),
|
|
1918
|
-
showOnboarding && /* @__PURE__ */ jsx(InspectorOnboarding, { onDismiss: dismissOnboarding })
|
|
1856
|
+
showOnboarding && /* @__PURE__ */ jsxRuntime.jsx(InspectorOnboarding, { onDismiss: dismissOnboarding })
|
|
1919
1857
|
] });
|
|
1920
1858
|
}
|
|
1921
1859
|
const aiInspectorId = "ai-assistance", assistInspector = {
|
|
1922
1860
|
name: aiInspectorId,
|
|
1923
1861
|
useMenuItem: () => ({
|
|
1924
|
-
icon: SparklesIcon,
|
|
1862
|
+
icon: icons.SparklesIcon,
|
|
1925
1863
|
title: pluginTitle,
|
|
1926
1864
|
hidden: !0,
|
|
1927
1865
|
showAsAction: !1
|
|
@@ -1929,7 +1867,7 @@ const aiInspectorId = "ai-assistance", assistInspector = {
|
|
|
1929
1867
|
component: AssistInspectorWrapper,
|
|
1930
1868
|
onClose({ params }) {
|
|
1931
1869
|
return {
|
|
1932
|
-
params: typed({
|
|
1870
|
+
params: sanity.typed({
|
|
1933
1871
|
...params,
|
|
1934
1872
|
[fieldPathParam]: void 0,
|
|
1935
1873
|
[instructionParam]: void 0
|
|
@@ -2021,9 +1959,9 @@ function drawConnectorPath(options2, line) {
|
|
|
2021
1959
|
), join(cmds);
|
|
2022
1960
|
}
|
|
2023
1961
|
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(
|
|
1962
|
+
const { from, options: options2, to } = props, { strokeWidth } = options2.path, theme = ui.useTheme(), line = react.useMemo(() => mapConnectorToLine(options2, { from, to }), [from, options2, to]);
|
|
1963
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1964
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2027
1965
|
"path",
|
|
2028
1966
|
{
|
|
2029
1967
|
d: drawConnectorPath(options2, line),
|
|
@@ -2031,15 +1969,15 @@ function ConnectorPath(props) {
|
|
|
2031
1969
|
strokeWidth: strokeWidth + 4
|
|
2032
1970
|
}
|
|
2033
1971
|
),
|
|
2034
|
-
/* @__PURE__ */ jsx(
|
|
1972
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2035
1973
|
"path",
|
|
2036
1974
|
{
|
|
2037
1975
|
d: drawConnectorPath(options2, line),
|
|
2038
|
-
stroke: rgba(theme.sanity.color.base.border, 0.5),
|
|
1976
|
+
stroke: ui.rgba(theme.sanity.color.base.border, 0.5),
|
|
2039
1977
|
strokeWidth
|
|
2040
1978
|
}
|
|
2041
1979
|
),
|
|
2042
|
-
line.from.isAbove && /* @__PURE__ */ jsx(
|
|
1980
|
+
line.from.isAbove && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2043
1981
|
"path",
|
|
2044
1982
|
{
|
|
2045
1983
|
d: arrowPath(
|
|
@@ -2052,7 +1990,7 @@ function ConnectorPath(props) {
|
|
|
2052
1990
|
strokeWidth
|
|
2053
1991
|
}
|
|
2054
1992
|
),
|
|
2055
|
-
line.from.isBelow && /* @__PURE__ */ jsx(
|
|
1993
|
+
line.from.isBelow && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2056
1994
|
"path",
|
|
2057
1995
|
{
|
|
2058
1996
|
d: arrowPath(
|
|
@@ -2084,11 +2022,11 @@ const DEBUG = !1, options = {
|
|
|
2084
2022
|
}
|
|
2085
2023
|
};
|
|
2086
2024
|
function AssistConnectorsOverlay(props) {
|
|
2087
|
-
const { connectors } = props, [, setRedraw] = useState(!1);
|
|
2088
|
-
return useEffect(() => {
|
|
2025
|
+
const { connectors } = props, [, setRedraw] = react.useState(!1);
|
|
2026
|
+
return react.useEffect(() => {
|
|
2089
2027
|
setRedraw(!0);
|
|
2090
|
-
}, []), /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2091
|
-
/* @__PURE__ */ jsx(
|
|
2028
|
+
}, []), /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2029
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2092
2030
|
"svg",
|
|
2093
2031
|
{
|
|
2094
2032
|
fill: "none",
|
|
@@ -2104,7 +2042,7 @@ function AssistConnectorsOverlay(props) {
|
|
|
2104
2042
|
zIndex: 150
|
|
2105
2043
|
// zIndex,
|
|
2106
2044
|
},
|
|
2107
|
-
children: connectors.map((connector) => /* @__PURE__ */ jsx(
|
|
2045
|
+
children: connectors.map((connector) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2108
2046
|
ConnectorPath,
|
|
2109
2047
|
{
|
|
2110
2048
|
from: connector.from,
|
|
@@ -2138,7 +2076,7 @@ const getLanguageParams = (select, document2) => {
|
|
|
2138
2076
|
return {};
|
|
2139
2077
|
const selection = select || {}, selectedValue = {};
|
|
2140
2078
|
for (const [key, path] of Object.entries(selection)) {
|
|
2141
|
-
let value =
|
|
2079
|
+
let value = get__default.default(document2, path);
|
|
2142
2080
|
Array.isArray(value) && (value = value.filter(
|
|
2143
2081
|
(item) => typeof item == "object" ? item?._type !== "reference" || "_ref" in item : !0
|
|
2144
2082
|
)), selectedValue[key] = value;
|
|
@@ -2156,11 +2094,11 @@ function setPreferredToFieldLanguages(fromLanguageId, languageIds) {
|
|
|
2156
2094
|
}
|
|
2157
2095
|
const DEFAULT_MAX_DEPTH = 6, ABSOLUTE_MAX_DEPTH = 50;
|
|
2158
2096
|
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"), []);
|
|
2097
|
+
return sanity.isDocumentSchemaType(schemaType) ? extractPaths(doc, schemaType, [], Math.min(maxDepth2, ABSOLUTE_MAX_DEPTH)) : (console.error("Schema type is not a document"), []);
|
|
2160
2098
|
}
|
|
2161
2099
|
function extractPaths(doc, schemaType, path, maxDepth2) {
|
|
2162
2100
|
return path.length >= maxDepth2 ? [] : schemaType.fields.reduce((acc, field) => {
|
|
2163
|
-
const fieldPath = [...path, field.name], fieldSchema = field.type, { value } = extractWithPath(pathToString(fieldPath), doc)[0] ?? {};
|
|
2101
|
+
const fieldPath = [...path, field.name], fieldSchema = field.type, { value } = mutator.extractWithPath(sanity.pathToString(fieldPath), doc)[0] ?? {};
|
|
2164
2102
|
if (!value)
|
|
2165
2103
|
return acc;
|
|
2166
2104
|
const thisFieldWithPath = {
|
|
@@ -2174,7 +2112,7 @@ function extractPaths(doc, schemaType, path, maxDepth2) {
|
|
|
2174
2112
|
return [...acc, thisFieldWithPath, ...innerFields];
|
|
2175
2113
|
} 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
2114
|
path.length + 1 < maxDepth2) {
|
|
2177
|
-
const { value: arrayValue } = extractWithPath(pathToString(fieldPath), doc)[0] ?? {};
|
|
2115
|
+
const { value: arrayValue } = mutator.extractWithPath(sanity.pathToString(fieldPath), doc)[0] ?? {};
|
|
2178
2116
|
let arrayPaths = [];
|
|
2179
2117
|
if (arrayValue?.length)
|
|
2180
2118
|
for (const item of arrayValue) {
|
|
@@ -2210,7 +2148,7 @@ function extractPaths(doc, schemaType, path, maxDepth2) {
|
|
|
2210
2148
|
const defaultLanguageOutputs = function(member, enclosingType, translateFromLanguageId, translateToLanguageIds) {
|
|
2211
2149
|
if (member.schemaType.jsonType === "object" && member.schemaType.name.startsWith("internationalizedArray")) {
|
|
2212
2150
|
const pathEnd = member.path.slice(-1);
|
|
2213
|
-
return (isKeySegment(pathEnd[0]) ? pathEnd[0]._key : null) === translateFromLanguageId ? translateToLanguageIds.map((translateToId) => ({
|
|
2151
|
+
return (sanity.isKeySegment(pathEnd[0]) ? pathEnd[0]._key : null) === translateFromLanguageId ? translateToLanguageIds.map((translateToId) => ({
|
|
2214
2152
|
id: translateToId,
|
|
2215
2153
|
outputPath: [...member.path.slice(0, -1), { _key: translateToId }]
|
|
2216
2154
|
})) : void 0;
|
|
@@ -2224,7 +2162,7 @@ const defaultLanguageOutputs = function(member, enclosingType, translateFromLang
|
|
|
2224
2162
|
function getFieldLanguageMap(documentSchema, documentMembers, translateFromLanguageId, outputLanguageIds, langFn) {
|
|
2225
2163
|
const translationMaps = [];
|
|
2226
2164
|
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(
|
|
2165
|
+
const parentPath = member.path.slice(0, -1), enclosingType = documentMembers.find((m) => sanity.pathToString(m.path) === sanity.pathToString(parentPath))?.schemaType ?? documentSchema, translations = langFn(
|
|
2228
2166
|
member,
|
|
2229
2167
|
enclosingType,
|
|
2230
2168
|
translateFromLanguageId,
|
|
@@ -2238,25 +2176,25 @@ function getFieldLanguageMap(documentSchema, documentMembers, translateFromLangu
|
|
|
2238
2176
|
}
|
|
2239
2177
|
return translationMaps;
|
|
2240
2178
|
}
|
|
2241
|
-
const FieldTranslationContext = createContext({
|
|
2179
|
+
const FieldTranslationContext = react.createContext({
|
|
2242
2180
|
openFieldTranslation: () => {
|
|
2243
2181
|
},
|
|
2244
2182
|
translationLoading: !1
|
|
2245
2183
|
});
|
|
2246
2184
|
function useFieldTranslation() {
|
|
2247
|
-
return useContext(FieldTranslationContext);
|
|
2185
|
+
return react.useContext(FieldTranslationContext);
|
|
2248
2186
|
}
|
|
2249
2187
|
function hasValuesToTranslate(fieldLanguageMaps, fromLanguage, basePath2) {
|
|
2250
2188
|
return fieldLanguageMaps?.some(
|
|
2251
|
-
(map) => map.inputLanguageId === fromLanguage?.id && map.inputPath && pathToString(map.inputPath).startsWith(pathToString(basePath2))
|
|
2189
|
+
(map) => map.inputLanguageId === fromLanguage?.id && map.inputPath && sanity.pathToString(map.inputPath).startsWith(sanity.pathToString(basePath2))
|
|
2252
2190
|
);
|
|
2253
2191
|
}
|
|
2254
2192
|
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(() => {
|
|
2193
|
+
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
2194
|
setDialogOpen(!1), setLanguages(void 0), setFieldTranslationParams(void 0);
|
|
2257
|
-
}, []), languageClient = useClient({
|
|
2195
|
+
}, []), languageClient = sanity.useClient({
|
|
2258
2196
|
apiVersion: config?.apiVersion ?? API_VERSION_WITH_EXTENDED_TYPES
|
|
2259
|
-
}), documentId = fieldTranslationParams?.document?._id, id = useId(), selectFromLanguage = useCallback(
|
|
2197
|
+
}), documentId = fieldTranslationParams?.document?._id, id = react.useId(), selectFromLanguage = react.useCallback(
|
|
2260
2198
|
(from, languages2, params) => {
|
|
2261
2199
|
const { document: document2, documentSchema } = params ?? {};
|
|
2262
2200
|
if (setFromLanguage(from), !document2 || !documentSchema || !params || !languages2) {
|
|
@@ -2281,7 +2219,7 @@ function FieldTranslationProvider(props) {
|
|
|
2281
2219
|
setFieldLanguageMaps(void 0);
|
|
2282
2220
|
},
|
|
2283
2221
|
[config]
|
|
2284
|
-
), toggleToLanguage = useCallback(
|
|
2222
|
+
), toggleToLanguage = react.useCallback(
|
|
2285
2223
|
(toggledLang, toLanguages2, languages2) => {
|
|
2286
2224
|
if (!languages2 || !fromLanguage)
|
|
2287
2225
|
return;
|
|
@@ -2296,7 +2234,7 @@ function FieldTranslationProvider(props) {
|
|
|
2296
2234
|
);
|
|
2297
2235
|
},
|
|
2298
2236
|
[fromLanguage]
|
|
2299
|
-
), openFieldTranslation = useCallback(
|
|
2237
|
+
), openFieldTranslation = react.useCallback(
|
|
2300
2238
|
async (params) => {
|
|
2301
2239
|
setDialogOpen(!0);
|
|
2302
2240
|
const languageParams = getLanguageParams(config?.selectLanguageParams, params.document), languages2 = await (typeof config?.languages == "function" ? config?.languages(languageClient, languageParams) : Promise.resolve(config?.languages));
|
|
@@ -2305,10 +2243,10 @@ function FieldTranslationProvider(props) {
|
|
|
2305
2243
|
fromLanguage2 ? selectFromLanguage(fromLanguage2, languages2, params) : console.error("No languages available for selected language params", languageParams);
|
|
2306
2244
|
},
|
|
2307
2245
|
[selectFromLanguage, config, languageClient]
|
|
2308
|
-
), contextValue = useMemo(() => ({
|
|
2246
|
+
), contextValue = react.useMemo(() => ({
|
|
2309
2247
|
openFieldTranslation,
|
|
2310
2248
|
translationLoading: !1
|
|
2311
|
-
}), [openFieldTranslation]), runDisabled = !fromLanguage || !toLanguages?.length || !fieldLanguageMaps?.length || !documentId || !hasValuesToTranslate(fieldLanguageMaps, fromLanguage, fieldTranslationParams.translatePath), onRunTranslation = useCallback(() => {
|
|
2249
|
+
}), [openFieldTranslation]), runDisabled = !fromLanguage || !toLanguages?.length || !fieldLanguageMaps?.length || !documentId || !hasValuesToTranslate(fieldLanguageMaps, fromLanguage, fieldTranslationParams.translatePath), onRunTranslation = react.useCallback(() => {
|
|
2312
2250
|
const translatePath = fieldTranslationParams?.translatePath;
|
|
2313
2251
|
fieldLanguageMaps && documentId && translatePath && runTranslate({
|
|
2314
2252
|
documentId,
|
|
@@ -2337,38 +2275,38 @@ function FieldTranslationProvider(props) {
|
|
|
2337
2275
|
fieldTranslationParams?.conditionalMembers,
|
|
2338
2276
|
fieldTranslationParams?.documentSchema,
|
|
2339
2277
|
languageClient
|
|
2340
|
-
]), runButton = /* @__PURE__ */ jsx(
|
|
2341
|
-
Button,
|
|
2278
|
+
]), runButton = /* @__PURE__ */ jsxRuntime.jsx(
|
|
2279
|
+
ui.Button,
|
|
2342
2280
|
{
|
|
2343
2281
|
text: "Translate",
|
|
2344
2282
|
tone: "primary",
|
|
2345
|
-
icon: PlayIcon,
|
|
2283
|
+
icon: icons.PlayIcon,
|
|
2346
2284
|
style: { width: "100%" },
|
|
2347
2285
|
disabled: runDisabled,
|
|
2348
2286
|
onClick: onRunTranslation
|
|
2349
2287
|
}
|
|
2350
2288
|
);
|
|
2351
|
-
return /* @__PURE__ */ jsxs(FieldTranslationContext.Provider, { value: contextValue, children: [
|
|
2352
|
-
dialogOpen ? /* @__PURE__ */ jsx(
|
|
2353
|
-
Dialog,
|
|
2289
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(FieldTranslationContext.Provider, { value: contextValue, children: [
|
|
2290
|
+
dialogOpen ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2291
|
+
ui.Dialog,
|
|
2354
2292
|
{
|
|
2355
2293
|
id,
|
|
2356
2294
|
width: 1,
|
|
2357
2295
|
open: dialogOpen,
|
|
2358
2296
|
onClose: close,
|
|
2359
2297
|
header: "Translate fields",
|
|
2360
|
-
footer: /* @__PURE__ */ jsx(Flex, { justify: "space-between", padding: 2, flex: 1, children: runDisabled ? /* @__PURE__ */ jsx(
|
|
2361
|
-
Tooltip,
|
|
2298
|
+
footer: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { justify: "space-between", padding: 2, flex: 1, children: runDisabled ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2299
|
+
ui.Tooltip,
|
|
2362
2300
|
{
|
|
2363
|
-
content: /* @__PURE__ */ jsx(Flex, { padding: 2, children: /* @__PURE__ */ jsx(Text, { children: "There is nothing to translate in the selected from-language." }) }),
|
|
2301
|
+
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
2302
|
placement: "top",
|
|
2365
|
-
children: /* @__PURE__ */ jsx(Flex, { flex: 1, children: runButton })
|
|
2303
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { flex: 1, children: runButton })
|
|
2366
2304
|
}
|
|
2367
2305
|
) : 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(
|
|
2306
|
+
children: languages ? /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { padding: 4, gap: 5, align: "flex-start", justify: "center", children: [
|
|
2307
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
2308
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", children: "From" }) }),
|
|
2309
|
+
languages?.map((radioLanguage) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2372
2310
|
FromLanguageRadio,
|
|
2373
2311
|
{
|
|
2374
2312
|
radioLanguage,
|
|
@@ -2380,9 +2318,9 @@ function FieldTranslationProvider(props) {
|
|
|
2380
2318
|
radioLanguage.id
|
|
2381
2319
|
))
|
|
2382
2320
|
] }),
|
|
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(
|
|
2321
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
2322
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { marginBottom: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "semibold", children: "To" }) }),
|
|
2323
|
+
languages.map((checkboxLanguage) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2386
2324
|
ToLanguageCheckbox,
|
|
2387
2325
|
{
|
|
2388
2326
|
checkboxLanguage,
|
|
@@ -2394,9 +2332,9 @@ function FieldTranslationProvider(props) {
|
|
|
2394
2332
|
checkboxLanguage.id
|
|
2395
2333
|
))
|
|
2396
2334
|
] })
|
|
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..." })
|
|
2335
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { padding: 4, gap: 2, align: "flex-start", justify: "center", children: [
|
|
2336
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, {}) }),
|
|
2337
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading languages..." })
|
|
2400
2338
|
] })
|
|
2401
2339
|
}
|
|
2402
2340
|
) : null,
|
|
@@ -2404,20 +2342,20 @@ function FieldTranslationProvider(props) {
|
|
|
2404
2342
|
] });
|
|
2405
2343
|
}
|
|
2406
2344
|
function ToLanguageCheckbox(props) {
|
|
2407
|
-
const { checkboxLanguage, fromLanguage, toLanguages, toggleToLanguage, languages } = props, langId = checkboxLanguage.id, onChange = useCallback(
|
|
2345
|
+
const { checkboxLanguage, fromLanguage, toLanguages, toggleToLanguage, languages } = props, langId = checkboxLanguage.id, onChange = react.useCallback(
|
|
2408
2346
|
() => toggleToLanguage(checkboxLanguage, toLanguages, languages),
|
|
2409
2347
|
[toggleToLanguage, checkboxLanguage, toLanguages, languages]
|
|
2410
2348
|
);
|
|
2411
|
-
return /* @__PURE__ */ jsxs(
|
|
2412
|
-
Flex,
|
|
2349
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2350
|
+
ui.Flex,
|
|
2413
2351
|
{
|
|
2414
2352
|
gap: 3,
|
|
2415
2353
|
align: "center",
|
|
2416
2354
|
as: "label",
|
|
2417
2355
|
style: langId === fromLanguage?.id ? { opacity: 0.5 } : void 0,
|
|
2418
2356
|
children: [
|
|
2419
|
-
/* @__PURE__ */ jsx(
|
|
2420
|
-
Checkbox,
|
|
2357
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2358
|
+
ui.Checkbox,
|
|
2421
2359
|
{
|
|
2422
2360
|
name: "toLang",
|
|
2423
2361
|
value: langId,
|
|
@@ -2426,20 +2364,20 @@ function ToLanguageCheckbox(props) {
|
|
|
2426
2364
|
disabled: langId === fromLanguage?.id
|
|
2427
2365
|
}
|
|
2428
2366
|
),
|
|
2429
|
-
/* @__PURE__ */ jsx(Text, { muted: langId === fromLanguage?.id, children: checkboxLanguage.title ?? langId })
|
|
2367
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: langId === fromLanguage?.id, children: checkboxLanguage.title ?? langId })
|
|
2430
2368
|
]
|
|
2431
2369
|
},
|
|
2432
2370
|
langId
|
|
2433
2371
|
);
|
|
2434
2372
|
}
|
|
2435
2373
|
function FromLanguageRadio(props) {
|
|
2436
|
-
const { languages, radioLanguage, selectFromLanguage, fromLanguage, fieldTranslationParams } = props, langId = radioLanguage.id, onChange = useCallback(
|
|
2374
|
+
const { languages, radioLanguage, selectFromLanguage, fromLanguage, fieldTranslationParams } = props, langId = radioLanguage.id, onChange = react.useCallback(
|
|
2437
2375
|
() => selectFromLanguage(radioLanguage, languages, fieldTranslationParams),
|
|
2438
2376
|
[selectFromLanguage, radioLanguage, languages, fieldTranslationParams]
|
|
2439
2377
|
);
|
|
2440
|
-
return /* @__PURE__ */ jsxs(Flex, { gap: 3, align: "center", as: "label", children: [
|
|
2441
|
-
/* @__PURE__ */ jsx(
|
|
2442
|
-
Radio,
|
|
2378
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", as: "label", children: [
|
|
2379
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2380
|
+
ui.Radio,
|
|
2443
2381
|
{
|
|
2444
2382
|
name: "fromLang",
|
|
2445
2383
|
value: langId,
|
|
@@ -2447,7 +2385,7 @@ function FromLanguageRadio(props) {
|
|
|
2447
2385
|
onChange
|
|
2448
2386
|
}
|
|
2449
2387
|
),
|
|
2450
|
-
/* @__PURE__ */ jsx(Text, { children: radioLanguage.title ?? radioLanguage.id })
|
|
2388
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: radioLanguage.title ?? radioLanguage.id })
|
|
2451
2389
|
] }, langId);
|
|
2452
2390
|
}
|
|
2453
2391
|
const hiddenTypes = [
|
|
@@ -2547,7 +2485,7 @@ function serializeMember(schema, type, name, options2) {
|
|
|
2547
2485
|
}
|
|
2548
2486
|
function serializeInlineOf(blockSchemaType, schema, options2) {
|
|
2549
2487
|
const childrenType = blockSchemaType.fields.find((f) => f.name === "children")?.type;
|
|
2550
|
-
if (!(!childrenType || !isArraySchemaType(childrenType)))
|
|
2488
|
+
if (!(!childrenType || !sanity.isArraySchemaType(childrenType)))
|
|
2551
2489
|
return arrayOf(
|
|
2552
2490
|
{
|
|
2553
2491
|
of: childrenType.of.filter((t) => !isType(t, "span"))
|
|
@@ -2558,7 +2496,7 @@ function serializeInlineOf(blockSchemaType, schema, options2) {
|
|
|
2558
2496
|
}
|
|
2559
2497
|
function serializeAnnotations(blockSchemaType, schema, options2) {
|
|
2560
2498
|
const marksType = blockSchemaType.fields.find((f) => f.name === "markDefs")?.type;
|
|
2561
|
-
if (!(!marksType || !isArraySchemaType(marksType)))
|
|
2499
|
+
if (!(!marksType || !sanity.isArraySchemaType(marksType)))
|
|
2562
2500
|
return arrayOf(marksType, schema, options2);
|
|
2563
2501
|
}
|
|
2564
2502
|
function arrayOf(arrayType, schema, options2) {
|
|
@@ -2566,7 +2504,7 @@ function arrayOf(arrayType, schema, options2) {
|
|
|
2566
2504
|
}
|
|
2567
2505
|
function refToTypeNames(type) {
|
|
2568
2506
|
return type.to.map((t) => ({
|
|
2569
|
-
type: typed(t.name)
|
|
2507
|
+
type: sanity.typed(t.name)
|
|
2570
2508
|
}));
|
|
2571
2509
|
}
|
|
2572
2510
|
function removeUndef(obj) {
|
|
@@ -2586,13 +2524,13 @@ function createFieldRefCache() {
|
|
|
2586
2524
|
return getRefsForType;
|
|
2587
2525
|
}
|
|
2588
2526
|
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(() => {
|
|
2527
|
+
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);
|
|
2528
|
+
react.useEffect(() => {
|
|
2591
2529
|
getInstructStatus().then((s) => setStatus(s)).catch((e) => {
|
|
2592
2530
|
console.error(e), setError(e);
|
|
2593
2531
|
});
|
|
2594
2532
|
}, [getInstructStatus]);
|
|
2595
|
-
const init = useCallback(async () => {
|
|
2533
|
+
const init = react.useCallback(async () => {
|
|
2596
2534
|
setError(void 0);
|
|
2597
2535
|
try {
|
|
2598
2536
|
await initInstruct();
|
|
@@ -2601,7 +2539,7 @@ function AiAssistanceConfigProvider(props) {
|
|
|
2601
2539
|
} catch (e) {
|
|
2602
2540
|
console.error("Failed to init ai assistance", e), setError(e);
|
|
2603
2541
|
}
|
|
2604
|
-
}, [initInstruct, getInstructStatus, setStatus]), { config, children } = props, context = useMemo(() => ({
|
|
2542
|
+
}, [initInstruct, getInstructStatus, setStatus]), { config, children } = props, context = react.useMemo(() => ({
|
|
2605
2543
|
config,
|
|
2606
2544
|
status,
|
|
2607
2545
|
statusLoading,
|
|
@@ -2622,10 +2560,10 @@ function AiAssistanceConfigProvider(props) {
|
|
|
2622
2560
|
getFieldRefs2,
|
|
2623
2561
|
getFieldRefsByTypePath
|
|
2624
2562
|
]);
|
|
2625
|
-
return /* @__PURE__ */ jsx(AiAssistanceConfigContext.Provider, { value: context, children });
|
|
2563
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AiAssistanceConfigContext.Provider, { value: context, children });
|
|
2626
2564
|
}
|
|
2627
2565
|
function useFieldRefGetters(schema) {
|
|
2628
|
-
return useMemo(() => {
|
|
2566
|
+
return react.useMemo(() => {
|
|
2629
2567
|
const getForSchemaType = createFieldRefCache();
|
|
2630
2568
|
function getRefsForType(documentType) {
|
|
2631
2569
|
const schemaType = schema.get(documentType);
|
|
@@ -2640,23 +2578,23 @@ function useFieldRefGetters(schema) {
|
|
|
2640
2578
|
}, [schema]);
|
|
2641
2579
|
}
|
|
2642
2580
|
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: [
|
|
2581
|
+
const [connectors, setConnectors] = react.useState([]);
|
|
2582
|
+
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
2583
|
props.renderDefault(props),
|
|
2646
|
-
/* @__PURE__ */ jsx(ThemeProvider, { tone: "default", children: /* @__PURE__ */ jsx(AssistConnectorsOverlay, { connectors }) })
|
|
2584
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.ThemeProvider, { tone: "default", children: /* @__PURE__ */ jsxRuntime.jsx(AssistConnectorsOverlay, { connectors }) })
|
|
2647
2585
|
] }) }) }) });
|
|
2648
2586
|
}
|
|
2649
|
-
const ImageContext = createContext({});
|
|
2587
|
+
const ImageContext = react.createContext({});
|
|
2650
2588
|
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),
|
|
2589
|
+
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(
|
|
2590
|
+
sanity.getPublishedId(assistableDocumentId),
|
|
2653
2591
|
documentSchemaType.name,
|
|
2654
2592
|
selectedReleaseId
|
|
2655
|
-
), isShowingOlderRevision = !!usePaneRouter().params?.rev;
|
|
2656
|
-
useEffect(() => {
|
|
2593
|
+
), isShowingOlderRevision = !!structure.usePaneRouter().params?.rev;
|
|
2594
|
+
react.useEffect(() => {
|
|
2657
2595
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
2658
2596
|
assetRef && assistableDocumentId && descriptionField?.updateOnImageChange && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly && (setAssetRefState(assetRef), canUseAssist(status) && generateCaption({
|
|
2659
|
-
path: pathToString([...path, descriptionField.path]),
|
|
2597
|
+
path: sanity.pathToString([...path, descriptionField.path]),
|
|
2660
2598
|
documentId: assistableDocumentId
|
|
2661
2599
|
}));
|
|
2662
2600
|
}, [
|
|
@@ -2671,27 +2609,27 @@ function ImageContextProvider(props) {
|
|
|
2671
2609
|
readOnly,
|
|
2672
2610
|
isShowingOlderRevision
|
|
2673
2611
|
]);
|
|
2674
|
-
const context = useMemo(() => {
|
|
2612
|
+
const context = react.useMemo(() => {
|
|
2675
2613
|
const descriptionField = getDescriptionFieldOption(schemaType), imageInstructionField = getImageInstructionFieldOption(schemaType);
|
|
2676
2614
|
return {
|
|
2677
|
-
imageDescriptionPath: descriptionField?.path ? pathToString([...path, descriptionField.path]) : void 0,
|
|
2678
|
-
imageInstructionPath: imageInstructionField ? pathToString([...path, imageInstructionField]) : void 0,
|
|
2615
|
+
imageDescriptionPath: descriptionField?.path ? sanity.pathToString([...path, descriptionField.path]) : void 0,
|
|
2616
|
+
imageInstructionPath: imageInstructionField ? sanity.pathToString([...path, imageInstructionField]) : void 0,
|
|
2679
2617
|
assetRef
|
|
2680
2618
|
};
|
|
2681
2619
|
}, [schemaType, path, assetRef]);
|
|
2682
|
-
return /* @__PURE__ */ jsx(ImageContext.Provider, { value: context, children: props.renderDefault(props) });
|
|
2620
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ImageContext.Provider, { value: context, children: props.renderDefault(props) });
|
|
2683
2621
|
}
|
|
2684
2622
|
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)),
|
|
2623
|
+
const { value, onChange } = props, id = react.useId(), items = react.useMemo(
|
|
2624
|
+
() => Object.entries(icons.icons).map(([key, icon]) => /* @__PURE__ */ jsxRuntime.jsx(IconItem, { iconKey: key, icon, onChange }, key)),
|
|
2687
2625
|
[onChange]
|
|
2688
|
-
), selectedIcon = useMemo(() => getIcon(value), [value]);
|
|
2689
|
-
return /* @__PURE__ */ jsx(
|
|
2690
|
-
MenuButton,
|
|
2626
|
+
), selectedIcon = react.useMemo(() => getIcon(value), [value]);
|
|
2627
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2628
|
+
ui.MenuButton,
|
|
2691
2629
|
{
|
|
2692
|
-
button: /* @__PURE__ */ jsx(Button, { icon: selectedIcon, title: "Select icon", padding: 3, mode: "ghost", radius: 1 }),
|
|
2630
|
+
button: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { icon: selectedIcon, title: "Select icon", padding: 3, mode: "ghost", radius: 1 }),
|
|
2693
2631
|
id,
|
|
2694
|
-
menu: /* @__PURE__ */ jsx(Menu, { style: { maxHeight: 300 }, children: items }),
|
|
2632
|
+
menu: /* @__PURE__ */ jsxRuntime.jsx(ui.Menu, { style: { maxHeight: 300 }, children: items }),
|
|
2695
2633
|
popover: { portal: !0 }
|
|
2696
2634
|
}
|
|
2697
2635
|
);
|
|
@@ -2701,19 +2639,19 @@ function IconItem({
|
|
|
2701
2639
|
iconKey: key,
|
|
2702
2640
|
onChange
|
|
2703
2641
|
}) {
|
|
2704
|
-
const onClick = useCallback(() => onChange(set(key)), [onChange, key]);
|
|
2705
|
-
return /* @__PURE__ */ jsx(MenuItem, { icon, title: key, text: key, onClick });
|
|
2642
|
+
const onClick = react.useCallback(() => onChange(sanity.set(key)), [onChange, key]);
|
|
2643
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.MenuItem, { icon, title: key, text: key, onClick });
|
|
2706
2644
|
}
|
|
2707
2645
|
function getIcon(iconName) {
|
|
2708
|
-
return Object.entries(icons).find(([key]) => key === iconName)?.[1] ?? icons.sparkles;
|
|
2646
|
+
return Object.entries(icons.icons).find(([key]) => key === iconName)?.[1] ?? icons.icons.sparkles;
|
|
2709
2647
|
}
|
|
2710
2648
|
function useAssistSupported(path, schemaType) {
|
|
2711
|
-
return useMemo(() => isAssistSupported(schemaType), [schemaType]);
|
|
2649
|
+
return react.useMemo(() => isAssistSupported(schemaType), [schemaType]);
|
|
2712
2650
|
}
|
|
2713
2651
|
const translateActions = {
|
|
2714
2652
|
name: "sanity-assist-translate",
|
|
2715
2653
|
useAction(props) {
|
|
2716
|
-
const { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), client = useClient({ apiVersion: API_VERSION_WITH_EXTENDED_TYPES }), {
|
|
2654
|
+
const { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), client = sanity.useClient({ apiVersion: API_VERSION_WITH_EXTENDED_TYPES }), {
|
|
2717
2655
|
schemaType: fieldSchemaType,
|
|
2718
2656
|
path,
|
|
2719
2657
|
documentId,
|
|
@@ -2721,21 +2659,21 @@ const translateActions = {
|
|
|
2721
2659
|
documentIsAssistable
|
|
2722
2660
|
} = 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
2661
|
if (documentSchemaType && (documentTranslationEnabled || fieldTransEnabled)) {
|
|
2724
|
-
const { value: documentValue, onChange: documentOnChange, formState } = useDocumentPane(), docRef = useRef(documentValue);
|
|
2662
|
+
const { value: documentValue, onChange: documentOnChange, formState } = structure.useDocumentPane(), docRef = react.useRef(documentValue);
|
|
2725
2663
|
docRef.current = documentValue;
|
|
2726
|
-
const formStateRef = useRef(formState);
|
|
2664
|
+
const formStateRef = react.useRef(formState);
|
|
2727
2665
|
formStateRef.current = formState;
|
|
2728
2666
|
const translationApi = useTranslate(apiClient), translate = useDraftDelayedTask({
|
|
2729
2667
|
documentOnChange,
|
|
2730
2668
|
isDocAssistable: documentIsAssistable ?? !1,
|
|
2731
2669
|
task: translationApi.translate
|
|
2732
|
-
}), styleguide = config.translate?.styleguide, languagePath = config.translate?.document?.languageField, translateDocumentAction = useMemo(() => {
|
|
2670
|
+
}), styleguide = config.translate?.styleguide, languagePath = config.translate?.document?.languageField, translateDocumentAction = react.useMemo(() => {
|
|
2733
2671
|
if (!languagePath || !documentTranslationEnabled)
|
|
2734
2672
|
return;
|
|
2735
2673
|
const title = path.length ? "Translate" : "Translate document";
|
|
2736
2674
|
return {
|
|
2737
2675
|
type: "action",
|
|
2738
|
-
icon: translationApi.loading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : TranslateIcon,
|
|
2676
|
+
icon: translationApi.loading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.TranslateIcon,
|
|
2739
2677
|
title,
|
|
2740
2678
|
onAction: () => {
|
|
2741
2679
|
translationApi.loading || !languagePath || !documentId || translate({
|
|
@@ -2768,10 +2706,10 @@ const translateActions = {
|
|
|
2768
2706
|
documentOnChange,
|
|
2769
2707
|
isDocAssistable: documentIsAssistable ?? !1,
|
|
2770
2708
|
task: fieldTranslate.openFieldTranslation
|
|
2771
|
-
}), maxDepth2 = config.translate?.field?.maxPathDepth, translateFieldsAction = useMemo(
|
|
2709
|
+
}), maxDepth2 = config.translate?.field?.maxPathDepth, translateFieldsAction = react.useMemo(
|
|
2772
2710
|
() => fieldTransEnabled ? {
|
|
2773
2711
|
type: "action",
|
|
2774
|
-
icon: fieldTranslate.translationLoading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : TranslateIcon,
|
|
2712
|
+
icon: fieldTranslate.translationLoading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.TranslateIcon,
|
|
2775
2713
|
title: "Translate fields...",
|
|
2776
2714
|
onAction: () => {
|
|
2777
2715
|
fieldTranslate.translationLoading || !documentId || (formStateRef.current && getConditionalMembers(formStateRef.current), openFieldTranslation({
|
|
@@ -2798,7 +2736,7 @@ const translateActions = {
|
|
|
2798
2736
|
maxDepth2
|
|
2799
2737
|
]
|
|
2800
2738
|
);
|
|
2801
|
-
return useMemo(() => {
|
|
2739
|
+
return react.useMemo(() => {
|
|
2802
2740
|
if (status?.initialized)
|
|
2803
2741
|
return {
|
|
2804
2742
|
type: "group",
|
|
@@ -2815,12 +2753,12 @@ const translateActions = {
|
|
|
2815
2753
|
}, generateCaptionsActions = {
|
|
2816
2754
|
name: "sanity-assist-generate-captions",
|
|
2817
2755
|
useAction(props) {
|
|
2818
|
-
const pathKey = usePathKey(props.path), { openInspector } = useDocumentPane(), { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateCaption, loading } = useGenerateCaption(apiClient), imageContext = useContext(ImageContext);
|
|
2756
|
+
const pathKey = usePathKey(props.path), { openInspector } = structure.useDocumentPane(), { config, status } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateCaption, loading } = useGenerateCaption(apiClient), imageContext = react.useContext(ImageContext);
|
|
2819
2757
|
if (imageContext && pathKey === imageContext?.imageDescriptionPath) {
|
|
2820
2758
|
const { assistableDocumentId } = useAssistDocumentContext();
|
|
2821
|
-
return useMemo(() => ({
|
|
2759
|
+
return react.useMemo(() => ({
|
|
2822
2760
|
type: "action",
|
|
2823
|
-
icon: loading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : ImageIcon,
|
|
2761
|
+
icon: loading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.ImageIcon,
|
|
2824
2762
|
title: "Generate image description",
|
|
2825
2763
|
onAction: () => {
|
|
2826
2764
|
if (!loading) {
|
|
@@ -2851,12 +2789,12 @@ const translateActions = {
|
|
|
2851
2789
|
}, generateImagActions = {
|
|
2852
2790
|
name: "sanity-assist-generate-image",
|
|
2853
2791
|
useAction(props) {
|
|
2854
|
-
const pathKey = usePathKey(props.path), { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateImage, loading } = useGenerateImage(apiClient), imageContext = useContext(ImageContext);
|
|
2792
|
+
const pathKey = usePathKey(props.path), { config } = useAiAssistanceConfig(), apiClient = useApiClient(config?.__customApiClient), { generateImage, loading } = useGenerateImage(apiClient), imageContext = react.useContext(ImageContext);
|
|
2855
2793
|
if (imageContext && pathKey === imageContext?.imageInstructionPath) {
|
|
2856
2794
|
const { assistableDocumentId } = useAssistDocumentContext();
|
|
2857
|
-
return useMemo(() => ({
|
|
2795
|
+
return react.useMemo(() => ({
|
|
2858
2796
|
type: "action",
|
|
2859
|
-
icon: loading ? () => /* @__PURE__ */ jsx(Box, { style: { height: 17 }, children: /* @__PURE__ */ jsx(Spinner, { style: { transform: "translateY(6px)" } }) }) : ImageIcon,
|
|
2797
|
+
icon: loading ? () => /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { height: 17 }, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { transform: "translateY(6px)" } }) }) : icons.ImageIcon,
|
|
2860
2798
|
title: "Generate image from prompt",
|
|
2861
2799
|
onAction: () => {
|
|
2862
2800
|
loading || generateImage({ path: pathKey, documentId: assistableDocumentId });
|
|
@@ -2868,15 +2806,15 @@ const translateActions = {
|
|
|
2868
2806
|
}
|
|
2869
2807
|
};
|
|
2870
2808
|
function PrivateIcon() {
|
|
2871
|
-
return /* @__PURE__ */ jsx(
|
|
2872
|
-
Tooltip,
|
|
2809
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2810
|
+
ui.Tooltip,
|
|
2873
2811
|
{
|
|
2874
|
-
content: /* @__PURE__ */ jsx(Text, { size: 1, style: { whiteSpace: "nowrap" }, children: "Only visible to you" }),
|
|
2812
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, style: { whiteSpace: "nowrap" }, children: "Only visible to you" }),
|
|
2875
2813
|
fallbackPlacements: ["bottom"],
|
|
2876
2814
|
padding: 2,
|
|
2877
2815
|
placement: "top",
|
|
2878
2816
|
portal: !0,
|
|
2879
|
-
children: /* @__PURE__ */ jsx(LockIcon, {})
|
|
2817
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.LockIcon, {})
|
|
2880
2818
|
}
|
|
2881
2819
|
);
|
|
2882
2820
|
}
|
|
@@ -2925,12 +2863,12 @@ function defineAssistFieldActionGroup(group) {
|
|
|
2925
2863
|
function useCustomFieldActions(props) {
|
|
2926
2864
|
const {
|
|
2927
2865
|
config: { fieldActions }
|
|
2928
|
-
} = useAiAssistanceConfig(), { addSyntheticTask, removeSyntheticTask } = useAssistDocumentContext(), schemaId = useWorkspaceSchemaId(), { push: pushToast } = useToast(), configActions = fieldActions?.useFieldActions?.({
|
|
2866
|
+
} = useAiAssistanceConfig(), { addSyntheticTask, removeSyntheticTask } = useAssistDocumentContext(), schemaId = sanity.useWorkspaceSchemaId(), { push: pushToast } = ui.useToast(), configActions = fieldActions?.useFieldActions?.({
|
|
2929
2867
|
...props,
|
|
2930
2868
|
schemaId,
|
|
2931
2869
|
path: props.path
|
|
2932
2870
|
});
|
|
2933
|
-
return useMemo(() => {
|
|
2871
|
+
return react.useMemo(() => {
|
|
2934
2872
|
const title = fieldActions?.title, customActions = configActions?.filter(isDefined).map((node) => createSafeNode({
|
|
2935
2873
|
node,
|
|
2936
2874
|
pushToast,
|
|
@@ -3019,30 +2957,30 @@ const assistFieldActions = {
|
|
|
3019
2957
|
selectedPath,
|
|
3020
2958
|
assistableDocumentId,
|
|
3021
2959
|
fieldRefsByTypePath
|
|
3022
|
-
} = useAssistDocumentContext(), { value: docValue, formState } = useDocumentPane(), docValueRef = useRef(docValue), formStateRef = useRef(formState);
|
|
2960
|
+
} = useAssistDocumentContext(), { value: docValue, formState } = structure.useDocumentPane(), docValueRef = react.useRef(docValue), formStateRef = react.useRef(formState);
|
|
3023
2961
|
formStateRef.current = formState;
|
|
3024
|
-
const currentUser = useCurrentUser(), isHidden = !assistDocument, pathKey = usePathKey(props.path), typePath = useTypePath(docValue, pathKey), assistDocumentId2 = assistDocument?._id, { requestRunInstruction } = useRequestRunInstruction({
|
|
2962
|
+
const currentUser = sanity.useCurrentUser(), isHidden = !assistDocument, pathKey = usePathKey(props.path), typePath = useTypePath(docValue, pathKey), assistDocumentId2 = assistDocument?._id, { requestRunInstruction } = useRequestRunInstruction({
|
|
3025
2963
|
documentOnChange,
|
|
3026
2964
|
isDocAssistable: documentIsAssistable ?? !1
|
|
3027
|
-
}), isSelectable = !!useSelectedField(documentSchemaType, typePath), assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType) && schemaType.readOnly !== !0, fieldAssist = useMemo(
|
|
2965
|
+
}), isSelectable = !!useSelectedField(documentSchemaType, typePath), assistSupported = useAssistSupported(props.path, schemaType) && isSelectable && isSchemaAssistEnabled(documentSchemaType) && schemaType.readOnly !== !0, fieldAssist = react.useMemo(
|
|
3028
2966
|
() => (assistDocument?.fields ?? []).find(
|
|
3029
2967
|
(f) => f.path === typePath || pathKey === documentRootKey && f.path === pathKey
|
|
3030
2968
|
),
|
|
3031
2969
|
[assistDocument?.fields, pathKey, typePath]
|
|
3032
2970
|
), fieldAssistKey = fieldAssist?._key, isSelected = inspector?.name === aiInspectorId && pathKey === selectedPath, imageCaptionAction = generateCaptionsActions.useAction(props), imageGenAction = generateImagActions.useAction(props), translateAction = translateActions.useAction(
|
|
3033
|
-
typed({
|
|
2971
|
+
sanity.typed({
|
|
3034
2972
|
...props,
|
|
3035
2973
|
documentId: assistableDocumentId,
|
|
3036
2974
|
documentIsAssistable,
|
|
3037
2975
|
documentSchemaType
|
|
3038
2976
|
})
|
|
3039
|
-
), manageInstructions = useCallback(
|
|
2977
|
+
), manageInstructions = react.useCallback(
|
|
3040
2978
|
() => isSelected ? closeInspector(aiInspectorId) : openInspector(aiInspectorId, {
|
|
3041
2979
|
[fieldPathParam]: pathKey,
|
|
3042
2980
|
[instructionParam]: void 0
|
|
3043
2981
|
}),
|
|
3044
2982
|
[openInspector, closeInspector, isSelected, pathKey]
|
|
3045
|
-
), onInstructionAction = useCallback(
|
|
2983
|
+
), onInstructionAction = react.useCallback(
|
|
3046
2984
|
(instruction2) => {
|
|
3047
2985
|
!pathKey || !fieldAssistKey || !assistDocumentId2 || !assistableDocumentId || requestRunInstruction({
|
|
3048
2986
|
documentId: assistableDocumentId,
|
|
@@ -3061,16 +2999,16 @@ const assistFieldActions = {
|
|
|
3061
2999
|
assistDocumentId2,
|
|
3062
3000
|
fieldAssistKey
|
|
3063
3001
|
]
|
|
3064
|
-
), privateInstructions = useMemo(
|
|
3002
|
+
), privateInstructions = react.useMemo(
|
|
3065
3003
|
() => fieldAssist?.instructions?.filter((i) => i.userId && i.userId === currentUser?.id) || [],
|
|
3066
3004
|
[fieldAssist?.instructions, currentUser]
|
|
3067
|
-
), sharedInstructions = useMemo(
|
|
3005
|
+
), sharedInstructions = react.useMemo(
|
|
3068
3006
|
() => fieldAssist?.instructions?.filter((i) => !i.userId) || [],
|
|
3069
3007
|
[fieldAssist?.instructions]
|
|
3070
|
-
), instructions = useMemo(
|
|
3008
|
+
), instructions = react.useMemo(
|
|
3071
3009
|
() => [...privateInstructions, ...sharedInstructions],
|
|
3072
3010
|
[privateInstructions, sharedInstructions]
|
|
3073
|
-
), runInstructionsGroup = useMemo(() => instructions?.length || imageCaptionAction || translateAction || imageGenAction ? {
|
|
3011
|
+
), runInstructionsGroup = react.useMemo(() => instructions?.length || imageCaptionAction || translateAction || imageGenAction ? {
|
|
3074
3012
|
type: "group",
|
|
3075
3013
|
icon: () => null,
|
|
3076
3014
|
title: "Run instructions",
|
|
@@ -3098,20 +3036,20 @@ const assistFieldActions = {
|
|
|
3098
3036
|
imageCaptionAction,
|
|
3099
3037
|
translateAction,
|
|
3100
3038
|
imageGenAction
|
|
3101
|
-
]), getDocumentValue = useCallback(() => docValueRef.current, []), getConditionalPaths = useCallback(() => (formStateRef.current ? getConditionalMembers(formStateRef.current) : []).flatMap(
|
|
3039
|
+
]), getDocumentValue = react.useCallback(() => docValueRef.current, []), getConditionalPaths = react.useCallback(() => (formStateRef.current ? getConditionalMembers(formStateRef.current) : []).flatMap(
|
|
3102
3040
|
(cm) => {
|
|
3103
|
-
const path = stringToPath(cm.path);
|
|
3041
|
+
const path = sanity.stringToPath(cm.path);
|
|
3104
3042
|
return path.some((s) => typeof s == "number") ? [] : {
|
|
3105
3043
|
...cm,
|
|
3106
3044
|
path
|
|
3107
3045
|
};
|
|
3108
3046
|
}
|
|
3109
|
-
), []), parentSchemaType = useMemo(() => {
|
|
3047
|
+
), []), parentSchemaType = react.useMemo(() => {
|
|
3110
3048
|
if (props.path.length) {
|
|
3111
3049
|
if (props.path.length === 1)
|
|
3112
3050
|
return documentSchemaType;
|
|
3113
3051
|
} else return;
|
|
3114
|
-
const parentPath = props.path.slice(0, -1), typePath2 = getTypePath(docValueRef.current, pathToString(parentPath));
|
|
3052
|
+
const parentPath = props.path.slice(0, -1), typePath2 = getTypePath(docValueRef.current, sanity.pathToString(parentPath));
|
|
3115
3053
|
return typePath2 ? fieldRefsByTypePath[typePath2]?.schemaType : void 0;
|
|
3116
3054
|
}, [fieldRefsByTypePath, props.path, documentSchemaType]), customActions = useCustomFieldActions({
|
|
3117
3055
|
actionType: props.path.length ? "field" : "document",
|
|
@@ -3122,19 +3060,19 @@ const assistFieldActions = {
|
|
|
3122
3060
|
getDocumentValue,
|
|
3123
3061
|
getConditionalPaths,
|
|
3124
3062
|
parentSchemaType
|
|
3125
|
-
}), manageInstructionsItem = useMemo(
|
|
3063
|
+
}), manageInstructionsItem = react.useMemo(
|
|
3126
3064
|
() => ({
|
|
3127
3065
|
type: "action",
|
|
3128
|
-
icon: ControlsIcon,
|
|
3066
|
+
icon: icons.ControlsIcon,
|
|
3129
3067
|
title: "Manage instructions",
|
|
3130
3068
|
onAction: manageInstructions,
|
|
3131
3069
|
selected: isSelected
|
|
3132
3070
|
}),
|
|
3133
3071
|
[manageInstructions, isSelected]
|
|
3134
|
-
), group = useMemo(
|
|
3072
|
+
), group = react.useMemo(
|
|
3135
3073
|
() => ({
|
|
3136
3074
|
type: "group",
|
|
3137
|
-
icon: SparklesIcon,
|
|
3075
|
+
icon: icons.SparklesIcon,
|
|
3138
3076
|
title: pluginTitleShort,
|
|
3139
3077
|
children: [
|
|
3140
3078
|
runInstructionsGroup,
|
|
@@ -3156,11 +3094,11 @@ const assistFieldActions = {
|
|
|
3156
3094
|
imageGenAction,
|
|
3157
3095
|
customActions
|
|
3158
3096
|
]
|
|
3159
|
-
), emptyAction = useMemo(
|
|
3097
|
+
), emptyAction = react.useMemo(
|
|
3160
3098
|
() => ({
|
|
3161
3099
|
type: "action",
|
|
3162
3100
|
hidden: !assistSupported,
|
|
3163
|
-
icon: SparklesIcon,
|
|
3101
|
+
icon: icons.SparklesIcon,
|
|
3164
3102
|
onAction: manageInstructions,
|
|
3165
3103
|
renderAsButton: !0,
|
|
3166
3104
|
title: pluginTitleShort,
|
|
@@ -3185,11 +3123,11 @@ function instructionItem(props) {
|
|
|
3185
3123
|
}
|
|
3186
3124
|
function createAssistDocumentPresence(documentId) {
|
|
3187
3125
|
return function() {
|
|
3188
|
-
return documentId ? /* @__PURE__ */ jsx(AssistDocumentPresence, {}) : null;
|
|
3126
|
+
return documentId ? /* @__PURE__ */ jsxRuntime.jsx(AssistDocumentPresence, {}) : null;
|
|
3189
3127
|
};
|
|
3190
3128
|
}
|
|
3191
3129
|
function AssistDocumentPresence() {
|
|
3192
|
-
const { assistDocument, syntheticTasks } = useAssistDocumentContext(), anyPresence = useMemo(() => {
|
|
3130
|
+
const { assistDocument, syntheticTasks } = useAssistDocumentContext(), anyPresence = react.useMemo(() => {
|
|
3193
3131
|
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
3132
|
if (anyPresence2)
|
|
3195
3133
|
return aiPresence(anyPresence2, []);
|
|
@@ -3202,19 +3140,19 @@ function AssistDocumentPresence() {
|
|
|
3202
3140
|
[]
|
|
3203
3141
|
) : void 0;
|
|
3204
3142
|
}, [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 }) }) }) });
|
|
3143
|
+
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
3144
|
}
|
|
3207
3145
|
function BackToInstructionListLink() {
|
|
3208
|
-
const { openInspector } = useDocumentPane(), goBack = useCallback(
|
|
3146
|
+
const { openInspector } = structure.useDocumentPane(), goBack = react.useCallback(
|
|
3209
3147
|
() => openInspector(aiInspectorId, { [instructionParam]: void 0 }),
|
|
3210
3148
|
[openInspector]
|
|
3211
3149
|
);
|
|
3212
|
-
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
3213
|
-
Button,
|
|
3150
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3151
|
+
ui.Button,
|
|
3214
3152
|
{
|
|
3215
3153
|
as: "a",
|
|
3216
3154
|
fontSize: 1,
|
|
3217
|
-
icon: ArrowLeftIcon,
|
|
3155
|
+
icon: icons.ArrowLeftIcon,
|
|
3218
3156
|
mode: "bleed",
|
|
3219
3157
|
padding: 1,
|
|
3220
3158
|
space: 2,
|
|
@@ -3224,38 +3162,38 @@ function BackToInstructionListLink() {
|
|
|
3224
3162
|
}
|
|
3225
3163
|
) });
|
|
3226
3164
|
}
|
|
3227
|
-
const SelectedFieldContext = createContext(void 0), SelectedFieldContextProvider = SelectedFieldContext.Provider, EMPTY_FIELDS = [];
|
|
3165
|
+
const SelectedFieldContext = react.createContext(void 0), SelectedFieldContextProvider = SelectedFieldContext.Provider, EMPTY_FIELDS = [];
|
|
3228
3166
|
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 });
|
|
3167
|
+
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
3168
|
}
|
|
3231
3169
|
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(() => {
|
|
3170
|
+
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
3171
|
if (typePath)
|
|
3234
3172
|
return (fields ?? EMPTY_FIELDS).find((f) => f.path === typePath)?._key;
|
|
3235
|
-
}, [fields, typePath]), activePath = useMemo(() => {
|
|
3173
|
+
}, [fields, typePath]), activePath = react.useMemo(() => {
|
|
3236
3174
|
if (!activeKey)
|
|
3237
3175
|
return;
|
|
3238
3176
|
const base = ["fields", { _key: activeKey }];
|
|
3239
3177
|
return instruction2 ? [...base, "instructions", { _key: instruction2 }] : base;
|
|
3240
|
-
}, [activeKey, instruction2]), schema = useSchema(), documentSchema = useMemo(() => {
|
|
3178
|
+
}, [activeKey, instruction2]), schema = sanity.useSchema(), documentSchema = react.useMemo(() => {
|
|
3241
3179
|
if (targetDocumentType)
|
|
3242
3180
|
return schema.get(targetDocumentType);
|
|
3243
|
-
}, [schema, targetDocumentType]), fieldSchema = useSelectedSchema(pathKey, documentSchema), context = useMemo(
|
|
3181
|
+
}, [schema, targetDocumentType]), fieldSchema = useSelectedSchema(pathKey, documentSchema), context = react.useMemo(
|
|
3244
3182
|
() => ({
|
|
3245
3183
|
documentSchema,
|
|
3246
3184
|
fieldSchema: fieldSchema ?? documentSchema
|
|
3247
3185
|
}),
|
|
3248
3186
|
[fieldSchema, documentSchema]
|
|
3249
3187
|
), title = value?.title;
|
|
3250
|
-
useEffect(() => {
|
|
3251
|
-
!title && documentSchema && !id?.startsWith("drafts.") && onChange(set(documentSchema.title ?? documentSchema.name, ["title"]));
|
|
3188
|
+
react.useEffect(() => {
|
|
3189
|
+
!title && documentSchema && !id?.startsWith("drafts.") && onChange(sanity.set(documentSchema.title ?? documentSchema.name, ["title"]));
|
|
3252
3190
|
}, [title, documentSchema, onChange, id]);
|
|
3253
|
-
const { onPathOpen, ...formCallbacks } = useFormCallbacks(), newCallbacks = useMemo(
|
|
3191
|
+
const { onPathOpen, ...formCallbacks } = sanity.useFormCallbacks(), newCallbacks = react.useMemo(
|
|
3254
3192
|
() => ({
|
|
3255
3193
|
...formCallbacks,
|
|
3256
3194
|
onPathOpen: (path) => {
|
|
3257
3195
|
!instruction2 && path.length === 4 && path[2] === "instructions" ? (setParams(
|
|
3258
|
-
typed({
|
|
3196
|
+
sanity.typed({
|
|
3259
3197
|
...params,
|
|
3260
3198
|
[instructionParam]: path[3]?._key
|
|
3261
3199
|
})
|
|
@@ -3264,18 +3202,18 @@ function AssistDocumentFormEditable(props) {
|
|
|
3264
3202
|
}),
|
|
3265
3203
|
[formCallbacks, onPathOpen, params, setParams, instruction2]
|
|
3266
3204
|
);
|
|
3267
|
-
useEffect(() => {
|
|
3205
|
+
react.useEffect(() => {
|
|
3268
3206
|
activePath && !instruction2 && onPathOpen([]);
|
|
3269
3207
|
}, [activePath, instruction2, onPathOpen]);
|
|
3270
|
-
const fieldError = useMemo(() => {
|
|
3208
|
+
const fieldError = react.useMemo(() => {
|
|
3271
3209
|
const fieldError2 = props.members.find(
|
|
3272
3210
|
(m) => m.kind === "error" && m.fieldName === "fields"
|
|
3273
3211
|
);
|
|
3274
3212
|
if (fieldError2)
|
|
3275
|
-
return /* @__PURE__ */ jsx(MemberFieldError, { member: fieldError2 });
|
|
3213
|
+
return /* @__PURE__ */ jsxRuntime.jsx(sanity.MemberFieldError, { member: fieldError2 });
|
|
3276
3214
|
}, [props.members]);
|
|
3277
|
-
return /* @__PURE__ */ jsx(SelectedFieldContextProvider, { value: context, children: /* @__PURE__ */ jsxs(Stack, { space: 5, children: [
|
|
3278
|
-
/* @__PURE__ */ jsx(
|
|
3215
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectedFieldContextProvider, { value: context, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 5, children: [
|
|
3216
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3279
3217
|
FieldsInitializer,
|
|
3280
3218
|
{
|
|
3281
3219
|
pathKey: typePath,
|
|
@@ -3286,19 +3224,19 @@ function AssistDocumentFormEditable(props) {
|
|
|
3286
3224
|
},
|
|
3287
3225
|
typePath
|
|
3288
3226
|
),
|
|
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 }) }) }),
|
|
3227
|
+
instruction2 && /* @__PURE__ */ jsxRuntime.jsx(BackToInstructionListLink, {}),
|
|
3228
|
+
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
3229
|
fieldError,
|
|
3292
3230
|
!activePath && props.renderDefault(props)
|
|
3293
3231
|
] }) });
|
|
3294
3232
|
}
|
|
3295
3233
|
function useSelectedSchema(fieldPath, documentSchema) {
|
|
3296
|
-
return useMemo(() => {
|
|
3234
|
+
return react.useMemo(() => {
|
|
3297
3235
|
if (!fieldPath)
|
|
3298
3236
|
return;
|
|
3299
3237
|
if (fieldPath === documentRootKey)
|
|
3300
3238
|
return documentSchema;
|
|
3301
|
-
const path = stringToPath(fieldPath);
|
|
3239
|
+
const path = sanity.stringToPath(fieldPath);
|
|
3302
3240
|
let currentSchema = documentSchema;
|
|
3303
3241
|
for (let i = 0; i < path.length; i++) {
|
|
3304
3242
|
const segment = path[i], field = currentSchema?.fields.find((f) => f.name === segment);
|
|
@@ -3322,22 +3260,22 @@ function FieldsInitializer({
|
|
|
3322
3260
|
}) {
|
|
3323
3261
|
const {
|
|
3324
3262
|
config: { __presets: presets }
|
|
3325
|
-
} = useAiAssistanceConfig(), existingField = fields?.find((f) => f._key === pathKey), documentPresets = !!documentSchema?.name && presets?.[documentSchema?.name], missingPresetInstructions = useMemo(() => {
|
|
3263
|
+
} = useAiAssistanceConfig(), existingField = fields?.find((f) => f._key === pathKey), documentPresets = !!documentSchema?.name && presets?.[documentSchema?.name], missingPresetInstructions = react.useMemo(() => {
|
|
3326
3264
|
if (!documentPresets || !pathKey)
|
|
3327
3265
|
return;
|
|
3328
3266
|
const existingInstructions = existingField?.instructions;
|
|
3329
3267
|
return documentPresets.fields?.find((f) => f.path === pathKey)?.instructions?.filter(
|
|
3330
3268
|
(i) => !existingInstructions?.some((ei) => ei._key === i._key)
|
|
3331
3269
|
);
|
|
3332
|
-
}, [documentPresets, pathKey, existingField]), initialized = useRef(!1);
|
|
3333
|
-
return useEffect(() => {
|
|
3270
|
+
}, [documentPresets, pathKey, existingField]), initialized = react.useRef(!1);
|
|
3271
|
+
return react.useEffect(() => {
|
|
3334
3272
|
if (initialized.current || !pathKey || existingField && !missingPresetInstructions?.length)
|
|
3335
3273
|
return;
|
|
3336
|
-
let event = PatchEvent.from([setIfMissing([], ["fields"])]);
|
|
3274
|
+
let event = sanity.PatchEvent.from([sanity.setIfMissing([], ["fields"])]);
|
|
3337
3275
|
existingField || (event = event.append(
|
|
3338
|
-
insert(
|
|
3276
|
+
sanity.insert(
|
|
3339
3277
|
[
|
|
3340
|
-
typed({
|
|
3278
|
+
sanity.typed({
|
|
3341
3279
|
_key: pathKey,
|
|
3342
3280
|
_type: assistFieldTypeName,
|
|
3343
3281
|
path: pathKey,
|
|
@@ -3347,8 +3285,8 @@ function FieldsInitializer({
|
|
|
3347
3285
|
"after",
|
|
3348
3286
|
["fields", -1]
|
|
3349
3287
|
)
|
|
3350
|
-
)), existingField?.instructions?.length || (event = event.append([setIfMissing([], ["fields", { _key: pathKey }, "instructions"])])), missingPresetInstructions?.length && (event = event.append(
|
|
3351
|
-
insert(
|
|
3288
|
+
)), existingField?.instructions?.length || (event = event.append([sanity.setIfMissing([], ["fields", { _key: pathKey }, "instructions"])])), missingPresetInstructions?.length && (event = event.append(
|
|
3289
|
+
sanity.insert(
|
|
3352
3290
|
missingPresetInstructions.map(
|
|
3353
3291
|
(preset) => ({
|
|
3354
3292
|
...preset,
|
|
@@ -3363,9 +3301,9 @@ function FieldsInitializer({
|
|
|
3363
3301
|
}, [activePath, onChange, pathKey, existingField, missingPresetInstructions]), null;
|
|
3364
3302
|
}
|
|
3365
3303
|
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" }) }) }),
|
|
3304
|
+
const { actions } = props, documentSchema = react.useContext(SelectedFieldContext)?.documentSchema, path = react.useContext(InlineBlockValueContext)?.path ?? props.path, selectedField = useSelectedField(documentSchema, path);
|
|
3305
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "center", style: { width: "100%" }, children: [
|
|
3306
|
+
/* @__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
3307
|
actions
|
|
3370
3308
|
] });
|
|
3371
3309
|
}
|
|
@@ -3373,13 +3311,13 @@ function HiddenFieldTitle(props) {
|
|
|
3373
3311
|
return props.renderDefault({ ...props, title: "", level: props.level - 2, changed: !1 });
|
|
3374
3312
|
}
|
|
3375
3313
|
function InstructionVisibility(props) {
|
|
3376
|
-
const { value, onChange } = props, user = useCurrentUser(), handleChange = useCallback(() => {
|
|
3314
|
+
const { value, onChange } = props, user = sanity.useCurrentUser(), handleChange = react.useCallback(() => {
|
|
3377
3315
|
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,
|
|
3316
|
+
onChange(newValue ? sanity.set(newValue) : sanity.unset());
|
|
3317
|
+
}, [onChange, user, value]), id = react.useId();
|
|
3318
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "flex-start", children: [
|
|
3319
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { margin: "-3px 0" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3320
|
+
ui.Switch,
|
|
3383
3321
|
{
|
|
3384
3322
|
...props.elementProps,
|
|
3385
3323
|
id,
|
|
@@ -3389,15 +3327,15 @@ function InstructionVisibility(props) {
|
|
|
3389
3327
|
disabled: props.elementProps.readOnly
|
|
3390
3328
|
}
|
|
3391
3329
|
) }),
|
|
3392
|
-
/* @__PURE__ */ jsx(Text, { muted: !0, size: 1, weight: "medium", children: /* @__PURE__ */ jsx("label", { htmlFor: id, children: "Make visible to all Studio members" }) })
|
|
3330
|
+
/* @__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
3331
|
] }) });
|
|
3394
3332
|
}
|
|
3395
3333
|
function FieldRefPathInput(props) {
|
|
3396
|
-
const documentSchema = useContext(SelectedFieldContext)?.documentSchema, { typePath } = useContext(AssistTypeContext), ref = useRef(null), id = useId(), { onChange } = props;
|
|
3397
|
-
useEffect(() => {
|
|
3334
|
+
const documentSchema = react.useContext(SelectedFieldContext)?.documentSchema, { typePath } = react.useContext(AssistTypeContext), ref = react.useRef(null), id = react.useId(), { onChange } = props;
|
|
3335
|
+
react.useEffect(() => {
|
|
3398
3336
|
ref.current?.querySelector("input")?.focus();
|
|
3399
3337
|
}, []);
|
|
3400
|
-
const onSelect = useCallback((path) => onChange(set(path)), [onChange]),
|
|
3338
|
+
const onSelect = react.useCallback((path) => onChange(sanity.set(path)), [onChange]), filter = react.useCallback(
|
|
3401
3339
|
(field) => {
|
|
3402
3340
|
if (!field.key.includes("|") || !typePath)
|
|
3403
3341
|
return !0;
|
|
@@ -3408,14 +3346,14 @@ function FieldRefPathInput(props) {
|
|
|
3408
3346
|
},
|
|
3409
3347
|
[typePath]
|
|
3410
3348
|
);
|
|
3411
|
-
return documentSchema ? /* @__PURE__ */ jsx(Box, { flex: 1, style: { minWidth: 300 }, ref, children: /* @__PURE__ */ jsx(
|
|
3349
|
+
return documentSchema ? /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, style: { minWidth: 300 }, ref, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3412
3350
|
FieldAutocomplete,
|
|
3413
3351
|
{
|
|
3414
3352
|
id,
|
|
3415
3353
|
schemaType: documentSchema,
|
|
3416
3354
|
onSelect,
|
|
3417
3355
|
fieldPath: props.value,
|
|
3418
|
-
filter
|
|
3356
|
+
filter
|
|
3419
3357
|
}
|
|
3420
3358
|
) }) : props.renderDefault(props);
|
|
3421
3359
|
}
|
|
@@ -3430,20 +3368,20 @@ function findFieldsetMember(members, fieldsetName) {
|
|
|
3430
3368
|
);
|
|
3431
3369
|
}
|
|
3432
3370
|
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 })
|
|
3371
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: [4, 4, 4, 5], children: [
|
|
3372
|
+
/* @__PURE__ */ jsxRuntime.jsx(NameField, { ...props }),
|
|
3373
|
+
/* @__PURE__ */ jsxRuntime.jsx(ShareField, { ...props }),
|
|
3374
|
+
/* @__PURE__ */ jsxRuntime.jsx(ObjectMember, { fieldName: "prompt", ...props }),
|
|
3375
|
+
/* @__PURE__ */ jsxRuntime.jsx(ObjectMember, { fieldName: "output", ...props })
|
|
3438
3376
|
] });
|
|
3439
3377
|
}
|
|
3440
3378
|
function ObjectMember({ fieldName, ...props }) {
|
|
3441
3379
|
const member = findFieldMember(props.members, fieldName);
|
|
3442
|
-
return member ? /* @__PURE__ */ jsx(ObjectInputMember, { ...props, member }) : null;
|
|
3380
|
+
return member ? /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member }) : null;
|
|
3443
3381
|
}
|
|
3444
3382
|
const NONE = [];
|
|
3445
3383
|
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(() => {
|
|
3384
|
+
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
3385
|
if (titleMember)
|
|
3448
3386
|
return titleMember.kind === "error" ? titleMember : {
|
|
3449
3387
|
...titleMember,
|
|
@@ -3456,28 +3394,28 @@ function NameField(props) {
|
|
|
3456
3394
|
}
|
|
3457
3395
|
};
|
|
3458
3396
|
}, [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 }) })
|
|
3397
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 5, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
3398
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { gap: 1, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { as: "label", weight: "semibold", size: 1, htmlFor: titleId, children: "Name" }) }),
|
|
3399
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Text, { muted: !0, size: 1, children: "How this instruction appears in menus" }),
|
|
3400
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { align: "center", children: [
|
|
3401
|
+
iconMember && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member: iconMember }) }),
|
|
3402
|
+
moddedTitleMember && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: 1, style: { marginLeft: -1 }, children: /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member: moddedTitleMember }) })
|
|
3465
3403
|
] })
|
|
3466
3404
|
] }) });
|
|
3467
3405
|
}
|
|
3468
3406
|
function ShareField(props) {
|
|
3469
3407
|
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 }) });
|
|
3408
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: visibilityMember && /* @__PURE__ */ jsxRuntime.jsx(sanity.ObjectInputMember, { ...props, member: visibilityMember }) });
|
|
3471
3409
|
}
|
|
3472
3410
|
function InstructionOutputField(props) {
|
|
3473
|
-
const { fieldSchema } = useContext(SelectedFieldContext) ?? {};
|
|
3474
|
-
return !fieldSchema || !(isObjectSchemaType(fieldSchema) || isArrayOfObjectsSchemaType(fieldSchema)) ? null : /* @__PURE__ */ jsx(EnabledOutputField, { ...props, fieldSchema, children: props.children });
|
|
3411
|
+
const { fieldSchema } = react.useContext(SelectedFieldContext) ?? {};
|
|
3412
|
+
return !fieldSchema || !(sanity.isObjectSchemaType(fieldSchema) || sanity.isArrayOfObjectsSchemaType(fieldSchema)) ? null : /* @__PURE__ */ jsxRuntime.jsx(EnabledOutputField, { ...props, fieldSchema, children: props.children });
|
|
3475
3413
|
}
|
|
3476
3414
|
function EnabledOutputField({
|
|
3477
3415
|
fieldSchema,
|
|
3478
3416
|
...props
|
|
3479
3417
|
}) {
|
|
3480
|
-
const [open, setOpen] = useState(!!props.value?.length), onExpand = useCallback(() => setOpen(!0), []), onCollapse = useCallback(() => setOpen(!1), []);
|
|
3418
|
+
const [open, setOpen] = react.useState(!!props.value?.length), onExpand = react.useCallback(() => setOpen(!0), []), onCollapse = react.useCallback(() => setOpen(!1), []);
|
|
3481
3419
|
return props.renderDefault({
|
|
3482
3420
|
...props,
|
|
3483
3421
|
collapsible: !0,
|
|
@@ -3485,46 +3423,46 @@ function EnabledOutputField({
|
|
|
3485
3423
|
onCollapse,
|
|
3486
3424
|
collapsed: !open,
|
|
3487
3425
|
level: 1,
|
|
3488
|
-
title: isObjectSchemaType(fieldSchema) ? "Allowed fields" : "Allowed types"
|
|
3426
|
+
title: sanity.isObjectSchemaType(fieldSchema) ? "Allowed fields" : "Allowed types"
|
|
3489
3427
|
});
|
|
3490
3428
|
}
|
|
3491
3429
|
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;
|
|
3430
|
+
const { fieldSchema } = react.useContext(SelectedFieldContext) ?? {};
|
|
3431
|
+
return fieldSchema ? sanity.isObjectSchemaType(fieldSchema) ? /* @__PURE__ */ jsxRuntime.jsx(ObjectOutputInput, { ...props, fieldSchema }) : sanity.isArrayOfObjectsSchemaType(fieldSchema) ? /* @__PURE__ */ jsxRuntime.jsx(ArrayOutputInput, { ...props, fieldSchema }) : null : null;
|
|
3494
3432
|
}
|
|
3495
3433
|
function useEmptySelectAllValue(value, allowedValues, onChange) {
|
|
3496
|
-
useEffect(() => {
|
|
3434
|
+
react.useEffect(() => {
|
|
3497
3435
|
const validValues = value?.filter(
|
|
3498
3436
|
(v) => allowedValues.find(
|
|
3499
3437
|
(f) => f.name === (v._type === outputFieldTypeName ? v.relativePath : v.type)
|
|
3500
3438
|
)
|
|
3501
3439
|
), valueLength = value?.length ?? 0, validLength = validValues?.length ?? 0;
|
|
3502
|
-
(!validLength && valueLength || validLength >= allowedValues.length) && onChange(PatchEvent.from([unset()]));
|
|
3440
|
+
(!validLength && valueLength || validLength >= allowedValues.length) && onChange(sanity.PatchEvent.from([sanity.unset()]));
|
|
3503
3441
|
}, [allowedValues, value, onChange]);
|
|
3504
3442
|
}
|
|
3505
3443
|
function ObjectOutputInput({
|
|
3506
3444
|
fieldSchema,
|
|
3507
3445
|
...props
|
|
3508
3446
|
}) {
|
|
3509
|
-
const { value, onChange } = props, fields = useMemo(
|
|
3447
|
+
const { value, onChange } = props, fields = react.useMemo(
|
|
3510
3448
|
() => fieldSchema.fields.filter((field) => isAssistSupported(field.type)),
|
|
3511
3449
|
[fieldSchema.fields]
|
|
3512
3450
|
);
|
|
3513
3451
|
useEmptySelectAllValue(value, fields, onChange);
|
|
3514
|
-
const onSelectChange = useCallback(
|
|
3452
|
+
const onSelectChange = react.useCallback(
|
|
3515
3453
|
(checked, selectedValue) => {
|
|
3516
3454
|
if (checked)
|
|
3517
3455
|
if (value?.length)
|
|
3518
|
-
onChange(PatchEvent.from(unset([{ _key: selectedValue }])));
|
|
3456
|
+
onChange(sanity.PatchEvent.from(sanity.unset([{ _key: selectedValue }])));
|
|
3519
3457
|
else {
|
|
3520
3458
|
const items = fields.filter((f) => f.name !== selectedValue).map(
|
|
3521
|
-
(field) => typed({
|
|
3459
|
+
(field) => sanity.typed({
|
|
3522
3460
|
_key: field.name,
|
|
3523
3461
|
_type: "sanity.assist.output.field",
|
|
3524
3462
|
relativePath: field.name
|
|
3525
3463
|
})
|
|
3526
3464
|
);
|
|
3527
|
-
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
3465
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert(items, "after", [-1])]));
|
|
3528
3466
|
}
|
|
3529
3467
|
else {
|
|
3530
3468
|
const patchValue = {
|
|
@@ -3532,12 +3470,12 @@ function ObjectOutputInput({
|
|
|
3532
3470
|
_type: "sanity.assist.output.field",
|
|
3533
3471
|
relativePath: selectedValue
|
|
3534
3472
|
};
|
|
3535
|
-
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
3473
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert([patchValue], "after", [-1])]));
|
|
3536
3474
|
}
|
|
3537
3475
|
},
|
|
3538
3476
|
[onChange, value, fields]
|
|
3539
3477
|
);
|
|
3540
|
-
return /* @__PURE__ */ jsx(Stack, { space: 2, children: fields.map((field) => /* @__PURE__ */ jsx(Flex, { align: "center", gap: 2, children: /* @__PURE__ */ jsx(
|
|
3478
|
+
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
3479
|
Selectable,
|
|
3542
3480
|
{
|
|
3543
3481
|
value: field.name,
|
|
@@ -3551,25 +3489,25 @@ function ArrayOutputInput({
|
|
|
3551
3489
|
fieldSchema,
|
|
3552
3490
|
...props
|
|
3553
3491
|
}) {
|
|
3554
|
-
const { value, onChange } = props, ofItems = useMemo(
|
|
3492
|
+
const { value, onChange } = props, ofItems = react.useMemo(
|
|
3555
3493
|
() => fieldSchema.of.filter((itemType) => isAssistSupported(itemType)),
|
|
3556
3494
|
[fieldSchema.of]
|
|
3557
3495
|
);
|
|
3558
3496
|
useEmptySelectAllValue(value, ofItems, onChange);
|
|
3559
|
-
const onSelectChange = useCallback(
|
|
3497
|
+
const onSelectChange = react.useCallback(
|
|
3560
3498
|
(checked, selectedValue) => {
|
|
3561
3499
|
if (checked)
|
|
3562
3500
|
if (value?.length)
|
|
3563
|
-
onChange(PatchEvent.from(unset([{ _key: selectedValue }])));
|
|
3501
|
+
onChange(sanity.PatchEvent.from(sanity.unset([{ _key: selectedValue }])));
|
|
3564
3502
|
else {
|
|
3565
3503
|
const items = ofItems.filter((f) => f.name !== selectedValue).map(
|
|
3566
|
-
(field) => typed({
|
|
3504
|
+
(field) => sanity.typed({
|
|
3567
3505
|
_key: field.name,
|
|
3568
3506
|
_type: "sanity.assist.output.type",
|
|
3569
3507
|
type: field.name
|
|
3570
3508
|
})
|
|
3571
3509
|
);
|
|
3572
|
-
onChange(PatchEvent.from([setIfMissing([]), insert(items, "after", [-1])]));
|
|
3510
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert(items, "after", [-1])]));
|
|
3573
3511
|
}
|
|
3574
3512
|
else {
|
|
3575
3513
|
const patchValue = {
|
|
@@ -3577,12 +3515,12 @@ function ArrayOutputInput({
|
|
|
3577
3515
|
_type: "sanity.assist.output.type",
|
|
3578
3516
|
type: selectedValue
|
|
3579
3517
|
};
|
|
3580
|
-
onChange(PatchEvent.from([setIfMissing([]), insert([patchValue], "after", [-1])]));
|
|
3518
|
+
onChange(sanity.PatchEvent.from([sanity.setIfMissing([]), sanity.insert([patchValue], "after", [-1])]));
|
|
3581
3519
|
}
|
|
3582
3520
|
},
|
|
3583
3521
|
[onChange, value, ofItems]
|
|
3584
3522
|
);
|
|
3585
|
-
return /* @__PURE__ */ jsx(Stack, { space: 2, children: ofItems.map((itemType) => /* @__PURE__ */ jsx(Flex, { children: /* @__PURE__ */ jsx(
|
|
3523
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { space: 2, children: ofItems.map((itemType) => /* @__PURE__ */ jsxRuntime.jsx(ui.Flex, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3586
3524
|
Selectable,
|
|
3587
3525
|
{
|
|
3588
3526
|
value: itemType.name,
|
|
@@ -3598,13 +3536,13 @@ function Selectable({
|
|
|
3598
3536
|
value,
|
|
3599
3537
|
onChange
|
|
3600
3538
|
}) {
|
|
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 }) })
|
|
3539
|
+
const checked = !arrayValue?.length || !!arrayValue?.find((v) => v._key === value), handleChange = react.useCallback(() => onChange(checked, value), [onChange, checked, value]);
|
|
3540
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, align: "flex-start", children: [
|
|
3541
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { checked, onChange: handleChange }),
|
|
3542
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Card, { marginTop: 1, onClick: handleChange, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { style: { cursor: "default" }, size: 1, children: title }) })
|
|
3605
3543
|
] });
|
|
3606
3544
|
}
|
|
3607
|
-
const PteMods = styled(Box)`
|
|
3545
|
+
const PteMods = styledComponents.styled(ui.Box)`
|
|
3608
3546
|
& [data-testid='pt-editor__toolbar-card'] > div > div:last-child {
|
|
3609
3547
|
display: none;
|
|
3610
3548
|
}
|
|
@@ -3616,12 +3554,12 @@ const PteMods = styled(Box)`
|
|
|
3616
3554
|
}
|
|
3617
3555
|
`;
|
|
3618
3556
|
function PromptInput(props) {
|
|
3619
|
-
return useOnlyInlineBlocks(props), /* @__PURE__ */ jsx(PteMods, { children: props.renderDefault(props) });
|
|
3557
|
+
return useOnlyInlineBlocks(props), /* @__PURE__ */ jsxRuntime.jsx(PteMods, { children: props.renderDefault(props) });
|
|
3620
3558
|
}
|
|
3621
3559
|
function useOnlyInlineBlocks(props) {
|
|
3622
|
-
useEffect(() => {
|
|
3560
|
+
react.useEffect(() => {
|
|
3623
3561
|
let needsFix = !1;
|
|
3624
|
-
const val = (props.value ?? []).map((block) => block._type === "block" ? block : (needsFix = !0, typed({
|
|
3562
|
+
const val = (props.value ?? []).map((block) => block._type === "block" ? block : (needsFix = !0, sanity.typed({
|
|
3625
3563
|
_key: randomKey(12),
|
|
3626
3564
|
_type: "block",
|
|
3627
3565
|
level: 0,
|
|
@@ -3629,7 +3567,7 @@ function useOnlyInlineBlocks(props) {
|
|
|
3629
3567
|
style: "normal",
|
|
3630
3568
|
children: [block]
|
|
3631
3569
|
})));
|
|
3632
|
-
needsFix && props.onChange(set(val));
|
|
3570
|
+
needsFix && props.onChange(sanity.set(val));
|
|
3633
3571
|
}, []);
|
|
3634
3572
|
}
|
|
3635
3573
|
function InstructionsArrayField(props) {
|
|
@@ -3639,10 +3577,10 @@ function InstructionsArrayField(props) {
|
|
|
3639
3577
|
});
|
|
3640
3578
|
}
|
|
3641
3579
|
function InstructionsArrayInput(props) {
|
|
3642
|
-
const user = useCurrentUser(), originalValue = props.value, originalMembers = props.members, value = useMemo(
|
|
3580
|
+
const user = sanity.useCurrentUser(), originalValue = props.value, originalMembers = props.members, value = react.useMemo(
|
|
3643
3581
|
() => (originalValue ?? []).filter((v) => !v.userId || v.userId === user?.id),
|
|
3644
3582
|
[originalValue, user]
|
|
3645
|
-
), members = useMemo(
|
|
3583
|
+
), members = react.useMemo(
|
|
3646
3584
|
() => (originalMembers ?? []).filter((v) => {
|
|
3647
3585
|
if (v.kind === "error")
|
|
3648
3586
|
return !0;
|
|
@@ -3654,8 +3592,8 @@ function InstructionsArrayInput(props) {
|
|
|
3654
3592
|
return props.renderDefault({ ...props, value, members });
|
|
3655
3593
|
}
|
|
3656
3594
|
function HideReferenceChangedBannerInput(props) {
|
|
3657
|
-
const ref = useRef(null);
|
|
3658
|
-
return useEffect(() => {
|
|
3595
|
+
const ref = react.useRef(null);
|
|
3596
|
+
return react.useEffect(() => {
|
|
3659
3597
|
const parent = ref.current?.closest('[data-testid="pane-content"]');
|
|
3660
3598
|
if (!parent)
|
|
3661
3599
|
return;
|
|
@@ -3663,29 +3601,29 @@ function HideReferenceChangedBannerInput(props) {
|
|
|
3663
3601
|
parent.id = parentId, style.innerText = `
|
|
3664
3602
|
#${parentId} [data-testid="reference-changed-banner"] { display: none; }
|
|
3665
3603
|
`, parent.prepend(style);
|
|
3666
|
-
}, [ref]), /* @__PURE__ */ jsx(Box, { ref, children: props.renderDefault(props) });
|
|
3604
|
+
}, [ref]), /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { ref, children: props.renderDefault(props) });
|
|
3667
3605
|
}
|
|
3668
|
-
const contextDocumentSchema = defineType({
|
|
3606
|
+
const contextDocumentSchema = sanity.defineType({
|
|
3669
3607
|
type: "document",
|
|
3670
3608
|
name: contextDocumentTypeName,
|
|
3671
3609
|
title: "AI context",
|
|
3672
3610
|
liveEdit: !0,
|
|
3673
|
-
icon: TokenIcon,
|
|
3611
|
+
icon: icons.TokenIcon,
|
|
3674
3612
|
components: {
|
|
3675
3613
|
input: HideReferenceChangedBannerInput
|
|
3676
3614
|
},
|
|
3677
3615
|
fields: [
|
|
3678
|
-
defineField({
|
|
3616
|
+
sanity.defineField({
|
|
3679
3617
|
type: "string",
|
|
3680
3618
|
name: "title",
|
|
3681
3619
|
title: "Title"
|
|
3682
3620
|
}),
|
|
3683
|
-
defineField({
|
|
3621
|
+
sanity.defineField({
|
|
3684
3622
|
name: "context",
|
|
3685
3623
|
type: "array",
|
|
3686
3624
|
title: "Context",
|
|
3687
3625
|
of: [
|
|
3688
|
-
defineArrayMember({
|
|
3626
|
+
sanity.defineArrayMember({
|
|
3689
3627
|
type: "block",
|
|
3690
3628
|
styles: [{ title: "Normal", value: "normal" }],
|
|
3691
3629
|
lists: [],
|
|
@@ -3707,17 +3645,17 @@ const contextDocumentSchema = defineType({
|
|
|
3707
3645
|
return {
|
|
3708
3646
|
title,
|
|
3709
3647
|
subtitle: `Words: ${words}`,
|
|
3710
|
-
media: DocumentTextIcon
|
|
3648
|
+
media: icons.DocumentTextIcon
|
|
3711
3649
|
};
|
|
3712
3650
|
}
|
|
3713
3651
|
}
|
|
3714
|
-
}), fieldReference = defineType({
|
|
3652
|
+
}), fieldReference = sanity.defineType({
|
|
3715
3653
|
type: "object",
|
|
3716
3654
|
name: fieldReferenceTypeName,
|
|
3717
3655
|
title: "Field",
|
|
3718
|
-
icon: ThListIcon,
|
|
3656
|
+
icon: icons.ThListIcon,
|
|
3719
3657
|
fields: [
|
|
3720
|
-
defineField({
|
|
3658
|
+
sanity.defineField({
|
|
3721
3659
|
type: "string",
|
|
3722
3660
|
name: "path",
|
|
3723
3661
|
title: "Field",
|
|
@@ -3753,7 +3691,7 @@ const contextDocumentSchema = defineType({
|
|
|
3753
3691
|
return {
|
|
3754
3692
|
title: path,
|
|
3755
3693
|
path,
|
|
3756
|
-
icon: CodeIcon
|
|
3694
|
+
icon: icons.CodeIcon
|
|
3757
3695
|
};
|
|
3758
3696
|
}
|
|
3759
3697
|
},
|
|
@@ -3765,13 +3703,13 @@ const contextDocumentSchema = defineType({
|
|
|
3765
3703
|
type: "popover"
|
|
3766
3704
|
}
|
|
3767
3705
|
}
|
|
3768
|
-
}), userInput = defineType({
|
|
3706
|
+
}), userInput = sanity.defineType({
|
|
3769
3707
|
type: "object",
|
|
3770
3708
|
name: userInputTypeName,
|
|
3771
3709
|
title: "User input",
|
|
3772
|
-
icon: ComposeIcon,
|
|
3710
|
+
icon: icons.ComposeIcon,
|
|
3773
3711
|
fields: [
|
|
3774
|
-
defineField({
|
|
3712
|
+
sanity.defineField({
|
|
3775
3713
|
type: "string",
|
|
3776
3714
|
name: "message",
|
|
3777
3715
|
title: "User input title",
|
|
@@ -3779,7 +3717,7 @@ const contextDocumentSchema = defineType({
|
|
|
3779
3717
|
description: "The header above the user input text field",
|
|
3780
3718
|
validation: (rule) => rule.required()
|
|
3781
3719
|
}),
|
|
3782
|
-
defineField({
|
|
3720
|
+
sanity.defineField({
|
|
3783
3721
|
type: "text",
|
|
3784
3722
|
rows: 3,
|
|
3785
3723
|
name: "description",
|
|
@@ -3798,13 +3736,13 @@ const contextDocumentSchema = defineType({
|
|
|
3798
3736
|
width: 1
|
|
3799
3737
|
}
|
|
3800
3738
|
}
|
|
3801
|
-
}), promptContext = defineType({
|
|
3739
|
+
}), promptContext = sanity.defineType({
|
|
3802
3740
|
type: "object",
|
|
3803
3741
|
name: instructionContextTypeName,
|
|
3804
3742
|
title: contextDocumentSchema.title,
|
|
3805
3743
|
icon: contextDocumentSchema.icon,
|
|
3806
3744
|
fields: [
|
|
3807
|
-
defineField({
|
|
3745
|
+
sanity.defineField({
|
|
3808
3746
|
type: "reference",
|
|
3809
3747
|
name: "reference",
|
|
3810
3748
|
to: [{ type: contextDocumentSchema.name }],
|
|
@@ -3813,14 +3751,14 @@ const contextDocumentSchema = defineType({
|
|
|
3813
3751
|
validation: (rule) => rule.required(),
|
|
3814
3752
|
components: {
|
|
3815
3753
|
input: function(props) {
|
|
3816
|
-
return /* @__PURE__ */ jsx(Box, { style: { maxWidth: 300 }, children: props.renderDefault(props) });
|
|
3754
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { style: { maxWidth: 300 }, children: props.renderDefault(props) });
|
|
3817
3755
|
}
|
|
3818
3756
|
}
|
|
3819
3757
|
})
|
|
3820
3758
|
],
|
|
3821
3759
|
preview: {
|
|
3822
3760
|
select: {
|
|
3823
|
-
ref: "reference.
|
|
3761
|
+
ref: "reference._id",
|
|
3824
3762
|
title: "reference.title",
|
|
3825
3763
|
context: "reference.context"
|
|
3826
3764
|
},
|
|
@@ -3834,12 +3772,12 @@ const contextDocumentSchema = defineType({
|
|
|
3834
3772
|
width: "auto"
|
|
3835
3773
|
}
|
|
3836
3774
|
}
|
|
3837
|
-
}), prompt = defineType({
|
|
3775
|
+
}), prompt = sanity.defineType({
|
|
3838
3776
|
type: "array",
|
|
3839
3777
|
name: promptTypeName,
|
|
3840
3778
|
title: "Prompt",
|
|
3841
3779
|
of: [
|
|
3842
|
-
defineArrayMember({
|
|
3780
|
+
sanity.defineArrayMember({
|
|
3843
3781
|
type: "block",
|
|
3844
3782
|
styles: [{ title: "Normal", value: "normal" }],
|
|
3845
3783
|
lists: [],
|
|
@@ -3848,13 +3786,13 @@ const contextDocumentSchema = defineType({
|
|
|
3848
3786
|
annotations: []
|
|
3849
3787
|
},
|
|
3850
3788
|
of: [
|
|
3851
|
-
defineArrayMember({
|
|
3789
|
+
sanity.defineArrayMember({
|
|
3852
3790
|
type: fieldReference.name
|
|
3853
3791
|
}),
|
|
3854
|
-
defineArrayMember({
|
|
3792
|
+
sanity.defineArrayMember({
|
|
3855
3793
|
type: promptContext.name
|
|
3856
3794
|
}),
|
|
3857
|
-
defineArrayMember({
|
|
3795
|
+
sanity.defineArrayMember({
|
|
3858
3796
|
type: userInput.name
|
|
3859
3797
|
})
|
|
3860
3798
|
]
|
|
@@ -3869,29 +3807,29 @@ const contextDocumentSchema = defineType({
|
|
|
3869
3807
|
type: userInput.name,
|
|
3870
3808
|
}),*/
|
|
3871
3809
|
]
|
|
3872
|
-
}), outputFieldType = defineType({
|
|
3810
|
+
}), outputFieldType = sanity.defineType({
|
|
3873
3811
|
type: "object",
|
|
3874
3812
|
name: outputFieldTypeName,
|
|
3875
3813
|
title: "Output field",
|
|
3876
3814
|
fields: [
|
|
3877
|
-
defineField({
|
|
3815
|
+
sanity.defineField({
|
|
3878
3816
|
type: "string",
|
|
3879
3817
|
name: "path",
|
|
3880
3818
|
title: "Path"
|
|
3881
3819
|
})
|
|
3882
3820
|
]
|
|
3883
|
-
}), outputTypeType = defineType({
|
|
3821
|
+
}), outputTypeType = sanity.defineType({
|
|
3884
3822
|
type: "object",
|
|
3885
3823
|
name: outputTypeTypeName,
|
|
3886
3824
|
title: "Output type",
|
|
3887
3825
|
fields: [
|
|
3888
|
-
defineField({
|
|
3826
|
+
sanity.defineField({
|
|
3889
3827
|
type: "string",
|
|
3890
3828
|
name: "type",
|
|
3891
3829
|
title: "Type"
|
|
3892
3830
|
})
|
|
3893
3831
|
]
|
|
3894
|
-
}), instruction = defineType({
|
|
3832
|
+
}), instruction = sanity.defineType({
|
|
3895
3833
|
type: "object",
|
|
3896
3834
|
name: instructionTypeName,
|
|
3897
3835
|
title: "Instruction",
|
|
@@ -3906,45 +3844,45 @@ const contextDocumentSchema = defineType({
|
|
|
3906
3844
|
},
|
|
3907
3845
|
prepare: ({ icon, title, userId }) => ({
|
|
3908
3846
|
title,
|
|
3909
|
-
icon: icon ? icons[icon] : SparklesIcon,
|
|
3847
|
+
icon: icon ? icons.icons[icon] : icons.SparklesIcon,
|
|
3910
3848
|
userId
|
|
3911
3849
|
})
|
|
3912
3850
|
},
|
|
3913
3851
|
components: {
|
|
3914
3852
|
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,
|
|
3853
|
+
preview: (props) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 3, align: "center", padding: 2, children: [
|
|
3854
|
+
props.icon && /* @__PURE__ */ jsxRuntime.jsx(ui.Box, { flex: "none", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: react.createElement(props.icon) }) }),
|
|
3855
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Stack, { flex: 1, space: 2, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, textOverflow: "ellipsis", weight: "medium", children: getInstructionTitle(props) }) }),
|
|
3856
|
+
props.userId && /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3857
|
+
ui.Tooltip,
|
|
3920
3858
|
{
|
|
3921
|
-
content: /* @__PURE__ */ jsx(Text, { size: 1, children: "Only visible to you" }),
|
|
3859
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: 1, children: "Only visible to you" }),
|
|
3922
3860
|
padding: 2,
|
|
3923
3861
|
placement: "top",
|
|
3924
3862
|
portal: !0,
|
|
3925
|
-
children: /* @__PURE__ */ jsx(LockIcon, {})
|
|
3863
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(icons.LockIcon, {})
|
|
3926
3864
|
}
|
|
3927
3865
|
) })
|
|
3928
3866
|
] })
|
|
3929
3867
|
},
|
|
3930
3868
|
fields: [
|
|
3931
|
-
defineField({
|
|
3869
|
+
sanity.defineField({
|
|
3932
3870
|
type: prompt.name,
|
|
3933
3871
|
name: "prompt",
|
|
3934
3872
|
title: "Instruction",
|
|
3935
|
-
description: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3873
|
+
description: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
3936
3874
|
"Learn from",
|
|
3937
3875
|
" ",
|
|
3938
|
-
/* @__PURE__ */ jsxs("a", { href: instructionGuideUrl, target: "_blank", rel: "noreferrer", children: [
|
|
3876
|
+
/* @__PURE__ */ jsxRuntime.jsxs("a", { href: instructionGuideUrl, target: "_blank", rel: "noreferrer", children: [
|
|
3939
3877
|
"our instruction guide ",
|
|
3940
|
-
/* @__PURE__ */ jsx(ArrowRightIcon, {})
|
|
3878
|
+
/* @__PURE__ */ jsxRuntime.jsx(icons.ArrowRightIcon, {})
|
|
3941
3879
|
] })
|
|
3942
3880
|
] }),
|
|
3943
3881
|
components: {
|
|
3944
3882
|
input: PromptInput
|
|
3945
3883
|
}
|
|
3946
3884
|
}),
|
|
3947
|
-
defineField({
|
|
3885
|
+
sanity.defineField({
|
|
3948
3886
|
type: "string",
|
|
3949
3887
|
name: "icon",
|
|
3950
3888
|
title: "Icon",
|
|
@@ -3954,7 +3892,7 @@ const contextDocumentSchema = defineType({
|
|
|
3954
3892
|
input: IconInput
|
|
3955
3893
|
}
|
|
3956
3894
|
}),
|
|
3957
|
-
defineField({
|
|
3895
|
+
sanity.defineField({
|
|
3958
3896
|
type: "string",
|
|
3959
3897
|
name: "title",
|
|
3960
3898
|
title: "Title",
|
|
@@ -3963,7 +3901,7 @@ const contextDocumentSchema = defineType({
|
|
|
3963
3901
|
field: HiddenFieldTitle
|
|
3964
3902
|
}
|
|
3965
3903
|
}),
|
|
3966
|
-
defineField({
|
|
3904
|
+
sanity.defineField({
|
|
3967
3905
|
type: "string",
|
|
3968
3906
|
name: "userId",
|
|
3969
3907
|
title: "Visibility",
|
|
@@ -3975,7 +3913,7 @@ const contextDocumentSchema = defineType({
|
|
|
3975
3913
|
initialValue: (params, context) => context.currentUser?.id ?? "",
|
|
3976
3914
|
readOnly: (context) => !!(context.parent?.createdById && context.parent?.createdById !== context.currentUser?.id)
|
|
3977
3915
|
}),
|
|
3978
|
-
defineField({
|
|
3916
|
+
sanity.defineField({
|
|
3979
3917
|
type: "string",
|
|
3980
3918
|
name: "createdById",
|
|
3981
3919
|
title: "Created by",
|
|
@@ -3983,7 +3921,7 @@ const contextDocumentSchema = defineType({
|
|
|
3983
3921
|
fieldset: "appearance",
|
|
3984
3922
|
initialValue: (params, context) => context.currentUser?.id ?? ""
|
|
3985
3923
|
}),
|
|
3986
|
-
defineField({
|
|
3924
|
+
sanity.defineField({
|
|
3987
3925
|
type: "array",
|
|
3988
3926
|
name: "output",
|
|
3989
3927
|
title: "Output filter",
|
|
@@ -3992,12 +3930,12 @@ const contextDocumentSchema = defineType({
|
|
|
3992
3930
|
field: InstructionOutputField
|
|
3993
3931
|
},
|
|
3994
3932
|
of: [
|
|
3995
|
-
defineArrayMember({ type: outputFieldType.name }),
|
|
3996
|
-
defineArrayMember({ type: outputTypeType.name })
|
|
3933
|
+
sanity.defineArrayMember({ type: outputFieldType.name }),
|
|
3934
|
+
sanity.defineArrayMember({ type: outputTypeType.name })
|
|
3997
3935
|
]
|
|
3998
3936
|
})
|
|
3999
3937
|
]
|
|
4000
|
-
}), fieldInstructions = defineType({
|
|
3938
|
+
}), fieldInstructions = sanity.defineType({
|
|
4001
3939
|
type: "object",
|
|
4002
3940
|
name: assistFieldTypeName,
|
|
4003
3941
|
title: "Field prompt",
|
|
@@ -4005,14 +3943,14 @@ const contextDocumentSchema = defineType({
|
|
|
4005
3943
|
input: FieldPromptInput,
|
|
4006
3944
|
},*/
|
|
4007
3945
|
fields: [
|
|
4008
|
-
defineField({
|
|
3946
|
+
sanity.defineField({
|
|
4009
3947
|
type: "string",
|
|
4010
3948
|
name: "path",
|
|
4011
3949
|
title: "Path",
|
|
4012
3950
|
readOnly: !0,
|
|
4013
3951
|
hidden: !0
|
|
4014
3952
|
}),
|
|
4015
|
-
defineField({
|
|
3953
|
+
sanity.defineField({
|
|
4016
3954
|
type: "array",
|
|
4017
3955
|
name: "instructions",
|
|
4018
3956
|
title: "Instructions",
|
|
@@ -4028,7 +3966,7 @@ const contextDocumentSchema = defineType({
|
|
|
4028
3966
|
title: "path"
|
|
4029
3967
|
}
|
|
4030
3968
|
}
|
|
4031
|
-
}), assistDocumentSchema = defineType({
|
|
3969
|
+
}), assistDocumentSchema = sanity.defineType({
|
|
4032
3970
|
//NOTE: this is a document type. Using object here ensures it does not appear in structure menus
|
|
4033
3971
|
type: "object",
|
|
4034
3972
|
liveEdit: !0,
|
|
@@ -4039,12 +3977,12 @@ const contextDocumentSchema = defineType({
|
|
|
4039
3977
|
field: (props) => props.renderDefault({ ...props, title: "" })
|
|
4040
3978
|
},
|
|
4041
3979
|
fields: [
|
|
4042
|
-
defineField({
|
|
3980
|
+
sanity.defineField({
|
|
4043
3981
|
type: "string",
|
|
4044
3982
|
name: "title",
|
|
4045
3983
|
title: "Title"
|
|
4046
3984
|
}),
|
|
4047
|
-
defineField({
|
|
3985
|
+
sanity.defineField({
|
|
4048
3986
|
type: "array",
|
|
4049
3987
|
name: "fields",
|
|
4050
3988
|
title: "Fields",
|
|
@@ -4056,45 +3994,45 @@ const contextDocumentSchema = defineType({
|
|
|
4056
3994
|
title: "title"
|
|
4057
3995
|
}
|
|
4058
3996
|
}
|
|
4059
|
-
}), instructionTask = defineType({
|
|
3997
|
+
}), instructionTask = sanity.defineType({
|
|
4060
3998
|
type: "object",
|
|
4061
3999
|
name: instructionTaskTypeName,
|
|
4062
4000
|
title: "Instruction task",
|
|
4063
4001
|
fields: [
|
|
4064
|
-
defineField({
|
|
4002
|
+
sanity.defineField({
|
|
4065
4003
|
type: "string",
|
|
4066
4004
|
name: "path",
|
|
4067
4005
|
title: "Path"
|
|
4068
4006
|
}),
|
|
4069
|
-
defineField({
|
|
4007
|
+
sanity.defineField({
|
|
4070
4008
|
type: "string",
|
|
4071
4009
|
name: "instructionKey",
|
|
4072
4010
|
title: "Instruction key"
|
|
4073
4011
|
}),
|
|
4074
|
-
defineField({
|
|
4012
|
+
sanity.defineField({
|
|
4075
4013
|
type: "datetime",
|
|
4076
4014
|
name: "started",
|
|
4077
4015
|
title: "Started"
|
|
4078
4016
|
}),
|
|
4079
|
-
defineField({
|
|
4017
|
+
sanity.defineField({
|
|
4080
4018
|
type: "datetime",
|
|
4081
4019
|
name: "updated",
|
|
4082
4020
|
title: "Updated"
|
|
4083
4021
|
}),
|
|
4084
|
-
defineField({
|
|
4022
|
+
sanity.defineField({
|
|
4085
4023
|
type: "string",
|
|
4086
4024
|
name: "info",
|
|
4087
4025
|
title: "Info"
|
|
4088
4026
|
})
|
|
4089
4027
|
]
|
|
4090
|
-
}), documentInstructionStatus = defineType({
|
|
4028
|
+
}), documentInstructionStatus = sanity.defineType({
|
|
4091
4029
|
//NOTE: this is a document type. Using object here ensures it does not appear in structure menus
|
|
4092
4030
|
type: "object",
|
|
4093
4031
|
liveEdit: !0,
|
|
4094
4032
|
name: assistTasksStatusTypeName,
|
|
4095
4033
|
title: "Document instruction status",
|
|
4096
4034
|
fields: [
|
|
4097
|
-
defineField({
|
|
4035
|
+
sanity.defineField({
|
|
4098
4036
|
type: "array",
|
|
4099
4037
|
name: "tasks",
|
|
4100
4038
|
title: "Tasks",
|
|
@@ -4140,7 +4078,7 @@ const instructionForm = [
|
|
|
4140
4078
|
documentInstructionStatus,
|
|
4141
4079
|
instructionTask,
|
|
4142
4080
|
contextDocumentSchema
|
|
4143
|
-
], assist = definePlugin((config) => {
|
|
4081
|
+
], assist = sanity.definePlugin((config) => {
|
|
4144
4082
|
const configWithDefaults = config ?? {}, styleguide = configWithDefaults.translate?.styleguide || "", maxPathDepth = configWithDefaults.assist?.maxPathDepth, temperature = configWithDefaults.assist?.temperature;
|
|
4145
4083
|
if (typeof styleguide == "string" && validateStyleguide(styleguide), maxPathDepth !== void 0 && (maxPathDepth < 1 || maxPathDepth > 12))
|
|
4146
4084
|
throw new Error(
|
|
@@ -4174,7 +4112,7 @@ const instructionForm = [
|
|
|
4174
4112
|
if (schemaType === assistDocumentTypeName)
|
|
4175
4113
|
return [];
|
|
4176
4114
|
const docSchema = schema.get(schemaType);
|
|
4177
|
-
return docSchema && isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema) ? [...prev, createAssistDocumentPresence(documentId)] : prev;
|
|
4115
|
+
return docSchema && sanity.isObjectSchemaType(docSchema) && isSchemaAssistEnabled(docSchema) ? [...prev, createAssistDocumentPresence(documentId)] : prev;
|
|
4178
4116
|
},
|
|
4179
4117
|
components: {
|
|
4180
4118
|
unstable_layout: AssistDocumentLayout
|
|
@@ -4183,7 +4121,7 @@ const instructionForm = [
|
|
|
4183
4121
|
studio: {
|
|
4184
4122
|
components: {
|
|
4185
4123
|
layout: function(props) {
|
|
4186
|
-
return /* @__PURE__ */ jsx(AssistLayout, { ...props, config: configWithDefaults });
|
|
4124
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AssistLayout, { ...props, config: configWithDefaults });
|
|
4187
4125
|
}
|
|
4188
4126
|
}
|
|
4189
4127
|
},
|
|
@@ -4197,24 +4135,24 @@ const instructionForm = [
|
|
|
4197
4135
|
}
|
|
4198
4136
|
},
|
|
4199
4137
|
plugins: [
|
|
4200
|
-
definePlugin({
|
|
4138
|
+
sanity.definePlugin({
|
|
4201
4139
|
name: `${packageName}/safe-value-input`,
|
|
4202
4140
|
form: { components: { input: SafeValueInput } }
|
|
4203
4141
|
})(),
|
|
4204
|
-
definePlugin({
|
|
4142
|
+
sanity.definePlugin({
|
|
4205
4143
|
name: `${packageName}/generate-caption`,
|
|
4206
4144
|
form: {
|
|
4207
4145
|
components: {
|
|
4208
4146
|
input: (props) => {
|
|
4209
4147
|
const { schemaType } = props;
|
|
4210
|
-
return isImage(schemaType) ? /* @__PURE__ */ jsx(ImageContextProvider, { ...props }) : props.renderDefault(props);
|
|
4148
|
+
return isImage(schemaType) ? /* @__PURE__ */ jsxRuntime.jsx(ImageContextProvider, { ...props }) : props.renderDefault(props);
|
|
4211
4149
|
}
|
|
4212
4150
|
}
|
|
4213
4151
|
}
|
|
4214
4152
|
})()
|
|
4215
4153
|
]
|
|
4216
4154
|
};
|
|
4217
|
-
}), fetch = (client, query, params, options2) => defer(
|
|
4155
|
+
}), fetch = (client, query, params, options2) => rxjs.defer(
|
|
4218
4156
|
() => (
|
|
4219
4157
|
// getVersionedClient(options.apiVersion)
|
|
4220
4158
|
client.observable.fetch(query, params, {
|
|
@@ -4222,7 +4160,7 @@ const instructionForm = [
|
|
|
4222
4160
|
filterResponse: !0
|
|
4223
4161
|
})
|
|
4224
4162
|
)
|
|
4225
|
-
), listen = (client, query, params, options2) => defer(
|
|
4163
|
+
), listen = (client, query, params, options2) => rxjs.defer(
|
|
4226
4164
|
() => (
|
|
4227
4165
|
// getVersionedClient(options.apiVersion)
|
|
4228
4166
|
client.listen(query, params, {
|
|
@@ -4238,35 +4176,35 @@ function isWelcomeEvent(event) {
|
|
|
4238
4176
|
}
|
|
4239
4177
|
const listenQuery = (client, query, params = {}, options2 = {}) => {
|
|
4240
4178
|
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(
|
|
4179
|
+
operators.mergeMap((ev, i) => i === 0 && !isWelcomeEvent(ev) ? rxjs.throwError(
|
|
4242
4180
|
new Error(
|
|
4243
4181
|
ev.type === "reconnect" ? "Could not establish EventSource connection" : `Received unexpected type of first event "${ev.type}"`
|
|
4244
4182
|
)
|
|
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)),
|
|
4183
|
+
) : rxjs.of(ev)),
|
|
4184
|
+
operators.share()
|
|
4185
|
+
), [welcome$, mutationAndReconnect$] = rxjs.partition(events$, isWelcomeEvent), isRelevantEvent = (event) => !options2.transitions || event.type !== "mutation" ? !0 : options2.transitions.includes(event.transition);
|
|
4186
|
+
return rxjs.merge(
|
|
4187
|
+
welcome$.pipe(operators.take(1)),
|
|
4250
4188
|
mutationAndReconnect$.pipe(
|
|
4251
|
-
filter(isRelevantEvent),
|
|
4252
|
-
switchMap((event) => merge(of(event), of(event).pipe(delay(options2.throttleTime || 1e3))))
|
|
4189
|
+
operators.filter(isRelevantEvent),
|
|
4190
|
+
rxjs.switchMap((event) => rxjs.merge(rxjs.of(event), rxjs.of(event).pipe(rxjs.delay(options2.throttleTime || 1e3))))
|
|
4253
4191
|
)
|
|
4254
|
-
).pipe(exhaustMapToWithTrailing(fetchOnce$));
|
|
4192
|
+
).pipe(rxjsExhaustmapWithTrailing.exhaustMapToWithTrailing(fetchOnce$));
|
|
4255
4193
|
}, DEFAULT_PARAMS = {}, DEFAULT_OPTIONS = { apiVersion: "v2022-05-09" };
|
|
4256
4194
|
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))
|
|
4195
|
+
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" });
|
|
4196
|
+
return react.useEffect(() => (subscription.current = listenQuery(client, query, params, options2).pipe(
|
|
4197
|
+
operators.distinctUntilChanged(isEqual__default.default),
|
|
4198
|
+
operators.catchError((err) => (console.error(err), setError(err), setLoading(!1), setData(null), err))
|
|
4261
4199
|
).subscribe((documents) => {
|
|
4262
|
-
setData((current) =>
|
|
4200
|
+
setData((current) => isEqual__default.default(current, documents) ? current : documents), setLoading(!1), setError(!1);
|
|
4263
4201
|
}), () => subscription.current ? subscription.current.unsubscribe() : void 0), [query, params, options2, client]), { loading, error, data };
|
|
4264
4202
|
}
|
|
4265
4203
|
const NO_DATA = [], defaultTitle = "Sync schema";
|
|
4266
4204
|
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)", {
|
|
4205
|
+
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
4206
|
type: assistSerializedTypeName
|
|
4269
|
-
}), types = useMemo(() => serializeSchema(schema), [schema]), storeTypes = useCallback(() => {
|
|
4207
|
+
}), types = react.useMemo(() => serializeSchema(schema), [schema]), storeTypes = react.useCallback(() => {
|
|
4270
4208
|
setSaving(!0);
|
|
4271
4209
|
let canSave = !0;
|
|
4272
4210
|
async function store() {
|
|
@@ -4284,45 +4222,43 @@ function SchemaTypeTool() {
|
|
|
4284
4222
|
canSave = !1, setSaving(!1), setSyncTitle(defaultTitle);
|
|
4285
4223
|
};
|
|
4286
4224
|
}, [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,
|
|
4225
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ui.Card, { padding: 4, overflow: "auto", style: { height: "calc(100vh - 81px)" }, children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 4, children: [
|
|
4226
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4227
|
+
ui.Button,
|
|
4290
4228
|
{
|
|
4291
|
-
icon: saving ? /* @__PURE__ */ jsx(Spinner, { style: { marginTop: 5 } }) : SyncIcon,
|
|
4229
|
+
icon: saving ? /* @__PURE__ */ jsxRuntime.jsx(ui.Spinner, { style: { marginTop: 5 } }) : icons.SyncIcon,
|
|
4292
4230
|
text: syncTitle,
|
|
4293
4231
|
disabled: saving,
|
|
4294
4232
|
onClick: storeTypes
|
|
4295
4233
|
}
|
|
4296
4234
|
) }),
|
|
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)) })
|
|
4235
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Flex, { gap: 2, children: [
|
|
4236
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
4237
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Studio schema" }),
|
|
4238
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: types.map((type) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(SchemaEntry, { schemaStub: type }) }, type.name)) })
|
|
4301
4239
|
] }),
|
|
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)) })
|
|
4240
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { space: 2, children: [
|
|
4241
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.Label, { children: "Stored schema" }),
|
|
4242
|
+
/* @__PURE__ */ jsxRuntime.jsx("ul", { children: (data ?? NO_DATA).map((type) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(SchemaEntry, { schemaStub: type }) }, type.name)) })
|
|
4305
4243
|
] })
|
|
4306
4244
|
] })
|
|
4307
4245
|
] }) });
|
|
4308
4246
|
}
|
|
4309
4247
|
function SchemaEntry({ schemaStub }) {
|
|
4310
|
-
const out = useMemo(() => JSON.stringify(schemaStub, null, 2), [schemaStub]);
|
|
4311
|
-
return /* @__PURE__ */ jsx("pre", { children: out });
|
|
4248
|
+
const out = react.useMemo(() => JSON.stringify(schemaStub, null, 2), [schemaStub]);
|
|
4249
|
+
return /* @__PURE__ */ jsxRuntime.jsx("pre", { children: out });
|
|
4312
4250
|
}
|
|
4313
4251
|
function useUserInput() {
|
|
4314
4252
|
const { getUserInput } = useRunInstruction();
|
|
4315
4253
|
return getUserInput;
|
|
4316
4254
|
}
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
};
|
|
4328
|
-
//# sourceMappingURL=index.esm.js.map
|
|
4255
|
+
exports.SchemaTypeTool = SchemaTypeTool;
|
|
4256
|
+
exports.assist = assist;
|
|
4257
|
+
exports.contextDocumentTypeName = contextDocumentTypeName;
|
|
4258
|
+
exports.defaultLanguageOutputs = defaultLanguageOutputs;
|
|
4259
|
+
exports.defineAssistFieldAction = defineAssistFieldAction;
|
|
4260
|
+
exports.defineAssistFieldActionGroup = defineAssistFieldActionGroup;
|
|
4261
|
+
exports.defineFieldActionDivider = defineFieldActionDivider;
|
|
4262
|
+
exports.isType = isType;
|
|
4263
|
+
exports.useUserInput = useUserInput;
|
|
4264
|
+
//# sourceMappingURL=index.cjs.map
|