diff --git a/web/app/components/base/date-and-time-picker/date-picker/index.tsx b/web/app/components/base/date-and-time-picker/date-picker/index.tsx index 67dbec3b90..82f6500f1d 100644 --- a/web/app/components/base/date-and-time-picker/date-picker/index.tsx +++ b/web/app/components/base/date-and-time-picker/date-picker/index.tsx @@ -234,7 +234,7 @@ const DatePicker = ({ )} - +
{/* Header */} {view === ViewType.date ? ( diff --git a/web/app/components/base/date-and-time-picker/time-picker/index.tsx b/web/app/components/base/date-and-time-picker/time-picker/index.tsx index 1fecda00b7..9a15888789 100644 --- a/web/app/components/base/date-and-time-picker/time-picker/index.tsx +++ b/web/app/components/base/date-and-time-picker/time-picker/index.tsx @@ -142,7 +142,7 @@ const TimePicker = ({
)} - +
{/* Header */}
diff --git a/web/app/components/base/markdown-blocks/form.tsx b/web/app/components/base/markdown-blocks/form.tsx index 7ce3e82b1d..89b9d76dc8 100644 --- a/web/app/components/base/markdown-blocks/form.tsx +++ b/web/app/components/base/markdown-blocks/form.tsx @@ -2,6 +2,10 @@ import React, { useEffect, useState } from 'react' import Button from '@/app/components/base/button' import Input from '@/app/components/base/input' import Textarea from '@/app/components/base/textarea' +import DatePicker from '@/app/components/base/date-and-time-picker/date-picker' +import TimePicker from '@/app/components/base/date-and-time-picker/time-picker' +import Checkbox from '@/app/components/base/checkbox' +import Select from '@/app/components/base/select' import { useChatContext } from '@/app/components/base/chat/chat/context' enum DATA_FORMAT { @@ -19,18 +23,13 @@ enum SUPPORTED_TYPES { PASSWORD = 'password', EMAIL = 'email', NUMBER = 'number', + DATE = 'date', + TIME = 'time', + DATETIME = 'datetime', + CHECKBOX = 'checkbox', + SELECT = 'select', } const MarkdownForm = ({ node }: any) => { - // const supportedTypes = ['text', 'password', 'email', 'number'] - //
- // - // - // - // - // - // - // - //
const { onSend } = useChatContext() const [formValues, setFormValues] = useState<{ [key: string]: any }>({}) @@ -90,6 +89,97 @@ const MarkdownForm = ({ node }: any) => { ) } if (child.tagName === SUPPORTED_TAGS.INPUT && Object.values(SUPPORTED_TYPES).includes(child.properties.type)) { + if (child.properties.type === SUPPORTED_TYPES.DATE || child.properties.type === SUPPORTED_TYPES.DATETIME) { + return ( + { + setFormValues(prevValues => ({ + ...prevValues, + [child.properties.name]: date, + })) + }} + onClear={() => { + setFormValues(prevValues => ({ + ...prevValues, + [child.properties.name]: undefined, + })) + }} + /> + ) + } + if (child.properties.type === SUPPORTED_TYPES.TIME) { + return ( + { + setFormValues(prevValues => ({ + ...prevValues, + [child.properties.name]: time, + })) + }} + onClear={() => { + setFormValues(prevValues => ({ + ...prevValues, + [child.properties.name]: undefined, + })) + }} + /> + ) + } + if (child.properties.type === SUPPORTED_TYPES.CHECKBOX) { + return ( +
+ { + setFormValues(prevValues => ({ + ...prevValues, + [child.properties.name]: !prevValues[child.properties.name], + })) + }} + /> + {child.properties.dataTip || child.properties['data-tip'] || ''} +
+ ) + } + if (child.properties.type === SUPPORTED_TYPES.SELECT) { + return ( + :first-child { margin-top: 0; } @@ -1035,4 +1038,4 @@ .markdown-body .react-syntax-highlighter-line-number { color: var(--color-text-quaternary); -} \ No newline at end of file +}