index.tsx 1006 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React, {lazy, Suspense} from 'react';
  2. import LoadingIndicator from '../loadingIndicator';
  3. import Placeholder from '../placeholder';
  4. import type {DatePickerProps} from './datePicker';
  5. import type {DateRangePickerProps} from './dateRangePicker';
  6. const LazyDatePicker = lazy(() => import('./datePicker'));
  7. const LazyDateRangePicker = lazy(() => import('./dateRangePicker'));
  8. const CalendarSuspenseWrapper: React.FC = ({children}) => {
  9. return (
  10. <Suspense
  11. fallback={
  12. <Placeholder width="342px" height="254px">
  13. <LoadingIndicator />
  14. </Placeholder>
  15. }
  16. >
  17. {children}
  18. </Suspense>
  19. );
  20. };
  21. export const DatePicker = (props: DatePickerProps) => {
  22. return (
  23. <CalendarSuspenseWrapper>
  24. <LazyDatePicker {...props} />
  25. </CalendarSuspenseWrapper>
  26. );
  27. };
  28. export const DateRangePicker = (props: DateRangePickerProps) => {
  29. return (
  30. <CalendarSuspenseWrapper>
  31. <LazyDateRangePicker {...props} />
  32. </CalendarSuspenseWrapper>
  33. );
  34. };