@mui/docs 9.0.0-alpha.2 → 9.0.0-alpha.4

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 (261) 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/CHANGELOG.md +191 -0
  11. package/CodeCopy/CodeCopy.js +10 -19
  12. package/CodeCopy/CodeCopyButton.js +9 -16
  13. package/CodeCopy/index.js +3 -40
  14. package/CodeCopy/useClipboardCopy.js +4 -12
  15. package/ComponentLinkHeader/ComponentLinkHeader.js +46 -54
  16. package/ComponentLinkHeader/index.js +2 -24
  17. package/DemoContext/DemoContext.d.ts +86 -0
  18. package/DemoContext/DemoContext.js +13 -0
  19. package/DemoContext/index.d.ts +2 -0
  20. package/DemoContext/index.js +1 -0
  21. package/DocsApp/AnalyticsProvider.d.ts +17 -0
  22. package/DocsApp/AnalyticsProvider.js +225 -0
  23. package/DocsApp/DocsApp.d.ts +79 -0
  24. package/DocsApp/DocsApp.js +105 -0
  25. package/DocsApp/GoogleAnalytics.d.ts +9 -0
  26. package/DocsApp/GoogleAnalytics.js +129 -0
  27. package/DocsApp/StyledEngineProvider.d.ts +8 -0
  28. package/DocsApp/StyledEngineProvider.js +38 -0
  29. package/DocsApp/consoleBanner.d.ts +1 -0
  30. package/DocsApp/consoleBanner.js +19 -0
  31. package/DocsApp/createEmotionCache.d.ts +1 -0
  32. package/DocsApp/createEmotionCache.js +12 -0
  33. package/DocsApp/createGetInitialProps.d.ts +30 -0
  34. package/DocsApp/createGetInitialProps.js +29 -0
  35. package/DocsApp/index.d.ts +5 -0
  36. package/DocsApp/index.js +4 -0
  37. package/DocsApp/loadDependencies.d.ts +1 -0
  38. package/DocsApp/loadDependencies.js +11 -0
  39. package/DocsApp/reportWebVitals.d.ts +13 -0
  40. package/DocsApp/reportWebVitals.js +24 -0
  41. package/DocsApp/serviceWorker.d.ts +1 -0
  42. package/DocsApp/serviceWorker.js +61 -0
  43. package/DocsProvider/DocsProvider.js +9 -17
  44. package/DocsProvider/index.js +1 -16
  45. package/Document/Document.d.ts +16 -0
  46. package/Document/Document.js +147 -0
  47. package/Document/getInitialProps.d.ts +18 -0
  48. package/Document/getInitialProps.js +62 -0
  49. package/Document/index.d.ts +2 -0
  50. package/Document/index.js +2 -0
  51. package/HighlightedCode/HighlightedCode.js +18 -26
  52. package/HighlightedCode/index.js +1 -16
  53. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.js +22 -31
  54. package/HighlightedCodeWithTabs/index.js +2 -24
  55. package/IconImage/IconImage.js +13 -21
  56. package/IconImage/index.js +1 -13
  57. package/InfoCard/InfoCard.js +20 -29
  58. package/InfoCard/index.js +1 -16
  59. package/Link/Link.js +17 -25
  60. package/Link/MarkdownLinks.d.ts +2 -0
  61. package/Link/MarkdownLinks.js +84 -0
  62. package/Link/SkipLink.d.ts +1 -0
  63. package/Link/SkipLink.js +66 -0
  64. package/Link/index.d.ts +3 -1
  65. package/Link/index.js +3 -16
  66. package/MarkdownElement/MarkdownElement.js +178 -186
  67. package/MarkdownElement/index.js +1 -16
  68. package/MuiPage/MuiPage.d.ts +67 -0
  69. package/MuiPage/MuiPage.js +1 -0
  70. package/MuiPage/index.d.ts +1 -0
  71. package/MuiPage/index.js +1 -0
  72. package/NextNProgressBar/NextNProgressBar.d.ts +1 -0
  73. package/NextNProgressBar/NextNProgressBar.js +44 -0
  74. package/NextNProgressBar/index.d.ts +1 -0
  75. package/NextNProgressBar/index.js +1 -0
  76. package/PageContext/PageContext.d.ts +32 -0
  77. package/PageContext/PageContext.js +6 -0
  78. package/PageContext/index.d.ts +2 -0
  79. package/PageContext/index.js +1 -0
  80. package/SectionHeadline/SectionHeadline.js +9 -17
  81. package/SectionHeadline/index.js +2 -25
  82. package/SectionTitle/SectionTitle.js +7 -13
  83. package/SectionTitle/index.js +1 -16
  84. package/ThemeContext/ThemeContext.js +26 -38
  85. package/ThemeContext/index.js +1 -42
  86. package/branding/BrandingCssVarsProvider.d.ts +27 -0
  87. package/branding/BrandingCssVarsProvider.js +170 -0
  88. package/branding/BrandingProvider.js +8 -15
  89. package/branding/brandingTheme.js +184 -188
  90. package/branding/index.d.ts +2 -1
  91. package/branding/index.js +3 -27
  92. package/codeStyling/codeStyling.d.ts +7 -0
  93. package/codeStyling/codeStyling.js +80 -0
  94. package/codeStyling/index.d.ts +1 -0
  95. package/codeStyling/index.js +1 -0
  96. package/codeVariant/codeVariant.d.ts +7 -0
  97. package/codeVariant/codeVariant.js +69 -0
  98. package/codeVariant/index.d.ts +1 -0
  99. package/codeVariant/index.js +1 -0
  100. package/constants/constants.d.ts +13 -0
  101. package/constants/constants.js +15 -0
  102. package/constants/index.d.ts +1 -0
  103. package/constants/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 +217 -132
  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.js +1 -13
  140. package/useLazyCSS/useLazyCSS.js +5 -11
  141. package/utils/index.d.ts +1 -0
  142. package/utils/index.js +2 -0
  143. package/utils/loadScript.js +1 -7
  144. package/webpack/index.d.ts +17 -0
  145. package/webpack/index.js +1 -0
  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/IconImage/IconImage.d.mts +0 -11
  189. package/IconImage/IconImage.mjs +0 -83
  190. package/IconImage/index.d.mts +0 -1
  191. package/IconImage/index.mjs +0 -1
  192. package/InfoCard/InfoCard.d.mts +0 -22
  193. package/InfoCard/InfoCard.mjs +0 -87
  194. package/InfoCard/index.d.mts +0 -1
  195. package/InfoCard/index.mjs +0 -1
  196. package/Link/Link.d.mts +0 -25
  197. package/Link/Link.mjs +0 -75
  198. package/Link/index.d.mts +0 -1
  199. package/Link/index.mjs +0 -1
  200. package/MarkdownElement/MarkdownElement.d.mts +0 -7
  201. package/MarkdownElement/MarkdownElement.mjs +0 -847
  202. package/MarkdownElement/index.d.mts +0 -1
  203. package/MarkdownElement/index.mjs +0 -1
  204. package/NProgressBar/NProgressBar.d.mts +0 -6
  205. package/NProgressBar/NProgressBar.js +0 -98
  206. package/NProgressBar/index.d.mts +0 -2
  207. package/NProgressBar/index.d.ts +0 -2
  208. package/NProgressBar/index.js +0 -13
  209. package/NProgressBar/index.mjs +0 -1
  210. package/SectionHeadline/SectionHeadline.d.mts +0 -13
  211. package/SectionHeadline/SectionHeadline.mjs +0 -81
  212. package/SectionHeadline/index.d.mts +0 -2
  213. package/SectionHeadline/index.mjs +0 -2
  214. package/SectionTitle/SectionTitle.d.mts +0 -6
  215. package/SectionTitle/SectionTitle.mjs +0 -29
  216. package/SectionTitle/index.d.mts +0 -1
  217. package/SectionTitle/index.mjs +0 -1
  218. package/ThemeContext/ThemeContext.d.mts +0 -92
  219. package/ThemeContext/ThemeContext.mjs +0 -200
  220. package/ThemeContext/index.d.mts +0 -1
  221. package/ThemeContext/index.mjs +0 -1
  222. package/branding/BrandingProvider.d.mts +0 -9
  223. package/branding/BrandingProvider.mjs +0 -17
  224. package/branding/brandingTheme.d.mts +0 -147
  225. package/branding/brandingTheme.mjs +0 -1527
  226. package/branding/index.d.mts +0 -2
  227. package/branding/index.mjs +0 -2
  228. package/i18n/i18n.d.mts +0 -27
  229. package/i18n/i18n.mjs +0 -111
  230. package/i18n/index.d.mts +0 -1
  231. package/i18n/index.mjs +0 -1
  232. package/nextFonts/index.d.mts +0 -6
  233. package/nextFonts/index.mjs +0 -59
  234. package/svgIcons/BundleSizeIcon.d.mts +0 -4
  235. package/svgIcons/BundleSizeIcon.mjs +0 -13
  236. package/svgIcons/FigmaIcon.d.mts +0 -4
  237. package/svgIcons/FigmaIcon.mjs +0 -22
  238. package/svgIcons/FileDownload.d.mts +0 -6
  239. package/svgIcons/FileDownload.mjs +0 -13
  240. package/svgIcons/JavaScript.d.mts +0 -6
  241. package/svgIcons/JavaScript.mjs +0 -13
  242. package/svgIcons/MarkdownIcon.d.mts +0 -2
  243. package/svgIcons/MarkdownIcon.mjs +0 -22
  244. package/svgIcons/MaterialDesignIcon.d.mts +0 -4
  245. package/svgIcons/MaterialDesignIcon.mjs +0 -18
  246. package/svgIcons/SketchIcon.d.mts +0 -4
  247. package/svgIcons/SketchIcon.mjs +0 -27
  248. package/svgIcons/TypeScript.d.mts +0 -6
  249. package/svgIcons/TypeScript.mjs +0 -13
  250. package/svgIcons/W3CIcon.d.mts +0 -4
  251. package/svgIcons/W3CIcon.mjs +0 -15
  252. package/translations/index.d.mts +0 -3
  253. package/translations/index.mjs +0 -4
  254. package/useLazyCSS/index.d.mts +0 -1
  255. package/useLazyCSS/index.mjs +0 -1
  256. package/useLazyCSS/useLazyCSS.d.mts +0 -11
  257. package/useLazyCSS/useLazyCSS.mjs +0 -70
  258. package/utils/loadScript.d.mts +0 -1
  259. package/utils/loadScript.mjs +0 -7
  260. /package/{NProgressBar → NextNProgressBar}/NProgressBar.d.ts +0 -0
  261. /package/{NProgressBar/NProgressBar.mjs → NextNProgressBar/NProgressBar.js} +0 -0
@@ -0,0 +1,38 @@
1
+ var _GlobalStyles;
2
+ import * as React from 'react';
3
+ import { StyleSheetManager } from 'styled-components';
4
+ import { CacheProvider } from '@emotion/react';
5
+ import { createEmotionCache as createCache } from '@mui/material-nextjs/v15-pagesRouter';
6
+ import { prefixer } from 'stylis';
7
+ import rtlPlugin from '@mui/stylis-plugin-rtl';
8
+ import GlobalStyles from '@mui/material/GlobalStyles';
9
+ import { ThemeOptionsContext } from "../ThemeContext/index.js";
10
+ import globalSelector from "../globalSelector/index.js";
11
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
12
+ // Cache for the rtl version of the styles
13
+ const cacheRtl = createCache({
14
+ key: 'rtl',
15
+ prepend: true,
16
+ enableCssLayer: true,
17
+ stylisPlugins: [prefixer, rtlPlugin, globalSelector]
18
+ });
19
+ export default function StyledEngineProvider(props) {
20
+ const {
21
+ children,
22
+ cacheLtr
23
+ } = props;
24
+ const {
25
+ direction
26
+ } = React.useContext(ThemeOptionsContext);
27
+ const rtl = direction === 'rtl';
28
+ const emotionCache = direction === 'rtl' ? cacheRtl : cacheLtr;
29
+ return /*#__PURE__*/_jsx(StyleSheetManager, {
30
+ stylisPlugins: rtl ? [rtlPlugin] : [],
31
+ children: /*#__PURE__*/_jsxs(CacheProvider, {
32
+ value: emotionCache,
33
+ children: [_GlobalStyles || (_GlobalStyles = /*#__PURE__*/_jsx(GlobalStyles, {
34
+ styles: "@layer theme, docsearch, mui, utilities;"
35
+ })), children]
36
+ })
37
+ });
38
+ }
@@ -0,0 +1 @@
1
+ export declare function printConsoleBanner(): void;
@@ -0,0 +1,19 @@
1
+ import { getTheme } from "../branding/index.js";
2
+ // eslint-disable-next-line import/prefer-default-export
3
+ export function printConsoleBanner() {
4
+ if (typeof window !== 'undefined' && process.env.NODE_ENV === 'production') {
5
+ window.theme = getTheme('ltr');
6
+ // eslint-disable-next-line no-console
7
+ console.log(`%c
8
+
9
+ ███╗ ███╗ ██╗ ██╗ ██████╗
10
+ ████╗ ████║ ██║ ██║ ██╔═╝
11
+ ██╔████╔██║ ██║ ██║ ██║
12
+ ██║╚██╔╝██║ ██║ ██║ ██║
13
+ ██║ ╚═╝ ██║ ╚██████╔╝ ██████╗
14
+ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝
15
+
16
+ Tip: you can access the documentation \`theme\` object directly in the console.
17
+ `, 'font-family:monospace;color:#1976d2;font-size:12px;');
18
+ }
19
+ }
@@ -0,0 +1 @@
1
+ export default function createEmotionCache(): import("@emotion/cache").EmotionCache;
@@ -0,0 +1,12 @@
1
+ import { createEmotionCache as createCache } from '@mui/material-nextjs/v15-pagesRouter';
2
+ import { prefixer } from 'stylis';
3
+ import globalSelector from "../globalSelector/index.js";
4
+ export default function createEmotionCache() {
5
+ // TODO remove prepend: true once JSS is out
6
+ return createCache({
7
+ key: 'css',
8
+ prepend: true,
9
+ enableCssLayer: true,
10
+ stylisPlugins: [prefixer, globalSelector]
11
+ });
12
+ }
@@ -0,0 +1,30 @@
1
+ import type { RequireContext } from "../i18n/index.js";
2
+ interface AppContext {
3
+ ctx: {
4
+ query: {
5
+ userLanguage?: string;
6
+ };
7
+ };
8
+ Component: {
9
+ getInitialProps?: (ctx: AppContext['ctx']) => Promise<Record<string, unknown>>;
10
+ };
11
+ }
12
+ /**
13
+ * Factory to create MyApp.getInitialProps.
14
+ * Follows the same pattern as `@mui/docs/Document`'s `createGetInitialProps`.
15
+ *
16
+ * @param options.translationsContext - A webpack require.context pointing at translation JSON files.
17
+ * e.g. `require.context('docs/translations', false, /\.\/translations.*\.json$/)`
18
+ */
19
+ export declare function createGetInitialProps(options: {
20
+ translationsContext: RequireContext;
21
+ }): ({
22
+ ctx,
23
+ Component
24
+ }: AppContext) => Promise<{
25
+ pageProps: {
26
+ userLanguage: string;
27
+ translations: import("../i18n/index.js").Translations;
28
+ };
29
+ }>;
30
+ export {};
@@ -0,0 +1,29 @@
1
+ import { mapTranslations } from "../i18n/index.js";
2
+ /**
3
+ * Factory to create MyApp.getInitialProps.
4
+ * Follows the same pattern as `@mui/docs/Document`'s `createGetInitialProps`.
5
+ *
6
+ * @param options.translationsContext - A webpack require.context pointing at translation JSON files.
7
+ * e.g. `require.context('docs/translations', false, /\.\/translations.*\.json$/)`
8
+ */
9
+ // eslint-disable-next-line import/prefer-default-export
10
+ export function createGetInitialProps(options) {
11
+ async function getInitialPropsApp({
12
+ ctx,
13
+ Component
14
+ }) {
15
+ let pageProps = {};
16
+ const translations = mapTranslations(options.translationsContext);
17
+ if (Component.getInitialProps) {
18
+ pageProps = await Component.getInitialProps(ctx);
19
+ }
20
+ return {
21
+ pageProps: {
22
+ userLanguage: ctx.query.userLanguage || 'en',
23
+ translations,
24
+ ...pageProps
25
+ }
26
+ };
27
+ }
28
+ return getInitialPropsApp;
29
+ }
@@ -0,0 +1,5 @@
1
+ export { DocsApp } from "./DocsApp.js";
2
+ export type { DocsAppProps } from "./DocsApp.js";
3
+ export { createGetInitialProps } from "./createGetInitialProps.js";
4
+ export { printConsoleBanner } from "./consoleBanner.js";
5
+ export { reportWebVitals } from "./reportWebVitals.js";
@@ -0,0 +1,4 @@
1
+ export { DocsApp } from "./DocsApp.js";
2
+ export { createGetInitialProps } from "./createGetInitialProps.js";
3
+ export { printConsoleBanner } from "./consoleBanner.js";
4
+ export { reportWebVitals } from "./reportWebVitals.js";
@@ -0,0 +1 @@
1
+ export declare function loadDependencies(): void;
@@ -0,0 +1,11 @@
1
+ import { loadCSS } from 'fg-loadcss';
2
+ let dependenciesLoaded = false;
3
+
4
+ // eslint-disable-next-line import/prefer-default-export
5
+ export function loadDependencies() {
6
+ if (dependenciesLoaded) {
7
+ return;
8
+ }
9
+ dependenciesLoaded = true;
10
+ loadCSS('https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Two+Tone', document.querySelector('#material-icon-font') ?? undefined);
11
+ }
@@ -0,0 +1,13 @@
1
+ export declare function reportWebVitals({
2
+ id,
3
+ name,
4
+ label,
5
+ delta,
6
+ value
7
+ }: {
8
+ id: string;
9
+ name: string;
10
+ label: string;
11
+ delta: number;
12
+ value: number;
13
+ }): void;
@@ -0,0 +1,24 @@
1
+ // Track fraction of actual events to prevent exceeding event quota.
2
+ // Filter sessions instead of individual events so that we can track multiple metrics per device.
3
+ // See https://github.com/GoogleChromeLabs/web-vitals-report to use this data
4
+ const disableWebVitalsReporting = Math.random() > 0.0001;
5
+
6
+ // eslint-disable-next-line import/prefer-default-export
7
+ export function reportWebVitals({
8
+ id,
9
+ name,
10
+ label,
11
+ delta,
12
+ value
13
+ }) {
14
+ if (disableWebVitalsReporting) {
15
+ return;
16
+ }
17
+ window.gtag('event', name, {
18
+ value: delta,
19
+ metric_label: label === 'web-vital' ? 'Web Vitals' : 'Next.js custom metric',
20
+ metric_value: value,
21
+ metric_delta: delta,
22
+ metric_id: id // id unique to current page load
23
+ });
24
+ }
@@ -0,0 +1 @@
1
+ export declare function registerServiceWorker(swPath: string): Promise<void>;
@@ -0,0 +1,61 @@
1
+ let reloadInterval;
2
+
3
+ // Avoid infinite loop when "Update on reload" is set in the Chrome sw dev tools.
4
+ function lazyReload() {
5
+ clearInterval(reloadInterval);
6
+ reloadInterval = setInterval(() => {
7
+ if (document.hasFocus()) {
8
+ window.location.reload();
9
+ }
10
+ }, 100);
11
+ }
12
+
13
+ // Inspired by
14
+ // https://developers.google.com/web/tools/workbox/guides/advanced-recipes#offer_a_page_reload_for_users
15
+ function forcePageReload(registration) {
16
+ // console.log('already controlled?', Boolean(navigator.serviceWorker.controller));
17
+
18
+ if (!navigator.serviceWorker.controller) {
19
+ // The window client isn't currently controlled so it's a new service
20
+ // worker that will activate immediately.
21
+ return;
22
+ }
23
+
24
+ // console.log('registration waiting?', Boolean(registration.waiting));
25
+ if (registration.waiting) {
26
+ // SW is waiting to activate. Can occur if multiple clients open and
27
+ // one of the clients is refreshed.
28
+ registration.waiting.postMessage('skipWaiting');
29
+ return;
30
+ }
31
+ function listenInstalledStateChange() {
32
+ registration.installing.addEventListener('statechange', event => {
33
+ // console.log('statechange', event.target.state);
34
+ if (event.target.state === 'installed' && registration.waiting) {
35
+ // A new service worker is available, inform the user
36
+ registration.waiting.postMessage('skipWaiting');
37
+ } else if (event.target.state === 'activated') {
38
+ // Force the control of the page by the activated service worker.
39
+ lazyReload();
40
+ }
41
+ });
42
+ }
43
+ if (registration.installing) {
44
+ listenInstalledStateChange();
45
+ return;
46
+ }
47
+
48
+ // We are currently controlled so a new SW may be found...
49
+ // Add a listener in case a new SW is found,
50
+ registration.addEventListener('updatefound', listenInstalledStateChange);
51
+ }
52
+
53
+ // eslint-disable-next-line import/prefer-default-export
54
+ export async function registerServiceWorker(swPath) {
55
+ if ('serviceWorker' in navigator && process.env.NODE_ENV === 'production' && window.location.host.includes('mui.com')) {
56
+ // register() automatically attempts to refresh the sw.js.
57
+ const registration = await navigator.serviceWorker.register(swPath);
58
+ // Force the page reload for users.
59
+ forcePageReload(registration);
60
+ }
61
+ }
@@ -1,28 +1,20 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.DocsProvider = DocsProvider;
8
- exports.useDocsConfig = useDocsConfig;
9
- var React = _interopRequireWildcard(require("react"));
10
- var _i18n = require("../i18n");
11
- var _Ad = require("../Ad");
12
- var _jsxRuntime = require("react/jsx-runtime");
1
+ import * as React from 'react';
2
+ import { UserLanguageProvider } from "../i18n/index.js";
3
+ import { AdProvider } from "../Ad/index.js";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
13
5
  const DocsConfigContext = /*#__PURE__*/React.createContext(null);
14
- function DocsProvider({
6
+ export function DocsProvider({
15
7
  config,
16
8
  adConfig,
17
9
  defaultUserLanguage,
18
10
  translations,
19
11
  children
20
12
  }) {
21
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(DocsConfigContext.Provider, {
13
+ return /*#__PURE__*/_jsx(DocsConfigContext.Provider, {
22
14
  value: config,
23
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Ad.AdProvider, {
15
+ children: /*#__PURE__*/_jsx(AdProvider, {
24
16
  config: adConfig,
25
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_i18n.UserLanguageProvider, {
17
+ children: /*#__PURE__*/_jsx(UserLanguageProvider, {
26
18
  defaultUserLanguage: defaultUserLanguage,
27
19
  translations: translations,
28
20
  children: children
@@ -30,7 +22,7 @@ function DocsProvider({
30
22
  })
31
23
  });
32
24
  }
33
- function useDocsConfig() {
25
+ export function useDocsConfig() {
34
26
  const config = React.useContext(DocsConfigContext);
35
27
  if (!config) {
36
28
  throw new Error('Could not find docs config context value; please ensure the component is wrapped in a <DocsProvider>');
@@ -1,16 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _DocsProvider = require("./DocsProvider");
7
- Object.keys(_DocsProvider).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _DocsProvider[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _DocsProvider[key];
14
- }
15
- });
16
- });
1
+ export * from "./DocsProvider.js";
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ export type DocumentProps = {
3
+ canonicalAsServer: string;
4
+ analytics: {
5
+ google: string;
6
+ apollo: string;
7
+ };
8
+ userLanguage: string;
9
+ children?: React.ReactNode;
10
+ };
11
+ export declare function Document({
12
+ canonicalAsServer,
13
+ userLanguage,
14
+ analytics,
15
+ children
16
+ }: DocumentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,147 @@
1
+ var _link, _link2, _link3, _MuiInitColorSchemeSc, _Main, _NextScript;
2
+ import * as React from 'react';
3
+ import Script from 'next/script';
4
+ import { Html, Head, Main, NextScript } from 'next/document';
5
+ import GlobalStyles from '@mui/material/GlobalStyles';
6
+ import MuiInitColorSchemeScript from '@mui/material/InitColorSchemeScript';
7
+ import { getMetaThemeColor } from '@mui/docs/branding';
8
+ import { fontClasses } from '@mui/docs/nextFonts';
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ export function Document({
11
+ canonicalAsServer,
12
+ userLanguage,
13
+ analytics,
14
+ children
15
+ }) {
16
+ return /*#__PURE__*/_jsxs(Html, {
17
+ lang: userLanguage,
18
+ "data-mui-color-scheme": "light",
19
+ children: [/*#__PURE__*/_jsxs(Head, {
20
+ children: [_link || (_link = /*#__PURE__*/_jsx("link", {
21
+ rel: "manifest",
22
+ href: "/static/manifest.json"
23
+ })), /*#__PURE__*/_jsx("meta", {
24
+ name: "theme-color",
25
+ content: getMetaThemeColor('light'),
26
+ media: "(prefers-color-scheme: light)"
27
+ }), /*#__PURE__*/_jsx("meta", {
28
+ name: "theme-color",
29
+ content: getMetaThemeColor('dark'),
30
+ media: "(prefers-color-scheme: dark)"
31
+ }), _link2 || (_link2 = /*#__PURE__*/_jsx("link", {
32
+ rel: "icon",
33
+ href: "/static/favicon.ico"
34
+ })), _link3 || (_link3 = /*#__PURE__*/_jsx("link", {
35
+ rel: "apple-touch-icon",
36
+ sizes: "180x180",
37
+ href: "/static/icons/180x180.png"
38
+ })), /*#__PURE__*/_jsx("link", {
39
+ rel: "canonical",
40
+ href: `https://mui.com${userLanguage === 'en' ? '' : `/${userLanguage}`}${canonicalAsServer}`
41
+ }), /*#__PURE__*/_jsx("link", {
42
+ rel: "alternate",
43
+ href: `https://mui.com${canonicalAsServer}`,
44
+ hrefLang: "x-default"
45
+ }), /*#__PURE__*/_jsx(GlobalStyles, {
46
+ styles: {
47
+ // First SSR paint
48
+ '.only-light-mode': {
49
+ display: 'block'
50
+ },
51
+ '.only-dark-mode': {
52
+ display: 'none'
53
+ },
54
+ // Post SSR Hydration
55
+ '.mode-dark .only-light-mode': {
56
+ display: 'none'
57
+ },
58
+ '.mode-dark .only-dark-mode': {
59
+ display: 'block'
60
+ },
61
+ // TODO migrate to .only-dark-mode to .only-dark-mode-v2
62
+ '[data-mui-color-scheme="light"] .only-dark-mode-v2': {
63
+ display: 'none'
64
+ },
65
+ '[data-mui-color-scheme="dark"] .only-light-mode-v2': {
66
+ display: 'none'
67
+ },
68
+ '.plan-pro, .plan-premium': {
69
+ display: 'inline-block',
70
+ height: '0.9em',
71
+ width: '1em',
72
+ verticalAlign: 'middle',
73
+ marginLeft: '0.3em',
74
+ marginBottom: '0.08em',
75
+ backgroundSize: 'contain',
76
+ backgroundRepeat: 'no-repeat',
77
+ flexShrink: 0
78
+ },
79
+ '.plan-pro': {
80
+ backgroundImage: 'url(/static/x/pro.svg)'
81
+ },
82
+ '.plan-premium': {
83
+ backgroundImage: 'url(/static/x/premium.svg)'
84
+ }
85
+ }
86
+ })]
87
+ }), /*#__PURE__*/_jsxs("body", {
88
+ className: fontClasses,
89
+ children: [_MuiInitColorSchemeSc || (_MuiInitColorSchemeSc = /*#__PURE__*/_jsx(MuiInitColorSchemeScript, {
90
+ defaultMode: "system"
91
+ })), children, _Main || (_Main = /*#__PURE__*/_jsx(Main, {})), /*#__PURE__*/_jsx("script", {
92
+ // eslint-disable-next-line react/no-danger
93
+ dangerouslySetInnerHTML: {
94
+ __html: `
95
+ window.dataLayer = window.dataLayer || [];
96
+ function gtag(){dataLayer.push(arguments);}
97
+ window.gtag = gtag;
98
+
99
+ ${ /* Set default consent to denied (Google Consent Mode v2) */''}
100
+ gtag('consent', 'default', {
101
+ 'ad_storage': 'denied',
102
+ 'ad_user_data': 'denied',
103
+ 'ad_personalization': 'denied',
104
+ 'analytics_storage': 'denied',
105
+ 'wait_for_update': 500
106
+ });
107
+ gtag('set', 'ads_data_redaction', true);
108
+ gtag('set', 'url_passthrough', true);
109
+
110
+ gtag('js', new Date());
111
+ gtag('config', '${analytics.google}', {
112
+ send_page_view: false,
113
+ });
114
+
115
+ ${ /* Apollo initialization - called by AnalyticsProvider when consent is granted */''}
116
+ window.initApollo = function() {
117
+ if (window.apolloInitialized) return;
118
+ window.apolloInitialized = true;
119
+ var n = Math.random().toString(36).substring(7),
120
+ o = document.createElement('script');
121
+ o.src = 'https://assets.apollo.io/micro/website-tracker/tracker.iife.js?nocache=' + n;
122
+ o.async = true;
123
+ o.defer = true;
124
+ o.onload = function () {
125
+ window.trackingFunctions.onLoad({ appId: '${analytics.apollo}' });
126
+ };
127
+ document.head.appendChild(o);
128
+ };
129
+
130
+ ${ /* Check localStorage for existing consent and initialize if already granted */''}
131
+ (function() {
132
+ try {
133
+ var consent = localStorage.getItem('docs-cookie-consent');
134
+ if (consent === 'analytics') {
135
+ window.initApollo();
136
+ }
137
+ } catch (e) {}
138
+ })();
139
+ `
140
+ }
141
+ }), /*#__PURE__*/_jsx(Script, {
142
+ strategy: "afterInteractive",
143
+ src: `https://www.googletagmanager.com/gtag/js?id=${analytics.google}`
144
+ }), _NextScript || (_NextScript = /*#__PURE__*/_jsx(NextScript, {}))]
145
+ })]
146
+ });
147
+ }
@@ -0,0 +1,18 @@
1
+ import * as React from 'react';
2
+ import type { DocumentContext } from 'next/document';
3
+ export declare function createGetInitialProps({
4
+ setupStyledComponents
5
+ }: {
6
+ setupStyledComponents: boolean;
7
+ }): (ctx: DocumentContext) => Promise<{
8
+ canonicalAsServer: string;
9
+ analytics: {
10
+ google: string;
11
+ apollo: string;
12
+ };
13
+ userLanguage: string | string[];
14
+ styles: (string | number | bigint | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element)[];
15
+ html: string;
16
+ head?: Array<React.JSX.Element | null>;
17
+ emotionStyleTags: React.ReactElement<unknown>[];
18
+ }>;
@@ -0,0 +1,62 @@
1
+ var _style, _style2, _style3, _style4;
2
+ import * as React from 'react';
3
+ import { documentGetInitialProps } from '@mui/material-nextjs/v13-pagesRouter';
4
+ import createEmotionCache from "../DocsApp/createEmotionCache.js";
5
+ import { pathnameToLanguage } from "../helpers/helpers.js";
6
+
7
+ // eslint-disable-next-line import/prefer-default-export
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export function createGetInitialProps({
10
+ setupStyledComponents = false
11
+ }) {
12
+ async function getInitialPropsDocument(ctx) {
13
+ const styledComponentsSheet = setupStyledComponents ? new (await import('styled-components')).ServerStyleSheet() : null;
14
+ try {
15
+ const finalProps = await documentGetInitialProps(ctx, {
16
+ emotionCache: createEmotionCache(),
17
+ plugins: styledComponentsSheet ? [{
18
+ enhanceApp: App => props => styledComponentsSheet.collectStyles(/*#__PURE__*/_jsx(App, {
19
+ ...props
20
+ })),
21
+ resolveProps: async initialProps => ({
22
+ ...initialProps,
23
+ styles: [styledComponentsSheet.getStyleElement(), ...React.Children.toArray(initialProps.styles)]
24
+ })
25
+ }] : []
26
+ });
27
+
28
+ // All the URLs should have a leading /.
29
+ // This is missing in the Next.js static export.
30
+ let url = ctx.req?.url;
31
+ if (url && url[url.length - 1] !== '/') {
32
+ url += '/';
33
+ }
34
+ const isProd = process.env.DEPLOY_ENV === 'production' || process.env.DEPLOY_ENV === 'staging';
35
+ const google = isProd ? 'G-5NXDQLC2ZK' : 'G-XJ83JQEK7J';
36
+ const apollo = isProd ? '691c2e920c5e20000d7801b6' : 'dev-id';
37
+ return {
38
+ ...finalProps,
39
+ canonicalAsServer: pathnameToLanguage(url ?? '').canonicalAsServer,
40
+ analytics: {
41
+ google,
42
+ apollo
43
+ },
44
+ userLanguage: ctx.query.userLanguage || 'en',
45
+ styles: [_style || (_style = /*#__PURE__*/_jsx("style", {
46
+ id: "material-icon-font"
47
+ }, "material-icon-font")), _style2 || (_style2 = /*#__PURE__*/_jsx("style", {
48
+ id: "font-awesome-css"
49
+ }, "font-awesome-css")), ...finalProps.emotionStyleTags, _style3 || (_style3 = /*#__PURE__*/_jsx("style", {
50
+ id: "app-search"
51
+ }, "app-search")), _style4 || (_style4 = /*#__PURE__*/_jsx("style", {
52
+ id: "prismjs"
53
+ }, "prismjs")), ...React.Children.toArray(finalProps.styles)]
54
+ };
55
+ } finally {
56
+ if (styledComponentsSheet) {
57
+ styledComponentsSheet.seal();
58
+ }
59
+ }
60
+ }
61
+ return getInitialPropsDocument;
62
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Document.js";
2
+ export * from "./getInitialProps.js";
@@ -0,0 +1,2 @@
1
+ export * from "./Document.js";
2
+ export * from "./getInitialProps.js";