1 | 'use client';
|
2 | import React from 'react';
|
3 | import { localStorageColorSchemeManager } from './color-scheme-managers/local-storage-manager.mjs';
|
4 | import { MantineContext } from './Mantine.context.mjs';
|
5 | import { MantineClasses } from './MantineClasses/MantineClasses.mjs';
|
6 | import { MantineCssVariables } from './MantineCssVariables/MantineCssVariables.mjs';
|
7 | import { MantineThemeProvider } from './MantineThemeProvider/MantineThemeProvider.mjs';
|
8 | import { suppressNextjsWarning } from './suppress-nextjs-warning.mjs';
|
9 | import '@mantine/hooks';
|
10 | import { useProviderColorScheme } from './use-mantine-color-scheme/use-provider-color-scheme.mjs';
|
11 | import { useRespectReduceMotion } from './use-respect-reduce-motion/use-respect-reduce-motion.mjs';
|
12 |
|
13 | suppressNextjsWarning();
|
14 | function MantineProvider({
|
15 | theme,
|
16 | children,
|
17 | getStyleNonce,
|
18 | withCssVariables = true,
|
19 | cssVariablesSelector = ":root",
|
20 | classNamesPrefix = "mantine",
|
21 | colorSchemeManager = localStorageColorSchemeManager(),
|
22 | defaultColorScheme = "light",
|
23 | getRootElement = () => document.documentElement,
|
24 | cssVariablesResolver,
|
25 | forceColorScheme
|
26 | }) {
|
27 | const { colorScheme, setColorScheme, clearColorScheme } = useProviderColorScheme({
|
28 | defaultColorScheme,
|
29 | forceColorScheme,
|
30 | manager: colorSchemeManager,
|
31 | getRootElement
|
32 | });
|
33 | useRespectReduceMotion({
|
34 | respectReducedMotion: theme?.respectReducedMotion || false,
|
35 | getRootElement
|
36 | });
|
37 | return React.createElement(
|
38 | MantineContext.Provider,
|
39 | {
|
40 | value: {
|
41 | colorSchemeManager,
|
42 | colorScheme,
|
43 | setColorScheme,
|
44 | clearColorScheme,
|
45 | getRootElement,
|
46 | classNamesPrefix,
|
47 | getStyleNonce,
|
48 | cssVariablesResolver,
|
49 | cssVariablesSelector
|
50 | }
|
51 | },
|
52 | React.createElement(MantineThemeProvider, { theme }, withCssVariables && React.createElement(MantineCssVariables, { cssVariablesSelector }), React.createElement(MantineClasses, null), children)
|
53 | );
|
54 | }
|
55 | MantineProvider.displayName = "@mantine/core/MantineProvider";
|
56 |
|
57 | export { MantineProvider };
|
58 |
|