Blame view

天文台pc/tianwentai-ui/node_modules/react-day-picker/src/contexts/RootProvider.tsx 1.64 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  import { ReactNode } from 'react';
  
  import { ModifiersProvider } from 'contexts/Modifiers/ModifiersContext';
  
  import { DayPickerProvider } from './DayPicker';
  import { FocusProvider } from './Focus';
  import { NavigationProvider } from './Navigation';
  import { SelectMultipleProvider } from './SelectMultiple';
  import { SelectRangeProvider } from './SelectRange';
  import { SelectSingleProvider } from './SelectSingle';
  import { DayPickerDefaultProps } from 'types/DayPickerDefault';
  import { DayPickerSingleProps } from 'types/DayPickerSingle';
  import { DayPickerMultipleProps } from 'types/DayPickerMultiple';
  import { DayPickerRangeProps } from 'types/DayPickerRange';
  
  type RootContextProps =
    | Partial<DayPickerDefaultProps>
    | Partial<DayPickerSingleProps>
    | Partial<DayPickerMultipleProps>
    | Partial<DayPickerRangeProps>;
  
  /** The props of {@link RootProvider}. */
  export type RootContext = RootContextProps & {
    children?: ReactNode;
  };
  
  /** Provide the value for all the context providers. */
  export function RootProvider(props: RootContext): JSX.Element {
    const { children, ...initialProps } = props;
  
    return (
      <DayPickerProvider initialProps={initialProps}>
        <NavigationProvider>
          <SelectSingleProvider initialProps={initialProps}>
            <SelectMultipleProvider initialProps={initialProps}>
              <SelectRangeProvider initialProps={initialProps}>
                <ModifiersProvider>
                  <FocusProvider>{children}</FocusProvider>
                </ModifiersProvider>
              </SelectRangeProvider>
            </SelectMultipleProvider>
          </SelectSingleProvider>
        </NavigationProvider>
      </DayPickerProvider>
    );
  }