InputFormatConfirm.jsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React from 'react';
  2. import { DatePicker, Space, Button } from '../../../index';
  3. InputFormatConfirm.storyName = '输入时间 + needConfirm';
  4. export default function InputFormatConfirm() {
  5. const [insetInput, setInputInput] = React.useState(false);
  6. const format = 'yyyy-MM-dd HH:mm';
  7. const defaultPickerValue = '2021-03-15 14:00';
  8. const defaultPickerValue2 = ['2021-01-10 00:01', '2021-03-15 23:59'];
  9. const handleChange = (...args) => {
  10. console.log('change', ...args);
  11. };
  12. const handleConfirm = (...args) => {
  13. console.log('confirm', ...args);
  14. };
  15. const props = {
  16. format,
  17. onChange: handleChange,
  18. onConfirm: handleConfirm,
  19. motion: false,
  20. needConfirm: true,
  21. insetInput
  22. };
  23. return (
  24. <div data-cy="container">
  25. <Space>
  26. <Button data-cy="inset-switch" onClick={() => setInputInput(!insetInput)}>{`insetInput=${insetInput}`}</Button>
  27. <Space>
  28. <div data-cy="dateTime">
  29. <DatePicker {...props} type="dateTime" defaultPickerValue={defaultPickerValue} />
  30. </div>
  31. <div data-cy="dateTimeRange">
  32. <DatePicker {...props} type="dateTimeRange" defaultPickerValue={defaultPickerValue2} />
  33. </div>
  34. </Space>
  35. </Space>
  36. </div>
  37. );
  38. }