aiChatInput.stories.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import React, { useCallback, useState } from 'react';
  2. import { AIChatInput } from '../../index';
  3. import { storiesOf } from '@storybook/react';
  4. import { uploadProps } from './constant';
  5. const stories = storiesOf('AIChatInput', module);
  6. const outerStyle = { margin: 12, maxHeight: 300 };
  7. stories.add('default', () => {
  8. const [generating, setGenerating] = useState(false);
  9. const onContentChange = useCallback((content) => {
  10. console.log('onContentChange', content);
  11. }, []);
  12. const onUploadChange = useCallback((fileList) => {
  13. console.log('onUploadChange', fileList);
  14. }, []);
  15. const toggleGenerate = useCallback(() => {
  16. setGenerating(value => !value);
  17. }, []);
  18. return (
  19. <AIChatInput
  20. generating={generating}
  21. defaultContent={''}
  22. placeholder={'输入内容或者上传内容'}
  23. uploadProps={uploadProps}
  24. onContentChange={onContentChange}
  25. onUploadChange={onUploadChange}
  26. style={outerStyle}
  27. onMessageSend={toggleGenerate}
  28. onStopGenerate={toggleGenerate}
  29. />
  30. );
  31. });