@mui/docs 9.0.0-alpha.1 → 9.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/Ad/Ad.js +33 -42
  2. package/Ad/AdCarbon.js +18 -27
  3. package/Ad/AdDisplay.js +22 -29
  4. package/Ad/AdGuest.js +8 -15
  5. package/Ad/AdInHouse.js +4 -11
  6. package/Ad/AdManager.js +8 -17
  7. package/Ad/AdProvider.js +5 -13
  8. package/Ad/ad.styles.js +5 -13
  9. package/Ad/index.js +6 -62
  10. package/AnalyticsProvider/AnalyticsProvider.d.ts +17 -0
  11. package/AnalyticsProvider/AnalyticsProvider.js +225 -0
  12. package/AnalyticsProvider/index.d.ts +1 -0
  13. package/AnalyticsProvider/index.js +1 -0
  14. package/CHANGELOG.md +65 -0
  15. package/CodeCopy/CodeCopy.js +10 -19
  16. package/CodeCopy/CodeCopyButton.js +9 -16
  17. package/CodeCopy/index.js +3 -40
  18. package/CodeCopy/useClipboardCopy.js +4 -12
  19. package/ComponentLinkHeader/ComponentLinkHeader.js +46 -54
  20. package/ComponentLinkHeader/index.js +2 -24
  21. package/DemoContext/DemoContext.d.ts +86 -0
  22. package/DemoContext/DemoContext.js +13 -0
  23. package/DemoContext/index.d.ts +2 -0
  24. package/DemoContext/index.js +1 -0
  25. package/DocsProvider/DocsProvider.js +9 -17
  26. package/DocsProvider/index.js +1 -16
  27. package/Document/Document.d.ts +16 -0
  28. package/Document/Document.js +147 -0
  29. package/Document/getInitialProps.d.ts +18 -0
  30. package/Document/getInitialProps.js +62 -0
  31. package/Document/index.d.ts +2 -0
  32. package/Document/index.js +2 -0
  33. package/GoogleAnalytics/GoogleAnalytics.d.ts +9 -0
  34. package/GoogleAnalytics/GoogleAnalytics.js +129 -0
  35. package/GoogleAnalytics/index.d.ts +1 -0
  36. package/GoogleAnalytics/index.js +1 -0
  37. package/HighlightedCode/HighlightedCode.js +18 -26
  38. package/HighlightedCode/index.js +1 -16
  39. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.js +22 -31
  40. package/HighlightedCodeWithTabs/index.js +2 -24
  41. package/IconImage/IconImage.d.ts +11 -0
  42. package/IconImage/IconImage.js +83 -0
  43. package/IconImage/index.d.ts +1 -0
  44. package/IconImage/index.js +1 -0
  45. package/InfoCard/InfoCard.js +20 -29
  46. package/InfoCard/index.js +1 -16
  47. package/Link/Link.js +17 -25
  48. package/Link/MarkdownLinks.d.ts +2 -0
  49. package/Link/MarkdownLinks.js +84 -0
  50. package/Link/SkipLink.d.ts +1 -0
  51. package/Link/SkipLink.js +66 -0
  52. package/Link/index.d.ts +3 -1
  53. package/Link/index.js +3 -16
  54. package/MarkdownElement/MarkdownElement.js +178 -186
  55. package/MarkdownElement/index.js +1 -16
  56. package/MuiPage/MuiPage.d.ts +67 -0
  57. package/MuiPage/MuiPage.js +1 -0
  58. package/MuiPage/index.d.ts +1 -0
  59. package/MuiPage/index.js +1 -0
  60. package/NextNProgressBar/NextNProgressBar.d.ts +1 -0
  61. package/NextNProgressBar/NextNProgressBar.js +44 -0
  62. package/NextNProgressBar/index.d.ts +1 -0
  63. package/NextNProgressBar/index.js +1 -0
  64. package/PageContext/PageContext.d.ts +31 -0
  65. package/PageContext/PageContext.js +6 -0
  66. package/PageContext/index.d.ts +2 -0
  67. package/PageContext/index.js +1 -0
  68. package/SectionHeadline/SectionHeadline.d.ts +13 -0
  69. package/SectionHeadline/SectionHeadline.js +81 -0
  70. package/SectionHeadline/index.d.ts +2 -0
  71. package/SectionHeadline/index.js +2 -0
  72. package/SectionTitle/SectionTitle.js +7 -13
  73. package/SectionTitle/index.js +1 -16
  74. package/StyledEngineProvider/StyledEngineProvider.d.ts +9 -0
  75. package/StyledEngineProvider/StyledEngineProvider.js +44 -0
  76. package/StyledEngineProvider/index.d.ts +1 -0
  77. package/StyledEngineProvider/index.js +1 -0
  78. package/ThemeContext/ThemeContext.d.ts +92 -0
  79. package/ThemeContext/ThemeContext.js +200 -0
  80. package/ThemeContext/index.d.ts +1 -0
  81. package/ThemeContext/index.js +1 -0
  82. package/branding/BrandingCssVarsProvider.d.ts +23 -0
  83. package/branding/BrandingCssVarsProvider.js +170 -0
  84. package/branding/BrandingProvider.js +8 -15
  85. package/branding/brandingTheme.js +115 -126
  86. package/branding/index.d.ts +2 -1
  87. package/branding/index.js +3 -27
  88. package/codeStyling/codeStyling.d.ts +10 -0
  89. package/codeStyling/codeStyling.js +84 -0
  90. package/codeStyling/index.d.ts +1 -0
  91. package/codeStyling/index.js +1 -0
  92. package/codeVariant/codeVariant.d.ts +10 -0
  93. package/codeVariant/codeVariant.js +73 -0
  94. package/codeVariant/index.d.ts +1 -0
  95. package/codeVariant/index.js +1 -0
  96. package/constants/constants.d.ts +13 -0
  97. package/constants/constants.js +15 -0
  98. package/constants/index.d.ts +1 -0
  99. package/constants/index.js +1 -0
  100. package/createEmotionCache/createEmotionCache.d.ts +1 -0
  101. package/createEmotionCache/createEmotionCache.js +12 -0
  102. package/createEmotionCache/index.d.ts +1 -0
  103. package/createEmotionCache/index.js +1 -0
  104. package/findActivePage/findActivePage.d.ts +5 -0
  105. package/findActivePage/findActivePage.js +35 -0
  106. package/findActivePage/index.d.ts +1 -0
  107. package/findActivePage/index.js +1 -0
  108. package/getProductInfoFromUrl/getProductInfoFromUrl.d.ts +8 -0
  109. package/getProductInfoFromUrl/getProductInfoFromUrl.js +50 -0
  110. package/getProductInfoFromUrl/index.d.ts +2 -0
  111. package/getProductInfoFromUrl/index.js +1 -0
  112. package/globalSelector/globalSelector.d.ts +2 -0
  113. package/globalSelector/globalSelector.js +17 -0
  114. package/globalSelector/index.d.ts +1 -0
  115. package/globalSelector/index.js +1 -0
  116. package/helpers/helpers.d.ts +31 -0
  117. package/helpers/helpers.js +87 -0
  118. package/helpers/index.d.ts +2 -0
  119. package/helpers/index.js +1 -0
  120. package/i18n/i18n.js +17 -29
  121. package/i18n/index.js +1 -16
  122. package/mapApiPageTranslations/index.d.ts +1 -0
  123. package/mapApiPageTranslations/index.js +1 -0
  124. package/mapApiPageTranslations/mapApiPageTranslations.d.ts +11 -0
  125. package/mapApiPageTranslations/mapApiPageTranslations.js +46 -0
  126. package/nextFonts/index.js +8 -15
  127. package/package.json +265 -102
  128. package/svgIcons/BundleSizeIcon.js +5 -11
  129. package/svgIcons/FigmaIcon.js +8 -14
  130. package/svgIcons/FileDownload.js +5 -12
  131. package/svgIcons/JavaScript.js +5 -12
  132. package/svgIcons/MarkdownIcon.js +7 -14
  133. package/svgIcons/MaterialDesignIcon.js +6 -12
  134. package/svgIcons/SketchIcon.js +10 -16
  135. package/svgIcons/TypeScript.js +5 -12
  136. package/svgIcons/W3CIcon.js +6 -12
  137. package/translations/index.js +3 -10
  138. package/translations/translations.json +0 -1
  139. package/useLazyCSS/index.d.ts +1 -0
  140. package/useLazyCSS/index.js +1 -0
  141. package/useLazyCSS/useLazyCSS.d.ts +11 -0
  142. package/useLazyCSS/useLazyCSS.js +70 -0
  143. package/utils/index.d.ts +1 -0
  144. package/utils/index.js +2 -0
  145. package/utils/loadScript.js +1 -7
  146. package/Ad/Ad.d.mts +0 -5
  147. package/Ad/Ad.mjs +0 -226
  148. package/Ad/AdCarbon.d.mts +0 -2
  149. package/Ad/AdCarbon.mjs +0 -125
  150. package/Ad/AdDisplay.d.mts +0 -16
  151. package/Ad/AdDisplay.mjs +0 -86
  152. package/Ad/AdGuest.d.mts +0 -10
  153. package/Ad/AdGuest.mjs +0 -29
  154. package/Ad/AdInHouse.d.mts +0 -4
  155. package/Ad/AdInHouse.mjs +0 -14
  156. package/Ad/AdManager.d.mts +0 -19
  157. package/Ad/AdManager.mjs +0 -36
  158. package/Ad/AdProvider.d.mts +0 -15
  159. package/Ad/AdProvider.mjs +0 -24
  160. package/Ad/ad.styles.d.mts +0 -4512
  161. package/Ad/ad.styles.mjs +0 -91
  162. package/Ad/index.d.mts +0 -5
  163. package/Ad/index.mjs +0 -7
  164. package/CodeCopy/CodeCopy.d.mts +0 -22
  165. package/CodeCopy/CodeCopy.mjs +0 -172
  166. package/CodeCopy/CodeCopyButton.d.mts +0 -4
  167. package/CodeCopy/CodeCopyButton.mjs +0 -40
  168. package/CodeCopy/index.d.mts +0 -3
  169. package/CodeCopy/index.mjs +0 -3
  170. package/CodeCopy/useClipboardCopy.d.mts +0 -4
  171. package/CodeCopy/useClipboardCopy.mjs +0 -21
  172. package/ComponentLinkHeader/ComponentLinkHeader.d.mts +0 -8
  173. package/ComponentLinkHeader/ComponentLinkHeader.mjs +0 -197
  174. package/ComponentLinkHeader/index.d.mts +0 -2
  175. package/ComponentLinkHeader/index.mjs +0 -2
  176. package/DocsProvider/DocsProvider.d.mts +0 -24
  177. package/DocsProvider/DocsProvider.mjs +0 -31
  178. package/DocsProvider/index.d.mts +0 -1
  179. package/DocsProvider/index.mjs +0 -1
  180. package/HighlightedCode/HighlightedCode.d.mts +0 -14
  181. package/HighlightedCode/HighlightedCode.mjs +0 -67
  182. package/HighlightedCode/index.d.mts +0 -1
  183. package/HighlightedCode/index.mjs +0 -1
  184. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.d.mts +0 -28
  185. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.mjs +0 -362
  186. package/HighlightedCodeWithTabs/index.d.mts +0 -2
  187. package/HighlightedCodeWithTabs/index.mjs +0 -2
  188. package/InfoCard/InfoCard.d.mts +0 -22
  189. package/InfoCard/InfoCard.mjs +0 -87
  190. package/InfoCard/index.d.mts +0 -1
  191. package/InfoCard/index.mjs +0 -1
  192. package/Link/Link.d.mts +0 -25
  193. package/Link/Link.mjs +0 -75
  194. package/Link/index.d.mts +0 -1
  195. package/Link/index.mjs +0 -1
  196. package/MarkdownElement/MarkdownElement.d.mts +0 -7
  197. package/MarkdownElement/MarkdownElement.mjs +0 -847
  198. package/MarkdownElement/index.d.mts +0 -1
  199. package/MarkdownElement/index.mjs +0 -1
  200. package/NProgressBar/NProgressBar.d.mts +0 -6
  201. package/NProgressBar/NProgressBar.js +0 -98
  202. package/NProgressBar/index.d.mts +0 -2
  203. package/NProgressBar/index.d.ts +0 -2
  204. package/NProgressBar/index.js +0 -13
  205. package/NProgressBar/index.mjs +0 -1
  206. package/SectionTitle/SectionTitle.d.mts +0 -6
  207. package/SectionTitle/SectionTitle.mjs +0 -29
  208. package/SectionTitle/index.d.mts +0 -1
  209. package/SectionTitle/index.mjs +0 -1
  210. package/branding/BrandingProvider.d.mts +0 -9
  211. package/branding/BrandingProvider.mjs +0 -17
  212. package/branding/brandingTheme.d.mts +0 -147
  213. package/branding/brandingTheme.mjs +0 -1527
  214. package/branding/index.d.mts +0 -2
  215. package/branding/index.mjs +0 -2
  216. package/i18n/i18n.d.mts +0 -27
  217. package/i18n/i18n.mjs +0 -111
  218. package/i18n/index.d.mts +0 -1
  219. package/i18n/index.mjs +0 -1
  220. package/nextFonts/index.d.mts +0 -6
  221. package/nextFonts/index.mjs +0 -59
  222. package/svgIcons/BundleSizeIcon.d.mts +0 -4
  223. package/svgIcons/BundleSizeIcon.mjs +0 -13
  224. package/svgIcons/FigmaIcon.d.mts +0 -4
  225. package/svgIcons/FigmaIcon.mjs +0 -22
  226. package/svgIcons/FileDownload.d.mts +0 -6
  227. package/svgIcons/FileDownload.mjs +0 -13
  228. package/svgIcons/JavaScript.d.mts +0 -6
  229. package/svgIcons/JavaScript.mjs +0 -13
  230. package/svgIcons/MarkdownIcon.d.mts +0 -2
  231. package/svgIcons/MarkdownIcon.mjs +0 -22
  232. package/svgIcons/MaterialDesignIcon.d.mts +0 -4
  233. package/svgIcons/MaterialDesignIcon.mjs +0 -18
  234. package/svgIcons/SketchIcon.d.mts +0 -4
  235. package/svgIcons/SketchIcon.mjs +0 -27
  236. package/svgIcons/TypeScript.d.mts +0 -6
  237. package/svgIcons/TypeScript.mjs +0 -13
  238. package/svgIcons/W3CIcon.d.mts +0 -4
  239. package/svgIcons/W3CIcon.mjs +0 -15
  240. package/translations/index.d.mts +0 -3
  241. package/translations/index.mjs +0 -4
  242. package/utils/loadScript.d.mts +0 -1
  243. package/utils/loadScript.mjs +0 -7
  244. /package/{NProgressBar → NextNProgressBar}/NProgressBar.d.ts +0 -0
  245. /package/{NProgressBar/NProgressBar.mjs → NextNProgressBar/NProgressBar.js} +0 -0
@@ -0,0 +1,200 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { createTheme as createMdTheme } from '@mui/material/styles';
4
+ import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
5
+ import useMediaQuery from '@mui/material/useMediaQuery';
6
+ import useLocalStorageState from '@mui/utils/useLocalStorageState';
7
+ import useLazyCSS from "../useLazyCSS/index.js";
8
+ import { getMetaThemeColor } from "../branding/index.js";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const themeInitialOptions = {
11
+ dense: false,
12
+ direction: 'ltr',
13
+ paletteMode: 'light'
14
+ };
15
+ export const highDensity = {
16
+ components: {
17
+ MuiButton: {
18
+ defaultProps: {
19
+ size: 'small'
20
+ }
21
+ },
22
+ MuiFilledInput: {
23
+ defaultProps: {
24
+ margin: 'dense'
25
+ }
26
+ },
27
+ MuiFormControl: {
28
+ defaultProps: {
29
+ margin: 'dense'
30
+ }
31
+ },
32
+ MuiFormHelperText: {
33
+ defaultProps: {
34
+ margin: 'dense'
35
+ }
36
+ },
37
+ MuiIconButton: {
38
+ defaultProps: {
39
+ size: 'small'
40
+ }
41
+ },
42
+ MuiInputBase: {
43
+ defaultProps: {
44
+ margin: 'dense'
45
+ }
46
+ },
47
+ MuiInputLabel: {
48
+ defaultProps: {
49
+ margin: 'dense'
50
+ }
51
+ },
52
+ MuiListItem: {
53
+ defaultProps: {
54
+ dense: true
55
+ }
56
+ },
57
+ MuiOutlinedInput: {
58
+ defaultProps: {
59
+ margin: 'dense'
60
+ }
61
+ },
62
+ MuiFab: {
63
+ defaultProps: {
64
+ size: 'small'
65
+ }
66
+ },
67
+ MuiTable: {
68
+ defaultProps: {
69
+ size: 'small'
70
+ }
71
+ },
72
+ MuiTextField: {
73
+ defaultProps: {
74
+ margin: 'dense'
75
+ }
76
+ },
77
+ MuiToolbar: {
78
+ defaultProps: {
79
+ variant: 'dense'
80
+ }
81
+ }
82
+ }
83
+ };
84
+ export const DispatchContext = /*#__PURE__*/React.createContext(() => {
85
+ throw new Error('Forgot to wrap component in `ThemeProvider`');
86
+ });
87
+ if (process.env.NODE_ENV !== 'production') {
88
+ DispatchContext.displayName = 'ThemeDispatchContext';
89
+ }
90
+ export const ThemeOptionsContext = /*#__PURE__*/React.createContext(themeInitialOptions);
91
+ if (process.env.NODE_ENV !== 'production') {
92
+ ThemeOptionsContext.displayName = 'ThemeOptionsContext';
93
+ }
94
+ export function ThemeProvider(props) {
95
+ const {
96
+ children
97
+ } = props;
98
+ const [themeOptions, dispatch] = React.useReducer((state, action) => {
99
+ switch (action.type) {
100
+ case 'SET_DENSE':
101
+ return {
102
+ ...state,
103
+ dense: action.payload
104
+ };
105
+ case 'RESET_DENSITY':
106
+ return {
107
+ ...state,
108
+ dense: themeInitialOptions.dense
109
+ };
110
+ case 'CHANGE':
111
+ // No value changed
112
+ if ((!action.payload.paletteMode || action.payload.paletteMode === state.paletteMode) && (!action.payload.direction || action.payload.direction === state.direction)) {
113
+ return state;
114
+ }
115
+ return {
116
+ ...state,
117
+ paletteMode: action.payload.paletteMode || state.paletteMode,
118
+ direction: action.payload.direction || state.direction
119
+ };
120
+ default:
121
+ throw new Error(`Unrecognized type ${action.type}`);
122
+ }
123
+ }, themeInitialOptions);
124
+ const {
125
+ direction,
126
+ paletteMode
127
+ } = themeOptions;
128
+ useLazyCSS('/static/styles/prism-okaidia.css', '#prismjs');
129
+
130
+ // TODO replace with useColorScheme once all pages support css vars
131
+ const {
132
+ mode,
133
+ systemMode
134
+ } = useColorSchemeShim();
135
+ const calculatedMode = mode === 'system' ? systemMode : mode;
136
+ useEnhancedEffect(() => {
137
+ dispatch({
138
+ type: 'CHANGE',
139
+ payload: {
140
+ paletteMode: calculatedMode
141
+ }
142
+ });
143
+ }, [calculatedMode]);
144
+ useEnhancedEffect(() => {
145
+ document.body.setAttribute('dir', direction);
146
+ }, [direction]);
147
+ useEnhancedEffect(() => {
148
+ // To support light and dark mode images in the docs
149
+ if (paletteMode === 'dark') {
150
+ document.body.classList.remove('mode-light');
151
+ document.body.classList.add('mode-dark');
152
+ } else {
153
+ document.body.classList.remove('mode-dark');
154
+ document.body.classList.add('mode-light');
155
+ }
156
+ const metas = document.querySelectorAll('meta[name="theme-color"]');
157
+ metas.forEach(meta => {
158
+ meta.setAttribute('content', getMetaThemeColor(paletteMode));
159
+ });
160
+ }, [paletteMode]);
161
+ React.useEffect(() => {
162
+ // Expose the theme as a global variable so people can play with it.
163
+ window.createTheme = createMdTheme;
164
+ }, []);
165
+ return /*#__PURE__*/_jsx(ThemeOptionsContext.Provider, {
166
+ value: themeOptions,
167
+ children: /*#__PURE__*/_jsx(DispatchContext.Provider, {
168
+ value: dispatch,
169
+ children: children
170
+ })
171
+ });
172
+ }
173
+ process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
174
+ children: PropTypes.node
175
+ } : void 0;
176
+
177
+ /**
178
+ * @returns {(nextOptions: Partial<typeof themeInitialOptions>) => void}
179
+ */
180
+ export function useChangeTheme() {
181
+ const dispatch = React.useContext(DispatchContext);
182
+ return React.useCallback(options => dispatch({
183
+ type: 'CHANGE',
184
+ payload: options
185
+ }), [dispatch]);
186
+ }
187
+
188
+ // TODO: remove once all pages support css vars and replace call sites with useColorScheme()
189
+ export function useColorSchemeShim() {
190
+ const [mode, setMode] = useLocalStorageState('mui-mode', 'system');
191
+ const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)', {
192
+ noSsr: true
193
+ });
194
+ const systemMode = prefersDarkMode ? 'dark' : 'light';
195
+ return {
196
+ mode,
197
+ systemMode,
198
+ setMode
199
+ };
200
+ }
@@ -0,0 +1 @@
1
+ export { ThemeProvider, ThemeOptionsContext, DispatchContext, highDensity, useChangeTheme, useColorSchemeShim } from "./ThemeContext.js";
@@ -0,0 +1 @@
1
+ export { ThemeProvider, ThemeOptionsContext, DispatchContext, highDensity, useChangeTheme, useColorSchemeShim } from "./ThemeContext.js";
@@ -0,0 +1,23 @@
1
+ import * as React from 'react';
2
+ import { PaletteColorOptions } from '@mui/material/styles';
3
+ declare module '@mui/material/styles' {
4
+ interface PaletteOptions {
5
+ primaryDark?: PaletteColorOptions;
6
+ }
7
+ }
8
+ export declare function setDocsColors(primary: Record<string, string>, secondary: Record<string, string>): void;
9
+ export declare function resetDocsColor(): void;
10
+ export declare function setDocsSpacing(value: number): void;
11
+ export declare function resetDocsSpacing(): void;
12
+ export declare function BrandingCssThemeProvider({
13
+ children,
14
+ direction,
15
+ forceThemeRerender
16
+ }: React.PropsWithChildren<{
17
+ direction?: 'ltr' | 'rtl';
18
+ forceThemeRerender?: boolean;
19
+ }>): import("react/jsx-runtime").JSX.Element;
20
+ export declare function BrandingCssVarsProvider(props: {
21
+ children: React.ReactNode;
22
+ direction?: 'ltr' | 'rtl';
23
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,170 @@
1
+ var _NextNProgressBar, _CssBaseline, _SkipLink, _MarkdownLinks;
2
+ import * as React from 'react';
3
+ import { useRouter } from 'next/router';
4
+ import deepmerge from '@mui/utils/deepmerge';
5
+ import { ThemeProvider, createTheme } from '@mui/material/styles';
6
+ import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
7
+ import { colorChannel, getContrastRatio, lighten, darken } from '@mui/system/colorManipulator';
8
+ import CssBaseline from '@mui/material/CssBaseline';
9
+ import { getCookie, pathnameToLanguage } from "../helpers/helpers.js";
10
+ import { NextNProgressBar } from "../NextNProgressBar/index.js";
11
+ import { getDesignTokens, getThemedComponents } from "./brandingTheme.js";
12
+ import { SkipLink, MarkdownLinks } from "../Link/index.js";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ const {
15
+ palette: lightPalette,
16
+ typography,
17
+ ...designTokens
18
+ } = getDesignTokens('light');
19
+ const {
20
+ palette: darkPalette
21
+ } = getDesignTokens('dark');
22
+ const themeOptions = {
23
+ colorSchemes: {
24
+ light: {
25
+ palette: lightPalette
26
+ },
27
+ dark: {
28
+ palette: darkPalette
29
+ }
30
+ },
31
+ ...designTokens,
32
+ typography: deepmerge(typography, {
33
+ h1: {
34
+ ':where([data-mui-color-scheme="dark"]) &': {
35
+ color: 'var(--muidocs-palette-common-white)'
36
+ }
37
+ },
38
+ h2: {
39
+ ':where([data-mui-color-scheme="dark"]) &': {
40
+ color: 'var(--muidocs-palette-grey-100)'
41
+ }
42
+ },
43
+ h5: {
44
+ ':where([data-mui-color-scheme="dark"]) &': {
45
+ color: 'var(--muidocs-palette-primary-300)'
46
+ }
47
+ }
48
+ }),
49
+ ...getThemedComponents()
50
+ };
51
+ export function setDocsColors(primary, secondary) {
52
+ function injectPalette(prefix, palette, color, el) {
53
+ // simplified logic of `createPalette` to avoid `useTheme`.
54
+ const light = lighten(color, 0.2);
55
+ const dark = darken(color, 0.3);
56
+ const contrastText = getContrastRatio(color, '#fff') >= 3 ? '#fff' : 'rgba(0, 0, 0, 0.87)';
57
+ const elStyle = el.style;
58
+ elStyle.setProperty(`--${prefix}-palette-${palette}-main`, color);
59
+ elStyle.setProperty(`--${prefix}-palette-${palette}-mainChannel`, colorChannel(color));
60
+ elStyle.setProperty(`--${prefix}-palette-${palette}-light`, light);
61
+ elStyle.setProperty(`--${prefix}-palette-${palette}-lightChannel`, colorChannel(light));
62
+ elStyle.setProperty(`--${prefix}-palette-${palette}-dark`, dark);
63
+ elStyle.setProperty(`--${prefix}-palette-${palette}-darkChannel`, colorChannel(dark));
64
+ elStyle.setProperty(`--${prefix}-palette-${palette}-contrastText`, contrastText);
65
+ elStyle.setProperty(`--${prefix}-palette-${palette}-contrastTextChannel`, colorChannel(contrastText));
66
+ }
67
+ if (typeof document !== 'undefined') {
68
+ const htmlEl = document.documentElement;
69
+ injectPalette('muidocs', 'primary', primary.main, htmlEl);
70
+ injectPalette('muidocs', 'secondary', secondary.main, htmlEl);
71
+ ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'].forEach(key => {
72
+ htmlEl.style.setProperty(`--muidocs-palette-primary-${key}`, primary[key]);
73
+ htmlEl.style.setProperty(`--muidocs-palette-secondary-${key}`, secondary[key]);
74
+ });
75
+ injectPalette('mui', 'primary', primary.main, htmlEl);
76
+ injectPalette('mui', 'secondary', secondary.main, htmlEl);
77
+ }
78
+ }
79
+ export function resetDocsColor() {
80
+ if (typeof document !== 'undefined') {
81
+ const htmlElStyle = document.documentElement.style;
82
+ htmlElStyle.removeProperty('--muidocs-palette-primary-main');
83
+ htmlElStyle.removeProperty('--muidocs-palette-secondary-main');
84
+ htmlElStyle.removeProperty('--mui-palette-primary-main');
85
+ htmlElStyle.removeProperty('--mui-palette-secondary-main');
86
+ ['50', '100', '200', '300', '400', '500', '600', '700', '800', '900'].forEach(key => {
87
+ htmlElStyle.removeProperty(`--muidocs-palette-primary-${key}`);
88
+ htmlElStyle.removeProperty(`--muidocs-palette-secondary-${key}`);
89
+ });
90
+ }
91
+ }
92
+ export function setDocsSpacing(value) {
93
+ if (typeof document !== 'undefined') {
94
+ const htmlElStyle = document.documentElement.style;
95
+ htmlElStyle.setProperty('--muidocs-spacing', `${value}px`);
96
+ htmlElStyle.setProperty('--mui-spacing', `${value}px`);
97
+ }
98
+ }
99
+ export function resetDocsSpacing() {
100
+ if (typeof document !== 'undefined') {
101
+ const htmlElStyle = document.documentElement.style;
102
+ htmlElStyle.removeProperty('--muidocs-spacing');
103
+ htmlElStyle.removeProperty('--mui-spacing');
104
+ }
105
+ }
106
+ const themeCache = new Map();
107
+ function getTheme(direction) {
108
+ let cachedTheme = themeCache.get(direction);
109
+ if (!cachedTheme) {
110
+ cachedTheme = createTheme({
111
+ cssVariables: {
112
+ cssVarPrefix: 'muidocs',
113
+ colorSchemeSelector: 'data-mui-color-scheme'
114
+ },
115
+ direction,
116
+ ...themeOptions
117
+ });
118
+ themeCache.set(direction, cachedTheme);
119
+ }
120
+ return cachedTheme;
121
+ }
122
+ export function BrandingCssThemeProvider({
123
+ children,
124
+ direction = 'ltr',
125
+ forceThemeRerender = false
126
+ }) {
127
+ const theme = React.useMemo(() => getTheme(direction), [direction]);
128
+ return /*#__PURE__*/_jsx(ThemeProvider, {
129
+ theme: theme,
130
+ disableTransitionOnChange: true
131
+ // TODO: remove `forceThemeRerender` once custom theme on some demos rely on CSS variables instead of `theme.palette.mode`
132
+ ,
133
+ forceThemeRerender: forceThemeRerender,
134
+ children: children
135
+ });
136
+ }
137
+ export function BrandingCssVarsProvider(props) {
138
+ const {
139
+ direction = 'ltr',
140
+ children
141
+ } = props;
142
+ const {
143
+ asPath
144
+ } = useRouter();
145
+ const {
146
+ canonicalAs
147
+ } = pathnameToLanguage(asPath);
148
+ useEnhancedEffect(() => {
149
+ const nextPaletteColors = JSON.parse(getCookie('paletteColors') || 'null');
150
+ if (nextPaletteColors) {
151
+ setDocsColors(nextPaletteColors.primary, nextPaletteColors.secondary);
152
+ }
153
+ }, []);
154
+ useEnhancedEffect(() => {
155
+ // This is required to ensure that the layer order is declared first in the head
156
+ // because when the direction is RTL on the client, emotion reinserts the RTL styles back to the top of the insertion point.
157
+ if (direction === 'rtl') {
158
+ const head = document.querySelector('head');
159
+ if (head) {
160
+ const style = document.createElement('style');
161
+ style.textContent = '@layer theme, docsearch, mui, mui.global, mui.default, mui.theme, mui.custom, mui.sx, utilities;';
162
+ head.prepend(style);
163
+ }
164
+ }
165
+ }, [direction]);
166
+ return /*#__PURE__*/_jsxs(BrandingCssThemeProvider, {
167
+ forceThemeRerender: canonicalAs.startsWith('/x/') || canonicalAs.startsWith('/toolpad/'),
168
+ children: [_NextNProgressBar || (_NextNProgressBar = /*#__PURE__*/_jsx(NextNProgressBar, {})), _CssBaseline || (_CssBaseline = /*#__PURE__*/_jsx(CssBaseline, {})), _SkipLink || (_SkipLink = /*#__PURE__*/_jsx(SkipLink, {})), _MarkdownLinks || (_MarkdownLinks = /*#__PURE__*/_jsx(MarkdownLinks, {})), children]
169
+ });
170
+ }
@@ -1,23 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.BrandingProvider = BrandingProvider;
8
- var React = _interopRequireWildcard(require("react"));
9
- var _styles = require("@mui/material/styles");
10
- var _brandingTheme = require("./brandingTheme");
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- function BrandingProvider(props) {
1
+ import * as React from 'react';
2
+ import { ThemeProvider, useTheme } from '@mui/material/styles';
3
+ import { brandingDarkTheme, brandingLightTheme } from "./brandingTheme.js";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ export function BrandingProvider(props) {
13
6
  const {
14
7
  children,
15
8
  mode: modeProp
16
9
  } = props;
17
- const upperTheme = (0, _styles.useTheme)();
10
+ const upperTheme = useTheme();
18
11
  const mode = modeProp || upperTheme.palette.mode;
19
- const theme = mode === 'dark' ? _brandingTheme.brandingDarkTheme : _brandingTheme.brandingLightTheme;
20
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ThemeProvider, {
12
+ const theme = mode === 'dark' ? brandingDarkTheme : brandingLightTheme;
13
+ return /*#__PURE__*/_jsx(ThemeProvider, {
21
14
  theme: modeProp ? () => theme : theme,
22
15
  children: children
23
16
  });