@ai-stack/payloadcms 3.76.0-beta.1 → 3.76.0-beta.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/ai/core/generateObject.js +1 -4
- package/dist/ai/core/generateObject.js.map +1 -1
- package/dist/ai/core/generateText.js +1 -5
- package/dist/ai/core/generateText.js.map +1 -1
- package/dist/ai/core/media/generateMedia.js +1 -4
- package/dist/ai/core/media/generateMedia.js.map +1 -1
- package/dist/ai/core/media/image/generateImage.js +4 -14
- package/dist/ai/core/media/image/generateImage.js.map +1 -1
- package/dist/ai/core/media/image/handlers/multimodal.js +8 -25
- package/dist/ai/core/media/image/handlers/multimodal.js.map +1 -1
- package/dist/ai/core/media/image/handlers/standard.js +7 -2
- package/dist/ai/core/media/image/handlers/standard.js.map +1 -1
- package/dist/ai/core/media/speech/generateSpeech.js +2 -3
- package/dist/ai/core/media/speech/generateSpeech.js.map +1 -1
- package/dist/ai/core/media/types.d.ts +2 -3
- package/dist/ai/core/media/types.js.map +1 -1
- package/dist/ai/core/streamObject.js +0 -3
- package/dist/ai/core/streamObject.js.map +1 -1
- package/dist/ai/core/streamText.js +1 -4
- package/dist/ai/core/streamText.js.map +1 -1
- package/dist/ai/core/types.d.ts +2 -2
- package/dist/ai/core/types.js.map +1 -1
- package/dist/ai/providers/blocks/anthropic.js +0 -42
- package/dist/ai/providers/blocks/anthropic.js.map +1 -1
- package/dist/ai/providers/blocks/elevenlabs.js +1 -106
- package/dist/ai/providers/blocks/elevenlabs.js.map +1 -1
- package/dist/ai/providers/blocks/fal.js +0 -118
- package/dist/ai/providers/blocks/fal.js.map +1 -1
- package/dist/ai/providers/blocks/google.js +2 -237
- package/dist/ai/providers/blocks/google.js.map +1 -1
- package/dist/ai/providers/blocks/openai-compatible.js +0 -144
- package/dist/ai/providers/blocks/openai-compatible.js.map +1 -1
- package/dist/ai/providers/blocks/openai.js +0 -200
- package/dist/ai/providers/blocks/openai.js.map +1 -1
- package/dist/ai/providers/blocks/xai.js +0 -53
- package/dist/ai/providers/blocks/xai.js.map +1 -1
- package/dist/ai/providers/index.d.ts +1 -1
- package/dist/ai/providers/index.js +0 -2
- package/dist/ai/providers/index.js.map +1 -1
- package/dist/ai/providers/registry.d.ts +24 -28
- package/dist/ai/providers/registry.js +184 -138
- package/dist/ai/providers/registry.js.map +1 -1
- package/dist/ai/providers/types.d.ts +12 -33
- package/dist/ai/providers/types.js +0 -1
- package/dist/ai/providers/types.js.map +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.js +1 -1
- package/dist/ai/schemas/lexicalJsonSchema.js.map +1 -1
- package/dist/ai/utilities/filterEditorSchemaByNodes.js.map +1 -0
- package/dist/ai/utilities/generateFileNameByPrompt.js.map +1 -0
- package/dist/ai/utilities/isObjectSchema.js.map +1 -0
- package/dist/ai/utilities/nodeToSchemaMap.js.map +1 -0
- package/dist/ai/{prompts.d.ts → utilities/prompts.d.ts} +1 -1
- package/dist/ai/utilities/prompts.js.map +1 -0
- package/dist/ai/utilities/systemGenerate.js.map +1 -0
- package/dist/collections/AIJobs.js +3 -12
- package/dist/collections/AIJobs.js.map +1 -1
- package/dist/collections/AIProviders.js +47 -20
- package/dist/collections/AIProviders.js.map +1 -1
- package/dist/collections/Instructions.js +86 -54
- package/dist/collections/Instructions.js.map +1 -1
- package/dist/collections/shared.d.ts +30 -0
- package/dist/collections/shared.js +15 -0
- package/dist/collections/shared.js.map +1 -0
- package/dist/endpoints/fetchFields.js +14 -6
- package/dist/endpoints/fetchFields.js.map +1 -1
- package/dist/endpoints/fetchVoices.js +1 -1
- package/dist/endpoints/fetchVoices.js.map +1 -1
- package/dist/endpoints/generate.d.ts +7 -0
- package/dist/endpoints/generate.js +268 -0
- package/dist/endpoints/generate.js.map +1 -0
- package/dist/endpoints/index.js +9 -639
- package/dist/endpoints/index.js.map +1 -1
- package/dist/endpoints/promptMentions.d.ts +2 -0
- package/dist/endpoints/promptMentions.js +166 -0
- package/dist/endpoints/promptMentions.js.map +1 -0
- package/dist/endpoints/upload.d.ts +7 -0
- package/dist/endpoints/upload.js +294 -0
- package/dist/endpoints/upload.js.map +1 -0
- package/dist/endpoints/videogenWebhook.d.ts +7 -0
- package/dist/endpoints/videogenWebhook.js +132 -0
- package/dist/endpoints/videogenWebhook.js.map +1 -0
- package/dist/exports/client.d.ts +2 -1
- package/dist/exports/client.js +2 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/fields.d.ts +2 -1
- package/dist/exports/fields.js +2 -1
- package/dist/exports/fields.js.map +1 -1
- package/dist/fields/ArrayComposeField/ArrayComposeField.js +1 -1
- package/dist/fields/ArrayComposeField/ArrayComposeField.js.map +1 -1
- package/dist/fields/ArrayComposeField/ArrayComposeField.jsx +1 -1
- package/dist/fields/ComposeField/ComposeField.d.ts +1 -0
- package/dist/fields/ComposeField/ComposeField.js +18 -8
- package/dist/fields/ComposeField/ComposeField.js.map +1 -1
- package/dist/fields/ComposeField/ComposeField.jsx +12 -7
- package/dist/fields/PromptEditorField/feature.client.d.ts +1 -0
- package/dist/fields/PromptEditorField/feature.client.js +173 -0
- package/dist/fields/PromptEditorField/feature.client.js.map +1 -0
- package/dist/fields/PromptEditorField/feature.client.jsx +148 -0
- package/dist/fields/PromptEditorField/feature.server.d.ts +1 -0
- package/dist/fields/PromptEditorField/feature.server.js +30 -0
- package/dist/fields/PromptEditorField/feature.server.js.map +1 -0
- package/dist/fields/PromptField.d.ts +4 -0
- package/dist/fields/PromptField.js +18 -0
- package/dist/fields/PromptField.js.map +1 -0
- package/dist/fields/SelectField/SelectField.js +0 -1
- package/dist/fields/SelectField/SelectField.js.map +1 -1
- package/dist/fields/SelectField/SelectField.jsx +0 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/libraries/handlebars/helpers.js +2 -2
- package/dist/libraries/handlebars/helpers.js.map +1 -1
- package/dist/libraries/handlebars/replacePlaceholders.js +5 -1
- package/dist/libraries/handlebars/replacePlaceholders.js.map +1 -1
- package/dist/payload-ai.d.ts +5 -19
- package/dist/plugin.js +17 -20
- package/dist/plugin.js.map +1 -1
- package/dist/providers/FieldProvider/FieldProvider.js +10 -19
- package/dist/providers/FieldProvider/FieldProvider.js.map +1 -1
- package/dist/providers/FieldProvider/FieldProvider.jsx +7 -17
- package/dist/providers/InstructionsProvider/InstructionsProvider.js +4 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.jsx +3 -0
- package/dist/translations/de.json +47 -0
- package/dist/translations/en.json +45 -2
- package/dist/translations/es.json +45 -2
- package/dist/translations/fa.json +45 -2
- package/dist/translations/fr.json +46 -3
- package/dist/translations/hi.json +47 -0
- package/dist/translations/index.d.ts +88 -26
- package/dist/translations/index.js +18 -32
- package/dist/translations/index.js.map +1 -1
- package/dist/translations/ja.json +47 -0
- package/dist/translations/nb.json +47 -0
- package/dist/translations/nl.json +47 -0
- package/dist/translations/pl.json +45 -2
- package/dist/translations/pt.json +47 -0
- package/dist/translations/ru.json +45 -2
- package/dist/translations/th.json +47 -0
- package/dist/translations/translation-schema.json +184 -11
- package/dist/translations/uk.json +45 -2
- package/dist/translations/zh.json +47 -0
- package/dist/types.d.ts +54 -28
- package/dist/types.js.map +1 -1
- package/dist/ui/Compose/Compose.js +42 -79
- package/dist/ui/Compose/Compose.js.map +1 -1
- package/dist/ui/Compose/Compose.jsx +32 -86
- package/dist/ui/Compose/ComposePlaceholder.js +1 -1
- package/dist/ui/Compose/ComposePlaceholder.js.map +1 -1
- package/dist/ui/Compose/ComposePlaceholder.jsx +1 -1
- package/dist/ui/Compose/{compose.module.css → compose.module.scss} +3 -5
- package/dist/ui/Compose/hooks/menu/Item.d.ts +1 -1
- package/dist/ui/Compose/hooks/menu/Item.js +7 -3
- package/dist/ui/Compose/hooks/menu/Item.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/Item.jsx +11 -5
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js +3 -1
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/TranslateMenu.jsx +3 -1
- package/dist/ui/Compose/hooks/menu/items.d.ts +8 -8
- package/dist/ui/Compose/hooks/menu/itemsMap.d.ts +2 -1
- package/dist/ui/Compose/hooks/menu/itemsMap.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/types.d.ts +21 -0
- package/dist/ui/Compose/hooks/menu/types.js +3 -0
- package/dist/ui/Compose/hooks/menu/types.js.map +1 -0
- package/dist/ui/Compose/hooks/menu/useMenu.d.ts +2 -2
- package/dist/ui/Compose/hooks/menu/useMenu.js +45 -23
- package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.jsx +43 -23
- package/dist/ui/Compose/hooks/mergeGeneratedValue.d.ts +14 -0
- package/dist/ui/Compose/hooks/mergeGeneratedValue.js +38 -0
- package/dist/ui/Compose/hooks/mergeGeneratedValue.js.map +1 -0
- package/dist/ui/Compose/hooks/useGenerate.js +37 -12
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Compose/hooks/useGenerateUpload.js +66 -24
- package/dist/ui/Compose/hooks/useGenerateUpload.js.map +1 -1
- package/dist/ui/Compose/hooks/useStreamingUpdate.js +4 -4
- package/dist/ui/Compose/hooks/useStreamingUpdate.js.map +1 -1
- package/dist/ui/ConfigDashboard/configDashboard.module.css +94 -0
- package/dist/ui/ConfigDashboard/index.js +27 -92
- package/dist/ui/ConfigDashboard/index.js.map +1 -1
- package/dist/ui/ConfigDashboard/index.jsx +24 -77
- package/dist/ui/DynamicModelSelect/index.js +6 -27
- package/dist/ui/DynamicModelSelect/index.js.map +1 -1
- package/dist/ui/DynamicModelSelect/index.jsx +6 -29
- package/dist/ui/DynamicProviderSelect/index.js +6 -27
- package/dist/ui/DynamicProviderSelect/index.js.map +1 -1
- package/dist/ui/DynamicProviderSelect/index.jsx +6 -29
- package/dist/ui/DynamicVoiceSelect/index.js +34 -83
- package/dist/ui/DynamicVoiceSelect/index.js.map +1 -1
- package/dist/ui/DynamicVoiceSelect/index.jsx +16 -53
- package/dist/ui/GlobalProviderOptions/index.d.ts +2 -0
- package/dist/ui/GlobalProviderOptions/index.js +118 -0
- package/dist/ui/GlobalProviderOptions/index.js.map +1 -0
- package/dist/ui/GlobalProviderOptions/index.jsx +60 -0
- package/dist/ui/Icons/Icons.js +1 -1
- package/dist/ui/Icons/Icons.js.map +1 -1
- package/dist/ui/Icons/Icons.jsx +1 -1
- package/dist/ui/Icons/LottieAnimation.js +1 -1
- package/dist/ui/Icons/LottieAnimation.js.map +1 -1
- package/dist/ui/Icons/LottieAnimation.jsx +1 -1
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.d.ts +12 -0
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.js +166 -0
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.js.map +1 -0
- package/dist/ui/InstructionProviderOptions/ProviderOptionsTree.jsx +83 -0
- package/dist/ui/InstructionProviderOptions/index.d.ts +2 -0
- package/dist/ui/InstructionProviderOptions/index.js +157 -0
- package/dist/ui/InstructionProviderOptions/index.js.map +1 -0
- package/dist/ui/InstructionProviderOptions/index.jsx +92 -0
- package/dist/ui/VoicesFetcher/index.js.map +1 -1
- package/dist/ui/hooks/useAISettings.d.ts +26 -0
- package/dist/ui/hooks/useAISettings.js +73 -0
- package/dist/ui/hooks/useAISettings.js.map +1 -0
- package/dist/ui/providerOptions/updateProviderOptionsValue.d.ts +6 -0
- package/dist/ui/providerOptions/updateProviderOptionsValue.js +50 -0
- package/dist/ui/providerOptions/updateProviderOptionsValue.js.map +1 -0
- package/dist/ui/shared/handleSelectChange.d.ts +5 -0
- package/dist/ui/shared/handleSelectChange.js +12 -0
- package/dist/ui/shared/handleSelectChange.js.map +1 -0
- package/dist/ui/shared/types.d.ts +11 -0
- package/dist/ui/shared/types.js +5 -0
- package/dist/ui/shared/types.js.map +1 -0
- package/dist/utilities/ai/resolveEffectiveInstructionSettings.d.ts +15 -0
- package/dist/utilities/ai/resolveEffectiveInstructionSettings.js +136 -0
- package/dist/utilities/ai/resolveEffectiveInstructionSettings.js.map +1 -0
- package/dist/{endpoints → utilities}/buildPromptUtils.js +14 -5
- package/dist/utilities/buildPromptUtils.js.map +1 -0
- package/dist/utilities/buildSmartPrompt.js +3 -3
- package/dist/utilities/buildSmartPrompt.js.map +1 -1
- package/dist/utilities/fields/fieldToJsonSchema.js.map +1 -0
- package/dist/utilities/fields/getFieldBySchemaPath.js.map +1 -0
- package/dist/utilities/fields/getFieldInfo.js.map +1 -0
- package/dist/utilities/{updateFieldsConfig.js → fields/updateFieldsConfig.js} +7 -2
- package/dist/utilities/fields/updateFieldsConfig.js.map +1 -0
- package/dist/utilities/images/extractImageData.js.map +1 -0
- package/dist/utilities/images/extractPromptAttachments.js.map +1 -0
- package/dist/utilities/{fetchImages.d.ts → images/fetchImages.d.ts} +1 -1
- package/dist/utilities/images/fetchImages.js +49 -0
- package/dist/utilities/images/fetchImages.js.map +1 -0
- package/dist/utilities/images/resolveImageReferences.js +183 -0
- package/dist/utilities/images/resolveImageReferences.js.map +1 -0
- package/dist/utilities/init/autoSetupProviders.d.ts +3 -0
- package/dist/utilities/init/autoSetupProviders.js +216 -0
- package/dist/utilities/init/autoSetupProviders.js.map +1 -0
- package/dist/utilities/lexical/editorSchemaValidator.js.map +1 -0
- package/dist/utilities/lexical/lexicalToHTML.js.map +1 -0
- package/dist/utilities/lexical/lexicalToPromptTemplate.d.ts +2 -0
- package/dist/utilities/lexical/lexicalToPromptTemplate.js +50 -0
- package/dist/utilities/lexical/lexicalToPromptTemplate.js.map +1 -0
- package/dist/utilities/lexical/setSafeLexicalState.js.map +1 -0
- package/dist/utilities/lexical/stringToLexicalJSON.d.ts +2 -0
- package/dist/utilities/lexical/stringToLexicalJSON.js +39 -0
- package/dist/utilities/lexical/stringToLexicalJSON.js.map +1 -0
- package/dist/utilities/sanitizeLog.d.ts +1 -0
- package/dist/utilities/sanitizeLog.js +39 -0
- package/dist/utilities/sanitizeLog.js.map +1 -0
- package/dist/utilities/seedProperties.js +37 -22
- package/dist/utilities/seedProperties.js.map +1 -1
- package/package.json +5 -2
- package/dist/ai/analyse.d.ts +0 -1
- package/dist/ai/analyse.js +0 -3
- package/dist/ai/analyse.js.map +0 -1
- package/dist/ai/index.d.ts +0 -11
- package/dist/ai/index.js +0 -25
- package/dist/ai/index.js.map +0 -1
- package/dist/ai/prompts.js.map +0 -1
- package/dist/ai/utils/filterEditorSchemaByNodes.js.map +0 -1
- package/dist/ai/utils/generateFileNameByPrompt.js.map +0 -1
- package/dist/ai/utils/isObjectSchema.js.map +0 -1
- package/dist/ai/utils/nodeToSchemaMap.js.map +0 -1
- package/dist/ai/utils/systemGenerate.js.map +0 -1
- package/dist/endpoints/buildPromptUtils.js.map +0 -1
- package/dist/endpoints/chat.d.ts +0 -4
- package/dist/fields/PromptEditorField/PromptEditorField.d.ts +0 -3
- package/dist/fields/PromptEditorField/PromptEditorField.js +0 -217
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +0 -1
- package/dist/fields/PromptEditorField/PromptEditorField.jsx +0 -160
- package/dist/ui/AIConfigDashboard/index.d.ts +0 -2
- package/dist/ui/AIConfigDashboard/index.js +0 -224
- package/dist/ui/AIConfigDashboard/index.js.map +0 -1
- package/dist/ui/AIConfigDashboard/index.jsx +0 -175
- package/dist/ui/ProviderOptionsEditor/index.d.ts +0 -7
- package/dist/ui/ProviderOptionsEditor/index.js +0 -291
- package/dist/ui/ProviderOptionsEditor/index.js.map +0 -1
- package/dist/ui/ProviderOptionsEditor/index.jsx +0 -210
- package/dist/utilities/editorSchemaValidator.js.map +0 -1
- package/dist/utilities/extractImageData.js.map +0 -1
- package/dist/utilities/extractPromptAttachments.js.map +0 -1
- package/dist/utilities/fetchImages.js +0 -38
- package/dist/utilities/fetchImages.js.map +0 -1
- package/dist/utilities/fieldToJsonSchema.js.map +0 -1
- package/dist/utilities/getFieldBySchemaPath.js.map +0 -1
- package/dist/utilities/getFieldInfo.js.map +0 -1
- package/dist/utilities/getProviderOptionsFields.d.ts +0 -16
- package/dist/utilities/getProviderOptionsFields.js +0 -80
- package/dist/utilities/getProviderOptionsFields.js.map +0 -1
- package/dist/utilities/isPluginActivated.d.ts +0 -2
- package/dist/utilities/isPluginActivated.js +0 -5
- package/dist/utilities/isPluginActivated.js.map +0 -1
- package/dist/utilities/lexicalToHTML.js.map +0 -1
- package/dist/utilities/resolveImageReferences.js +0 -167
- package/dist/utilities/resolveImageReferences.js.map +0 -1
- package/dist/utilities/schemaConverter.d.ts +0 -3
- package/dist/utilities/schemaConverter.js +0 -93
- package/dist/utilities/schemaConverter.js.map +0 -1
- package/dist/utilities/setSafeLexicalState.js.map +0 -1
- package/dist/utilities/updateFieldsConfig.js.map +0 -1
- /package/dist/ai/{utils → utilities}/filterEditorSchemaByNodes.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/filterEditorSchemaByNodes.js +0 -0
- /package/dist/ai/{utils → utilities}/generateFileNameByPrompt.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/generateFileNameByPrompt.js +0 -0
- /package/dist/ai/{utils → utilities}/isObjectSchema.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/isObjectSchema.js +0 -0
- /package/dist/ai/{utils → utilities}/nodeToSchemaMap.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/nodeToSchemaMap.js +0 -0
- /package/dist/ai/{prompts.js → utilities/prompts.js} +0 -0
- /package/dist/ai/{utils → utilities}/systemGenerate.d.ts +0 -0
- /package/dist/ai/{utils → utilities}/systemGenerate.js +0 -0
- /package/dist/ui/Icons/{icons.module.css → icons.module.scss} +0 -0
- /package/dist/{endpoints → utilities}/buildPromptUtils.d.ts +0 -0
- /package/dist/utilities/{fieldToJsonSchema.d.ts → fields/fieldToJsonSchema.d.ts} +0 -0
- /package/dist/utilities/{fieldToJsonSchema.js → fields/fieldToJsonSchema.js} +0 -0
- /package/dist/utilities/{getFieldBySchemaPath.d.ts → fields/getFieldBySchemaPath.d.ts} +0 -0
- /package/dist/utilities/{getFieldBySchemaPath.js → fields/getFieldBySchemaPath.js} +0 -0
- /package/dist/utilities/{getFieldInfo.d.ts → fields/getFieldInfo.d.ts} +0 -0
- /package/dist/utilities/{getFieldInfo.js → fields/getFieldInfo.js} +0 -0
- /package/dist/utilities/{updateFieldsConfig.d.ts → fields/updateFieldsConfig.d.ts} +0 -0
- /package/dist/utilities/{extractImageData.d.ts → images/extractImageData.d.ts} +0 -0
- /package/dist/utilities/{extractImageData.js → images/extractImageData.js} +0 -0
- /package/dist/utilities/{extractPromptAttachments.d.ts → images/extractPromptAttachments.d.ts} +0 -0
- /package/dist/utilities/{extractPromptAttachments.js → images/extractPromptAttachments.js} +0 -0
- /package/dist/utilities/{resolveImageReferences.d.ts → images/resolveImageReferences.d.ts} +0 -0
- /package/dist/utilities/{editorSchemaValidator.d.ts → lexical/editorSchemaValidator.d.ts} +0 -0
- /package/dist/utilities/{editorSchemaValidator.js → lexical/editorSchemaValidator.js} +0 -0
- /package/dist/utilities/{lexicalToHTML.d.ts → lexical/lexicalToHTML.d.ts} +0 -0
- /package/dist/utilities/{lexicalToHTML.js → lexical/lexicalToHTML.js} +0 -0
- /package/dist/utilities/{setSafeLexicalState.d.ts → lexical/setSafeLexicalState.d.ts} +0 -0
- /package/dist/utilities/{setSafeLexicalState.js → lexical/setSafeLexicalState.js} +0 -0
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { FieldDescription, FieldLabel, useConfig, useField } from '@payloadcms/ui';
|
|
4
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
5
|
-
import { Mention, MentionsInput } from 'react-mentions/dist/react-mentions.cjs.js';
|
|
6
|
-
import { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js';
|
|
7
|
-
import { defaultStyle } from './defaultStyle.js';
|
|
8
|
-
export const PromptEditorField = (props)=>{
|
|
9
|
-
const { field, path: pathFromContext } = props;
|
|
10
|
-
const { setValue, value: payloadValue } = useField({
|
|
11
|
-
path: pathFromContext
|
|
12
|
-
});
|
|
13
|
-
const [localValue, setLocalValue] = useState(payloadValue || '');
|
|
14
|
-
const hasInitialized = useRef(false);
|
|
15
|
-
const { activeCollection, promptEditorSuggestions } = useInstructions();
|
|
16
|
-
const { config } = useConfig();
|
|
17
|
-
const suggestions = useMemo(()=>promptEditorSuggestions.map((suggestion)=>({
|
|
18
|
-
id: suggestion,
|
|
19
|
-
display: suggestion
|
|
20
|
-
})), [
|
|
21
|
-
promptEditorSuggestions
|
|
22
|
-
]);
|
|
23
|
-
// Extract document ID from URL if available (to get specific filenames)
|
|
24
|
-
const [documentData, setDocumentData] = useState(null);
|
|
25
|
-
useEffect(()=>{
|
|
26
|
-
// Only run in browser
|
|
27
|
-
if (typeof window === 'undefined') {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
// Allow time for verify window.location is stable (unlikely to change but good practice)
|
|
31
|
-
const segments = window.location.pathname.split('/');
|
|
32
|
-
const collectionsIndex = segments.indexOf('collections');
|
|
33
|
-
if (collectionsIndex > -1 && segments.length > collectionsIndex + 2) {
|
|
34
|
-
const urlCollectionSlug = segments[collectionsIndex + 1];
|
|
35
|
-
const urlId = segments[collectionsIndex + 2];
|
|
36
|
-
// Only fetch if we are editing instructions for the same collection we are viewing
|
|
37
|
-
// and we haven't fetched yet (or ID changed)
|
|
38
|
-
if (urlCollectionSlug === activeCollection && urlId && urlId !== 'create') {
|
|
39
|
-
const fetchDocument = async ()=>{
|
|
40
|
-
try {
|
|
41
|
-
const response = await fetch(`${String(config.serverURL)}${String(config.routes.api)}/${String(urlCollectionSlug)}/${String(urlId)}`);
|
|
42
|
-
if (response.ok) {
|
|
43
|
-
const data = await response.json();
|
|
44
|
-
setDocumentData(data);
|
|
45
|
-
}
|
|
46
|
-
} catch (_err) {
|
|
47
|
-
// Ignore error
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
void fetchDocument();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}, [
|
|
54
|
-
activeCollection,
|
|
55
|
-
config
|
|
56
|
-
]);
|
|
57
|
-
// Extract all upload fields from the current collection schema
|
|
58
|
-
const imageFieldSuggestions = useMemo(()=>{
|
|
59
|
-
const suggestions = [];
|
|
60
|
-
// Use activeCollection from context which holds the target collection slug
|
|
61
|
-
const targetSlug = activeCollection;
|
|
62
|
-
if (!targetSlug || !config?.collections) {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
const collection = config.collections.find((c)=>c.slug === targetSlug);
|
|
66
|
-
if (!collection?.fields) {
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
|
-
const uploadFields = [];
|
|
70
|
-
// Recursive function to find upload fields
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
-
const findUploadFields = (fields, prefix = '')=>{
|
|
73
|
-
for (const field of fields){
|
|
74
|
-
if (field.type === 'upload' && field.name) {
|
|
75
|
-
const fieldPath = prefix ? `${prefix}.${String(field.name)}` : String(field.name);
|
|
76
|
-
uploadFields.push({
|
|
77
|
-
name: fieldPath,
|
|
78
|
-
hasMany: field.hasMany === true
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
// Check nested fields in groups, arrays, etc.
|
|
82
|
-
if (field.fields && Array.isArray(field.fields)) {
|
|
83
|
-
const newPrefix = field.name ? prefix ? `${prefix}.${String(field.name)}` : String(field.name) : prefix;
|
|
84
|
-
findUploadFields(field.fields, newPrefix);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
findUploadFields(collection.fields);
|
|
89
|
-
// Add generic field names (base suggestions) - ONLY for single uploads (not hasMany arrays)
|
|
90
|
-
uploadFields.forEach(({ name, hasMany })=>{
|
|
91
|
-
// User requested to hide the array itself for hasMany fields
|
|
92
|
-
if (!hasMany) {
|
|
93
|
-
suggestions.push({
|
|
94
|
-
id: name,
|
|
95
|
-
display: name
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
// If we have document data, add specific filename suggestions
|
|
100
|
-
if (documentData) {
|
|
101
|
-
uploadFields.forEach(({ name, hasMany })=>{
|
|
102
|
-
const value = documentData[name] // Note: nested access logic simplified for now
|
|
103
|
-
;
|
|
104
|
-
// Helper to extract filename from media doc (which might be ID or object)
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
-
const getFilename = (item)=>{
|
|
107
|
-
if (typeof item === 'object' && item && (item.filename || item.name)) {
|
|
108
|
-
return item.filename || item.name;
|
|
109
|
-
}
|
|
110
|
-
// If it's just an ID, we can't show filename without populating.
|
|
111
|
-
// Assuming compose view usually fetches with depth > 0 or we rely on what we have.
|
|
112
|
-
return null;
|
|
113
|
-
};
|
|
114
|
-
if (value) {
|
|
115
|
-
if (hasMany && Array.isArray(value)) {
|
|
116
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
-
value.forEach((item)=>{
|
|
118
|
-
const fname = getFilename(item);
|
|
119
|
-
if (fname) {
|
|
120
|
-
const suggestion = `${name}:${fname}`;
|
|
121
|
-
suggestions.push({
|
|
122
|
-
id: suggestion,
|
|
123
|
-
display: suggestion
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
} else if (!hasMany) {
|
|
128
|
-
// Single image - we already added the base name above.
|
|
129
|
-
// We can optionally add the specific filename too if desired,
|
|
130
|
-
// but user request focused on arrays.
|
|
131
|
-
// Adding the specific filename option for Single images too as it's explicit.
|
|
132
|
-
const fname = getFilename(value);
|
|
133
|
-
if (fname) {
|
|
134
|
-
const suggestion = `${name}:${fname}`;
|
|
135
|
-
suggestions.push({
|
|
136
|
-
id: suggestion,
|
|
137
|
-
display: suggestion
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
return suggestions;
|
|
145
|
-
}, [
|
|
146
|
-
activeCollection,
|
|
147
|
-
config,
|
|
148
|
-
documentData
|
|
149
|
-
]);
|
|
150
|
-
useEffect(()=>{
|
|
151
|
-
if (!hasInitialized.current || payloadValue === '') {
|
|
152
|
-
setLocalValue(payloadValue || '');
|
|
153
|
-
hasInitialized.current = true;
|
|
154
|
-
}
|
|
155
|
-
}, [
|
|
156
|
-
payloadValue
|
|
157
|
-
]);
|
|
158
|
-
const handleChange = useCallback((e)=>{
|
|
159
|
-
const newValue = e.target.value;
|
|
160
|
-
setLocalValue(newValue);
|
|
161
|
-
// Also update Payload value immediately to prevent loss when Save is clicked
|
|
162
|
-
setValue(newValue);
|
|
163
|
-
}, [
|
|
164
|
-
setValue
|
|
165
|
-
]);
|
|
166
|
-
const handleBlur = useCallback(()=>{
|
|
167
|
-
setValue(localValue);
|
|
168
|
-
}, [
|
|
169
|
-
localValue,
|
|
170
|
-
setValue
|
|
171
|
-
]);
|
|
172
|
-
const displayTransform = useCallback((id)=>`{{ ${id} }}`, []);
|
|
173
|
-
const imageDisplayTransform = useCallback((id)=>`@${id}`, []);
|
|
174
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
175
|
-
className: "field-type textarea",
|
|
176
|
-
children: [
|
|
177
|
-
/*#__PURE__*/ _jsx(FieldLabel, {
|
|
178
|
-
label: field.label
|
|
179
|
-
}),
|
|
180
|
-
/*#__PURE__*/ _jsxs(MentionsInput, {
|
|
181
|
-
onBlur: handleBlur,
|
|
182
|
-
onChange: handleChange,
|
|
183
|
-
placeholder: "Type {{ for fields }} or @imageField for images. For specific images use @imageField:filename.jpg",
|
|
184
|
-
style: defaultStyle,
|
|
185
|
-
value: localValue,
|
|
186
|
-
children: [
|
|
187
|
-
/*#__PURE__*/ _jsx(Mention, {
|
|
188
|
-
data: suggestions,
|
|
189
|
-
displayTransform: displayTransform,
|
|
190
|
-
markup: "{{__id__}}",
|
|
191
|
-
style: {
|
|
192
|
-
backgroundColor: 'var(--theme-elevation-100)',
|
|
193
|
-
padding: '2px 0'
|
|
194
|
-
},
|
|
195
|
-
trigger: "{"
|
|
196
|
-
}),
|
|
197
|
-
/*#__PURE__*/ _jsx(Mention, {
|
|
198
|
-
data: imageFieldSuggestions,
|
|
199
|
-
displayTransform: imageDisplayTransform,
|
|
200
|
-
markup: "@__id__",
|
|
201
|
-
style: {
|
|
202
|
-
backgroundColor: 'var(--theme-elevation-150)',
|
|
203
|
-
padding: '2px 0'
|
|
204
|
-
},
|
|
205
|
-
trigger: "@"
|
|
206
|
-
})
|
|
207
|
-
]
|
|
208
|
-
}),
|
|
209
|
-
/*#__PURE__*/ _jsx(FieldDescription, {
|
|
210
|
-
description: field?.admin?.description,
|
|
211
|
-
path: ""
|
|
212
|
-
})
|
|
213
|
-
]
|
|
214
|
-
});
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
//# sourceMappingURL=PromptEditorField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/PromptEditorField/PromptEditorField.tsx"],"sourcesContent":["'use client'\n\nimport type { TextareaFieldClientProps } from 'payload'\n\nimport { FieldDescription, FieldLabel, useConfig, useField } from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Mention, MentionsInput } from 'react-mentions/dist/react-mentions.cjs.js'\n\nimport { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js'\nimport { defaultStyle } from './defaultStyle.js'\n\nexport const PromptEditorField: React.FC<TextareaFieldClientProps> = (props) => {\n const { field, path: pathFromContext } = props\n const { setValue, value: payloadValue } = useField<string>({\n path: pathFromContext,\n })\n\n const [localValue, setLocalValue] = useState(payloadValue || '')\n const hasInitialized = useRef(false)\n\n const { activeCollection, promptEditorSuggestions } = useInstructions()\n const { config } = useConfig()\n\n const suggestions = useMemo(\n () =>\n promptEditorSuggestions.map((suggestion: string) => ({\n id: suggestion,\n display: suggestion,\n })),\n [promptEditorSuggestions],\n )\n\n // Extract document ID from URL if available (to get specific filenames)\n const [documentData, setDocumentData] = useState<null | Record<string, unknown>>(null)\n \n useEffect(() => {\n // Only run in browser\n if (typeof window === 'undefined') {\n return\n }\n\n // Allow time for verify window.location is stable (unlikely to change but good practice)\n const segments = window.location.pathname.split('/')\n const collectionsIndex = segments.indexOf('collections')\n \n if (collectionsIndex > -1 && segments.length > collectionsIndex + 2) {\n const urlCollectionSlug = segments[collectionsIndex + 1]\n const urlId = segments[collectionsIndex + 2]\n\n // Only fetch if we are editing instructions for the same collection we are viewing\n // and we haven't fetched yet (or ID changed)\n if (urlCollectionSlug === activeCollection && urlId && urlId !== 'create') {\n const fetchDocument = async () => {\n try {\n \n const response = await fetch(`${String(config.serverURL)}${String(config.routes.api)}/${String(urlCollectionSlug)}/${String(urlId)}`)\n if (response.ok) {\n const data = await response.json()\n setDocumentData(data)\n }\n } catch (_err) {\n // Ignore error\n }\n }\n void fetchDocument()\n }\n }\n }, [activeCollection, config])\n\n // Extract all upload fields from the current collection schema\n const imageFieldSuggestions = useMemo(() => {\n const suggestions: { display: string; id: string }[] = []\n \n // Use activeCollection from context which holds the target collection slug\n const targetSlug = activeCollection\n \n if (!targetSlug || !config?.collections) {\n return []\n }\n\n const collection = config.collections.find((c) => c.slug === targetSlug)\n if (!collection?.fields) {\n return []\n }\n\n const uploadFields: { hasMany: boolean; name: string }[] = []\n\n // Recursive function to find upload fields\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const findUploadFields = (fields: any[], prefix = ''): void => {\n for (const field of fields) {\n if (field.type === 'upload' && field.name) {\n const fieldPath = prefix ? `${prefix}.${String(field.name)}` : String(field.name)\n uploadFields.push({ name: fieldPath, hasMany: field.hasMany === true })\n }\n // Check nested fields in groups, arrays, etc.\n if (field.fields && Array.isArray(field.fields)) {\n const newPrefix = field.name ? (prefix ? `${prefix}.${String(field.name)}` : String(field.name)) : prefix\n findUploadFields(field.fields, newPrefix)\n }\n }\n }\n\n findUploadFields(collection.fields)\n \n // Add generic field names (base suggestions) - ONLY for single uploads (not hasMany arrays)\n uploadFields.forEach(({ name, hasMany }) => {\n // User requested to hide the array itself for hasMany fields\n if (!hasMany) {\n suggestions.push({ id: name, display: name })\n }\n })\n\n // If we have document data, add specific filename suggestions\n if (documentData) {\n uploadFields.forEach(({ name, hasMany }) => {\n const value = documentData[name] // Note: nested access logic simplified for now\n \n // Helper to extract filename from media doc (which might be ID or object)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const getFilename = (item: any): null | string => {\n if (typeof item === 'object' && item && (item.filename || item.name)) {\n return item.filename || item.name\n }\n // If it's just an ID, we can't show filename without populating. \n // Assuming compose view usually fetches with depth > 0 or we rely on what we have.\n return null\n }\n\n if (value) {\n if (hasMany && Array.isArray(value)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n value.forEach((item: any) => {\n const fname = getFilename(item)\n if (fname) {\n const suggestion = `${name}:${fname}`\n suggestions.push({ id: suggestion, display: suggestion })\n }\n })\n } else if (!hasMany) {\n // Single image - we already added the base name above.\n // We can optionally add the specific filename too if desired, \n // but user request focused on arrays.\n // Adding the specific filename option for Single images too as it's explicit.\n const fname = getFilename(value)\n if (fname) {\n const suggestion = `${name}:${fname}`\n suggestions.push({ id: suggestion, display: suggestion })\n }\n }\n }\n })\n }\n \n return suggestions\n }, [activeCollection, config, documentData])\n\n useEffect(() => {\n if (!hasInitialized.current || payloadValue === '') {\n setLocalValue(payloadValue || '')\n hasInitialized.current = true\n }\n }, [payloadValue])\n\n const handleChange = useCallback((e: React.ChangeEvent<HTMLTextAreaElement>) => {\n const newValue = e.target.value\n setLocalValue(newValue)\n // Also update Payload value immediately to prevent loss when Save is clicked\n setValue(newValue)\n }, [setValue])\n\n const handleBlur = useCallback(() => {\n setValue(localValue)\n }, [localValue, setValue])\n\n const displayTransform = useCallback((id: string) => `{{ ${id} }}`, [])\n const imageDisplayTransform = useCallback((id: string) => `@${id}`, [])\n\n return (\n <div className=\"field-type textarea\">\n <FieldLabel label={field.label} />\n <MentionsInput\n onBlur={handleBlur}\n onChange={handleChange}\n placeholder=\"Type {{ for fields }} or @imageField for images. For specific images use @imageField:filename.jpg\"\n style={defaultStyle}\n value={localValue}\n >\n <Mention\n data={suggestions}\n displayTransform={displayTransform}\n markup=\"{{__id__}}\"\n style={{\n backgroundColor: 'var(--theme-elevation-100)',\n padding: '2px 0',\n }}\n trigger=\"{\"\n />\n <Mention\n data={imageFieldSuggestions}\n displayTransform={imageDisplayTransform}\n markup=\"@__id__\"\n style={{\n backgroundColor: 'var(--theme-elevation-150)',\n padding: '2px 0',\n }}\n trigger=\"@\"\n />\n </MentionsInput>\n <FieldDescription description={field?.admin?.description} path=\"\" />\n </div>\n )\n}\n"],"names":["FieldDescription","FieldLabel","useConfig","useField","React","useCallback","useEffect","useMemo","useRef","useState","Mention","MentionsInput","useInstructions","defaultStyle","PromptEditorField","props","field","path","pathFromContext","setValue","value","payloadValue","localValue","setLocalValue","hasInitialized","activeCollection","promptEditorSuggestions","config","suggestions","map","suggestion","id","display","documentData","setDocumentData","window","segments","location","pathname","split","collectionsIndex","indexOf","length","urlCollectionSlug","urlId","fetchDocument","response","fetch","String","serverURL","routes","api","ok","data","json","_err","imageFieldSuggestions","targetSlug","collections","collection","find","c","slug","fields","uploadFields","findUploadFields","prefix","type","name","fieldPath","push","hasMany","Array","isArray","newPrefix","forEach","getFilename","item","filename","fname","current","handleChange","e","newValue","target","handleBlur","displayTransform","imageDisplayTransform","div","className","label","onBlur","onChange","placeholder","style","markup","backgroundColor","padding","trigger","description","admin"],"mappings":"AAAA;;AAIA,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,iBAAgB;AAClF,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QA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AiB;4BACjBC,SAAS;wBACX;wBACAC,SAAQ;;;;0BAGZ,KAAClG;gBAAiBmG,aAAanF,OAAOoF,OAAOD;gBAAalF,MAAK;;;;AAGrE,EAAC"}
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { FieldDescription, FieldLabel, useConfig, useField } from '@payloadcms/ui';
|
|
3
|
-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
-
import { Mention, MentionsInput } from 'react-mentions/dist/react-mentions.cjs.js';
|
|
5
|
-
import { useInstructions } from '../../providers/InstructionsProvider/useInstructions.js';
|
|
6
|
-
import { defaultStyle } from './defaultStyle.js';
|
|
7
|
-
export const PromptEditorField = (props) => {
|
|
8
|
-
const { field, path: pathFromContext } = props;
|
|
9
|
-
const { setValue, value: payloadValue } = useField({
|
|
10
|
-
path: pathFromContext,
|
|
11
|
-
});
|
|
12
|
-
const [localValue, setLocalValue] = useState(payloadValue || '');
|
|
13
|
-
const hasInitialized = useRef(false);
|
|
14
|
-
const { activeCollection, promptEditorSuggestions } = useInstructions();
|
|
15
|
-
const { config } = useConfig();
|
|
16
|
-
const suggestions = useMemo(() => promptEditorSuggestions.map((suggestion) => ({
|
|
17
|
-
id: suggestion,
|
|
18
|
-
display: suggestion,
|
|
19
|
-
})), [promptEditorSuggestions]);
|
|
20
|
-
// Extract document ID from URL if available (to get specific filenames)
|
|
21
|
-
const [documentData, setDocumentData] = useState(null);
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
// Only run in browser
|
|
24
|
-
if (typeof window === 'undefined') {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
// Allow time for verify window.location is stable (unlikely to change but good practice)
|
|
28
|
-
const segments = window.location.pathname.split('/');
|
|
29
|
-
const collectionsIndex = segments.indexOf('collections');
|
|
30
|
-
if (collectionsIndex > -1 && segments.length > collectionsIndex + 2) {
|
|
31
|
-
const urlCollectionSlug = segments[collectionsIndex + 1];
|
|
32
|
-
const urlId = segments[collectionsIndex + 2];
|
|
33
|
-
// Only fetch if we are editing instructions for the same collection we are viewing
|
|
34
|
-
// and we haven't fetched yet (or ID changed)
|
|
35
|
-
if (urlCollectionSlug === activeCollection && urlId && urlId !== 'create') {
|
|
36
|
-
const fetchDocument = async () => {
|
|
37
|
-
try {
|
|
38
|
-
const response = await fetch(`${String(config.serverURL)}${String(config.routes.api)}/${String(urlCollectionSlug)}/${String(urlId)}`);
|
|
39
|
-
if (response.ok) {
|
|
40
|
-
const data = await response.json();
|
|
41
|
-
setDocumentData(data);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
catch (_err) {
|
|
45
|
-
// Ignore error
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
void fetchDocument();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, [activeCollection, config]);
|
|
52
|
-
// Extract all upload fields from the current collection schema
|
|
53
|
-
const imageFieldSuggestions = useMemo(() => {
|
|
54
|
-
const suggestions = [];
|
|
55
|
-
// Use activeCollection from context which holds the target collection slug
|
|
56
|
-
const targetSlug = activeCollection;
|
|
57
|
-
if (!targetSlug || !config?.collections) {
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
const collection = config.collections.find((c) => c.slug === targetSlug);
|
|
61
|
-
if (!collection?.fields) {
|
|
62
|
-
return [];
|
|
63
|
-
}
|
|
64
|
-
const uploadFields = [];
|
|
65
|
-
// Recursive function to find upload fields
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
-
const findUploadFields = (fields, prefix = '') => {
|
|
68
|
-
for (const field of fields) {
|
|
69
|
-
if (field.type === 'upload' && field.name) {
|
|
70
|
-
const fieldPath = prefix ? `${prefix}.${String(field.name)}` : String(field.name);
|
|
71
|
-
uploadFields.push({ name: fieldPath, hasMany: field.hasMany === true });
|
|
72
|
-
}
|
|
73
|
-
// Check nested fields in groups, arrays, etc.
|
|
74
|
-
if (field.fields && Array.isArray(field.fields)) {
|
|
75
|
-
const newPrefix = field.name ? (prefix ? `${prefix}.${String(field.name)}` : String(field.name)) : prefix;
|
|
76
|
-
findUploadFields(field.fields, newPrefix);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
findUploadFields(collection.fields);
|
|
81
|
-
// Add generic field names (base suggestions) - ONLY for single uploads (not hasMany arrays)
|
|
82
|
-
uploadFields.forEach(({ name, hasMany }) => {
|
|
83
|
-
// User requested to hide the array itself for hasMany fields
|
|
84
|
-
if (!hasMany) {
|
|
85
|
-
suggestions.push({ id: name, display: name });
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
// If we have document data, add specific filename suggestions
|
|
89
|
-
if (documentData) {
|
|
90
|
-
uploadFields.forEach(({ name, hasMany }) => {
|
|
91
|
-
const value = documentData[name]; // Note: nested access logic simplified for now
|
|
92
|
-
// Helper to extract filename from media doc (which might be ID or object)
|
|
93
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
|
-
const getFilename = (item) => {
|
|
95
|
-
if (typeof item === 'object' && item && (item.filename || item.name)) {
|
|
96
|
-
return item.filename || item.name;
|
|
97
|
-
}
|
|
98
|
-
// If it's just an ID, we can't show filename without populating.
|
|
99
|
-
// Assuming compose view usually fetches with depth > 0 or we rely on what we have.
|
|
100
|
-
return null;
|
|
101
|
-
};
|
|
102
|
-
if (value) {
|
|
103
|
-
if (hasMany && Array.isArray(value)) {
|
|
104
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
105
|
-
value.forEach((item) => {
|
|
106
|
-
const fname = getFilename(item);
|
|
107
|
-
if (fname) {
|
|
108
|
-
const suggestion = `${name}:${fname}`;
|
|
109
|
-
suggestions.push({ id: suggestion, display: suggestion });
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
else if (!hasMany) {
|
|
114
|
-
// Single image - we already added the base name above.
|
|
115
|
-
// We can optionally add the specific filename too if desired,
|
|
116
|
-
// but user request focused on arrays.
|
|
117
|
-
// Adding the specific filename option for Single images too as it's explicit.
|
|
118
|
-
const fname = getFilename(value);
|
|
119
|
-
if (fname) {
|
|
120
|
-
const suggestion = `${name}:${fname}`;
|
|
121
|
-
suggestions.push({ id: suggestion, display: suggestion });
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return suggestions;
|
|
128
|
-
}, [activeCollection, config, documentData]);
|
|
129
|
-
useEffect(() => {
|
|
130
|
-
if (!hasInitialized.current || payloadValue === '') {
|
|
131
|
-
setLocalValue(payloadValue || '');
|
|
132
|
-
hasInitialized.current = true;
|
|
133
|
-
}
|
|
134
|
-
}, [payloadValue]);
|
|
135
|
-
const handleChange = useCallback((e) => {
|
|
136
|
-
const newValue = e.target.value;
|
|
137
|
-
setLocalValue(newValue);
|
|
138
|
-
// Also update Payload value immediately to prevent loss when Save is clicked
|
|
139
|
-
setValue(newValue);
|
|
140
|
-
}, [setValue]);
|
|
141
|
-
const handleBlur = useCallback(() => {
|
|
142
|
-
setValue(localValue);
|
|
143
|
-
}, [localValue, setValue]);
|
|
144
|
-
const displayTransform = useCallback((id) => `{{ ${id} }}`, []);
|
|
145
|
-
const imageDisplayTransform = useCallback((id) => `@${id}`, []);
|
|
146
|
-
return (<div className="field-type textarea">
|
|
147
|
-
<FieldLabel label={field.label}/>
|
|
148
|
-
<MentionsInput onBlur={handleBlur} onChange={handleChange} placeholder="Type {{ for fields }} or @imageField for images. For specific images use @imageField:filename.jpg" style={defaultStyle} value={localValue}>
|
|
149
|
-
<Mention data={suggestions} displayTransform={displayTransform} markup="{{__id__}}" style={{
|
|
150
|
-
backgroundColor: 'var(--theme-elevation-100)',
|
|
151
|
-
padding: '2px 0',
|
|
152
|
-
}} trigger="{"/>
|
|
153
|
-
<Mention data={imageFieldSuggestions} displayTransform={imageDisplayTransform} markup="@__id__" style={{
|
|
154
|
-
backgroundColor: 'var(--theme-elevation-150)',
|
|
155
|
-
padding: '2px 0',
|
|
156
|
-
}} trigger="@"/>
|
|
157
|
-
</MentionsInput>
|
|
158
|
-
<FieldDescription description={field?.admin?.description} path=""/>
|
|
159
|
-
</div>);
|
|
160
|
-
};
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button, toast, useConfig } from '@payloadcms/ui';
|
|
4
|
-
// @ts-expect-error - Next.js types are not resolving correctly with nodenext but runtime is fine
|
|
5
|
-
import { useRouter } from 'next/navigation';
|
|
6
|
-
import React, { use, useEffect, useState } from 'react';
|
|
7
|
-
import { excludeCollections } from '../../defaults.js';
|
|
8
|
-
import { InstructionsContext } from '../../providers/InstructionsProvider/context.js';
|
|
9
|
-
export const ConfigDashboard = ()=>{
|
|
10
|
-
const { config: { collections, routes: { admin: adminRoute, api: apiRoute } } } = useConfig();
|
|
11
|
-
const router = useRouter();
|
|
12
|
-
const { refresh, setEnabledCollections: setEnabledCollectionsInContext } = use(InstructionsContext);
|
|
13
|
-
const [enabledCollections, setEnabledCollections] = useState([]);
|
|
14
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
15
|
-
const [isSaving, setIsSaving] = useState(false);
|
|
16
|
-
const availableCollections = collections.filter((c)=>!excludeCollections.includes(c.slug) && !c.admin?.hidden);
|
|
17
|
-
useEffect(()=>{
|
|
18
|
-
const fetchSettings = async ()=>{
|
|
19
|
-
try {
|
|
20
|
-
const response = await fetch(`${apiRoute}/globals/ai-providers`);
|
|
21
|
-
if (response.ok) {
|
|
22
|
-
const data = await response.json();
|
|
23
|
-
// Handle both simple array and object wrapper if Payload wraps it
|
|
24
|
-
const storedEnabled = data.enabledCollections || [];
|
|
25
|
-
setEnabledCollections(Array.isArray(storedEnabled) ? storedEnabled : []);
|
|
26
|
-
}
|
|
27
|
-
} catch (error) {
|
|
28
|
-
console.error('Failed to fetch AI settings:', error);
|
|
29
|
-
} finally{
|
|
30
|
-
setIsLoading(false);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
fetchSettings().catch((e)=>{
|
|
34
|
-
console.log(e);
|
|
35
|
-
});
|
|
36
|
-
}, [
|
|
37
|
-
apiRoute
|
|
38
|
-
]);
|
|
39
|
-
const handleToggle = (slug)=>{
|
|
40
|
-
setEnabledCollections((prev)=>{
|
|
41
|
-
if (prev.includes(slug)) {
|
|
42
|
-
return prev.filter((s)=>s !== slug);
|
|
43
|
-
}
|
|
44
|
-
return [
|
|
45
|
-
...prev,
|
|
46
|
-
slug
|
|
47
|
-
];
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
const handleSave = async ()=>{
|
|
51
|
-
setIsSaving(true);
|
|
52
|
-
try {
|
|
53
|
-
// First fetch current settings to get ID or just rely on global update behavior
|
|
54
|
-
// We need to adhere to Payload's global update API
|
|
55
|
-
const response = await fetch(`${apiRoute}/globals/ai-providers`, {
|
|
56
|
-
body: JSON.stringify({
|
|
57
|
-
enabledCollections
|
|
58
|
-
}),
|
|
59
|
-
headers: {
|
|
60
|
-
'Content-Type': 'application/json'
|
|
61
|
-
},
|
|
62
|
-
method: 'POST'
|
|
63
|
-
});
|
|
64
|
-
if (response.ok) {
|
|
65
|
-
toast.success('Settings saved successfully');
|
|
66
|
-
if (setEnabledCollectionsInContext) {
|
|
67
|
-
setEnabledCollectionsInContext(enabledCollections);
|
|
68
|
-
}
|
|
69
|
-
if (refresh) {
|
|
70
|
-
await refresh();
|
|
71
|
-
}
|
|
72
|
-
router.refresh();
|
|
73
|
-
} else {
|
|
74
|
-
toast.error('Failed to save settings');
|
|
75
|
-
}
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error('Error saving settings:', error);
|
|
78
|
-
toast.error('Error saving settings');
|
|
79
|
-
} finally{
|
|
80
|
-
setIsSaving(false);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
if (isLoading) {
|
|
84
|
-
return /*#__PURE__*/ _jsx("div", {
|
|
85
|
-
style: {
|
|
86
|
-
padding: '20px',
|
|
87
|
-
textAlign: 'center'
|
|
88
|
-
},
|
|
89
|
-
children: "Loading configuration..."
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
93
|
-
style: {
|
|
94
|
-
background: 'var(--theme-elevation-50)',
|
|
95
|
-
// border: '1px solid var(--theme-elevation-150)',
|
|
96
|
-
// borderRadius: '8px',
|
|
97
|
-
// borderBottom: '1px solid var(--theme-elevation-150)',
|
|
98
|
-
// borderTop: '1px solid var(--theme-elevation-150)',
|
|
99
|
-
marginBottom: '20px',
|
|
100
|
-
overflow: 'hidden'
|
|
101
|
-
},
|
|
102
|
-
children: [
|
|
103
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
104
|
-
style: {
|
|
105
|
-
alignItems: 'center',
|
|
106
|
-
borderBottom: '1px solid var(--theme-elevation-150)',
|
|
107
|
-
display: 'flex',
|
|
108
|
-
justifyContent: 'space-between',
|
|
109
|
-
padding: '8px var(--gutter-h)'
|
|
110
|
-
},
|
|
111
|
-
children: [
|
|
112
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
113
|
-
children: [
|
|
114
|
-
/*#__PURE__*/ _jsx("h2", {
|
|
115
|
-
style: {
|
|
116
|
-
margin: '0 0 5px 0'
|
|
117
|
-
},
|
|
118
|
-
children: "Let's configure your AI Plugin"
|
|
119
|
-
}),
|
|
120
|
-
/*#__PURE__*/ _jsx("p", {
|
|
121
|
-
style: {
|
|
122
|
-
color: 'var(--theme-elevation-500)',
|
|
123
|
-
fontSize: '14px',
|
|
124
|
-
margin: '0'
|
|
125
|
-
},
|
|
126
|
-
children: "Set up the provider → Choose the content → Refine the behavior."
|
|
127
|
-
})
|
|
128
|
-
]
|
|
129
|
-
}),
|
|
130
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
131
|
-
style: {
|
|
132
|
-
display: 'flex',
|
|
133
|
-
gap: '10px'
|
|
134
|
-
},
|
|
135
|
-
children: [
|
|
136
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
137
|
-
buttonStyle: "secondary",
|
|
138
|
-
el: "link",
|
|
139
|
-
to: `${adminRoute}/globals/ai-providers`,
|
|
140
|
-
children: "Providers"
|
|
141
|
-
}),
|
|
142
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
143
|
-
disabled: isSaving,
|
|
144
|
-
onClick: handleSave,
|
|
145
|
-
children: isSaving ? 'Saving...' : 'Save Changes'
|
|
146
|
-
})
|
|
147
|
-
]
|
|
148
|
-
})
|
|
149
|
-
]
|
|
150
|
-
}),
|
|
151
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
152
|
-
style: {
|
|
153
|
-
padding: '24px var(--gutter-h)'
|
|
154
|
-
},
|
|
155
|
-
children: [
|
|
156
|
-
/*#__PURE__*/ _jsx("h5", {
|
|
157
|
-
style: {
|
|
158
|
-
marginBottom: '15px'
|
|
159
|
-
},
|
|
160
|
-
children: "Select the collections where AI features should be available, toggle them on or off, and save your changes."
|
|
161
|
-
}),
|
|
162
|
-
/*#__PURE__*/ _jsx("div", {
|
|
163
|
-
style: {
|
|
164
|
-
display: 'grid',
|
|
165
|
-
gap: '15px',
|
|
166
|
-
gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))'
|
|
167
|
-
},
|
|
168
|
-
children: availableCollections.map((collection)=>{
|
|
169
|
-
const isEnabled = enabledCollections.includes(collection.slug);
|
|
170
|
-
return /*#__PURE__*/ _jsxs("button", {
|
|
171
|
-
onClick: ()=>handleToggle(collection.slug),
|
|
172
|
-
style: {
|
|
173
|
-
alignItems: 'center',
|
|
174
|
-
background: isEnabled ? 'var(--theme-elevation-100)' : 'var(--theme-elevation-50)',
|
|
175
|
-
border: `1px solid ${isEnabled ? 'var(--theme-text-success)' : 'var(--theme-elevation-200)'}`,
|
|
176
|
-
borderRadius: '6px',
|
|
177
|
-
cursor: 'pointer',
|
|
178
|
-
display: 'flex',
|
|
179
|
-
gap: '10px',
|
|
180
|
-
padding: '10px 15px',
|
|
181
|
-
textAlign: 'left',
|
|
182
|
-
transition: 'all 0.2s ease',
|
|
183
|
-
width: '100%'
|
|
184
|
-
},
|
|
185
|
-
type: "button",
|
|
186
|
-
children: [
|
|
187
|
-
/*#__PURE__*/ _jsx("div", {
|
|
188
|
-
style: {
|
|
189
|
-
alignItems: 'center',
|
|
190
|
-
background: isEnabled ? 'var(--theme-text-success)' : 'var(--theme-elevation-200)',
|
|
191
|
-
borderRadius: '12px',
|
|
192
|
-
display: 'flex',
|
|
193
|
-
height: '24px',
|
|
194
|
-
justifyContent: isEnabled ? 'flex-end' : 'flex-start',
|
|
195
|
-
padding: '2px',
|
|
196
|
-
transition: 'all 0.2s ease',
|
|
197
|
-
width: '44px'
|
|
198
|
-
},
|
|
199
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
200
|
-
style: {
|
|
201
|
-
background: 'white',
|
|
202
|
-
borderRadius: '50%',
|
|
203
|
-
height: '20px',
|
|
204
|
-
width: '20px'
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
}),
|
|
208
|
-
/*#__PURE__*/ _jsx("span", {
|
|
209
|
-
style: {
|
|
210
|
-
fontWeight: 500
|
|
211
|
-
},
|
|
212
|
-
children: typeof collection.labels?.singular === 'string' ? collection.labels.singular : collection.labels?.singular?.en || collection.slug
|
|
213
|
-
})
|
|
214
|
-
]
|
|
215
|
-
}, collection.slug);
|
|
216
|
-
})
|
|
217
|
-
})
|
|
218
|
-
]
|
|
219
|
-
})
|
|
220
|
-
]
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
//# sourceMappingURL=index.js.map
|