@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { MoreInfoTooltip } from '@/components/MoreInfoTooltip'
|
import { MoreInfoTooltip } from '@/components/MoreInfoTooltip'
|
||||||
import { Select } from '@/components/inputs/Select'
|
import { Select } from '@/components/inputs/Select'
|
||||||
|
import { VariablesButton } from '@/features/variables/components/VariablesButton'
|
||||||
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
||||||
import { useToast } from '@/hooks/useToast'
|
import { useToast } from '@/hooks/useToast'
|
||||||
import { trpc } from '@/lib/trpc'
|
import { trpc } from '@/lib/trpc'
|
||||||
@ -29,6 +30,7 @@ type Props = {
|
|||||||
direction?: 'row' | 'column'
|
direction?: 'row' | 'column'
|
||||||
isRequired?: boolean
|
isRequired?: boolean
|
||||||
width?: 'full'
|
width?: 'full'
|
||||||
|
withVariableButton?: boolean
|
||||||
onChange: (value: string | undefined) => void
|
onChange: (value: string | undefined) => void
|
||||||
}
|
}
|
||||||
export const ForgeSelectInput = ({
|
export const ForgeSelectInput = ({
|
||||||
@ -43,6 +45,7 @@ export const ForgeSelectInput = ({
|
|||||||
isRequired,
|
isRequired,
|
||||||
direction = 'column',
|
direction = 'column',
|
||||||
width,
|
width,
|
||||||
|
withVariableButton = false,
|
||||||
onChange,
|
onChange,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { workspace } = useWorkspace()
|
const { workspace } = useWorkspace()
|
||||||
@ -99,12 +102,21 @@ export const ForgeSelectInput = ({
|
|||||||
)}
|
)}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
)}
|
)}
|
||||||
|
<HStack spacing="0">
|
||||||
<Select
|
<Select
|
||||||
items={data?.items}
|
items={data?.items}
|
||||||
selectedItem={defaultValue}
|
selectedItem={defaultValue}
|
||||||
onSelect={onChange}
|
onSelect={onChange}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
/>
|
/>
|
||||||
|
{withVariableButton ? (
|
||||||
|
<VariablesButton
|
||||||
|
onSelectVariable={(variable) => {
|
||||||
|
onChange(`{{${variable.name}}}`)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</HStack>
|
||||||
{helperText && <FormHelperText mt="0">{helperText}</FormHelperText>}
|
{helperText && <FormHelperText mt="0">{helperText}</FormHelperText>}
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)
|
)
|
||||||
|
@ -204,6 +204,7 @@ export const ZodFieldLayout = ({
|
|||||||
moreInfoTooltip={layout?.moreInfoTooltip}
|
moreInfoTooltip={layout?.moreInfoTooltip}
|
||||||
onChange={onDataChange}
|
onChange={onDataChange}
|
||||||
width={width}
|
width={width}
|
||||||
|
withVariableButton={layout.withVariableButton ?? true}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user