({
className,
style,
draggable = false,
position,
children,
onChange,
}: React.PropsWithChildren<IFloatProps>)
| 14 | } |
| 15 | |
| 16 | export default function Float({ |
| 17 | className, |
| 18 | style, |
| 19 | draggable = false, |
| 20 | position, |
| 21 | children, |
| 22 | onChange, |
| 23 | }: React.PropsWithChildren<IFloatProps>) { |
| 24 | const [dragging, setDragging] = useState(false); |
| 25 | const mergedDraggable = useMergeOption(draggable); |
| 26 | |
| 27 | const handleStopDrag: DraggableEventHandler = (e, data) => { |
| 28 | mergedDraggable.options.onStop?.(e, data); |
| 29 | onChange?.(e, data); |
| 30 | setDragging(false); |
| 31 | }; |
| 32 | |
| 33 | const handleDrag: DraggableEventHandler = (e, data) => { |
| 34 | mergedDraggable.options.onDrag?.(e, data); |
| 35 | setDragging(true); |
| 36 | }; |
| 37 | |
| 38 | return ( |
| 39 | <Draggable |
| 40 | disabled={mergedDraggable.disabled} |
| 41 | {...mergedDraggable.options} |
| 42 | position={position} |
| 43 | onDrag={handleDrag} |
| 44 | onStop={handleStopDrag} |
| 45 | > |
| 46 | <div |
| 47 | className={classNames( |
| 48 | 'dtc-float-container', |
| 49 | className, |
| 50 | dragging && 'dtc-float-container__dragging' |
| 51 | )} |
| 52 | style={style} |
| 53 | > |
| 54 | {children} |
| 55 | </div> |
| 56 | </Draggable> |
| 57 | ); |
| 58 | } |
nothing calls this directly
no test coverage detected