@mui/docs 6.0.0-beta.4 → 6.0.0-beta.4-dev.20240805-092432-9f940a61d6

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.
@@ -2,5 +2,6 @@ import * as React from 'react';
2
2
  export interface MarkdownElementProps {
3
3
  className?: string;
4
4
  renderedMarkdown?: string;
5
+ children?: React.ReactNode;
5
6
  }
6
7
  export declare const MarkdownElement: React.ForwardRefExoticComponent<MarkdownElementProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- export interface SectionTitleProps {
2
+ export interface SectionTitleProps<Hash extends string = string> {
3
3
  title: string;
4
- hash: string;
4
+ hash: Hash;
5
5
  level?: 'h2' | 'h3' | 'h4';
6
6
  }
7
7
  export declare function SectionTitle(props: SectionTitleProps): React.JSX.Element;
package/i18n/i18n.d.ts CHANGED
@@ -17,7 +17,8 @@ export declare function useSetUserLanguage(): React.Dispatch<React.SetStateActio
17
17
  export interface TranslateOptions {
18
18
  ignoreWarning?: boolean;
19
19
  }
20
- export declare function useTranslate(): (key: string, options?: TranslateOptions) => any;
20
+ export type Translate = (key: string, options?: TranslateOptions) => any;
21
+ export declare function useTranslate(): Translate;
21
22
  export type Translations = {
22
23
  [key in string]?: string | Translations;
23
24
  };
package/i18n/i18n.js CHANGED
@@ -19,7 +19,11 @@ function getPath(obj, path) {
19
19
  if (!path || typeof path !== 'string') {
20
20
  return null;
21
21
  }
22
- return path.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
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;
23
27
  }
24
28
  const UserLanguageContext = /*#__PURE__*/React.createContext({
25
29
  userLanguage: '',
@@ -85,7 +89,8 @@ export function useTranslate() {
85
89
  const translation = getPath(wordings, key);
86
90
  if (!translation) {
87
91
  warn(userLanguage, key, ignoreWarning);
88
- return getPath(translations.en, key);
92
+ const enTranslation = getPath(translations.en, key);
93
+ return enTranslation ?? null;
89
94
  }
90
95
  return translation;
91
96
  }, [userLanguage, translations]);
package/node/i18n/i18n.js CHANGED
@@ -32,7 +32,11 @@ function getPath(obj, path) {
32
32
  if (!path || typeof path !== 'string') {
33
33
  return null;
34
34
  }
35
- return path.split('.').reduce((acc, item) => acc && acc[item] ? acc[item] : null, obj);
35
+ const translation = path.split('.').reduce((acc, item) => acc && typeof acc === 'object' && acc[item] || null, obj);
36
+ if (typeof translation === 'object') {
37
+ return null;
38
+ }
39
+ return translation;
36
40
  }
37
41
  const UserLanguageContext = /*#__PURE__*/React.createContext({
38
42
  userLanguage: '',
@@ -98,7 +102,8 @@ function useTranslate() {
98
102
  const translation = getPath(wordings, key);
99
103
  if (!translation) {
100
104
  warn(userLanguage, key, ignoreWarning);
101
- return getPath(translations.en, key);
105
+ const enTranslation = getPath(translations.en, key);
106
+ return enTranslation != null ? enTranslation : null;
102
107
  }
103
108
  return translation;
104
109
  }, [userLanguage, translations]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/docs",
3
- "version": "6.0.0-beta.4",
3
+ "version": "6.0.0-beta.4-dev.20240805-092432-9f940a61d6",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "MUI Docs - Documentation building blocks.",