import { Center, Flex, FormControl, FormControlProps, FormLabel, IconButton, IconButtonProps, Text, useControllableState, UseControllableStateProps, } from "@chakra-ui/react"; import * as React from "react"; import { FiMinus, FiPlus } from "react-icons/fi"; interface QuantityPickerProps extends UseControllableStateProps { max?: number; min?: number; rootProps?: FormControlProps; } export const QuantityPicker = (props: QuantityPickerProps) => { const { min = 0, max, rootProps, ...rest } = props; const [value, setValue] = useControllableState(rest); const handleDecrement = () => setValue(value === min ? value : value - 1); const handleIncrement = () => setValue(value === max ? value : value + 1); return ( Quantity } isDisabled={value === min} aria-label="Decrement" />
{value}
} isDisabled={value === max} aria-label="Increment" />
); }; const QuantityPickerButton = (props: IconButtonProps) => ( );