button.tsx 954 B

123456789101112131415161718192021222324252627282930
  1. import React, { useCallback } from 'react';
  2. import { Button } from '../../index';
  3. import getConfigureItem from './getConfigureItem';
  4. import cls from 'classnames';
  5. import { cssClasses } from '@douyinfe/semi-foundation/aiChatInput/constants';
  6. const ConfigureButton = (props: any) => {
  7. const { value, onChange, className, onClick, ...rest } = props;
  8. const onButtonClick = useCallback(() => {
  9. const newValue = !value;
  10. onChange(newValue);
  11. onClick?.(newValue);
  12. }, [value, onChange, onClick]);
  13. return (
  14. <Button
  15. className={cls(`${cssClasses.PREFIX}-footer-configure-button`, {
  16. [className]: className,
  17. [`${cssClasses.PREFIX}-footer-configure-button-active`]: value,
  18. })}
  19. onClick={onButtonClick}
  20. theme='outline'
  21. type='tertiary'
  22. {...rest}
  23. />
  24. );
  25. };
  26. export default getConfigureItem(ConfigureButton);