@ai-stack/payloadcms 3.68.0 → 3.76.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/core/media/image/generateImage.js +2 -6
- package/dist/ai/core/media/image/generateImage.js.map +1 -1
- package/dist/ai/core/media/image/handlers/multimodal.js +13 -28
- package/dist/ai/core/media/image/handlers/multimodal.js.map +1 -1
- package/dist/ai/core/media/image/handlers/standard.js +10 -7
- package/dist/ai/core/media/image/handlers/standard.js.map +1 -1
- package/dist/ai/core/media/speech/generateSpeech.js +8 -8
- package/dist/ai/core/media/speech/generateSpeech.js.map +1 -1
- package/dist/ai/core/media/types.d.ts +1 -1
- package/dist/ai/core/media/types.js.map +1 -1
- package/dist/ai/core/streamObject.js +3 -3
- package/dist/ai/core/streamObject.js.map +1 -1
- package/dist/ai/core/types.d.ts +3 -0
- package/dist/ai/core/types.js.map +1 -1
- package/dist/ai/prompts.d.ts +1 -2
- package/dist/ai/prompts.js +0 -110
- package/dist/ai/prompts.js.map +1 -1
- package/dist/ai/providers/blocks/anthropic.js +2 -1
- package/dist/ai/providers/blocks/anthropic.js.map +1 -1
- package/dist/ai/providers/blocks/elevenlabs.js +3 -2
- package/dist/ai/providers/blocks/elevenlabs.js.map +1 -1
- package/dist/ai/providers/blocks/fal.js +2 -1
- package/dist/ai/providers/blocks/fal.js.map +1 -1
- package/dist/ai/providers/blocks/google.js +12 -6
- package/dist/ai/providers/blocks/google.js.map +1 -1
- package/dist/ai/providers/blocks/openai-compatible.js +2 -1
- package/dist/ai/providers/blocks/openai-compatible.js.map +1 -1
- package/dist/ai/providers/blocks/openai.js +3 -2
- package/dist/ai/providers/blocks/openai.js.map +1 -1
- package/dist/ai/providers/blocks/xai.js +2 -1
- package/dist/ai/providers/blocks/xai.js.map +1 -1
- package/dist/ai/providers/icons.d.ts +7 -0
- package/dist/ai/providers/icons.js +9 -0
- package/dist/ai/providers/icons.js.map +1 -0
- package/dist/ai/providers/registry.js +36 -26
- package/dist/ai/providers/registry.js.map +1 -1
- package/dist/ai/utils/filterEditorSchemaByNodes.d.ts +9 -0
- package/dist/ai/utils/filterEditorSchemaByNodes.js +30 -3
- package/dist/ai/utils/filterEditorSchemaByNodes.js.map +1 -1
- package/dist/ai/utils/nodeToSchemaMap.d.ts +22 -0
- package/dist/ai/utils/nodeToSchemaMap.js +72 -0
- package/dist/ai/utils/nodeToSchemaMap.js.map +1 -0
- package/dist/collections/AIJobs.js +1 -1
- package/dist/collections/AIJobs.js.map +1 -1
- package/dist/collections/AIProviders.d.ts +2 -0
- package/dist/collections/{AISettings.js → AIProviders.js} +53 -25
- package/dist/collections/AIProviders.js.map +1 -0
- package/dist/collections/Instructions.js +45 -4
- package/dist/collections/Instructions.js.map +1 -1
- package/dist/defaults.d.ts +1 -0
- package/dist/defaults.js +8 -0
- package/dist/defaults.js.map +1 -1
- package/dist/endpoints/chat.d.ts +4 -0
- package/dist/endpoints/fetchFields.js +10 -0
- package/dist/endpoints/fetchFields.js.map +1 -1
- package/dist/endpoints/fetchVoices.js +42 -25
- package/dist/endpoints/fetchVoices.js.map +1 -1
- package/dist/endpoints/index.js +248 -35
- package/dist/endpoints/index.js.map +1 -1
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/client.js +1 -1
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/fields.d.ts +1 -0
- package/dist/exports/fields.js +1 -0
- package/dist/exports/fields.js.map +1 -1
- package/dist/fields/ArrayComposeField/ArrayComposeField.d.ts +15 -0
- package/dist/fields/ArrayComposeField/ArrayComposeField.js +87 -0
- package/dist/fields/ArrayComposeField/ArrayComposeField.js.map +1 -0
- package/dist/fields/ArrayComposeField/ArrayComposeField.jsx +73 -0
- package/dist/fields/PromptEditorField/PromptEditorField.js +7 -2
- package/dist/fields/PromptEditorField/PromptEditorField.js.map +1 -1
- package/dist/fields/PromptEditorField/PromptEditorField.jsx +5 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/payload-ai.d.ts +152 -0
- package/dist/plugin.js +18 -34
- package/dist/plugin.js.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.js +47 -15
- package/dist/providers/InstructionsProvider/InstructionsProvider.js.map +1 -1
- package/dist/providers/InstructionsProvider/InstructionsProvider.jsx +39 -16
- package/dist/providers/InstructionsProvider/context.d.ts +3 -0
- package/dist/providers/InstructionsProvider/context.js +2 -0
- package/dist/providers/InstructionsProvider/context.js.map +1 -1
- package/dist/providers/InstructionsProvider/useInstructions.js +22 -3
- package/dist/providers/InstructionsProvider/useInstructions.js.map +1 -1
- package/dist/styles.d.ts +11 -0
- package/dist/types/handlebars-async-helpers.d.ts +1 -0
- package/dist/types/handlebars-dist-handlebars.d.ts +1 -0
- package/dist/types/react-mentions.d.ts +1 -0
- package/dist/types.d.ts +36 -7
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/dist/ui/AIConfigDashboard/index.d.ts +1 -1
- package/dist/ui/AIConfigDashboard/index.js +201 -23
- package/dist/ui/AIConfigDashboard/index.js.map +1 -1
- package/dist/ui/AIConfigDashboard/index.jsx +166 -15
- package/dist/ui/Compose/Compose.d.ts +1 -0
- package/dist/ui/Compose/Compose.js +23 -4
- package/dist/ui/Compose/Compose.js.map +1 -1
- package/dist/ui/Compose/Compose.jsx +23 -4
- package/dist/ui/Compose/UndoRedoActions.d.ts +2 -2
- package/dist/ui/Compose/UndoRedoActions.js +8 -5
- package/dist/ui/Compose/UndoRedoActions.js.map +1 -1
- package/dist/ui/Compose/UndoRedoActions.jsx +6 -5
- package/dist/ui/Compose/compose.module.css +56 -16
- package/dist/ui/Compose/hooks/menu/TranslateMenu.d.ts +5 -0
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js +45 -4
- package/dist/ui/Compose/hooks/menu/TranslateMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/TranslateMenu.jsx +41 -5
- package/dist/ui/Compose/hooks/menu/itemsMap.js +12 -6
- package/dist/ui/Compose/hooks/menu/itemsMap.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/menu.module.scss +4 -1
- package/dist/ui/Compose/hooks/menu/useMenu.js +26 -15
- package/dist/ui/Compose/hooks/menu/useMenu.js.map +1 -1
- package/dist/ui/Compose/hooks/menu/useMenu.jsx +25 -12
- package/dist/ui/Compose/hooks/useActiveFieldTracking.js +34 -0
- package/dist/ui/Compose/hooks/useActiveFieldTracking.js.map +1 -1
- package/dist/ui/Compose/hooks/useGenerate.js +26 -174
- package/dist/ui/Compose/hooks/useGenerate.js.map +1 -1
- package/dist/ui/Compose/hooks/useGenerateUpload.d.ts +11 -0
- package/dist/ui/Compose/hooks/useGenerateUpload.js +156 -0
- package/dist/ui/Compose/hooks/useGenerateUpload.js.map +1 -0
- package/dist/ui/Compose/hooks/useHistory.d.ts +0 -1
- package/dist/ui/Compose/hooks/useHistory.js +65 -25
- package/dist/ui/Compose/hooks/useHistory.js.map +1 -1
- package/dist/ui/Compose/hooks/useStreamingUpdate.d.ts +8 -0
- package/dist/ui/Compose/hooks/useStreamingUpdate.js +48 -0
- package/dist/ui/Compose/hooks/useStreamingUpdate.js.map +1 -0
- package/dist/ui/ConfigDashboard/index.d.ts +2 -0
- package/dist/ui/ConfigDashboard/index.js +224 -0
- package/dist/ui/ConfigDashboard/index.js.map +1 -0
- package/dist/ui/ConfigDashboard/index.jsx +175 -0
- package/dist/ui/DynamicModelSelect/index.js +1 -1
- package/dist/ui/DynamicModelSelect/index.js.map +1 -1
- package/dist/ui/DynamicModelSelect/index.jsx +1 -1
- package/dist/ui/DynamicProviderSelect/index.js +1 -1
- package/dist/ui/DynamicProviderSelect/index.js.map +1 -1
- package/dist/ui/DynamicProviderSelect/index.jsx +1 -1
- package/dist/ui/DynamicVoiceSelect/index.js +63 -11
- package/dist/ui/DynamicVoiceSelect/index.js.map +1 -1
- package/dist/ui/DynamicVoiceSelect/index.jsx +47 -14
- package/dist/ui/EncryptedTextField/index.js +4 -4
- package/dist/ui/EncryptedTextField/index.js.map +1 -1
- package/dist/ui/EncryptedTextField/index.jsx +4 -4
- package/dist/ui/ProviderOptionsEditor/index.js +1 -1
- package/dist/ui/ProviderOptionsEditor/index.js.map +1 -1
- package/dist/ui/ProviderOptionsEditor/index.jsx +1 -1
- package/dist/ui/VoicesFetcher/index.js +34 -16
- package/dist/ui/VoicesFetcher/index.js.map +1 -1
- package/dist/ui/VoicesFetcher/index.jsx +32 -15
- package/dist/utilities/buildSmartPrompt.d.ts +22 -0
- package/dist/utilities/buildSmartPrompt.js +141 -0
- package/dist/utilities/buildSmartPrompt.js.map +1 -0
- package/dist/utilities/encryption.js +2 -1
- package/dist/utilities/encryption.js.map +1 -1
- package/dist/utilities/fieldToJsonSchema.js +32 -3
- package/dist/utilities/fieldToJsonSchema.js.map +1 -1
- package/dist/utilities/resolveImageReferences.d.ts +3 -1
- package/dist/utilities/resolveImageReferences.js +21 -2
- package/dist/utilities/resolveImageReferences.js.map +1 -1
- package/dist/utilities/seedProperties.d.ts +7 -0
- package/dist/utilities/seedProperties.js +100 -0
- package/dist/utilities/seedProperties.js.map +1 -0
- package/dist/utilities/setSafeLexicalState.js +79 -6
- package/dist/utilities/setSafeLexicalState.js.map +1 -1
- package/dist/utilities/updateFieldsConfig.d.ts +1 -1
- package/dist/utilities/updateFieldsConfig.js +9 -2
- package/dist/utilities/updateFieldsConfig.js.map +1 -1
- package/package.json +35 -33
- package/dist/collections/AISettings.d.ts +0 -2
- package/dist/collections/AISettings.js.map +0 -1
- package/dist/endpoints/chat.d.js +0 -3
- package/dist/endpoints/chat.d.js.map +0 -1
- package/dist/init.d.ts +0 -7
- package/dist/init.js +0 -135
- package/dist/init.js.map +0 -1
- package/dist/payload-ai.d.js +0 -3
- package/dist/payload-ai.d.js.map +0 -1
- package/dist/styles.d.js +0 -2
- package/dist/styles.d.js.map +0 -1
- package/dist/types/handlebars-async-helpers.d.js +0 -2
- package/dist/types/handlebars-async-helpers.d.js.map +0 -1
- package/dist/types/handlebars-dist-handlebars.d.js +0 -2
- package/dist/types/handlebars-dist-handlebars.d.js.map +0 -1
- package/dist/types/react-mentions.d.js +0 -2
- package/dist/types/react-mentions.d.js.map +0 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Button, toast, useConfig } from '@payloadcms/ui';
|
|
3
|
+
// @ts-expect-error - Next.js types are not resolving correctly with nodenext but runtime is fine
|
|
4
|
+
import { useRouter } from 'next/navigation';
|
|
5
|
+
import React, { use, useEffect, useState } from 'react';
|
|
6
|
+
import { excludeCollections } from '../../defaults.js';
|
|
7
|
+
import { InstructionsContext } from '../../providers/InstructionsProvider/context.js';
|
|
8
|
+
export const ConfigDashboard = () => {
|
|
9
|
+
const { config: { collections, routes: { admin: adminRoute, api: apiRoute }, }, } = useConfig();
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const { refresh, setEnabledCollections: setEnabledCollectionsInContext } = use(InstructionsContext);
|
|
12
|
+
const [enabledCollections, setEnabledCollections] = useState([]);
|
|
13
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
14
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
15
|
+
const availableCollections = collections.filter((c) => !excludeCollections.includes(c.slug) &&
|
|
16
|
+
!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
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error('Failed to fetch AI settings:', error);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
setIsLoading(false);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
fetchSettings().catch((e) => {
|
|
36
|
+
console.log(e);
|
|
37
|
+
});
|
|
38
|
+
}, [apiRoute]);
|
|
39
|
+
const handleToggle = (slug) => {
|
|
40
|
+
setEnabledCollections((prev) => {
|
|
41
|
+
if (prev.includes(slug)) {
|
|
42
|
+
return prev.filter((s) => s !== slug);
|
|
43
|
+
}
|
|
44
|
+
return [...prev, slug];
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const handleSave = async () => {
|
|
48
|
+
setIsSaving(true);
|
|
49
|
+
try {
|
|
50
|
+
// First fetch current settings to get ID or just rely on global update behavior
|
|
51
|
+
// We need to adhere to Payload's global update API
|
|
52
|
+
const response = await fetch(`${apiRoute}/globals/ai-providers`, {
|
|
53
|
+
body: JSON.stringify({
|
|
54
|
+
enabledCollections,
|
|
55
|
+
}),
|
|
56
|
+
headers: {
|
|
57
|
+
'Content-Type': 'application/json',
|
|
58
|
+
},
|
|
59
|
+
method: 'POST',
|
|
60
|
+
});
|
|
61
|
+
if (response.ok) {
|
|
62
|
+
toast.success('Settings saved successfully');
|
|
63
|
+
if (setEnabledCollectionsInContext) {
|
|
64
|
+
setEnabledCollectionsInContext(enabledCollections);
|
|
65
|
+
}
|
|
66
|
+
if (refresh) {
|
|
67
|
+
await refresh();
|
|
68
|
+
}
|
|
69
|
+
router.refresh();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
toast.error('Failed to save settings');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error('Error saving settings:', error);
|
|
77
|
+
toast.error('Error saving settings');
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
setIsSaving(false);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
if (isLoading) {
|
|
84
|
+
return <div style={{ padding: '20px', textAlign: 'center' }}>Loading configuration...</div>;
|
|
85
|
+
}
|
|
86
|
+
return (<div style={{
|
|
87
|
+
background: 'var(--theme-elevation-50)',
|
|
88
|
+
// border: '1px solid var(--theme-elevation-150)',
|
|
89
|
+
// borderRadius: '8px',
|
|
90
|
+
// borderBottom: '1px solid var(--theme-elevation-150)',
|
|
91
|
+
// borderTop: '1px solid var(--theme-elevation-150)',
|
|
92
|
+
marginBottom: '20px',
|
|
93
|
+
overflow: 'hidden',
|
|
94
|
+
}}>
|
|
95
|
+
<div style={{
|
|
96
|
+
alignItems: 'center',
|
|
97
|
+
borderBottom: '1px solid var(--theme-elevation-150)',
|
|
98
|
+
display: 'flex',
|
|
99
|
+
justifyContent: 'space-between',
|
|
100
|
+
padding: '8px var(--gutter-h)',
|
|
101
|
+
}}>
|
|
102
|
+
<div>
|
|
103
|
+
<h2 style={{ margin: '0 0 5px 0' }}>Let's configure your AI Plugin</h2>
|
|
104
|
+
<p style={{ color: 'var(--theme-elevation-500)', fontSize: '14px', margin: '0' }}>
|
|
105
|
+
Set up the provider → Choose the content → Refine the behavior.
|
|
106
|
+
</p>
|
|
107
|
+
</div>
|
|
108
|
+
<div style={{ display: 'flex', gap: '10px' }}>
|
|
109
|
+
<Button buttonStyle="secondary" el="link" to={`${adminRoute}/globals/ai-providers`}>
|
|
110
|
+
Providers
|
|
111
|
+
</Button>
|
|
112
|
+
<Button disabled={isSaving} onClick={handleSave}>
|
|
113
|
+
{isSaving ? 'Saving...' : 'Save Changes'}
|
|
114
|
+
</Button>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<div style={{ padding: '24px var(--gutter-h)' }}>
|
|
119
|
+
<h5 style={{ marginBottom: '15px' }}>
|
|
120
|
+
Select the collections where AI features should be available, toggle them on or off, and
|
|
121
|
+
save your changes.
|
|
122
|
+
</h5>
|
|
123
|
+
<div style={{
|
|
124
|
+
display: 'grid',
|
|
125
|
+
gap: '15px',
|
|
126
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(250px, 1fr))',
|
|
127
|
+
}}>
|
|
128
|
+
{availableCollections.map((collection) => {
|
|
129
|
+
const isEnabled = enabledCollections.includes(collection.slug);
|
|
130
|
+
return (<button key={collection.slug} onClick={() => handleToggle(collection.slug)} style={{
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
background: isEnabled
|
|
133
|
+
? 'var(--theme-elevation-100)'
|
|
134
|
+
: 'var(--theme-elevation-50)',
|
|
135
|
+
border: `1px solid ${isEnabled ? 'var(--theme-text-success)' : 'var(--theme-elevation-200)'}`,
|
|
136
|
+
borderRadius: '6px',
|
|
137
|
+
cursor: 'pointer',
|
|
138
|
+
display: 'flex',
|
|
139
|
+
gap: '10px',
|
|
140
|
+
padding: '10px 15px',
|
|
141
|
+
textAlign: 'left',
|
|
142
|
+
transition: 'all 0.2s ease',
|
|
143
|
+
width: '100%',
|
|
144
|
+
}} type="button">
|
|
145
|
+
<div style={{
|
|
146
|
+
alignItems: 'center',
|
|
147
|
+
background: isEnabled
|
|
148
|
+
? 'var(--theme-text-success)'
|
|
149
|
+
: 'var(--theme-elevation-200)',
|
|
150
|
+
borderRadius: '12px',
|
|
151
|
+
display: 'flex',
|
|
152
|
+
height: '24px',
|
|
153
|
+
justifyContent: isEnabled ? 'flex-end' : 'flex-start',
|
|
154
|
+
padding: '2px',
|
|
155
|
+
transition: 'all 0.2s ease',
|
|
156
|
+
width: '44px',
|
|
157
|
+
}}>
|
|
158
|
+
<div style={{
|
|
159
|
+
background: 'white',
|
|
160
|
+
borderRadius: '50%',
|
|
161
|
+
height: '20px',
|
|
162
|
+
width: '20px',
|
|
163
|
+
}}/>
|
|
164
|
+
</div>
|
|
165
|
+
<span style={{ fontWeight: 500 }}>
|
|
166
|
+
{typeof collection.labels?.singular === 'string'
|
|
167
|
+
? collection.labels.singular
|
|
168
|
+
: collection.labels?.singular?.en || collection.slug}
|
|
169
|
+
</span>
|
|
170
|
+
</button>);
|
|
171
|
+
})}
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
</div>);
|
|
175
|
+
};
|
|
@@ -94,7 +94,7 @@ export const DynamicModelSelect = (props)=>{
|
|
|
94
94
|
useEffect(()=>{
|
|
95
95
|
const fetchSettings = async ()=>{
|
|
96
96
|
try {
|
|
97
|
-
const response = await fetch('/api/globals/ai-
|
|
97
|
+
const response = await fetch('/api/globals/ai-providers?depth=1');
|
|
98
98
|
if (response.ok) {
|
|
99
99
|
const data = await response.json();
|
|
100
100
|
if (data && data.providers) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/DynamicModelSelect/index.tsx"],"sourcesContent":["'use client'\n\nimport { SelectInput, useField, useFormFields } from '@payloadcms/ui'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport { allProviderBlocks } from '../../ai/providers/blocks/index.js'\n\ntype Props = {\n name: string\n path: string\n}\n\n/**\n * Find a field by name within a block's fields, searching through tabs\n */\nfunction findFieldInBlock(block: any, fieldName: string): any | undefined {\n const searchFields = (fields: any[]): any | undefined => {\n for (const field of fields) {\n if ('name' in field && field.name === fieldName) {\n return field\n }\n if (field.type === 'tabs' && 'tabs' in field) {\n for (const tab of field.tabs) {\n const found = searchFields(tab.fields)\n if (found) {\n return found\n }\n }\n }\n if (field.type === 'group' && 'fields' in field) {\n const found = searchFields(field.fields)\n if (found) {\n return found\n }\n }\n }\n return undefined\n }\n \n return searchFields(block.fields)\n}\n\n/**\n * Infer use case from field path\n * Handles both:\n * - AISettings paths: 'defaults.text.model', 'defaults.image.model'\n * - Instructions paths: 'text-settings.model', 'image-settings.model'\n */\nfunction inferUseCase(path: string): string {\n const pathParts = path.split('.')\n const parentName = pathParts[pathParts.length - 2]\n \n // AISettings: 'defaults.text.model' -> parentName is 'text'\n // Direct use case names\n if (['image', 'text', 'tts', 'video'].includes(parentName)) {\n return parentName\n }\n \n // Instructions: 'text-settings.model' -> parentName is 'text-settings'\n if (parentName === 'image-settings') {\n return 'image'\n }\n if (parentName === 'tts-settings') {\n return 'tts'\n }\n if (parentName === 'text-settings' || parentName === 'richtext-settings') {\n return 'text'\n }\n if (parentName === 'video-settings') {\n return 'video'\n }\n \n // Default to text\n return 'text'\n}\n\nexport const DynamicModelSelect: React.FC<Props> = (props) => {\n const { name, path } = props\n\n // Getting the 'provider' sibling field value\n const parentPath = path.split('.').slice(0, -1).join('.')\n const providerPath = `${parentPath}.provider`\n\n const providerField = useFormFields(([fields]) => fields[providerPath])\n const providerValue = providerField?.value as string\n\n // Get all form fields to search for live provider configuration (for AISettings context)\n // We filter to only 'providers' fields to avoid unnecessary re-renders, \n // but note that the selector runs on every change.\n const formProviders = useFormFields(([fields]) => {\n const providers: Record<string, any> = {}\n if (fields && typeof fields === 'object') {\n Object.keys(fields).forEach((key) => {\n if (key.startsWith('providers.')) {\n providers[key] = fields[key]\n }\n })\n }\n return providers\n })\n\n const { setValue, value } = useField<string>({ path })\n\n // State to hold fetched providers data\n const [providersData, setProvidersData] = useState<any[]>([])\n\n // Fetch AI Settings global to get configured providers\n useEffect(() => {\n const fetchSettings = async () => {\n try {\n const response = await fetch('/api/globals/ai-settings?depth=1')\n if (response.ok) {\n const data = await response.json()\n if (data && data.providers) {\n setProvidersData(data.providers)\n }\n }\n } catch (error) {\n console.error('Error fetching AI settings:', error)\n }\n }\n\n fetchSettings().catch(console.error)\n }, [])\n\n const inferredUseCase = useMemo(() => inferUseCase(path), [path])\n\n const options = useMemo(() => {\n if (!providerValue) {\n return []\n }\n\n const optionsList: { label: string; value: string }[] = []\n\n // Strategy:\n // 1. Try to find provider in LIVE form state (if editing AISettings)\n // 2. If not found, try to find in FETCHED API data (if editing Instructions or saved AISettings)\n // 3. Fall back to static defaults from block definitions\n\n let foundInForm = false\n let foundInAPI = false\n\n // --- 1. Live Form Search ---\n // Iterate through form fields to find the matching provider block\n // We assume standard block structure: providers.0.blockType, etc.\n // We search up to 20 providers to be safe (unlikely to have more)\n for (let i = 0; i < 20; i++) {\n const typeKey = `providers.${i}.blockType`\n const typeField = formProviders[typeKey]\n \n if (!typeField) {break} // Stop if no more blocks (or gap)\n \n if (typeof typeField === 'object' && 'value' in typeField && typeField.value === providerValue) {\n foundInForm = true\n // Found the provider! Now iterate its models\n // Models path: providers.0.models.0.id\n for (let j = 0; j < 50; j++) {\n const idKey = `providers.${i}.models.${j}.id`\n const nameKey = `providers.${i}.models.${j}.name`\n const useCaseKey = `providers.${i}.models.${j}.useCase`\n const enabledKey = `providers.${i}.models.${j}.enabled`\n \n const idField = formProviders[idKey]\n if (!idField) {break} // Stop if no more models\n \n const modelId = (idField).value as string\n const modelName = (formProviders[nameKey])?.value as string\n const modelUseCase = (formProviders[useCaseKey])?.value as string\n const modelEnabled = (formProviders[enabledKey])?.value\n \n // Check use case and enabled status (default to enabled if undefined)\n if (modelUseCase === inferredUseCase && modelEnabled !== false) {\n optionsList.push({\n label: modelName || modelId,\n value: modelId,\n })\n }\n }\n break // Stop searching providers\n }\n }\n\n // --- 2. API Data Search (if not found in form) ---\n if (!foundInForm) {\n const userProviderBlock = providersData.find((p: any) => p.blockType === providerValue)\n\n if (userProviderBlock && userProviderBlock.models) {\n foundInAPI = true\n userProviderBlock.models.forEach((m: any) => {\n if (m.useCase === inferredUseCase && m.enabled !== false) {\n // Avoid duplicates\n if (!optionsList.some((opt) => opt.value === m.id)) {\n optionsList.push({\n label: m.name,\n value: m.id,\n })\n }\n }\n })\n }\n }\n\n // --- 3. Static Defaults (if not found in form OR API) ---\n // Note: We only fall back to static if we didn't find ANY configuration for this provider.\n // If we found the provider but it had no models for this use case, we show empty list (correct).\n if (!foundInForm && !foundInAPI) {\n const staticBlock = allProviderBlocks.find((b) => b.slug === providerValue)\n\n if (staticBlock) {\n // Search through tabs to find models field\n const modelsField = findFieldInBlock(staticBlock, 'models')\n const defaultModels =\n modelsField && 'defaultValue' in modelsField ? (modelsField.defaultValue as any[]) : []\n\n defaultModels.forEach((m) => {\n if (m.useCase === inferredUseCase && m.enabled !== false) {\n optionsList.push({\n label: m.name,\n value: m.id,\n })\n }\n })\n }\n }\n\n return optionsList\n }, [providerValue, providersData, inferredUseCase, formProviders])\n\n return (\n <div className=\"field-type select\">\n <label className=\"field-label\" htmlFor={path}>\n Model\n </label>\n <SelectInput\n name={name}\n onChange={(option) => {\n if (option && typeof option === 'object' && 'value' in option) {\n setValue(option.value as string)\n } else {\n setValue(option)\n }\n }}\n options={options as any}\n path={path}\n value={value}\n />\n </div>\n )\n}\n\n"],"names":["SelectInput","useField","useFormFields","React","useEffect","useMemo","useState","allProviderBlocks","findFieldInBlock","block","fieldName","searchFields","fields","field","name","type","tab","tabs","found","undefined","inferUseCase","path","pathParts","split","parentName","length","includes","DynamicModelSelect","props","parentPath","slice","join","providerPath","providerField","providerValue","value","formProviders","providers","Object","keys","forEach","key","startsWith","setValue","providersData","setProvidersData","fetchSettings","response","fetch","ok","data","json","error","console","catch","inferredUseCase","options","optionsList","foundInForm","foundInAPI","i","typeKey","typeField","j","idKey","nameKey","useCaseKey","enabledKey","idField","modelId","modelName","modelUseCase","modelEnabled","push","label","userProviderBlock","find","p","blockType","models","m","useCase","enabled","some","opt","id","staticBlock","b","slug","modelsField","defaultModels","defaultValue","div","className","htmlFor","onChange","option"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACrE,OAAOC,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAE3D,SAASC,iBAAiB,QAAQ,qCAAoC;AAOtE;;CAEC,GACD,SAASC,iBAAiBC,KAAU,EAAEC,SAAiB;IACrD,MAAMC,eAAe,CAACC;QACpB,KAAK,MAAMC,SAASD,OAAQ;YAC1B,IAAI,UAAUC,SAASA,MAAMC,IAAI,KAAKJ,WAAW;gBAC/C,OAAOG;YACT;YACA,IAAIA,MAAME,IAAI,KAAK,UAAU,UAAUF,OAAO;gBAC5C,KAAK,MAAMG,OAAOH,MAAMI,IAAI,CAAE;oBAC5B,MAAMC,QAAQP,aAAaK,IAAIJ,MAAM;oBACrC,IAAIM,O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,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/DynamicModelSelect/index.tsx"],"sourcesContent":["'use client'\n\nimport { SelectInput, useField, useFormFields } from '@payloadcms/ui'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport { allProviderBlocks } from '../../ai/providers/blocks/index.js'\n\ntype Props = {\n name: string\n path: string\n}\n\n/**\n * Find a field by name within a block's fields, searching through tabs\n */\nfunction findFieldInBlock(block: any, fieldName: string): any | undefined {\n const searchFields = (fields: any[]): any | undefined => {\n for (const field of fields) {\n if ('name' in field && field.name === fieldName) {\n return field\n }\n if (field.type === 'tabs' && 'tabs' in field) {\n for (const tab of field.tabs) {\n const found = searchFields(tab.fields)\n if (found) {\n return found\n }\n }\n }\n if (field.type === 'group' && 'fields' in field) {\n const found = searchFields(field.fields)\n if (found) {\n return found\n }\n }\n }\n return undefined\n }\n \n return searchFields(block.fields)\n}\n\n/**\n * Infer use case from field path\n * Handles both:\n * - AISettings paths: 'defaults.text.model', 'defaults.image.model'\n * - Instructions paths: 'text-settings.model', 'image-settings.model'\n */\nfunction inferUseCase(path: string): string {\n const pathParts = path.split('.')\n const parentName = pathParts[pathParts.length - 2]\n \n // AISettings: 'defaults.text.model' -> parentName is 'text'\n // Direct use case names\n if (['image', 'text', 'tts', 'video'].includes(parentName)) {\n return parentName\n }\n \n // Instructions: 'text-settings.model' -> parentName is 'text-settings'\n if (parentName === 'image-settings') {\n return 'image'\n }\n if (parentName === 'tts-settings') {\n return 'tts'\n }\n if (parentName === 'text-settings' || parentName === 'richtext-settings') {\n return 'text'\n }\n if (parentName === 'video-settings') {\n return 'video'\n }\n \n // Default to text\n return 'text'\n}\n\nexport const DynamicModelSelect: React.FC<Props> = (props) => {\n const { name, path } = props\n\n // Getting the 'provider' sibling field value\n const parentPath = path.split('.').slice(0, -1).join('.')\n const providerPath = `${parentPath}.provider`\n\n const providerField = useFormFields(([fields]) => fields[providerPath])\n const providerValue = providerField?.value as string\n\n // Get all form fields to search for live provider configuration (for AISettings context)\n // We filter to only 'providers' fields to avoid unnecessary re-renders, \n // but note that the selector runs on every change.\n const formProviders = useFormFields(([fields]) => {\n const providers: Record<string, any> = {}\n if (fields && typeof fields === 'object') {\n Object.keys(fields).forEach((key) => {\n if (key.startsWith('providers.')) {\n providers[key] = fields[key]\n }\n })\n }\n return providers\n })\n\n const { setValue, value } = useField<string>({ path })\n\n // State to hold fetched providers data\n const [providersData, setProvidersData] = useState<any[]>([])\n\n // Fetch AI Settings global to get configured providers\n useEffect(() => {\n const fetchSettings = async () => {\n try {\n const response = await fetch('/api/globals/ai-providers?depth=1')\n if (response.ok) {\n const data = await response.json()\n if (data && data.providers) {\n setProvidersData(data.providers)\n }\n }\n } catch (error) {\n console.error('Error fetching AI settings:', error)\n }\n }\n\n fetchSettings().catch(console.error)\n }, [])\n\n const inferredUseCase = useMemo(() => inferUseCase(path), [path])\n\n const options = useMemo(() => {\n if (!providerValue) {\n return []\n }\n\n const optionsList: { label: string; value: string }[] = []\n\n // Strategy:\n // 1. Try to find provider in LIVE form state (if editing AISettings)\n // 2. If not found, try to find in FETCHED API data (if editing Instructions or saved AISettings)\n // 3. Fall back to static defaults from block definitions\n\n let foundInForm = false\n let foundInAPI = false\n\n // --- 1. Live Form Search ---\n // Iterate through form fields to find the matching provider block\n // We assume standard block structure: providers.0.blockType, etc.\n // We search up to 20 providers to be safe (unlikely to have more)\n for (let i = 0; i < 20; i++) {\n const typeKey = `providers.${i}.blockType`\n const typeField = formProviders[typeKey]\n \n if (!typeField) {break} // Stop if no more blocks (or gap)\n \n if (typeof typeField === 'object' && 'value' in typeField && typeField.value === providerValue) {\n foundInForm = true\n // Found the provider! Now iterate its models\n // Models path: providers.0.models.0.id\n for (let j = 0; j < 50; j++) {\n const idKey = `providers.${i}.models.${j}.id`\n const nameKey = `providers.${i}.models.${j}.name`\n const useCaseKey = `providers.${i}.models.${j}.useCase`\n const enabledKey = `providers.${i}.models.${j}.enabled`\n \n const idField = formProviders[idKey]\n if (!idField) {break} // Stop if no more models\n \n const modelId = (idField).value as string\n const modelName = (formProviders[nameKey])?.value as string\n const modelUseCase = (formProviders[useCaseKey])?.value as string\n const modelEnabled = (formProviders[enabledKey])?.value\n \n // Check use case and enabled status (default to enabled if undefined)\n if (modelUseCase === inferredUseCase && modelEnabled !== false) {\n optionsList.push({\n label: modelName || modelId,\n value: modelId,\n })\n }\n }\n break // Stop searching providers\n }\n }\n\n // --- 2. API Data Search (if not found in form) ---\n if (!foundInForm) {\n const userProviderBlock = providersData.find((p: any) => p.blockType === providerValue)\n\n if (userProviderBlock && userProviderBlock.models) {\n foundInAPI = true\n userProviderBlock.models.forEach((m: any) => {\n if (m.useCase === inferredUseCase && m.enabled !== false) {\n // Avoid duplicates\n if (!optionsList.some((opt) => opt.value === m.id)) {\n optionsList.push({\n label: m.name,\n value: m.id,\n })\n }\n }\n })\n }\n }\n\n // --- 3. Static Defaults (if not found in form OR API) ---\n // Note: We only fall back to static if we didn't find ANY configuration for this provider.\n // If we found the provider but it had no models for this use case, we show empty list (correct).\n if (!foundInForm && !foundInAPI) {\n const staticBlock = allProviderBlocks.find((b) => b.slug === providerValue)\n\n if (staticBlock) {\n // Search through tabs to find models field\n const modelsField = findFieldInBlock(staticBlock, 'models')\n const defaultModels =\n modelsField && 'defaultValue' in modelsField ? (modelsField.defaultValue as any[]) : []\n\n defaultModels.forEach((m) => {\n if (m.useCase === inferredUseCase && m.enabled !== false) {\n optionsList.push({\n label: m.name,\n value: m.id,\n })\n }\n })\n }\n }\n\n return optionsList\n }, [providerValue, providersData, inferredUseCase, formProviders])\n\n return (\n <div className=\"field-type select\">\n <label className=\"field-label\" htmlFor={path}>\n Model\n </label>\n <SelectInput\n name={name}\n onChange={(option) => {\n if (option && typeof option === 'object' && 'value' in option) {\n setValue(option.value as string)\n } else {\n setValue(option)\n }\n }}\n options={options as any}\n path={path}\n value={value}\n />\n </div>\n )\n}\n\n"],"names":["SelectInput","useField","useFormFields","React","useEffect","useMemo","useState","allProviderBlocks","findFieldInBlock","block","fieldName","searchFields","fields","field","name","type","tab","tabs","found","undefined","inferUseCase","path","pathParts","split","parentName","length","includes","DynamicModelSelect","props","parentPath","slice","join","providerPath","providerField","providerValue","value","formProviders","providers","Object","keys","forEach","key","startsWith","setValue","providersData","setProvidersData","fetchSettings","response","fetch","ok","data","json","error","console","catch","inferredUseCase","options","optionsList","foundInForm","foundInAPI","i","typeKey","typeField","j","idKey","nameKey","useCaseKey","enabledKey","idField","modelId","modelName","modelUseCase","modelEnabled","push","label","userProviderBlock","find","p","blockType","models","m","useCase","enabled","some","opt","id","staticBlock","b","slug","modelsField","defaultModels","defaultValue","div","className","htmlFor","onChange","option"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACrE,OAAOC,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAE3D,SAASC,iBAAiB,QAAQ,qCAAoC;AAOtE;;CAEC,GACD,SAASC,iBAAiBC,KAAU,EAAEC,SAAiB;IACrD,MAAMC,eAAe,CAACC;QACpB,KAAK,MAAMC,SAASD,OAAQ;YAC1B,IAAI,UAAUC,SAASA,MAAMC,IAAI,KAAKJ,WAAW;gBAC/C,OAAOG;YACT;YACA,IAAIA,MAAME,IAAI,KAAK,UAAU,UAAUF,OAAO;gBAC5C,KAAK,MAAMG,OAAOH,MAAMI,IAAI,CAAE;oBAC5B,MAAMC,QAAQP,aAAaK,IAAIJ,MAAM;oBACrC,IAAIM,OAAO;wBACT,OAAOA;oBACT;gBACF;YACF;YACA,IAAIL,MAAME,IAAI,KAAK,WAAW,YAAYF,OAAO;gBAC/C,MAAMK,QAAQP,aAAaE,MAAMD,MAAM;gBACvC,IAAIM,OAAO;oBACT,OAAOA;gBACT;YACF;QACF;QACA,OAAOC;IACT;IAEA,OAAOR,aAAaF,MAAMG,MAAM;AAClC;AAEA;;;;;CAKC,GACD,SAASQ,aAAaC,IAAY;IAChC,MAA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ACb;wBACF;oBACF;gBACF;YACF;QACF;QAEA,2DAA2D;QAC3D,2FAA2F;QAC3F,iGAAiG;QACjG,IAAI,CAAC3B,eAAe,CAACC,YAAY;YAC/B,MAAM2B,cAAc/E,kBAAkBqE,IAAI,CAAC,CAACW,IAAMA,EAAEC,IAAI,KAAKtD;YAE7D,IAAIoD,aAAa;gBACf,2CAA2C;gBAC3C,MAAMG,cAAcjF,iBAAiB8E,aAAa;gBAClD,MAAMI,gBACJD,eAAe,kBAAkBA,cAAeA,YAAYE,YAAY,GAAa,EAAE;gBAEzFD,cAAclD,OAAO,CAAC,CAACwC;oBACrB,IAAIA,EAAEC,OAAO,KAAK1B,mBAAmByB,EAAEE,OAAO,KAAK,OAAO;wBACvDzB,YAAYgB,IAAI,CAAC;4BACfC,OAAOM,EAAElE,IAAI;4BACbqB,OAAO6C,EAAEK,EAAE;wBACb;oBACH;gBACF;YACF;QACF;QAEA,OAAO5B;IACT,GAAG;QAACvB;QAAeU;QAAeW;QAAiBnB;KAAc;IAEjE,qBACE,MAACwD;QAAIC,WAAU;;0BACb,KAACnB;gBAAMmB,WAAU;gBAAcC,SAASzE;0BAAM;;0BAG9C,KAACrB;gBACCc,MAAMA;gBACNiF,UAAU,CAACC;oBACT,IAAIA,UAAU,OAAOA,WAAW,YAAY,WAAWA,QAAQ;wBAC7DrD,SAASqD,OAAO7D,KAAK;oBACvB,OAAO;wBACLQ,SAASqD;oBACX;gBACF;gBACAxC,SAASA;gBACTnC,MAAMA;gBACNc,OAAOA;;;;AAIf,EAAC"}
|
|
@@ -88,7 +88,7 @@ export const DynamicModelSelect = (props) => {
|
|
|
88
88
|
useEffect(() => {
|
|
89
89
|
const fetchSettings = async () => {
|
|
90
90
|
try {
|
|
91
|
-
const response = await fetch('/api/globals/ai-
|
|
91
|
+
const response = await fetch('/api/globals/ai-providers?depth=1');
|
|
92
92
|
if (response.ok) {
|
|
93
93
|
const data = await response.json();
|
|
94
94
|
if (data && data.providers) {
|
|
@@ -14,7 +14,7 @@ export const DynamicProviderSelect = (props)=>{
|
|
|
14
14
|
useEffect(()=>{
|
|
15
15
|
const fetchSettings = async ()=>{
|
|
16
16
|
try {
|
|
17
|
-
const response = await fetch('/api/globals/ai-
|
|
17
|
+
const response = await fetch('/api/globals/ai-providers?depth=1');
|
|
18
18
|
if (response.ok) {
|
|
19
19
|
const data = await response.json();
|
|
20
20
|
if (data && data.providers) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/DynamicProviderSelect/index.tsx"],"sourcesContent":["'use client'\n\nimport { SelectInput, useField } from '@payloadcms/ui'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport { allProviderBlocks } from '../../ai/providers/blocks/index.js'\n\ntype Props = {\n name: string\n path: string\n}\n\nexport const DynamicProviderSelect: React.FC<Props> = (props) => {\n const { name, path } = props\n\n const { setValue, value } = useField<string>({ path })\n\n // State to hold fetched providers data\n const [providersData, setProvidersData] = useState<any[]>([])\n\n // Fetch AI Settings global to get configured providers\n useEffect(() => {\n const fetchSettings = async () => {\n try {\n const response = await fetch('/api/globals/ai-
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/DynamicProviderSelect/index.tsx"],"sourcesContent":["'use client'\n\nimport { SelectInput, useField } from '@payloadcms/ui'\nimport React, { useEffect, useMemo, useState } from 'react'\n\nimport { allProviderBlocks } from '../../ai/providers/blocks/index.js'\n\ntype Props = {\n name: string\n path: string\n}\n\nexport const DynamicProviderSelect: React.FC<Props> = (props) => {\n const { name, path } = props\n\n const { setValue, value } = useField<string>({ path })\n\n // State to hold fetched providers data\n const [providersData, setProvidersData] = useState<any[]>([])\n\n // Fetch AI Settings global to get configured providers\n useEffect(() => {\n const fetchSettings = async () => {\n try {\n const response = await fetch('/api/globals/ai-providers?depth=1')\n if (response.ok) {\n const data = await response.json()\n if (data && data.providers) {\n setProvidersData(data.providers)\n }\n }\n } catch (error) {\n console.error('Error fetching AI settings:', error)\n }\n }\n\n void fetchSettings()\n }, [])\n\n const options = useMemo(() => {\n const optionsList: { label: string; value: string }[] = []\n const processedProviders = new Set<string>()\n\n // Iterate through fetched providers to find custom names\n providersData.forEach((provider: any) => {\n if (!provider.enabled) {\n return\n }\n\n const blockType = provider.blockType\n const customName = provider.providerName\n\n // Get static label as fallback\n const staticBlock = allProviderBlocks.find((b) => b.slug === blockType)\n const staticLabel = staticBlock?.labels?.singular\n ? typeof staticBlock.labels.singular === 'string'\n ? staticBlock.labels.singular\n : blockType\n : blockType\n\n const label = customName || staticLabel\n\n if (!processedProviders.has(blockType)) {\n optionsList.push({\n label,\n value: blockType,\n })\n processedProviders.add(blockType)\n } else if (customName) {\n // Update existing label if custom name is available\n const existingOpt = optionsList.find((o) => o.value === blockType)\n if (existingOpt && existingOpt.label === staticLabel) {\n existingOpt.label = customName\n }\n }\n })\n\n // Add any other available providers from blocks that might not be configured yet?\n // Usually we only want to show configured providers in the selection list.\n // But for standard providers (OpenAI, Google), they might not need much config other than API key.\n // If they are not in the list, user can't select them.\n // However, if they are not enabled in settings, maybe we shouldn't show them?\n // Let's stick to showing all available blocks, but prioritizing configured ones with custom names.\n\n allProviderBlocks.forEach((block) => {\n if (!processedProviders.has(block.slug)) {\n optionsList.push({\n label: typeof block.labels?.singular === 'string' ? block.labels.singular : block.slug,\n value: block.slug,\n })\n }\n })\n\n return optionsList\n }, [providersData])\n\n return (\n <div className=\"field-type select\">\n <label className=\"field-label\" htmlFor={path}>\n Provider\n </label>\n <SelectInput\n name={name}\n onChange={(option) => {\n if (option && typeof option === 'object' && 'value' in option) {\n setValue(option.value)\n } else {\n setValue(option)\n }\n }}\n options={options as any}\n path={path}\n value={value}\n />\n </div>\n )\n}\n"],"names":["SelectInput","useField","React","useEffect","useMemo","useState","allProviderBlocks","DynamicProviderSelect","props","name","path","setValue","value","providersData","setProvidersData","fetchSettings","response","fetch","ok","data","json","providers","error","console","options","optionsList","processedProviders","Set","forEach","provider","enabled","blockType","customName","providerName","staticBlock","find","b","slug","staticLabel","labels","singular","label","has","push","add","existingOpt","o","block","div","className","htmlFor","onChange","option"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,iBAAgB;AACtD,OAAOC,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAE3D,SAASC,iBAAiB,QAAQ,qCAAoC;AAOtE,OAAO,MAAMC,wBAAyC,CAACC;IACrD,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAAGF;IAEvB,MAAM,EAAEG,QAAQ,EAAEC,KAAK,EAAE,GAAGX,SAAiB;QAAES;IAAK;IAEpD,uCAAuC;IACvC,MAAM,CAACG,eAAeC,iBAAiB,GAAGT,SAAgB,EAAE;IAE5D,uDAAuD;IACvDF,UAAU;QACR,MAAMY,gBAAgB;YACpB,IAAI;gBACF,MAAMC,WAAW,MAAMC,MAAM;gBAC7B,IAAID,SAASE,EAAE,EAAE;oBACf,MAAMC,OAAO,MAAMH,SAASI,IAAI;oBAChC,IAAID,QAAQA,KAAKE,SAAS,EAAE;wBAC1BP,iBAAiBK,KAAKE,SAAS;oBACjC;gBACF;YACF,EAAE,OAAOC,OAAO;gBACdC,QAAQD,KAAK,CAAC,+BAA+BA;YAC/C;QACF;QAEA,KAAKP;IACP,GAAG,EAAE;IAEL,MAAMS,UAAUpB,QAAQ;QACtB,MAAMqB,cAAkD,EAAE;QAC1D,MAAMC,qBAAqB,IAAIC;QAE/B,yDAAyD;QACzDd,cAAce,OAAO,CAAC,CAACC;YACrB,IAAI,CAACA,SAASC,OAAO,EAAE;gBACrB;YACF;YAEA,MAAMC,YAAYF,SAASE,SAAS;YACpC,MAAMC,aAAaH,SAASI,YAAY;YAExC,+BAA+B;YAC/B,MAAMC,cAAc5B,kBAAkB6B,IAAI,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAKN;YAC7D,MAAMO,cAAcJ,aAAaK,QAAQC,WACrC,OAAON,YAAYK,MAAM,CAACC,QAAQ,KAAK,WACrCN,YAAY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fetchSettings = async () => {
|
|
13
13
|
try {
|
|
14
|
-
const response = await fetch('/api/globals/ai-
|
|
14
|
+
const response = await fetch('/api/globals/ai-providers?depth=1');
|
|
15
15
|
if (response.ok) {
|
|
16
16
|
const data = await response.json();
|
|
17
17
|
if (data && data.providers) {
|
|
@@ -6,27 +6,47 @@ export const DynamicVoiceSelect = (props)=>{
|
|
|
6
6
|
const { name, path } = props;
|
|
7
7
|
// Get provider from siblings
|
|
8
8
|
const parentPath = path.split('.').slice(0, -1).join('.');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
9
|
+
const providerPath = `${parentPath}.provider`;
|
|
10
|
+
// Use useFormFields to get the provider field value - this will re-render when provider changes
|
|
11
|
+
const providerField = useFormFields(([fields])=>fields[providerPath]);
|
|
12
|
+
const provider = providerField?.value || '';
|
|
12
13
|
const { setValue, value } = useField({
|
|
13
14
|
path
|
|
14
15
|
});
|
|
15
16
|
const [aiSettings, setAiSettings] = useState(null);
|
|
17
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
18
|
+
// Fetch AI Settings - re-fetch when provider changes to ensure we have latest voices
|
|
16
19
|
useEffect(()=>{
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
const fetchSettings = async ()=>{
|
|
21
|
+
setIsLoading(true);
|
|
22
|
+
try {
|
|
23
|
+
const response = await fetch('/api/globals/ai-providers?depth=1');
|
|
24
|
+
if (response.ok) {
|
|
25
|
+
const data = await response.json();
|
|
26
|
+
setAiSettings(data);
|
|
27
|
+
}
|
|
28
|
+
} catch (err) {
|
|
29
|
+
console.error('Error fetching AI settings:', err);
|
|
30
|
+
} finally{
|
|
31
|
+
setIsLoading(false);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
void fetchSettings();
|
|
35
|
+
}, [
|
|
36
|
+
provider
|
|
37
|
+
]) // Re-fetch when provider changes to ensure we have the latest voices
|
|
38
|
+
;
|
|
19
39
|
const voices = useMemo(()=>{
|
|
20
|
-
if (!provider || !aiSettings) {
|
|
40
|
+
if (!provider || !aiSettings?.providers) {
|
|
21
41
|
return [];
|
|
22
42
|
}
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
// Find the provider block matching the selected provider
|
|
44
|
+
const providerBlock = aiSettings.providers.find((p)=>p.blockType === provider && p.enabled !== false);
|
|
45
|
+
if (!providerBlock?.voices) {
|
|
25
46
|
return [];
|
|
26
47
|
}
|
|
27
|
-
// Get voices from provider block
|
|
28
|
-
|
|
29
|
-
return voicesArray.filter((v)=>v.enabled !== false).map((v)=>({
|
|
48
|
+
// Get enabled voices from provider block
|
|
49
|
+
return providerBlock.voices.filter((v)=>v.enabled !== false).map((v)=>({
|
|
30
50
|
label: v.name || v.id,
|
|
31
51
|
value: v.id
|
|
32
52
|
}));
|
|
@@ -34,6 +54,19 @@ export const DynamicVoiceSelect = (props)=>{
|
|
|
34
54
|
provider,
|
|
35
55
|
aiSettings
|
|
36
56
|
]);
|
|
57
|
+
// Clear voice selection when provider changes and current voice is not available
|
|
58
|
+
useEffect(()=>{
|
|
59
|
+
if (value && voices.length > 0) {
|
|
60
|
+
const voiceExists = voices.some((v)=>v.value === value);
|
|
61
|
+
if (!voiceExists) {
|
|
62
|
+
setValue('');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}, [
|
|
66
|
+
voices,
|
|
67
|
+
value,
|
|
68
|
+
setValue
|
|
69
|
+
]);
|
|
37
70
|
if (!provider) {
|
|
38
71
|
return /*#__PURE__*/ _jsxs("div", {
|
|
39
72
|
className: "field-type text",
|
|
@@ -53,6 +86,25 @@ export const DynamicVoiceSelect = (props)=>{
|
|
|
53
86
|
]
|
|
54
87
|
});
|
|
55
88
|
}
|
|
89
|
+
if (isLoading) {
|
|
90
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
91
|
+
className: "field-type text",
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ _jsx("label", {
|
|
94
|
+
className: "field-label",
|
|
95
|
+
htmlFor: path,
|
|
96
|
+
children: "Voice"
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ _jsx("p", {
|
|
99
|
+
style: {
|
|
100
|
+
color: 'var(--theme-elevation-600)',
|
|
101
|
+
fontSize: '13px'
|
|
102
|
+
},
|
|
103
|
+
children: "Loading voices..."
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
});
|
|
107
|
+
}
|
|
56
108
|
if (voices.length === 0) {
|
|
57
109
|
return /*#__PURE__*/ _jsxs("div", {
|
|
58
110
|
className: "field-type text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/DynamicVoiceSelect/index.tsx"],"sourcesContent":["'use client'\n\nimport { SelectInput, useField, useFormFields } from '@payloadcms/ui'\nimport React, { useEffect, useMemo, useState } from 'react'\n\ntype Props = {\n name: string\n path: string\n}\n\nexport const DynamicVoiceSelect: React.FC<Props> = (props) => {\n const { name, path } = props\n\n // Get provider from siblings\n const parentPath = path.split('.').slice(0, -1).join('.')\n //
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/DynamicVoiceSelect/index.tsx"],"sourcesContent":["'use client'\n\nimport { SelectInput, useField, useFormFields } from '@payloadcms/ui'\nimport React, { useEffect, useMemo, useState } from 'react'\n\ntype Props = {\n name: string\n path: string\n}\n\ninterface Voice {\n category?: string\n enabled?: boolean\n id: string\n labels?: Record<string, unknown>\n name: string\n preview_url?: string\n}\n\ninterface ProviderBlock {\n blockType: string\n enabled?: boolean\n voices?: Voice[]\n}\n\nexport const DynamicVoiceSelect: React.FC<Props> = (props) => {\n const { name, path } = props\n\n // Get provider from siblings\n const parentPath = path.split('.').slice(0, -1).join('.')\n const providerPath = `${parentPath}.provider`\n\n // Use useFormFields to get the provider field value - this will re-render when provider changes\n const providerField = useFormFields(([fields]) => fields[providerPath])\n const provider = (providerField?.value as string) || ''\n\n const { setValue, value } = useField<string>({ path })\n const [aiSettings, setAiSettings] = useState<{ providers?: ProviderBlock[] } | null>(null)\n const [isLoading, setIsLoading] = useState(true)\n\n // Fetch AI Settings - re-fetch when provider changes to ensure we have latest voices\n useEffect(() => {\n const fetchSettings = async () => {\n setIsLoading(true)\n try {\n const response = await fetch('/api/globals/ai-providers?depth=1')\n if (response.ok) {\n const data = await response.json()\n setAiSettings(data)\n }\n } catch (err) {\n console.error('Error fetching AI settings:', err)\n } finally {\n setIsLoading(false)\n }\n }\n\n void fetchSettings()\n }, [provider]) // Re-fetch when provider changes to ensure we have the latest voices\n\n const voices = useMemo(() => {\n if (!provider || !aiSettings?.providers) {\n return []\n }\n\n // Find the provider block matching the selected provider\n const providerBlock = aiSettings.providers.find(\n (p: ProviderBlock) => p.blockType === provider && p.enabled !== false,\n )\n\n if (!providerBlock?.voices) {\n return []\n }\n\n // Get enabled voices from provider block\n return providerBlock.voices\n .filter((v: Voice) => v.enabled !== false)\n .map((v: Voice) => ({\n label: v.name || v.id,\n value: v.id,\n }))\n }, [provider, aiSettings])\n\n // Clear voice selection when provider changes and current voice is not available\n useEffect(() => {\n if (value && voices.length > 0) {\n const voiceExists = voices.some((v) => v.value === value)\n if (!voiceExists) {\n setValue('')\n }\n }\n }, [voices, value, setValue])\n\n if (!provider) {\n return (\n <div className=\"field-type text\">\n <label className=\"field-label\" htmlFor={path}>\n Voice\n </label>\n <p style={{ color: 'var(--theme-elevation-600)', fontSize: '13px' }}>\n Please select a provider first.\n </p>\n </div>\n )\n }\n\n if (isLoading) {\n return (\n <div className=\"field-type text\">\n <label className=\"field-label\" htmlFor={path}>\n Voice\n </label>\n <p style={{ color: 'var(--theme-elevation-600)', fontSize: '13px' }}>Loading voices...</p>\n </div>\n )\n }\n\n if (voices.length === 0) {\n return (\n <div className=\"field-type text\">\n <label className=\"field-label\" htmlFor={path}>\n Voice\n </label>\n <p style={{ color: 'var(--theme-elevation-600)', fontSize: '13px' }}>\n No voices available. Please configure voices in AI Settings for {provider}.\n </p>\n </div>\n )\n }\n\n return (\n <div className=\"field-type select\">\n <label className=\"field-label\" htmlFor={path}>\n Voice\n </label>\n <SelectInput\n name={name}\n onChange={(option) => {\n if (option && typeof option === 'object' && 'value' in option) {\n setValue(option.value as string)\n } else {\n setValue(option)\n }\n }}\n options={voices}\n path={path}\n value={value}\n />\n </div>\n )\n}\n\n"],"names":["SelectInput","useField","useFormFields","React","useEffect","useMemo","useState","DynamicVoiceSelect","props","name","path","parentPath","split","slice","join","providerPath","providerField","fields","provider","value","setValue","aiSettings","setAiSettings","isLoading","setIsLoading","fetchSettings","response","fetch","ok","data","json","err","console","error","voices","providers","providerBlock","find","p","blockType","enabled","filter","v","map","label","id","length","voiceExists","some","div","className","htmlFor","style","color","fontSize","onChange","option","options"],"mappings":"AAAA;;AAEA,SAASA,WAAW,EAAEC,QAAQ,EAAEC,aAAa,QAAQ,iBAAgB;AACrE,OAAOC,SAASC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAsB3D,OAAO,MAAMC,qBAAsC,CAACC;IAClD,MAAM,EAAEC,IAAI,EAAEC,IAAI,EAAE,GAAGF;IAEvB,6BAA6B;IAC7B,MAAMG,aAAaD,KAAKE,KAAK,CAAC,KAAKC,KAAK,CAAC,GAAG,CAAC,GAAGC,IAAI,CAAC;IACrD,MAAMC,eAAe,CAAC,EAAEJ,WAAW,SAAS,CAAC;IAE7C,gGAAgG;IAChG,MAAMK,gBAAgBd,cAAc,CAAC,CAACe,OAAO,GAAKA,MAAM,CAACF,aAAa;IACtE,MAAMG,WAAW,AAACF,eAAeG,SAAoB;IAErD,MAAM,EAAEC,QAAQ,EAAED,KAAK,EAAE,GAAGlB,SAAiB;QAAES;IAAK;IACpD,MAAM,CAACW,YAAYC,cAAc,GAAGhB,SAAiD;IACrF,MAAM,CAACiB,WAAWC,aAAa,GAAGlB,SAAS;IAE3C,qFAAqF;IACrFF,UAAU;QACR,MAAMqB,gBAAgB;YACpBD,aAAa;YACb,IAAI;gBACF,MAAME,WAAW,MAAMC,MAAM;gBAC7B,IAAID,SAASE,EAAE,EAAE;oBACf,M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AAU;;8BACb,KAACN;oBAAMM,WAAU;oBAAcC,SAASzC;8BAAM;;8BAG9C,KAAC4B;oBAAEc,OAAO;wBAAEC,OAAO;wBAA8BC,UAAU;oBAAO;8BAAG;;;;IAG3E;IAEA,IAAIpB,OAAOY,MAAM,KAAK,GAAG;QACvB,qBACE,MAACG;YAAIC,WAAU;;8BACb,KAACN;oBAAMM,WAAU;oBAAcC,SAASzC;8BAAM;;8BAG9C,MAAC4B;oBAAEc,OAAO;wBAAEC,OAAO;wBAA8BC,UAAU;oBAAO;;wBAAG;wBACFpC;wBAAS;;;;;IAIlF;IAEA,qBACE,MAAC+B;QAAIC,WAAU;;0BACb,KAACN;gBAAMM,WAAU;gBAAcC,SAASzC;0BAAM;;0BAG9C,KAACV;gBACCS,MAAMA;gBACN8C,UAAU,CAACC;oBACT,IAAIA,UAAU,OAAOA,WAAW,YAAY,WAAWA,QAAQ;wBAC7DpC,SAASoC,OAAOrC,KAAK;oBACvB,OAAO;wBACLC,SAASoC;oBACX;gBACF;gBACAC,SAASvB;gBACTxB,MAAMA;gBACNS,OAAOA;;;;AAIf,EAAC"}
|
|
@@ -5,34 +5,59 @@ export const DynamicVoiceSelect = (props) => {
|
|
|
5
5
|
const { name, path } = props;
|
|
6
6
|
// Get provider from siblings
|
|
7
7
|
const parentPath = path.split('.').slice(0, -1).join('.');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
8
|
+
const providerPath = `${parentPath}.provider`;
|
|
9
|
+
// Use useFormFields to get the provider field value - this will re-render when provider changes
|
|
10
|
+
const providerField = useFormFields(([fields]) => fields[providerPath]);
|
|
11
|
+
const provider = providerField?.value || '';
|
|
11
12
|
const { setValue, value } = useField({ path });
|
|
12
13
|
const [aiSettings, setAiSettings] = useState(null);
|
|
14
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
15
|
+
// Fetch AI Settings - re-fetch when provider changes to ensure we have latest voices
|
|
13
16
|
useEffect(() => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const fetchSettings = async () => {
|
|
18
|
+
setIsLoading(true);
|
|
19
|
+
try {
|
|
20
|
+
const response = await fetch('/api/globals/ai-providers?depth=1');
|
|
21
|
+
if (response.ok) {
|
|
22
|
+
const data = await response.json();
|
|
23
|
+
setAiSettings(data);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
console.error('Error fetching AI settings:', err);
|
|
28
|
+
}
|
|
29
|
+
finally {
|
|
30
|
+
setIsLoading(false);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
void fetchSettings();
|
|
34
|
+
}, [provider]); // Re-fetch when provider changes to ensure we have the latest voices
|
|
19
35
|
const voices = useMemo(() => {
|
|
20
|
-
if (!provider || !aiSettings) {
|
|
36
|
+
if (!provider || !aiSettings?.providers) {
|
|
21
37
|
return [];
|
|
22
38
|
}
|
|
23
|
-
|
|
24
|
-
|
|
39
|
+
// Find the provider block matching the selected provider
|
|
40
|
+
const providerBlock = aiSettings.providers.find((p) => p.blockType === provider && p.enabled !== false);
|
|
41
|
+
if (!providerBlock?.voices) {
|
|
25
42
|
return [];
|
|
26
43
|
}
|
|
27
|
-
// Get voices from provider block
|
|
28
|
-
|
|
29
|
-
return voicesArray
|
|
44
|
+
// Get enabled voices from provider block
|
|
45
|
+
return providerBlock.voices
|
|
30
46
|
.filter((v) => v.enabled !== false)
|
|
31
47
|
.map((v) => ({
|
|
32
48
|
label: v.name || v.id,
|
|
33
49
|
value: v.id,
|
|
34
50
|
}));
|
|
35
51
|
}, [provider, aiSettings]);
|
|
52
|
+
// Clear voice selection when provider changes and current voice is not available
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (value && voices.length > 0) {
|
|
55
|
+
const voiceExists = voices.some((v) => v.value === value);
|
|
56
|
+
if (!voiceExists) {
|
|
57
|
+
setValue('');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, [voices, value, setValue]);
|
|
36
61
|
if (!provider) {
|
|
37
62
|
return (<div className="field-type text">
|
|
38
63
|
<label className="field-label" htmlFor={path}>
|
|
@@ -43,6 +68,14 @@ export const DynamicVoiceSelect = (props) => {
|
|
|
43
68
|
</p>
|
|
44
69
|
</div>);
|
|
45
70
|
}
|
|
71
|
+
if (isLoading) {
|
|
72
|
+
return (<div className="field-type text">
|
|
73
|
+
<label className="field-label" htmlFor={path}>
|
|
74
|
+
Voice
|
|
75
|
+
</label>
|
|
76
|
+
<p style={{ color: 'var(--theme-elevation-600)', fontSize: '13px' }}>Loading voices...</p>
|
|
77
|
+
</div>);
|
|
78
|
+
}
|
|
46
79
|
if (voices.length === 0) {
|
|
47
80
|
return (<div className="field-type text">
|
|
48
81
|
<label className="field-label" htmlFor={path}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useField } from '@payloadcms/ui';
|
|
3
|
+
import { Button, useField } from '@payloadcms/ui';
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
5
|
export const EncryptedTextField = ({ label, path, required })=>{
|
|
6
6
|
const { setValue, value } = useField({
|
|
@@ -48,13 +48,13 @@ export const EncryptedTextField = ({ label, path, required })=>{
|
|
|
48
48
|
})
|
|
49
49
|
]
|
|
50
50
|
}),
|
|
51
|
-
/*#__PURE__*/ _jsx(
|
|
52
|
-
|
|
51
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
52
|
+
buttonStyle: "secondary",
|
|
53
53
|
onClick: ()=>{
|
|
54
54
|
setValue('');
|
|
55
55
|
setIsEditing(true);
|
|
56
56
|
},
|
|
57
|
-
|
|
57
|
+
size: "medium",
|
|
58
58
|
children: "Change"
|
|
59
59
|
})
|
|
60
60
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/ui/EncryptedTextField/index.tsx"],"sourcesContent":["'use client'\n\nimport { useField } from '@payloadcms/ui'\nimport React, { useState } from 'react'\n\ntype Props = {\n label?: string\n path: string\n required?: boolean\n}\n\nexport const EncryptedTextField: React.FC<Props> = ({ label, path, required }) => {\n const { setValue, value } = useField<string>({ path })\n const [isEditing, setIsEditing] = useState(!value)\n\n const isMasked = typeof value === 'string' && value.startsWith('sk-') && value.includes('****')\n\n return (\n <div className=\"field-type text\">\n <label className=\"field-label\">\n {label || 'API Key'}\n {required && <span className=\"required\">*</span>}\n </label>\n\n {!isEditing && isMasked ? (\n <div style={{ alignItems: 'center', display: 'flex', gap: '10px' }}>\n <div\n style={{\n background: 'var(--theme-elevation-100)',\n borderRadius: '4px',\n flexGrow: 1,\n fontFamily: 'monospace',\n padding: '8px 12px',\n }}\n >\n {value}\n <span\n style={{ color: 'var(--theme-success-500)', fontSize: '0.8em', marginLeft: '10px' }}\n >\n ✓ Configured\n </span>\n </div>\n <
|
|
1
|
+
{"version":3,"sources":["../../../src/ui/EncryptedTextField/index.tsx"],"sourcesContent":["'use client'\n\nimport { Button, useField } from '@payloadcms/ui'\nimport React, { useState } from 'react'\n\ntype Props = {\n label?: string\n path: string\n required?: boolean\n}\n\nexport const EncryptedTextField: React.FC<Props> = ({ label, path, required }) => {\n const { setValue, value } = useField<string>({ path })\n const [isEditing, setIsEditing] = useState(!value)\n\n const isMasked = typeof value === 'string' && value.startsWith('sk-') && value.includes('****')\n\n return (\n <div className=\"field-type text\">\n <label className=\"field-label\">\n {label || 'API Key'}\n {required && <span className=\"required\">*</span>}\n </label>\n\n {!isEditing && isMasked ? (\n <div style={{ alignItems: 'center', display: 'flex', gap: '10px' }}>\n <div\n style={{\n background: 'var(--theme-elevation-100)',\n borderRadius: '4px',\n flexGrow: 1,\n fontFamily: 'monospace',\n padding: '8px 12px',\n }}\n >\n {value}\n <span\n style={{ color: 'var(--theme-success-500)', fontSize: '0.8em', marginLeft: '10px' }}\n >\n ✓ Configured\n </span>\n </div>\n <Button\n buttonStyle=\"secondary\"\n onClick={() => {\n setValue('')\n setIsEditing(true)\n }}\n size=\"medium\"\n >\n Change\n </Button>\n </div>\n ) : (\n <input\n onChange={(e) => setValue(e.target.value)}\n placeholder=\"sk-...\"\n style={{ width: '100%' }}\n type=\"password\"\n value={value || ''}\n />\n )}\n </div>\n )\n}\n"],"names":["Button","useField","React","useState","EncryptedTextField","label","path","required","setValue","value","isEditing","setIsEditing","isMasked","startsWith","includes","div","className","span","style","alignItems","display","gap","background","borderRadius","flexGrow","fontFamily","padding","color","fontSize","marginLeft","buttonStyle","onClick","size","input","onChange","e","target","placeholder","width","type"],"mappings":"AAAA;;AAEA,SAASA,MAAM,EAAEC,QAAQ,QAAQ,iBAAgB;AACjD,OAAOC,SAASC,QAAQ,QAAQ,QAAO;AAQvC,OAAO,MAAMC,qBAAsC,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAQ,EAAE;IAC3E,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGR,SAAiB;QAAEK;IAAK;IACpD,MAAM,CAACI,WAAWC,aAAa,GAAGR,SAAS,CAACM;IAE5C,MAAMG,WAAW,OAAOH,UAAU,YAAYA,MAAMI,UAAU,CAAC,UAAUJ,MAAMK,QAAQ,CAAC;IAExF,qBACE,MAACC;QAAIC,WAAU;;0BACb,MAACX;gBAAMW,WAAU;;oBACdX,SAAS;oBACTE,0BAAY,KAACU;wBAAKD,WAAU;kCAAW;;;;YAGzC,CAACN,aAAaE,yBACb,MAACG;gBAAIG,OAAO;oBAAEC,YAAY;oBAAUC,SAAS;oBAAQC,KAAK;gBAAO;;kCAC/D,MAACN;wBACCG,OAAO;4BACLI,YAAY;4BACZC,cAAc;4BACdC,UAAU;4BACVC,YAAY;4BACZC,SAAS;wBACX;;4BAECjB;0CACD,KAACQ;gCACCC,OAAO;oCAAES,OAAO;oCAA4BC,UAAU;oCAASC,YAAY;gCAAO;0CACnF;;;;kCAIH,KAAC7B;wBACC8B,aAAY;wBACZC,SAAS;4BACPvB,SAAS;4BACTG,aAAa;wBACf;wBACAqB,MAAK;kCACN;;;+BAKH,KAACC;gBACCC,UAAU,CAACC,IAAM3B,SAAS2B,EAAEC,MAAM,CAAC3B,KAAK;gBACxC4B,aAAY;gBACZnB,OAAO;oBAAEoB,OAAO;gBAAO;gBACvBC,MAAK;gBACL9B,OAAOA,SAAS;;;;AAK1B,EAAC"}
|