feat: implement input field dialog and related components for rag pipeline
parent
e04ae927b6
commit
5b8c43052e
@ -0,0 +1,55 @@
|
||||
import { Fragment, useCallback } from 'react'
|
||||
import type { ReactNode } from 'react'
|
||||
import { Dialog, DialogPanel, Transition, TransitionChild } from '@headlessui/react'
|
||||
import cn from '@/utils/classnames'
|
||||
|
||||
type DialogWrapperProps = {
|
||||
className?: string
|
||||
panelWrapperClassName?: string
|
||||
children: ReactNode
|
||||
show: boolean
|
||||
onClose?: () => void
|
||||
}
|
||||
|
||||
const DialogWrapper = ({
|
||||
className,
|
||||
panelWrapperClassName,
|
||||
children,
|
||||
show,
|
||||
onClose,
|
||||
}: DialogWrapperProps) => {
|
||||
const close = useCallback(() => onClose?.(), [onClose])
|
||||
return (
|
||||
<Transition appear show={show} as={Fragment}>
|
||||
<Dialog as='div' className='relative z-40' onClose={close}>
|
||||
<TransitionChild>
|
||||
<div className={cn(
|
||||
'fixed inset-0 bg-black/25',
|
||||
'data-[closed]:opacity-0',
|
||||
'data-[enter]:opacity-100 data-[enter]:duration-300 data-[enter]:ease-out',
|
||||
'data-[leave]:opacity-0 data-[leave]:duration-200 data-[leave]:ease-in',
|
||||
)} />
|
||||
</TransitionChild>
|
||||
|
||||
<div className='fixed inset-0'>
|
||||
<div className={cn('flex min-h-full flex-col items-end justify-center pb-1 pt-[116px]', panelWrapperClassName)}>
|
||||
<TransitionChild>
|
||||
<DialogPanel className={cn(
|
||||
'relative flex w-[420px] grow flex-col overflow-hidden border-components-panel-border bg-components-panel-bg-alt p-0 shadow-xl shadow-shadow-shadow-5 transition-all',
|
||||
'rounded-l-2xl border-y-[0.5px] border-l-[0.5px]',
|
||||
'data-[closed]:scale-95 data-[closed]:opacity-0',
|
||||
'data-[enter]:scale-100 data-[enter]:opacity-100 data-[enter]:duration-300 data-[enter]:ease-out',
|
||||
'data-[leave]:scale-95 data-[leave]:opacity-0 data-[leave]:duration-200 data-[leave]:ease-in',
|
||||
className,
|
||||
)}>
|
||||
{children}
|
||||
</DialogPanel>
|
||||
</TransitionChild>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog>
|
||||
</Transition >
|
||||
)
|
||||
}
|
||||
|
||||
export default DialogWrapper
|
||||
@ -0,0 +1,49 @@
|
||||
import InputFieldForm from '@/app/components/base/form/form-scenarios/input-field'
|
||||
import { RiCloseLine } from '@remixicon/react'
|
||||
import DialogWrapper from './dialog-wrapper'
|
||||
import type { InputVar } from '@/app/components/workflow/types'
|
||||
|
||||
type InputFieldEditorProps = {
|
||||
show: boolean
|
||||
onClose: () => void
|
||||
initialData?: InputVar
|
||||
}
|
||||
|
||||
const InputFieldEditor = ({
|
||||
show,
|
||||
onClose,
|
||||
initialData,
|
||||
}: InputFieldEditorProps) => {
|
||||
return (
|
||||
<DialogWrapper
|
||||
show={show}
|
||||
onClose={onClose}
|
||||
panelWrapperClassName='pr-[424px] justify-start'
|
||||
className='w-[400px] grow-0 rounded-2xl border-[0.5px] bg-components-panel-bg shadow-shadow-shadow-9'
|
||||
>
|
||||
<div className='relative flex h-fit flex-col'>
|
||||
<div className='system-xl-semibold flex items-center pb-1 pl-4 pr-11 pt-3.5 text-text-primary'>
|
||||
Add Input Field
|
||||
</div>
|
||||
<button
|
||||
type='button'
|
||||
className='absolute right-2.5 top-2.5 flex size-8 items-center justify-center'
|
||||
onClick={onClose}
|
||||
>
|
||||
<RiCloseLine className='size-4 text-text-tertiary' />
|
||||
</button>
|
||||
<InputFieldForm
|
||||
initialData={initialData}
|
||||
supportFile
|
||||
onCancel={onClose}
|
||||
onSubmit={(value) => {
|
||||
console.log('submit', value)
|
||||
onClose()
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</DialogWrapper>
|
||||
)
|
||||
}
|
||||
|
||||
export default InputFieldEditor
|
||||
@ -1,38 +0,0 @@
|
||||
import { useStore } from '@/app/components/workflow/store'
|
||||
import InputFieldForm from '@/app/components/base/form/form-scenarios/input-field'
|
||||
import { useCallback } from 'react'
|
||||
import { RiCloseLine } from '@remixicon/react'
|
||||
|
||||
const InputFieldEditor = () => {
|
||||
const setShowInputFieldEditor = useStore(state => state.setShowInputFieldEditor)
|
||||
|
||||
const closeEditor = useCallback(() => {
|
||||
setShowInputFieldEditor?.(false)
|
||||
}, [setShowInputFieldEditor])
|
||||
|
||||
return (
|
||||
<div className='relative flex h-fit w-[400px] flex-col rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-2xl shadow-shadow-shadow-9'>
|
||||
<div className='system-xl-semibold flex items-center pb-1 pl-4 pr-11 pt-3.5 text-text-primary'>
|
||||
Add Input Field
|
||||
</div>
|
||||
<button
|
||||
type='button'
|
||||
className='absolute right-2.5 top-2.5 flex size-8 items-center justify-center'
|
||||
onClick={closeEditor}
|
||||
>
|
||||
<RiCloseLine className='size-4 text-text-tertiary' />
|
||||
</button>
|
||||
<InputFieldForm
|
||||
initialData={undefined}
|
||||
supportFile
|
||||
onCancel={closeEditor}
|
||||
onSubmit={(value) => {
|
||||
console.log('submit', value)
|
||||
closeEditor()
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default InputFieldEditor
|
||||
@ -0,0 +1,20 @@
|
||||
import { useStore } from '../../workflow/store'
|
||||
import InputField from './input-field'
|
||||
import RagPipelinePanel from './panel'
|
||||
import RagPipelineHeader from './rag-pipeline-header'
|
||||
|
||||
const RagPipelineChildren = () => {
|
||||
const showInputFieldDialog = useStore(state => state.showInputFieldDialog)
|
||||
|
||||
return (
|
||||
<>
|
||||
<RagPipelineHeader />
|
||||
<RagPipelinePanel />
|
||||
{
|
||||
showInputFieldDialog && (<InputField />)
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default RagPipelineChildren
|
||||
@ -1,20 +1,16 @@
|
||||
import type { StateCreator } from 'zustand'
|
||||
|
||||
export type RagPipelineSliceShape = {
|
||||
showInputFieldEditor: boolean
|
||||
setShowInputFieldEditor: (showInputFieldDialog: boolean) => void
|
||||
showInputFieldPanel: boolean
|
||||
setShowInputFieldPanel: (showInputFieldPanel: boolean) => void
|
||||
showInputFieldDialog: boolean
|
||||
setShowInputFieldDialog: (showInputFieldPanel: boolean) => void
|
||||
nodesDefaultConfigs: Record<string, any>
|
||||
setNodesDefaultConfigs: (nodesDefaultConfigs: Record<string, any>) => void
|
||||
}
|
||||
|
||||
export type CreateRagPipelineSliceSlice = StateCreator<RagPipelineSliceShape>
|
||||
export const createRagPipelineSliceSlice: StateCreator<RagPipelineSliceShape> = set => ({
|
||||
showInputFieldEditor: false,
|
||||
setShowInputFieldEditor: showInputFieldEditor => set(() => ({ showInputFieldEditor })),
|
||||
showInputFieldPanel: false,
|
||||
setShowInputFieldPanel: showInputFieldPanel => set(() => ({ showInputFieldPanel })),
|
||||
showInputFieldDialog: false,
|
||||
setShowInputFieldDialog: showInputFieldDialog => set(() => ({ showInputFieldDialog })),
|
||||
nodesDefaultConfigs: {},
|
||||
setNodesDefaultConfigs: nodesDefaultConfigs => set(() => ({ nodesDefaultConfigs })),
|
||||
})
|
||||
|
||||
Loading…
Reference in New Issue