@mui/internal-core-docs 0.0.1 → 9.0.0-canary.1

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 (269) hide show
  1. package/Ad/Ad.d.ts +5 -0
  2. package/Ad/Ad.js +226 -0
  3. package/Ad/AdCarbon.d.ts +2 -0
  4. package/Ad/AdCarbon.js +125 -0
  5. package/Ad/AdDisplay.d.ts +16 -0
  6. package/Ad/AdDisplay.js +86 -0
  7. package/Ad/AdGuest.d.ts +10 -0
  8. package/Ad/AdGuest.js +29 -0
  9. package/Ad/AdInHouse.d.ts +4 -0
  10. package/Ad/AdInHouse.js +14 -0
  11. package/Ad/AdManager.d.ts +19 -0
  12. package/Ad/AdManager.js +36 -0
  13. package/Ad/AdProvider.d.ts +15 -0
  14. package/Ad/AdProvider.js +24 -0
  15. package/Ad/ad.styles.d.ts +4 -0
  16. package/Ad/ad.styles.js +91 -0
  17. package/Ad/index.d.ts +5 -0
  18. package/Ad/index.js +7 -0
  19. package/ApiPage/ApiWarningAlert.d.ts +10 -0
  20. package/ApiPage/ApiWarningAlert.js +22 -0
  21. package/ApiPage/definitions/classes.d.ts +18 -0
  22. package/ApiPage/definitions/classes.js +54 -0
  23. package/ApiPage/definitions/index.d.ts +4 -0
  24. package/ApiPage/definitions/index.js +4 -0
  25. package/ApiPage/definitions/properties.d.ts +58 -0
  26. package/ApiPage/definitions/properties.js +110 -0
  27. package/ApiPage/definitions/slots.d.ts +16 -0
  28. package/ApiPage/definitions/slots.js +39 -0
  29. package/ApiPage/definitions/types.d.ts +53 -0
  30. package/ApiPage/definitions/types.js +1 -0
  31. package/ApiPage/index.d.ts +2 -0
  32. package/ApiPage/index.js +2 -0
  33. package/ApiPage/list/ClassesList.d.ts +11 -0
  34. package/ApiPage/list/ClassesList.js +103 -0
  35. package/ApiPage/list/ExpandableApiItem.d.ts +18 -0
  36. package/ApiPage/list/ExpandableApiItem.js +241 -0
  37. package/ApiPage/list/PropertiesList.d.ts +7 -0
  38. package/ApiPage/list/PropertiesList.js +263 -0
  39. package/ApiPage/list/SlotsList.d.ts +7 -0
  40. package/ApiPage/list/SlotsList.js +93 -0
  41. package/ApiPage/list/index.d.ts +1 -0
  42. package/ApiPage/list/index.js +1 -0
  43. package/ApiPage/private.d.ts +3 -0
  44. package/ApiPage/private.js +3 -0
  45. package/ApiPage/sections/ClassesSection.d.ts +34 -0
  46. package/ApiPage/sections/ClassesSection.js +76 -0
  47. package/ApiPage/sections/PropertiesSection.d.ts +45 -0
  48. package/ApiPage/sections/PropertiesSection.js +59 -0
  49. package/ApiPage/sections/SlotsSection.d.ts +24 -0
  50. package/ApiPage/sections/SlotsSection.js +61 -0
  51. package/ApiPage/sections/ToggleDisplayOption.d.ts +17 -0
  52. package/ApiPage/sections/ToggleDisplayOption.js +161 -0
  53. package/ApiPage/sections/index.d.ts +4 -0
  54. package/ApiPage/sections/index.js +4 -0
  55. package/ApiPage/table/ClassesTable.d.ts +7 -0
  56. package/ApiPage/table/ClassesTable.js +116 -0
  57. package/ApiPage/table/PropertiesTable.d.ts +6 -0
  58. package/ApiPage/table/PropertiesTable.js +286 -0
  59. package/ApiPage/table/SlotsTable.d.ts +6 -0
  60. package/ApiPage/table/SlotsTable.js +126 -0
  61. package/ApiPage/table/StyledTableContainer.d.ts +1 -0
  62. package/ApiPage/table/StyledTableContainer.js +42 -0
  63. package/ApiPage/types.d.ts +11 -0
  64. package/ApiPage/types.js +1 -0
  65. package/CHANGELOG.md +1651 -0
  66. package/CodeCopy/CodeCopy.d.ts +22 -0
  67. package/CodeCopy/CodeCopy.js +172 -0
  68. package/CodeCopy/CodeCopyButton.d.ts +4 -0
  69. package/CodeCopy/CodeCopyButton.js +40 -0
  70. package/CodeCopy/index.d.ts +3 -0
  71. package/CodeCopy/index.js +3 -0
  72. package/CodeCopy/useClipboardCopy.d.ts +4 -0
  73. package/CodeCopy/useClipboardCopy.js +21 -0
  74. package/ComponentLinkHeader/ComponentLinkHeader.d.ts +8 -0
  75. package/ComponentLinkHeader/ComponentLinkHeader.js +197 -0
  76. package/ComponentLinkHeader/index.d.ts +2 -0
  77. package/ComponentLinkHeader/index.js +2 -0
  78. package/DemoContext/DemoContext.d.ts +86 -0
  79. package/DemoContext/DemoContext.js +13 -0
  80. package/DemoContext/index.d.ts +2 -0
  81. package/DemoContext/index.js +1 -0
  82. package/DocsApp/AnalyticsProvider.d.ts +17 -0
  83. package/DocsApp/AnalyticsProvider.js +229 -0
  84. package/DocsApp/DocsApp.d.ts +79 -0
  85. package/DocsApp/DocsApp.js +105 -0
  86. package/DocsApp/GoogleAnalytics.d.ts +9 -0
  87. package/DocsApp/GoogleAnalytics.js +129 -0
  88. package/DocsApp/StyledEngineProvider.d.ts +8 -0
  89. package/DocsApp/StyledEngineProvider.js +38 -0
  90. package/DocsApp/consoleBanner.d.ts +1 -0
  91. package/DocsApp/consoleBanner.js +18 -0
  92. package/DocsApp/createEmotionCache.d.ts +1 -0
  93. package/DocsApp/createEmotionCache.js +12 -0
  94. package/DocsApp/createGetInitialProps.d.ts +30 -0
  95. package/DocsApp/createGetInitialProps.js +29 -0
  96. package/DocsApp/index.d.ts +5 -0
  97. package/DocsApp/index.js +4 -0
  98. package/DocsApp/loadDependencies.d.ts +1 -0
  99. package/DocsApp/loadDependencies.js +9 -0
  100. package/DocsApp/reportWebVitals.d.ts +13 -0
  101. package/DocsApp/reportWebVitals.js +22 -0
  102. package/DocsApp/serviceWorker.d.ts +1 -0
  103. package/DocsApp/serviceWorker.js +59 -0
  104. package/DocsProvider/DocsProvider.d.ts +24 -0
  105. package/DocsProvider/DocsProvider.js +31 -0
  106. package/DocsProvider/index.d.ts +1 -0
  107. package/DocsProvider/index.js +1 -0
  108. package/Document/Document.d.ts +16 -0
  109. package/Document/Document.js +147 -0
  110. package/Document/getInitialProps.d.ts +18 -0
  111. package/Document/getInitialProps.js +60 -0
  112. package/Document/index.d.ts +2 -0
  113. package/Document/index.js +2 -0
  114. package/HighlightedCode/HighlightedCode.d.ts +14 -0
  115. package/HighlightedCode/HighlightedCode.js +67 -0
  116. package/HighlightedCode/index.d.ts +1 -0
  117. package/HighlightedCode/index.js +1 -0
  118. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.d.ts +28 -0
  119. package/HighlightedCodeWithTabs/HighlightedCodeWithTabs.js +362 -0
  120. package/HighlightedCodeWithTabs/index.d.ts +2 -0
  121. package/HighlightedCodeWithTabs/index.js +2 -0
  122. package/IconImage/IconImage.d.ts +11 -0
  123. package/IconImage/IconImage.js +83 -0
  124. package/IconImage/index.d.ts +1 -0
  125. package/IconImage/index.js +1 -0
  126. package/InfoCard/InfoCard.d.ts +22 -0
  127. package/InfoCard/InfoCard.js +91 -0
  128. package/InfoCard/index.d.ts +1 -0
  129. package/InfoCard/index.js +1 -0
  130. package/LICENSE +21 -0
  131. package/Link/Link.d.ts +25 -0
  132. package/Link/Link.js +75 -0
  133. package/Link/MarkdownLinks.d.ts +2 -0
  134. package/Link/MarkdownLinks.js +84 -0
  135. package/Link/SkipLink.d.ts +1 -0
  136. package/Link/SkipLink.js +64 -0
  137. package/Link/index.d.ts +3 -0
  138. package/Link/index.js +3 -0
  139. package/MarkdownElement/MarkdownElement.d.ts +7 -0
  140. package/MarkdownElement/MarkdownElement.js +847 -0
  141. package/MarkdownElement/index.d.ts +1 -0
  142. package/MarkdownElement/index.js +1 -0
  143. package/MuiPage/MuiPage.d.ts +67 -0
  144. package/MuiPage/MuiPage.js +1 -0
  145. package/MuiPage/index.d.ts +1 -0
  146. package/MuiPage/index.js +1 -0
  147. package/NextNProgressBar/NProgressBar.d.ts +6 -0
  148. package/NextNProgressBar/NProgressBar.js +91 -0
  149. package/NextNProgressBar/NextNProgressBar.d.ts +1 -0
  150. package/NextNProgressBar/NextNProgressBar.js +42 -0
  151. package/NextNProgressBar/index.d.ts +1 -0
  152. package/NextNProgressBar/index.js +1 -0
  153. package/PageContext/PageContext.d.ts +32 -0
  154. package/PageContext/PageContext.js +6 -0
  155. package/PageContext/index.d.ts +2 -0
  156. package/PageContext/index.js +1 -0
  157. package/README.md +26 -0
  158. package/SectionHeadline/SectionHeadline.d.ts +13 -0
  159. package/SectionHeadline/SectionHeadline.js +81 -0
  160. package/SectionHeadline/index.d.ts +2 -0
  161. package/SectionHeadline/index.js +2 -0
  162. package/SectionTitle/SectionTitle.d.ts +6 -0
  163. package/SectionTitle/SectionTitle.js +29 -0
  164. package/SectionTitle/index.d.ts +1 -0
  165. package/SectionTitle/index.js +1 -0
  166. package/ThemeContext/ThemeContext.d.ts +92 -0
  167. package/ThemeContext/ThemeContext.js +200 -0
  168. package/ThemeContext/index.d.ts +1 -0
  169. package/ThemeContext/index.js +1 -0
  170. package/branding/BrandingCssVarsProvider.d.ts +27 -0
  171. package/branding/BrandingCssVarsProvider.js +170 -0
  172. package/branding/BrandingProvider.d.ts +9 -0
  173. package/branding/BrandingProvider.js +17 -0
  174. package/branding/brandingTheme.d.ts +147 -0
  175. package/branding/brandingTheme.js +1534 -0
  176. package/branding/index.d.ts +3 -0
  177. package/branding/index.js +3 -0
  178. package/codeStyling/codeStyling.d.ts +7 -0
  179. package/codeStyling/codeStyling.js +80 -0
  180. package/codeStyling/index.d.ts +1 -0
  181. package/codeStyling/index.js +1 -0
  182. package/codeVariant/codeVariant.d.ts +7 -0
  183. package/codeVariant/codeVariant.js +69 -0
  184. package/codeVariant/index.d.ts +1 -0
  185. package/codeVariant/index.js +1 -0
  186. package/constants/constants.d.ts +13 -0
  187. package/constants/constants.js +15 -0
  188. package/constants/index.d.ts +1 -0
  189. package/constants/index.js +1 -0
  190. package/findActivePage/findActivePage.d.ts +5 -0
  191. package/findActivePage/findActivePage.js +35 -0
  192. package/findActivePage/index.d.ts +1 -0
  193. package/findActivePage/index.js +1 -0
  194. package/getProductInfoFromUrl/getProductInfoFromUrl.d.ts +8 -0
  195. package/getProductInfoFromUrl/getProductInfoFromUrl.js +50 -0
  196. package/getProductInfoFromUrl/index.d.ts +2 -0
  197. package/getProductInfoFromUrl/index.js +1 -0
  198. package/globalSelector/globalSelector.d.ts +2 -0
  199. package/globalSelector/globalSelector.js +17 -0
  200. package/globalSelector/index.d.ts +1 -0
  201. package/globalSelector/index.js +1 -0
  202. package/helpers/helpers.d.ts +31 -0
  203. package/helpers/helpers.js +87 -0
  204. package/helpers/index.d.ts +2 -0
  205. package/helpers/index.js +1 -0
  206. package/i18n/i18n.d.ts +27 -0
  207. package/i18n/i18n.js +111 -0
  208. package/i18n/index.d.ts +1 -0
  209. package/i18n/index.js +1 -0
  210. package/mapApiPageTranslations/index.d.ts +1 -0
  211. package/mapApiPageTranslations/index.js +1 -0
  212. package/mapApiPageTranslations/mapApiPageTranslations.d.ts +11 -0
  213. package/mapApiPageTranslations/mapApiPageTranslations.js +46 -0
  214. package/nextFonts/fonts/GeneralSans-Bold.ttf +0 -0
  215. package/nextFonts/fonts/GeneralSans-Bold.woff2 +0 -0
  216. package/nextFonts/fonts/GeneralSans-Medium.ttf +0 -0
  217. package/nextFonts/fonts/GeneralSans-Medium.woff2 +0 -0
  218. package/nextFonts/fonts/GeneralSans-Regular.ttf +0 -0
  219. package/nextFonts/fonts/GeneralSans-Regular.woff2 +0 -0
  220. package/nextFonts/fonts/GeneralSans-Semibold-subset.woff2 +0 -0
  221. package/nextFonts/fonts/GeneralSans-Semibold.ttf +0 -0
  222. package/nextFonts/fonts/GeneralSans-Semibold.woff2 +0 -0
  223. package/nextFonts/fonts/IBMPlexSans-Bold.ttf +0 -0
  224. package/nextFonts/fonts/IBMPlexSans-Bold.woff +0 -0
  225. package/nextFonts/fonts/IBMPlexSans-Bold.woff2 +0 -0
  226. package/nextFonts/fonts/IBMPlexSans-Medium.ttf +0 -0
  227. package/nextFonts/fonts/IBMPlexSans-Medium.woff +0 -0
  228. package/nextFonts/fonts/IBMPlexSans-Medium.woff2 +0 -0
  229. package/nextFonts/fonts/IBMPlexSans-Regular-subset.woff2 +0 -0
  230. package/nextFonts/fonts/IBMPlexSans-Regular.ttf +0 -0
  231. package/nextFonts/fonts/IBMPlexSans-Regular.woff +0 -0
  232. package/nextFonts/fonts/IBMPlexSans-Regular.woff2 +0 -0
  233. package/nextFonts/fonts/IBMPlexSans-SemiBold.ttf +0 -0
  234. package/nextFonts/fonts/IBMPlexSans-SemiBold.woff +0 -0
  235. package/nextFonts/fonts/IBMPlexSans-SemiBold.woff2 +0 -0
  236. package/nextFonts/index.d.ts +6 -0
  237. package/nextFonts/index.js +59 -0
  238. package/package.json +426 -3
  239. package/svgIcons/BundleSizeIcon.d.ts +4 -0
  240. package/svgIcons/BundleSizeIcon.js +13 -0
  241. package/svgIcons/FigmaIcon.d.ts +4 -0
  242. package/svgIcons/FigmaIcon.js +22 -0
  243. package/svgIcons/FileDownload.d.ts +6 -0
  244. package/svgIcons/FileDownload.js +13 -0
  245. package/svgIcons/JavaScript.d.ts +6 -0
  246. package/svgIcons/JavaScript.js +13 -0
  247. package/svgIcons/MarkdownIcon.d.ts +2 -0
  248. package/svgIcons/MarkdownIcon.js +22 -0
  249. package/svgIcons/MaterialDesignIcon.d.ts +4 -0
  250. package/svgIcons/MaterialDesignIcon.js +18 -0
  251. package/svgIcons/SketchIcon.d.ts +4 -0
  252. package/svgIcons/SketchIcon.js +27 -0
  253. package/svgIcons/TypeScript.d.ts +6 -0
  254. package/svgIcons/TypeScript.js +13 -0
  255. package/svgIcons/W3CIcon.d.ts +4 -0
  256. package/svgIcons/W3CIcon.js +15 -0
  257. package/translations/index.d.ts +3 -0
  258. package/translations/index.js +4 -0
  259. package/translations/translations.json +222 -0
  260. package/useLazyCSS/index.d.ts +1 -0
  261. package/useLazyCSS/index.js +1 -0
  262. package/useLazyCSS/useLazyCSS.d.ts +11 -0
  263. package/useLazyCSS/useLazyCSS.js +70 -0
  264. package/utils/index.d.ts +1 -0
  265. package/utils/index.js +1 -0
  266. package/utils/loadScript.d.ts +1 -0
  267. package/utils/loadScript.js +7 -0
  268. package/webpack/index.d.ts +17 -0
  269. package/webpack/index.js +1 -0
@@ -0,0 +1,3 @@
1
+ export * from "./brandingTheme.js";
2
+ export * from "./BrandingProvider.js";
3
+ export * from "./BrandingCssVarsProvider.js";
@@ -0,0 +1,3 @@
1
+ export * from "./brandingTheme.js";
2
+ export * from "./BrandingProvider.js";
3
+ export * from "./BrandingCssVarsProvider.js";
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export declare function CodeStylingProvider(props: {
3
+ children: React.ReactNode;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ export declare function useCodeStyling(): string;
6
+ export declare function useNoSsrCodeStyling(): string | undefined;
7
+ export declare function useSetCodeStyling(): React.Dispatch<React.SetStateAction<string>>;
@@ -0,0 +1,80 @@
1
+ import * as React from 'react';
2
+ import { CODE_STYLING } from "../constants/index.js";
3
+ import { getCookie } from "../helpers/index.js";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const CodeStylingContext = /*#__PURE__*/React.createContext({
6
+ codeStyling: CODE_STYLING.SYSTEM,
7
+ setCodeStyling: () => {}
8
+ });
9
+ if (process.env.NODE_ENV !== 'production') {
10
+ CodeStylingContext.displayName = 'CodeStyling';
11
+ }
12
+ function useFirstRender() {
13
+ const firstRenderRef = React.useRef(true);
14
+ React.useEffect(() => {
15
+ firstRenderRef.current = false;
16
+ }, []);
17
+ return firstRenderRef.current;
18
+ }
19
+ export function CodeStylingProvider(props) {
20
+ const {
21
+ children
22
+ } = props;
23
+ const [codeStyling, setCodeStyling] = React.useState(CODE_STYLING.SYSTEM);
24
+ const navigatedCodeStyling = React.useMemo(() => {
25
+ const navigatedCodeMatch = typeof window !== 'undefined' ? window.location.hash.match(/\.(js|tsx)$/) : null;
26
+ if (navigatedCodeMatch === null) {
27
+ return undefined;
28
+ }
29
+ if (typeof window !== 'undefined') {
30
+ if (window.location.hash.includes('tailwind-')) {
31
+ return CODE_STYLING.TAILWIND;
32
+ }
33
+ if (window.location.hash.includes('css-')) {
34
+ return CODE_STYLING.CSS;
35
+ }
36
+ if (window.location.hash.includes('system-')) {
37
+ return CODE_STYLING.SYSTEM;
38
+ }
39
+ }
40
+ return undefined;
41
+ }, []);
42
+ const persistedCodeStyling = React.useMemo(() => {
43
+ if (typeof window === 'undefined') {
44
+ return undefined;
45
+ }
46
+ return getCookie('codeStyling');
47
+ }, []);
48
+ const isFirstRender = useFirstRender();
49
+
50
+ // We initialize from navigation or cookies. on subsequent renders the store is the truth
51
+ const noSsrCodeStyling = isFirstRender === true ? navigatedCodeStyling || persistedCodeStyling || codeStyling : codeStyling;
52
+ React.useEffect(() => {
53
+ if (codeStyling !== noSsrCodeStyling) {
54
+ setCodeStyling(noSsrCodeStyling);
55
+ }
56
+ }, [codeStyling, noSsrCodeStyling]);
57
+ React.useEffect(() => {
58
+ document.cookie = `codeStyling=${codeStyling};path=/;max-age=31536000`;
59
+ }, [codeStyling]);
60
+ const contextValue = React.useMemo(() => {
61
+ return {
62
+ codeStyling,
63
+ noSsrCodeStyling,
64
+ setCodeStyling
65
+ };
66
+ }, [codeStyling, noSsrCodeStyling]);
67
+ return /*#__PURE__*/_jsx(CodeStylingContext.Provider, {
68
+ value: contextValue,
69
+ children: children
70
+ });
71
+ }
72
+ export function useCodeStyling() {
73
+ return React.useContext(CodeStylingContext).codeStyling;
74
+ }
75
+ export function useNoSsrCodeStyling() {
76
+ return React.useContext(CodeStylingContext).noSsrCodeStyling;
77
+ }
78
+ export function useSetCodeStyling() {
79
+ return React.useContext(CodeStylingContext).setCodeStyling;
80
+ }
@@ -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,7 @@
1
+ import * as React from 'react';
2
+ export declare function CodeVariantProvider(props: {
3
+ children: React.ReactNode;
4
+ }): import("react/jsx-runtime").JSX.Element;
5
+ export declare function useCodeVariant(): string;
6
+ export declare function useNoSsrCodeVariant(): string | undefined;
7
+ export declare function useSetCodeVariant(): React.Dispatch<React.SetStateAction<string>>;
@@ -0,0 +1,69 @@
1
+ import * as React from 'react';
2
+ import { CODE_VARIANTS } from "../constants/index.js";
3
+ import { getCookie } from "../helpers/index.js";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ const CodeVariantContext = /*#__PURE__*/React.createContext({
6
+ codeVariant: CODE_VARIANTS.TS,
7
+ setCodeVariant: () => {}
8
+ });
9
+ if (process.env.NODE_ENV !== 'production') {
10
+ CodeVariantContext.displayName = 'CodeVariant';
11
+ }
12
+ function useFirstRender() {
13
+ const firstRenderRef = React.useRef(true);
14
+ React.useEffect(() => {
15
+ firstRenderRef.current = false;
16
+ }, []);
17
+ return firstRenderRef.current;
18
+ }
19
+ export function CodeVariantProvider(props) {
20
+ const {
21
+ children
22
+ } = props;
23
+ const [codeVariant, setCodeVariant] = React.useState(CODE_VARIANTS.TS);
24
+ const navigatedCodeVariant = React.useMemo(() => {
25
+ const navigatedCodeVariantMatch = typeof window !== 'undefined' ? window.location.hash.match(/\.(js|tsx)$/) : null;
26
+ if (navigatedCodeVariantMatch === null) {
27
+ return undefined;
28
+ }
29
+ return navigatedCodeVariantMatch[1] === 'tsx' ? CODE_VARIANTS.TS : CODE_VARIANTS.JS;
30
+ }, []);
31
+ const persistedCodeVariant = React.useMemo(() => {
32
+ if (typeof window === 'undefined') {
33
+ return undefined;
34
+ }
35
+ return getCookie('codeVariant');
36
+ }, []);
37
+ const isFirstRender = useFirstRender();
38
+
39
+ // We initialize from navigation or cookies. on subsequent renders the store is the truth
40
+ const noSsrCodeVariant = isFirstRender === true ? navigatedCodeVariant || persistedCodeVariant || codeVariant : codeVariant;
41
+ React.useEffect(() => {
42
+ if (codeVariant !== noSsrCodeVariant) {
43
+ setCodeVariant(noSsrCodeVariant);
44
+ }
45
+ }, [codeVariant, noSsrCodeVariant]);
46
+ React.useEffect(() => {
47
+ document.cookie = `codeVariant=${codeVariant};path=/;max-age=31536000`;
48
+ }, [codeVariant]);
49
+ const contextValue = React.useMemo(() => {
50
+ return {
51
+ codeVariant,
52
+ noSsrCodeVariant,
53
+ setCodeVariant
54
+ };
55
+ }, [codeVariant, noSsrCodeVariant]);
56
+ return /*#__PURE__*/_jsx(CodeVariantContext.Provider, {
57
+ value: contextValue,
58
+ children: children
59
+ });
60
+ }
61
+ export function useCodeVariant() {
62
+ return React.useContext(CodeVariantContext).codeVariant;
63
+ }
64
+ export function useNoSsrCodeVariant() {
65
+ return React.useContext(CodeVariantContext).noSsrCodeVariant;
66
+ }
67
+ export function useSetCodeVariant() {
68
+ return React.useContext(CodeVariantContext).setCodeVariant;
69
+ }
@@ -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 declare const CODE_VARIANTS: {
2
+ JS: string;
3
+ TS: string;
4
+ };
5
+ export declare const CODE_STYLING: {
6
+ SYSTEM: string;
7
+ TAILWIND: string;
8
+ CSS: string;
9
+ };
10
+ export declare 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 * from "./constants.js";
@@ -0,0 +1 @@
1
+ export * from "./constants.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.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ export interface UserLanguageProviderProps {
4
+ children: React.ReactNode;
5
+ translations?: Translations;
6
+ defaultUserLanguage: string;
7
+ }
8
+ export declare function UserLanguageProvider(props: UserLanguageProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ export declare namespace UserLanguageProvider {
10
+ var propTypes: {
11
+ children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
12
+ defaultUserLanguage: PropTypes.Requireable<string>;
13
+ };
14
+ }
15
+ export declare function useUserLanguage(): string;
16
+ export declare function useSetUserLanguage(): React.Dispatch<React.SetStateAction<string>>;
17
+ export interface TranslateOptions {
18
+ ignoreWarning?: boolean;
19
+ }
20
+ export type Translate = (key: string, options?: TranslateOptions) => any;
21
+ export declare function useTranslate(): Translate;
22
+ export type Translations = { [key in string]?: string | Translations };
23
+ export interface RequireContext {
24
+ (req: string): string;
25
+ keys: () => string[];
26
+ }
27
+ export declare function mapTranslations(req: RequireContext): Translations;
package/i18n/i18n.js ADDED
@@ -0,0 +1,111 @@
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);
7
+ function TranslationsProvider({
8
+ translations = {},
9
+ children
10
+ }) {
11
+ const currentTranslations = React.useContext(TranslationsContext);
12
+ const mergedTranslations = React.useMemo(() => deepmerge(currentTranslations, translations), [currentTranslations, translations]);
13
+ return /*#__PURE__*/_jsx(TranslationsContext.Provider, {
14
+ value: mergedTranslations,
15
+ children: children
16
+ });
17
+ }
18
+ function getPath(obj, path) {
19
+ if (!path || typeof path !== 'string') {
20
+ return null;
21
+ }
22
+ const translation = path.split('.').reduce((acc, item) => acc && typeof acc === 'object' && acc[item] || null, obj);
23
+ if (typeof translation === 'object') {
24
+ return null;
25
+ }
26
+ return translation;
27
+ }
28
+ const UserLanguageContext = /*#__PURE__*/React.createContext({
29
+ userLanguage: '',
30
+ setUserLanguage: () => {}
31
+ });
32
+ if (process.env.NODE_ENV !== 'production') {
33
+ UserLanguageContext.displayName = 'UserLanguage';
34
+ }
35
+ export function UserLanguageProvider(props) {
36
+ const {
37
+ children,
38
+ translations,
39
+ defaultUserLanguage
40
+ } = props;
41
+ const [userLanguage, setUserLanguage] = React.useState(defaultUserLanguage);
42
+ const contextValue = React.useMemo(() => {
43
+ return {
44
+ userLanguage,
45
+ setUserLanguage
46
+ };
47
+ }, [userLanguage]);
48
+ return /*#__PURE__*/_jsx(TranslationsProvider, {
49
+ translations: translations,
50
+ children: /*#__PURE__*/_jsx(UserLanguageContext.Provider, {
51
+ value: contextValue,
52
+ children: children
53
+ })
54
+ });
55
+ }
56
+ process.env.NODE_ENV !== "production" ? UserLanguageProvider.propTypes = {
57
+ children: PropTypes.node.isRequired,
58
+ defaultUserLanguage: PropTypes.string
59
+ } : void 0;
60
+ export function useUserLanguage() {
61
+ return React.useContext(UserLanguageContext).userLanguage;
62
+ }
63
+ export function useSetUserLanguage() {
64
+ return React.useContext(UserLanguageContext).setUserLanguage;
65
+ }
66
+ const warnedOnce = {};
67
+
68
+ // TODO, migrate to use warnOnce() helper
69
+ const warn = (userLanguage, key, ignoreWarning) => {
70
+ const fullKey = `${userLanguage}:${key}`;
71
+ // No warnings in CI env
72
+ if (!ignoreWarning && !warnedOnce[fullKey] && typeof window !== 'undefined') {
73
+ console.warn(`Missing translation for ${fullKey}`);
74
+ warnedOnce[fullKey] = true;
75
+ }
76
+ };
77
+ export function useTranslate() {
78
+ const userLanguage = useUserLanguage();
79
+ const translations = React.useContext(TranslationsContext);
80
+ return React.useMemo(() => function translate(key, options = {}) {
81
+ const {
82
+ ignoreWarning = false
83
+ } = options;
84
+ const wordings = translations[userLanguage];
85
+ if (!wordings) {
86
+ console.error(`Missing language: ${userLanguage}.`);
87
+ return '…';
88
+ }
89
+ const translation = getPath(wordings, key);
90
+ if (!translation) {
91
+ if (process.env.NODE_ENV !== 'production') {
92
+ warn(userLanguage, key, ignoreWarning);
93
+ }
94
+ const enTranslation = getPath(translations.en, key);
95
+ return enTranslation ?? null;
96
+ }
97
+ return translation;
98
+ }, [userLanguage, translations]);
99
+ }
100
+ export function mapTranslations(req) {
101
+ const result = {};
102
+ req.keys().forEach(filename => {
103
+ const match = filename.match(/-([a-z]{2}).json$/);
104
+ if (match) {
105
+ result[match[1]] = req(filename);
106
+ } else {
107
+ result.en = req(filename);
108
+ }
109
+ });
110
+ return result;
111
+ }
@@ -0,0 +1 @@
1
+ export * from "./i18n.js";
package/i18n/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./i18n.js";
@@ -0,0 +1 @@
1
+ export { default } from "./mapApiPageTranslations.js";
@@ -0,0 +1 @@
1
+ export { default } from "./mapApiPageTranslations.js";