mirror of
https://github.com/langgenius/dify.git
synced 2026-02-03 09:31:13 +08:00
41 lines
870 B
TypeScript
41 lines
870 B
TypeScript
'use client'
|
|
import type { FC } from 'react'
|
|
import * as React from 'react'
|
|
import { useCallback } from 'react'
|
|
import OptionCard from '../../../nodes/_base/components/option-card'
|
|
|
|
type Props = {
|
|
value: boolean
|
|
onChange: (value: boolean) => void
|
|
}
|
|
|
|
const BoolValue: FC<Props> = ({
|
|
value,
|
|
onChange,
|
|
}) => {
|
|
const booleanValue = value
|
|
const handleChange = useCallback((newValue: boolean) => {
|
|
return () => {
|
|
onChange(newValue)
|
|
}
|
|
}, [onChange])
|
|
|
|
return (
|
|
<div className="flex w-full space-x-1">
|
|
<OptionCard
|
|
className="grow"
|
|
selected={booleanValue}
|
|
title="True"
|
|
onSelect={handleChange(true)}
|
|
/>
|
|
<OptionCard
|
|
className="grow"
|
|
selected={!booleanValue}
|
|
title="False"
|
|
onSelect={handleChange(false)}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|
|
export default React.memo(BoolValue)
|