@mui/docs 9.0.0-alpha.2 → 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 (253) 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 +37 -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.js +13 -21
  42. package/IconImage/index.js +1 -13
  43. package/InfoCard/InfoCard.js +20 -29
  44. package/InfoCard/index.js +1 -16
  45. package/Link/Link.js +17 -25
  46. package/Link/MarkdownLinks.d.ts +2 -0
  47. package/Link/MarkdownLinks.js +84 -0
  48. package/Link/SkipLink.d.ts +1 -0
  49. package/Link/SkipLink.js +66 -0
  50. package/Link/index.d.ts +3 -1
  51. package/Link/index.js +3 -16
  52. package/MarkdownElement/MarkdownElement.js +178 -186
  53. package/MarkdownElement/index.js +1 -16
  54. package/MuiPage/MuiPage.d.ts +67 -0
  55. package/MuiPage/MuiPage.js +1 -0
  56. package/MuiPage/index.d.ts +1 -0
  57. package/MuiPage/index.js +1 -0
  58. package/NextNProgressBar/NextNProgressBar.d.ts +1 -0
  59. package/NextNProgressBar/NextNProgressBar.js +44 -0
  60. package/NextNProgressBar/index.d.ts +1 -0
  61. package/NextNProgressBar/index.js +1 -0
  62. package/PageContext/PageContext.d.ts +31 -0
  63. package/PageContext/PageContext.js +6 -0
  64. package/PageContext/index.d.ts +2 -0
  65. package/PageContext/index.js +1 -0
  66. package/SectionHeadline/SectionHeadline.js +9 -17
  67. package/SectionHeadline/index.js +2 -25
  68. package/SectionTitle/SectionTitle.js +7 -13
  69. package/SectionTitle/index.js +1 -16
  70. package/StyledEngineProvider/StyledEngineProvider.d.ts +9 -0
  71. package/StyledEngineProvider/StyledEngineProvider.js +44 -0
  72. package/StyledEngineProvider/index.d.ts +1 -0
  73. package/StyledEngineProvider/index.js +1 -0
  74. package/ThemeContext/ThemeContext.js +26 -38
  75. package/ThemeContext/index.js +1 -42
  76. package/branding/BrandingCssVarsProvider.d.ts +23 -0
  77. package/branding/BrandingCssVarsProvider.js +170 -0
  78. package/branding/BrandingProvider.js +8 -15
  79. package/branding/brandingTheme.js +115 -126
  80. package/branding/index.d.ts +2 -1
  81. package/branding/index.js +3 -27
  82. package/codeStyling/codeStyling.d.ts +10 -0
  83. package/codeStyling/codeStyling.js +84 -0
  84. package/codeStyling/index.d.ts +1 -0
  85. package/codeStyling/index.js +1 -0
  86. package/codeVariant/codeVariant.d.ts +10 -0
  87. package/codeVariant/codeVariant.js +73 -0
  88. package/codeVariant/index.d.ts +1 -0
  89. package/codeVariant/index.js +1 -0
  90. package/constants/constants.d.ts +13 -0
  91. package/constants/constants.js +15 -0
  92. package/constants/index.d.ts +1 -0
  93. package/constants/index.js +1 -0
  94. package/createEmotionCache/createEmotionCache.d.ts +1 -0
  95. package/createEmotionCache/createEmotionCache.js +12 -0
  96. package/createEmotionCache/index.d.ts +1 -0
  97. package/createEmotionCache/index.js +1 -0
  98. package/findActivePage/findActivePage.d.ts +5 -0
  99. package/findActivePage/findActivePage.js +35 -0
  100. package/findActivePage/index.d.ts +1 -0
  101. package/findActivePage/index.js +1 -0
  102. package/getProductInfoFromUrl/getProductInfoFromUrl.d.ts +8 -0
  103. package/getProductInfoFromUrl/getProductInfoFromUrl.js +50 -0
  104. package/getProductInfoFromUrl/index.d.ts +2 -0
  105. package/getProductInfoFromUrl/index.js +1 -0
  106. package/globalSelector/globalSelector.d.ts +2 -0
  107. package/globalSelector/globalSelector.js +17 -0
  108. package/globalSelector/index.d.ts +1 -0
  109. package/globalSelector/index.js +1 -0
  110. package/helpers/helpers.d.ts +31 -0
  111. package/helpers/helpers.js +87 -0
  112. package/helpers/index.d.ts +2 -0
  113. package/helpers/index.js +1 -0
  114. package/i18n/i18n.js +17 -29
  115. package/i18n/index.js +1 -16
  116. package/mapApiPageTranslations/index.d.ts +1 -0
  117. package/mapApiPageTranslations/index.js +1 -0
  118. package/mapApiPageTranslations/mapApiPageTranslations.d.ts +11 -0
  119. package/mapApiPageTranslations/mapApiPageTranslations.js +46 -0
  120. package/nextFonts/index.js +8 -15
  121. package/package.json +231 -126
  122. package/svgIcons/BundleSizeIcon.js +5 -11
  123. package/svgIcons/FigmaIcon.js +8 -14
  124. package/svgIcons/FileDownload.js +5 -12
  125. package/svgIcons/JavaScript.js +5 -12
  126. package/svgIcons/MarkdownIcon.js +7 -14
  127. package/svgIcons/MaterialDesignIcon.js +6 -12
  128. package/svgIcons/SketchIcon.js +10 -16
  129. package/svgIcons/TypeScript.js +5 -12
  130. package/svgIcons/W3CIcon.js +6 -12
  131. package/translations/index.js +3 -10
  132. package/translations/translations.json +0 -1
  133. package/useLazyCSS/index.js +1 -13
  134. package/useLazyCSS/useLazyCSS.js +5 -11
  135. package/utils/index.d.ts +1 -0
  136. package/utils/index.js +2 -0
  137. package/utils/loadScript.js +1 -7
  138. package/Ad/Ad.d.mts +0 -5
  139. package/Ad/Ad.mjs +0 -226
  140. package/Ad/AdCarbon.d.mts +0 -2
  141. package/Ad/AdCarbon.mjs +0 -125
  142. package/Ad/AdDisplay.d.mts +0 -16
  143. package/Ad/AdDisplay.mjs +0 -86
  144. package/Ad/AdGuest.d.mts +0 -10
  145. package/Ad/AdGuest.mjs +0 -29
  146. package/Ad/AdInHouse.d.mts +0 -4
  147. package/Ad/AdInHouse.mjs +0 -14
  148. package/Ad/AdManager.d.mts +0 -19
  149. package/Ad/AdManager.mjs +0 -36
  150. package/Ad/AdProvider.d.mts +0 -15
  151. package/Ad/AdProvider.mjs +0 -24
  152. package/Ad/ad.styles.d.mts +0 -4512
  153. package/Ad/ad.styles.mjs +0 -91
  154. package/Ad/index.d.mts +0 -5
  155. package/Ad/index.mjs +0 -7
  156. package/CodeCopy/CodeCopy.d.mts +0 -22
  157. package/CodeCopy/CodeCopy.mjs +0 -172
  158. package/CodeCopy/CodeCopyButton.d.mts +0 -4
  159. package/CodeCopy/CodeCopyButton.mjs +0 -40
  160. package/CodeCopy/index.d.mts +0 -3
  161. package/CodeCopy/index.mjs +0 -3
  162. package/CodeCopy/useClipboardCopy.d.mts +0 -4
  163. package/CodeCopy/useClipboardCopy.mjs +0 -21
  164. package/ComponentLinkHeader/ComponentLinkHeader.d.mts +0 -8
  165. package/ComponentLinkHeader/ComponentLinkHeader.mjs +0 -197
  166. package/ComponentLinkHeader/index.d.mts +0 -2
  167. package/ComponentLinkHeader/index.mjs +0 -2
  168. package/DocsProvider/DocsProvider.d.mts +0 -24
  169. package/DocsProvider/DocsProvider.mjs +0 -31
  170. package/DocsProvider/index.d.mts +0 -1
  171. package/DocsProvider/index.mjs +0 -1
  172. package/HighlightedCode/HighlightedCode.d.mts +0 -14
  173. package/HighlightedCode/HighlightedCode.mjs +0 -67
  174. package/HighlightedCode/index.d.mts +0 -1
  175. package/HighlightedCode/index.mjs +0 -1
  176. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.d.mts +0 -28
  177. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.mjs +0 -362
  178. package/HighlightedCodeWithTabs/index.d.mts +0 -2
  179. package/HighlightedCodeWithTabs/index.mjs +0 -2
  180. package/IconImage/IconImage.d.mts +0 -11
  181. package/IconImage/IconImage.mjs +0 -83
  182. package/IconImage/index.d.mts +0 -1
  183. package/IconImage/index.mjs +0 -1
  184. package/InfoCard/InfoCard.d.mts +0 -22
  185. package/InfoCard/InfoCard.mjs +0 -87
  186. package/InfoCard/index.d.mts +0 -1
  187. package/InfoCard/index.mjs +0 -1
  188. package/Link/Link.d.mts +0 -25
  189. package/Link/Link.mjs +0 -75
  190. package/Link/index.d.mts +0 -1
  191. package/Link/index.mjs +0 -1
  192. package/MarkdownElement/MarkdownElement.d.mts +0 -7
  193. package/MarkdownElement/MarkdownElement.mjs +0 -847
  194. package/MarkdownElement/index.d.mts +0 -1
  195. package/MarkdownElement/index.mjs +0 -1
  196. package/NProgressBar/NProgressBar.d.mts +0 -6
  197. package/NProgressBar/NProgressBar.js +0 -98
  198. package/NProgressBar/index.d.mts +0 -2
  199. package/NProgressBar/index.d.ts +0 -2
  200. package/NProgressBar/index.js +0 -13
  201. package/NProgressBar/index.mjs +0 -1
  202. package/SectionHeadline/SectionHeadline.d.mts +0 -13
  203. package/SectionHeadline/SectionHeadline.mjs +0 -81
  204. package/SectionHeadline/index.d.mts +0 -2
  205. package/SectionHeadline/index.mjs +0 -2
  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/ThemeContext/ThemeContext.d.mts +0 -92
  211. package/ThemeContext/ThemeContext.mjs +0 -200
  212. package/ThemeContext/index.d.mts +0 -1
  213. package/ThemeContext/index.mjs +0 -1
  214. package/branding/BrandingProvider.d.mts +0 -9
  215. package/branding/BrandingProvider.mjs +0 -17
  216. package/branding/brandingTheme.d.mts +0 -147
  217. package/branding/brandingTheme.mjs +0 -1527
  218. package/branding/index.d.mts +0 -2
  219. package/branding/index.mjs +0 -2
  220. package/i18n/i18n.d.mts +0 -27
  221. package/i18n/i18n.mjs +0 -111
  222. package/i18n/index.d.mts +0 -1
  223. package/i18n/index.mjs +0 -1
  224. package/nextFonts/index.d.mts +0 -6
  225. package/nextFonts/index.mjs +0 -59
  226. package/svgIcons/BundleSizeIcon.d.mts +0 -4
  227. package/svgIcons/BundleSizeIcon.mjs +0 -13
  228. package/svgIcons/FigmaIcon.d.mts +0 -4
  229. package/svgIcons/FigmaIcon.mjs +0 -22
  230. package/svgIcons/FileDownload.d.mts +0 -6
  231. package/svgIcons/FileDownload.mjs +0 -13
  232. package/svgIcons/JavaScript.d.mts +0 -6
  233. package/svgIcons/JavaScript.mjs +0 -13
  234. package/svgIcons/MarkdownIcon.d.mts +0 -2
  235. package/svgIcons/MarkdownIcon.mjs +0 -22
  236. package/svgIcons/MaterialDesignIcon.d.mts +0 -4
  237. package/svgIcons/MaterialDesignIcon.mjs +0 -18
  238. package/svgIcons/SketchIcon.d.mts +0 -4
  239. package/svgIcons/SketchIcon.mjs +0 -27
  240. package/svgIcons/TypeScript.d.mts +0 -6
  241. package/svgIcons/TypeScript.mjs +0 -13
  242. package/svgIcons/W3CIcon.d.mts +0 -4
  243. package/svgIcons/W3CIcon.mjs +0 -15
  244. package/translations/index.d.mts +0 -3
  245. package/translations/index.mjs +0 -4
  246. package/useLazyCSS/index.d.mts +0 -1
  247. package/useLazyCSS/index.mjs +0 -1
  248. package/useLazyCSS/useLazyCSS.d.mts +0 -11
  249. package/useLazyCSS/useLazyCSS.mjs +0 -70
  250. package/utils/loadScript.d.mts +0 -1
  251. package/utils/loadScript.mjs +0 -7
  252. /package/{NProgressBar → NextNProgressBar}/NProgressBar.d.ts +0 -0
  253. /package/{NProgressBar/NProgressBar.mjs → NextNProgressBar/NProgressBar.js} +0 -0
@@ -1,2 +1,3 @@
1
1
  export * from "./brandingTheme.js";
2
- export * from "./BrandingProvider.js";
2
+ export * from "./BrandingProvider.js";
3
+ export * from "./BrandingCssVarsProvider.js";
package/branding/index.js CHANGED
@@ -1,27 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _brandingTheme = require("./brandingTheme");
7
- Object.keys(_brandingTheme).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _brandingTheme[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _brandingTheme[key];
14
- }
15
- });
16
- });
17
- var _BrandingProvider = require("./BrandingProvider");
18
- Object.keys(_BrandingProvider).forEach(function (key) {
19
- if (key === "default" || key === "__esModule") return;
20
- if (key in exports && exports[key] === _BrandingProvider[key]) return;
21
- Object.defineProperty(exports, key, {
22
- enumerable: true,
23
- get: function () {
24
- return _BrandingProvider[key];
25
- }
26
- });
27
- });
1
+ export * from "./brandingTheme.js";
2
+ export * from "./BrandingProvider.js";
3
+ export * from "./BrandingCssVarsProvider.js";
@@ -0,0 +1,10 @@
1
+ export function CodeStylingProvider(props: any): import("react/jsx-runtime").JSX.Element;
2
+ export namespace CodeStylingProvider {
3
+ namespace propTypes {
4
+ let children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
5
+ }
6
+ }
7
+ export function useCodeStyling(): string;
8
+ export function useNoSsrCodeStyling(): any;
9
+ export function useSetCodeStyling(): () => void;
10
+ import PropTypes from 'prop-types';
@@ -0,0 +1,84 @@
1
+ import PropTypes from 'prop-types';
2
+ import * as React from 'react';
3
+ import { CODE_STYLING } from "../constants/index.js";
4
+ import { getCookie } from "../helpers/index.js";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const CodeStylingContext = /*#__PURE__*/React.createContext({
7
+ codeStyling: CODE_STYLING.SYSTEM,
8
+ setCodeStyling: () => {}
9
+ });
10
+ if (process.env.NODE_ENV !== 'production') {
11
+ CodeStylingContext.displayName = 'CodeStyling';
12
+ }
13
+ function useFirstRender() {
14
+ const firstRenderRef = React.useRef(true);
15
+ React.useEffect(() => {
16
+ firstRenderRef.current = false;
17
+ }, []);
18
+ return firstRenderRef.current;
19
+ }
20
+ export function CodeStylingProvider(props) {
21
+ const {
22
+ children
23
+ } = props;
24
+ const [codeStyling, setCodeStyling] = React.useState(CODE_STYLING.SYSTEM);
25
+ const navigatedCodeStyling = React.useMemo(() => {
26
+ const navigatedCodeMatch = typeof window !== 'undefined' ? window.location.hash.match(/\.(js|tsx)$/) : null;
27
+ if (navigatedCodeMatch === null) {
28
+ return undefined;
29
+ }
30
+ if (typeof window !== 'undefined') {
31
+ if (window.location.hash.includes('tailwind-')) {
32
+ return CODE_STYLING.TAILWIND;
33
+ }
34
+ if (window.location.hash.includes('css-')) {
35
+ return CODE_STYLING.CSS;
36
+ }
37
+ if (window.location.hash.includes('system-')) {
38
+ return CODE_STYLING.SYSTEM;
39
+ }
40
+ }
41
+ return undefined;
42
+ }, []);
43
+ const persistedCodeStyling = React.useMemo(() => {
44
+ if (typeof window === 'undefined') {
45
+ return undefined;
46
+ }
47
+ return getCookie('codeStyling');
48
+ }, []);
49
+ const isFirstRender = useFirstRender();
50
+
51
+ // We initialize from navigation or cookies. on subsequent renders the store is the truth
52
+ const noSsrCodeStyling = isFirstRender === true ? navigatedCodeStyling || persistedCodeStyling || codeStyling : codeStyling;
53
+ React.useEffect(() => {
54
+ if (codeStyling !== noSsrCodeStyling) {
55
+ setCodeStyling(noSsrCodeStyling);
56
+ }
57
+ }, [codeStyling, noSsrCodeStyling]);
58
+ React.useEffect(() => {
59
+ document.cookie = `codeStyling=${codeStyling};path=/;max-age=31536000`;
60
+ }, [codeStyling]);
61
+ const contextValue = React.useMemo(() => {
62
+ return {
63
+ codeStyling,
64
+ noSsrCodeStyling,
65
+ setCodeStyling
66
+ };
67
+ }, [codeStyling, noSsrCodeStyling]);
68
+ return /*#__PURE__*/_jsx(CodeStylingContext.Provider, {
69
+ value: contextValue,
70
+ children: children
71
+ });
72
+ }
73
+ process.env.NODE_ENV !== "production" ? CodeStylingProvider.propTypes = {
74
+ children: PropTypes.node.isRequired
75
+ } : void 0;
76
+ export function useCodeStyling() {
77
+ return React.useContext(CodeStylingContext).codeStyling;
78
+ }
79
+ export function useNoSsrCodeStyling() {
80
+ return React.useContext(CodeStylingContext).noSsrCodeStyling;
81
+ }
82
+ export function useSetCodeStyling() {
83
+ return React.useContext(CodeStylingContext).setCodeStyling;
84
+ }
@@ -0,0 +1 @@
1
+ export { CodeStylingProvider, useCodeStyling, useNoSsrCodeStyling, useSetCodeStyling } from "./codeStyling.js";
@@ -0,0 +1 @@
1
+ export { CodeStylingProvider, useCodeStyling, useNoSsrCodeStyling, useSetCodeStyling } from "./codeStyling.js";
@@ -0,0 +1,10 @@
1
+ export function CodeVariantProvider(props: any): import("react/jsx-runtime").JSX.Element;
2
+ export namespace CodeVariantProvider {
3
+ namespace propTypes {
4
+ let children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
5
+ }
6
+ }
7
+ export function useCodeVariant(): string;
8
+ export function useNoSsrCodeVariant(): any;
9
+ export function useSetCodeVariant(): () => void;
10
+ import PropTypes from 'prop-types';
@@ -0,0 +1,73 @@
1
+ import PropTypes from 'prop-types';
2
+ import * as React from 'react';
3
+ import { CODE_VARIANTS } from "../constants/index.js";
4
+ import { getCookie } from "../helpers/index.js";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const CodeVariantContext = /*#__PURE__*/React.createContext({
7
+ codeVariant: CODE_VARIANTS.TS,
8
+ setCodeVariant: () => {}
9
+ });
10
+ if (process.env.NODE_ENV !== 'production') {
11
+ CodeVariantContext.displayName = 'CodeVariant';
12
+ }
13
+ function useFirstRender() {
14
+ const firstRenderRef = React.useRef(true);
15
+ React.useEffect(() => {
16
+ firstRenderRef.current = false;
17
+ }, []);
18
+ return firstRenderRef.current;
19
+ }
20
+ export function CodeVariantProvider(props) {
21
+ const {
22
+ children
23
+ } = props;
24
+ const [codeVariant, setCodeVariant] = React.useState(CODE_VARIANTS.TS);
25
+ const navigatedCodeVariant = React.useMemo(() => {
26
+ const navigatedCodeVariantMatch = typeof window !== 'undefined' ? window.location.hash.match(/\.(js|tsx)$/) : null;
27
+ if (navigatedCodeVariantMatch === null) {
28
+ return undefined;
29
+ }
30
+ return navigatedCodeVariantMatch[1] === 'tsx' ? CODE_VARIANTS.TS : CODE_VARIANTS.JS;
31
+ }, []);
32
+ const persistedCodeVariant = React.useMemo(() => {
33
+ if (typeof window === 'undefined') {
34
+ return undefined;
35
+ }
36
+ return getCookie('codeVariant');
37
+ }, []);
38
+ const isFirstRender = useFirstRender();
39
+
40
+ // We initialize from navigation or cookies. on subsequent renders the store is the truth
41
+ const noSsrCodeVariant = isFirstRender === true ? navigatedCodeVariant || persistedCodeVariant || codeVariant : codeVariant;
42
+ React.useEffect(() => {
43
+ if (codeVariant !== noSsrCodeVariant) {
44
+ setCodeVariant(noSsrCodeVariant);
45
+ }
46
+ }, [codeVariant, noSsrCodeVariant]);
47
+ React.useEffect(() => {
48
+ document.cookie = `codeVariant=${codeVariant};path=/;max-age=31536000`;
49
+ }, [codeVariant]);
50
+ const contextValue = React.useMemo(() => {
51
+ return {
52
+ codeVariant,
53
+ noSsrCodeVariant,
54
+ setCodeVariant
55
+ };
56
+ }, [codeVariant, noSsrCodeVariant]);
57
+ return /*#__PURE__*/_jsx(CodeVariantContext.Provider, {
58
+ value: contextValue,
59
+ children: children
60
+ });
61
+ }
62
+ process.env.NODE_ENV !== "production" ? CodeVariantProvider.propTypes = {
63
+ children: PropTypes.node.isRequired
64
+ } : void 0;
65
+ export function useCodeVariant() {
66
+ return React.useContext(CodeVariantContext).codeVariant;
67
+ }
68
+ export function useNoSsrCodeVariant() {
69
+ return React.useContext(CodeVariantContext).noSsrCodeVariant;
70
+ }
71
+ export function useSetCodeVariant() {
72
+ return React.useContext(CodeVariantContext).setCodeVariant;
73
+ }
@@ -0,0 +1 @@
1
+ export { CodeVariantProvider, useCodeVariant, useNoSsrCodeVariant, useSetCodeVariant } from "./codeVariant.js";
@@ -0,0 +1 @@
1
+ export { CodeVariantProvider, useCodeVariant, useNoSsrCodeVariant, useSetCodeVariant } from "./codeVariant.js";
@@ -0,0 +1,13 @@
1
+ export namespace CODE_VARIANTS {
2
+ let JS: string;
3
+ let TS: string;
4
+ }
5
+ export namespace CODE_STYLING {
6
+ let SYSTEM: string;
7
+ let TAILWIND: string;
8
+ let CSS: string;
9
+ }
10
+ export const LANGUAGES_LABEL: {
11
+ code: string;
12
+ text: string;
13
+ }[];
@@ -0,0 +1,15 @@
1
+ export const CODE_VARIANTS = {
2
+ JS: 'JS',
3
+ TS: 'TS'
4
+ };
5
+ export const CODE_STYLING = {
6
+ SYSTEM: 'MUI System',
7
+ TAILWIND: 'Tailwind',
8
+ CSS: 'CSS'
9
+ };
10
+
11
+ // Valid languages to use in production
12
+ export const LANGUAGES_LABEL = [{
13
+ code: 'en',
14
+ text: 'English'
15
+ }];
@@ -0,0 +1 @@
1
+ export { CODE_VARIANTS, CODE_STYLING, LANGUAGES_LABEL } from "./constants.js";
@@ -0,0 +1 @@
1
+ export { CODE_VARIANTS, CODE_STYLING, LANGUAGES_LABEL } from "./constants.js";
@@ -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 @@
1
+ export { default } from "./createEmotionCache.js";
@@ -0,0 +1 @@
1
+ export { default } from "./createEmotionCache.js";
@@ -0,0 +1,5 @@
1
+ import type { MuiPage } from "../MuiPage/index.js";
2
+ export default function findActivePage(currentPages: MuiPage[], currentPathname: string): {
3
+ activePage: MuiPage | null;
4
+ activePageParents: MuiPage[];
5
+ };
@@ -0,0 +1,35 @@
1
+ export default function findActivePage(currentPages, currentPathname) {
2
+ const map = {};
3
+ const mapParent = {};
4
+ const pathname = currentPathname.replace('/[docsTab]', '').replace('components-api', '').replace('hooks-api', '');
5
+ const traverse = parent => {
6
+ (parent.children || []).forEach(child => {
7
+ const childPathname = child.pathname.replace('/[docsTab]', '').replace('components-api', '').replace('hooks-api', '');
8
+ map[childPathname] = child;
9
+ const isChildApiPathname = child.pathname.includes('components-api') || child.pathname.includes('hooks-api');
10
+ if (!isChildApiPathname && mapParent[childPathname]) {
11
+ throw new Error(`Duplicated pathname ${child.pathname} in pages`);
12
+ }
13
+ if (!isChildApiPathname) {
14
+ mapParent[childPathname] = parent;
15
+ }
16
+ traverse(child);
17
+ });
18
+ };
19
+ traverse({
20
+ pathname: '/',
21
+ children: currentPages
22
+ });
23
+ const activePage = map[pathname] || null;
24
+ const activePageParents = [];
25
+ let traversePage = activePage;
26
+ while (traversePage && traversePage.pathname !== '/') {
27
+ const parent = mapParent[traversePage.pathname];
28
+ activePageParents.push(parent);
29
+ traversePage = parent;
30
+ }
31
+ return {
32
+ activePage,
33
+ activePageParents
34
+ };
35
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./findActivePage.js";
@@ -0,0 +1 @@
1
+ export { default } from "./findActivePage.js";
@@ -0,0 +1,8 @@
1
+ export type MuiProductId = 'null' | 'base-ui' | 'material-ui' | 'system' | 'docs-infra' | 'docs' | 'x-data-grid' | 'x-date-pickers' | 'x-charts' | 'x-tree-view' | 'toolpad-studio' | 'toolpad-core';
2
+ type MuiProductCategoryId = 'null' | 'core' | 'x';
3
+ interface MuiProductInfo {
4
+ productId: MuiProductId;
5
+ productCategoryId: MuiProductCategoryId;
6
+ }
7
+ export default function getProductInfoFromUrl(asPath: string): MuiProductInfo;
8
+ export {};
@@ -0,0 +1,50 @@
1
+ import { pathnameToLanguage } from "../helpers/helpers.js";
2
+ // This is a fallback logic to define the productId and productCategoryId of the page.
3
+ // Markdown pages can override this value when the URL patterns they follow are a bit strange,
4
+ // which should stay the rare exception.
5
+ export default function getProductInfoFromUrl(asPath) {
6
+ const asPathWithoutLang = pathnameToLanguage(asPath).canonicalAsServer;
7
+ const firstFolder = asPathWithoutLang.replace(/^\/+([^/]+)\/.*/, '$1');
8
+
9
+ // When serialized undefined/null are the same, so we encode null as 'null' to be
10
+ // able to differentiate when the value isn't set vs. set to the right null value.
11
+ let productCategoryId = 'null';
12
+ let productId = 'null';
13
+ if (firstFolder === 'material-ui' || firstFolder === 'joy-ui' || firstFolder === 'base-ui' || firstFolder === 'system') {
14
+ productCategoryId = 'core';
15
+ productId = firstFolder;
16
+ }
17
+ if (firstFolder === 'x') {
18
+ productCategoryId = 'x';
19
+ productId = `x-${asPathWithoutLang.replace('/x/react-', '').replace(/\/.*/, '')}`;
20
+
21
+ // No match, give up on it.
22
+ if (productId === 'x-') {
23
+ productId = 'null';
24
+ }
25
+ }
26
+ if (firstFolder === 'toolpad') {
27
+ productCategoryId = 'toolpad';
28
+ const secondFolder = asPathWithoutLang.replace(/^\/+[^/]+\/([^/]+)\/.*/, '$1');
29
+ if (secondFolder === 'studio') {
30
+ productId = 'toolpad-studio';
31
+ } else {
32
+ productId = 'toolpad-core';
33
+ }
34
+ }
35
+ if (firstFolder === 'docs') {
36
+ productId = firstFolder;
37
+ }
38
+
39
+ // TODO remove, legacy
40
+ if (firstFolder === 'versions' || firstFolder === 'production-error') {
41
+ productId = 'docs';
42
+ }
43
+ if (asPathWithoutLang.startsWith('/experiments/docs/')) {
44
+ productId = 'docs-infra';
45
+ }
46
+ return {
47
+ productCategoryId,
48
+ productId
49
+ };
50
+ }
@@ -0,0 +1,2 @@
1
+ export { default } from "./getProductInfoFromUrl.js";
2
+ export type { MuiProductId } from "./getProductInfoFromUrl.js";
@@ -0,0 +1 @@
1
+ export { default } from "./getProductInfoFromUrl.js";
@@ -0,0 +1,2 @@
1
+ import { Element } from 'stylis';
2
+ export default function globalSelector(element: Element): void;
@@ -0,0 +1,17 @@
1
+ /* eslint-disable default-case */
2
+ import { RULESET } from 'stylis';
3
+
4
+ // A workaround to https://github.com/emotion-js/emotion/issues/2836
5
+ // to be able to use `:where` selector for styling.
6
+ export default function globalSelector(element) {
7
+ switch (element.type) {
8
+ case RULESET:
9
+ element.props = element.props.map(value => {
10
+ if (value.match(/(:where|:is)\(/)) {
11
+ value = value.replace(/\.[^:]+(:where|:is)/, '$1');
12
+ return value;
13
+ }
14
+ return value;
15
+ });
16
+ }
17
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./globalSelector.js";
@@ -0,0 +1 @@
1
+ export { default } from "./globalSelector.js";
@@ -0,0 +1,31 @@
1
+ import type { Translate } from "../i18n/index.js";
2
+ export declare function pascalCase(str: string): string;
3
+ export interface Page {
4
+ pathname: string;
5
+ query?: object;
6
+ subheader?: string;
7
+ title?: string | false;
8
+ }
9
+ export declare function pageToTitle(page: Page): string | null;
10
+ export declare function pageToTitleI18n(page: Page, t: Translate): string | null;
11
+ /**
12
+ * Get the value of a cookie
13
+ * Source: https://vanillajstoolkit.com/helpers/getcookie/
14
+ * @param name - The name of the cookie
15
+ * @return The cookie value
16
+ */
17
+ export declare function getCookie(name: string): string | undefined;
18
+ /**
19
+ * as is a reference to Next.js's as, the path in the URL
20
+ * pathname is a reference to Next.js's pathname, the name of page in the filesystem
21
+ * https://nextjs.org/docs/api-reference/next/router
22
+ *
23
+ * @param pathname - The URL pathname
24
+ * @param languages - List of supported language codes. Defaults to `['en']`.
25
+ */
26
+ export declare function pathnameToLanguage(pathname: string, languages?: string[]): {
27
+ userLanguage: string;
28
+ canonicalAs: string;
29
+ canonicalAsServer: string;
30
+ canonicalPathname: string;
31
+ };
@@ -0,0 +1,87 @@
1
+ import { camelCase, upperFirst } from 'es-toolkit/string';
2
+ export function pascalCase(str) {
3
+ return upperFirst(camelCase(str));
4
+ }
5
+ function titleize(hyphenedString) {
6
+ return upperFirst(hyphenedString.split('-').join(' '));
7
+ }
8
+ export function pageToTitle(page) {
9
+ if (page.title === false) {
10
+ return null;
11
+ }
12
+ if (page.title) {
13
+ return page.title;
14
+ }
15
+ const path = page.subheader || page.pathname;
16
+ const name = path.replace(/.*\//, '').replace('react-', '').replace(/\..*/, '');
17
+
18
+ // TODO remove post migration
19
+ if (path.includes('/api-docs/')) {
20
+ return pascalCase(name);
21
+ }
22
+
23
+ // TODO support more than React component API (PascalCase)
24
+ if (path.includes('/api/')) {
25
+ return name.startsWith('use') ? camelCase(name) : pascalCase(name);
26
+ }
27
+ return titleize(name);
28
+ }
29
+ export function pageToTitleI18n(page, t) {
30
+ const path = page.subheader || page.pathname;
31
+ return page.query ? pageToTitle(page) : t(`pages.${path}`, {
32
+ ignoreWarning: true
33
+ }) || pageToTitle(page);
34
+ }
35
+
36
+ /**
37
+ * Get the value of a cookie
38
+ * Source: https://vanillajstoolkit.com/helpers/getcookie/
39
+ * @param name - The name of the cookie
40
+ * @return The cookie value
41
+ */
42
+ export function getCookie(name) {
43
+ if (typeof document === 'undefined') {
44
+ throw new Error('getCookie() is not supported on the server. Fallback to a different value when rendering on the server.');
45
+ }
46
+ const value = `; ${document.cookie}`;
47
+ const parts = value.split(`; ${name}=`);
48
+ if (parts.length === 2) {
49
+ return parts[1].split(';').shift();
50
+ }
51
+ return undefined;
52
+ }
53
+
54
+ /**
55
+ * as is a reference to Next.js's as, the path in the URL
56
+ * pathname is a reference to Next.js's pathname, the name of page in the filesystem
57
+ * https://nextjs.org/docs/api-reference/next/router
58
+ *
59
+ * @param pathname - The URL pathname
60
+ * @param languages - List of supported language codes. Defaults to `['en']`.
61
+ */
62
+ export function pathnameToLanguage(pathname, languages = ['en']) {
63
+ let userLanguage;
64
+ const userLanguageCandidate = pathname.substring(1, 3);
65
+ if ([...languages, 'zh'].includes(userLanguageCandidate) && pathname.startsWith(`/${userLanguageCandidate}/`)) {
66
+ userLanguage = userLanguageCandidate;
67
+ } else {
68
+ userLanguage = 'en';
69
+ }
70
+ const canonicalAs = userLanguage === 'en' ? pathname : pathname.substring(3);
71
+ // Remove hash as it's never sent to the server
72
+ // https://github.com/vercel/next.js/issues/25202
73
+ const canonicalAsServer = canonicalAs.replace(/#(.*)$/, '');
74
+ let canonicalPathname = canonicalAsServer.replace(/^\/api/, '/api-docs');
75
+
76
+ // Remove trailing slash as Next.js doesn't expect it here
77
+ // https://nextjs.org/docs/pages/api-reference/functions/use-router#router-object
78
+ if (canonicalPathname !== '/') {
79
+ canonicalPathname = canonicalPathname.replace(/\/$/, '');
80
+ }
81
+ return {
82
+ userLanguage,
83
+ canonicalAs,
84
+ canonicalAsServer,
85
+ canonicalPathname
86
+ };
87
+ }
@@ -0,0 +1,2 @@
1
+ export { pascalCase, pageToTitle, pageToTitleI18n, getCookie, pathnameToLanguage } from "./helpers.js";
2
+ export type { Page } from "./helpers.js";
@@ -0,0 +1 @@
1
+ export { pascalCase, pageToTitle, pageToTitleI18n, getCookie, pathnameToLanguage } from "./helpers.js";
package/i18n/i18n.js CHANGED
@@ -1,28 +1,16 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.UserLanguageProvider = UserLanguageProvider;
9
- exports.mapTranslations = mapTranslations;
10
- exports.useSetUserLanguage = useSetUserLanguage;
11
- exports.useTranslate = useTranslate;
12
- exports.useUserLanguage = useUserLanguage;
13
- var React = _interopRequireWildcard(require("react"));
14
- var _propTypes = _interopRequireDefault(require("prop-types"));
15
- var _deepmerge = _interopRequireDefault(require("@mui/utils/deepmerge"));
16
- var _translations = _interopRequireDefault(require("../translations"));
17
- var _jsxRuntime = require("react/jsx-runtime");
18
- const TranslationsContext = /*#__PURE__*/React.createContext(_translations.default);
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import deepmerge from '@mui/utils/deepmerge';
4
+ import defaultTranslations from "../translations/index.js";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ const TranslationsContext = /*#__PURE__*/React.createContext(defaultTranslations);
19
7
  function TranslationsProvider({
20
8
  translations = {},
21
9
  children
22
10
  }) {
23
11
  const currentTranslations = React.useContext(TranslationsContext);
24
- const mergedTranslations = React.useMemo(() => (0, _deepmerge.default)(currentTranslations, translations), [currentTranslations, translations]);
25
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(TranslationsContext.Provider, {
12
+ const mergedTranslations = React.useMemo(() => deepmerge(currentTranslations, translations), [currentTranslations, translations]);
13
+ return /*#__PURE__*/_jsx(TranslationsContext.Provider, {
26
14
  value: mergedTranslations,
27
15
  children: children
28
16
  });
@@ -44,7 +32,7 @@ const UserLanguageContext = /*#__PURE__*/React.createContext({
44
32
  if (process.env.NODE_ENV !== 'production') {
45
33
  UserLanguageContext.displayName = 'UserLanguage';
46
34
  }
47
- function UserLanguageProvider(props) {
35
+ export function UserLanguageProvider(props) {
48
36
  const {
49
37
  children,
50
38
  translations,
@@ -57,22 +45,22 @@ function UserLanguageProvider(props) {
57
45
  setUserLanguage
58
46
  };
59
47
  }, [userLanguage]);
60
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(TranslationsProvider, {
48
+ return /*#__PURE__*/_jsx(TranslationsProvider, {
61
49
  translations: translations,
62
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(UserLanguageContext.Provider, {
50
+ children: /*#__PURE__*/_jsx(UserLanguageContext.Provider, {
63
51
  value: contextValue,
64
52
  children: children
65
53
  })
66
54
  });
67
55
  }
68
56
  process.env.NODE_ENV !== "production" ? UserLanguageProvider.propTypes = {
69
- children: _propTypes.default.node.isRequired,
70
- defaultUserLanguage: _propTypes.default.string
57
+ children: PropTypes.node.isRequired,
58
+ defaultUserLanguage: PropTypes.string
71
59
  } : void 0;
72
- function useUserLanguage() {
60
+ export function useUserLanguage() {
73
61
  return React.useContext(UserLanguageContext).userLanguage;
74
62
  }
75
- function useSetUserLanguage() {
63
+ export function useSetUserLanguage() {
76
64
  return React.useContext(UserLanguageContext).setUserLanguage;
77
65
  }
78
66
  const warnedOnce = {};
@@ -86,7 +74,7 @@ const warn = (userLanguage, key, ignoreWarning) => {
86
74
  warnedOnce[fullKey] = true;
87
75
  }
88
76
  };
89
- function useTranslate() {
77
+ export function useTranslate() {
90
78
  const userLanguage = useUserLanguage();
91
79
  const translations = React.useContext(TranslationsContext);
92
80
  return React.useMemo(() => function translate(key, options = {}) {
@@ -109,7 +97,7 @@ function useTranslate() {
109
97
  return translation;
110
98
  }, [userLanguage, translations]);
111
99
  }
112
- function mapTranslations(req) {
100
+ export function mapTranslations(req) {
113
101
  const result = {};
114
102
  req.keys().forEach(filename => {
115
103
  const match = filename.match(/-([a-z]{2}).json$/);