feat: support number field

This commit is contained in:
Joel
2024-08-07 16:24:45 +08:00
parent 4474004e99
commit 9b2d75239a
4 changed files with 31 additions and 1 deletions
+9
View File
@@ -68,6 +68,15 @@ const ConfigSence: FC<IConfigSenceProps> = ({
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
/>
)}
{item.type === 'number' && (
<input
type="number"
className="block w-full p-2 text-gray-900 border border-gray-300 rounded-lg bg-gray-50 sm:text-xs focus:ring-blue-500 focus:border-blue-500 "
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
value={inputs[item.key]}
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
/>
)}
</div>
</div>
))}
+9
View File
@@ -73,6 +73,15 @@ const RunOnce: FC<IRunOnceProps> = ({
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
/>
)}
{item.type === 'number' && (
<input
type="number"
className="block w-full p-2 text-gray-900 border border-gray-300 rounded-lg bg-gray-50 sm:text-xs focus:ring-blue-500 focus:border-blue-500 "
placeholder={`${item.name}${!item.required ? `(${t('appDebug.variableTable.optional')})` : ''}`}
value={inputs[item.key]}
onChange={(e) => { onInputsChange({ ...inputs, [item.key]: e.target.value }) }}
/>
)}
</div>
</div>
))}
+1 -1
View File
@@ -39,7 +39,7 @@
"js-cookie": "^3.0.1",
"katex": "^0.16.7",
"negotiator": "^0.6.3",
"next": "^14.0.4",
"next": "^14.1.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-boundary": "^4.0.2",
+12
View File
@@ -24,6 +24,9 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
if (item['text-input'])
return ['string', item['text-input']]
if (item.number)
return ['number', item.number]
return ['select', item.select]
})()
if (type === 'string' || type === 'paragraph') {
@@ -36,6 +39,15 @@ export const userInputsFormToPromptVariables = (useInputs: UserInputFormItem[] |
options: [],
})
}
else if (type === 'number') {
promptVariables.push({
key: content.variable,
name: content.label,
required: content.required,
type,
options: [],
})
}
else {
promptVariables.push({
key: content.variable,