@mui/docs 5.15.11 → 5.15.12

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.
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { Translations } from '../i18n';
3
+ export interface DocsConfig {
4
+ LANGUAGES: string[];
5
+ LANGUAGES_SSR: string[];
6
+ LANGUAGES_IN_PROGRESS: string[];
7
+ LANGUAGES_IGNORE_PAGES: (pathname: string) => boolean;
8
+ }
9
+ export interface DocsProviderProps {
10
+ config: DocsConfig;
11
+ defaultUserLanguage: string;
12
+ children?: React.ReactNode;
13
+ translations?: Translations;
14
+ }
15
+ export declare function DocsProvider({ config, defaultUserLanguage, translations, children, }: DocsProviderProps): React.JSX.Element;
16
+ export declare function useDocsConfig(): DocsConfig;
@@ -5,12 +5,14 @@ const DocsConfigContext = /*#__PURE__*/React.createContext(null);
5
5
  export function DocsProvider({
6
6
  config,
7
7
  defaultUserLanguage,
8
+ translations,
8
9
  children
9
10
  }) {
10
11
  return /*#__PURE__*/_jsx(DocsConfigContext.Provider, {
11
12
  value: config,
12
13
  children: /*#__PURE__*/_jsx(UserLanguageProvider, {
13
14
  defaultUserLanguage: defaultUserLanguage,
15
+ translations: translations,
14
16
  children: children
15
17
  })
16
18
  });
@@ -0,0 +1 @@
1
+ export * from './DocsProvider';
package/Link/Link.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+ import { LinkProps as NextLinkProps } from 'next/link';
3
+ import { LinkProps as MuiLinkProps } from '@mui/material/Link';
4
+ interface NextLinkComposedProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>, Omit<NextLinkProps, 'href' | 'as' | 'passHref' | 'onMouseEnter' | 'onClick' | 'onTouchStart'> {
5
+ to: NextLinkProps['href'];
6
+ linkAs?: NextLinkProps['as'];
7
+ }
8
+ export type LinkProps = {
9
+ activeClassName?: string;
10
+ as?: NextLinkProps['as'];
11
+ href: NextLinkProps['href'];
12
+ linkAs?: NextLinkProps['as'];
13
+ noLinkStyle?: boolean;
14
+ } & Omit<NextLinkComposedProps, 'to' | 'linkAs' | 'href'> & Omit<MuiLinkProps, 'href'>;
15
+ export declare const Link: React.ForwardRefExoticComponent<Omit<LinkProps, "ref"> & React.RefAttributes<HTMLAnchorElement>>;
16
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Link';
package/i18n/i18n.d.ts ADDED
@@ -0,0 +1,28 @@
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): React.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 declare function useTranslate(): (key: string, options?: TranslateOptions) => any;
21
+ export type Translations = {
22
+ [key in string]?: string | Translations;
23
+ };
24
+ export interface RequireContext {
25
+ (req: string): string;
26
+ keys: () => string[];
27
+ }
28
+ export declare function mapTranslations(req: RequireContext): Translations;
package/i18n/i18n.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { deepmerge } from '@mui/utils';
4
+ import defaultTranslations from '../translations';
3
5
  import { jsx as _jsx } from "react/jsx-runtime";
4
- function mapTranslations(req) {
5
- const translations = {};
6
- req.keys().forEach(filename => {
7
- const match = filename.match(/-([a-z]{2}).json$/);
8
- if (match) {
9
- translations[match[1]] = req(filename);
10
- } else {
11
- translations.en = req(filename);
12
- }
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
13
16
  });
14
- return translations;
15
17
  }
16
- const req = require.context('docs/translations', false, /translations.*\.json$/);
17
- const translations = mapTranslations(req);
18
18
  function getPath(obj, path) {
19
19
  if (!path || typeof path !== 'string') {
20
20
  return null;
@@ -31,6 +31,7 @@ if (process.env.NODE_ENV !== 'production') {
31
31
  export function UserLanguageProvider(props) {
32
32
  const {
33
33
  children,
34
+ translations,
34
35
  defaultUserLanguage
35
36
  } = props;
36
37
  const [userLanguage, setUserLanguage] = React.useState(defaultUserLanguage);
@@ -40,9 +41,12 @@ export function UserLanguageProvider(props) {
40
41
  setUserLanguage
41
42
  };
42
43
  }, [userLanguage]);
43
- return /*#__PURE__*/_jsx(UserLanguageContext.Provider, {
44
- value: contextValue,
45
- children: children
44
+ return /*#__PURE__*/_jsx(TranslationsProvider, {
45
+ translations: translations,
46
+ children: /*#__PURE__*/_jsx(UserLanguageContext.Provider, {
47
+ value: contextValue,
48
+ children: children
49
+ })
46
50
  });
47
51
  }
48
52
  process.env.NODE_ENV !== "production" ? UserLanguageProvider.propTypes = {
@@ -58,6 +62,7 @@ export function useSetUserLanguage() {
58
62
  const warnedOnce = {};
59
63
  export function useTranslate() {
60
64
  const userLanguage = useUserLanguage();
65
+ const translations = React.useContext(TranslationsContext);
61
66
  return React.useMemo(() => function translate(key, options = {}) {
62
67
  const {
63
68
  ignoreWarning = false
@@ -78,5 +83,17 @@ export function useTranslate() {
78
83
  return getPath(translations.en, key);
79
84
  }
80
85
  return translation;
81
- }, [userLanguage]);
86
+ }, [userLanguage, translations]);
87
+ }
88
+ export function mapTranslations(req) {
89
+ const result = {};
90
+ req.keys().forEach(filename => {
91
+ const match = filename.match(/-([a-z]{2}).json$/);
92
+ if (match) {
93
+ result[match[1]] = req(filename);
94
+ } else {
95
+ result.en = req(filename);
96
+ }
97
+ });
98
+ return result;
82
99
  }
@@ -0,0 +1 @@
1
+ export * from './i18n';
package/i18n/package.json CHANGED
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/i18n/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -5,11 +5,13 @@ var DocsConfigContext = /*#__PURE__*/React.createContext(null);
5
5
  export function DocsProvider(_ref) {
6
6
  var config = _ref.config,
7
7
  defaultUserLanguage = _ref.defaultUserLanguage,
8
+ translations = _ref.translations,
8
9
  children = _ref.children;
9
10
  return /*#__PURE__*/_jsx(DocsConfigContext.Provider, {
10
11
  value: config,
11
12
  children: /*#__PURE__*/_jsx(UserLanguageProvider, {
12
13
  defaultUserLanguage: defaultUserLanguage,
14
+ translations: translations,
13
15
  children: children
14
16
  })
15
17
  });
@@ -1,20 +1,22 @@
1
1
  import * as React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { deepmerge } from '@mui/utils';
4
+ import defaultTranslations from '../translations';
3
5
  import { jsx as _jsx } from "react/jsx-runtime";
4
- function mapTranslations(req) {
5
- var translations = {};
6
- req.keys().forEach(function (filename) {
7
- var match = filename.match(/-([a-z]{2}).json$/);
8
- if (match) {
9
- translations[match[1]] = req(filename);
10
- } else {
11
- translations.en = req(filename);
12
- }
6
+ var TranslationsContext = /*#__PURE__*/React.createContext(defaultTranslations);
7
+ function TranslationsProvider(_ref) {
8
+ var _ref$translations = _ref.translations,
9
+ translations = _ref$translations === void 0 ? {} : _ref$translations,
10
+ children = _ref.children;
11
+ var currentTranslations = React.useContext(TranslationsContext);
12
+ var mergedTranslations = React.useMemo(function () {
13
+ return deepmerge(currentTranslations, translations);
14
+ }, [currentTranslations, translations]);
15
+ return /*#__PURE__*/_jsx(TranslationsContext.Provider, {
16
+ value: mergedTranslations,
17
+ children: children
13
18
  });
14
- return translations;
15
19
  }
16
- var req = require.context('docs/translations', false, /translations.*\.json$/);
17
- var translations = mapTranslations(req);
18
20
  function getPath(obj, path) {
19
21
  if (!path || typeof path !== 'string') {
20
22
  return null;
@@ -32,6 +34,7 @@ if (process.env.NODE_ENV !== 'production') {
32
34
  }
33
35
  export function UserLanguageProvider(props) {
34
36
  var children = props.children,
37
+ translations = props.translations,
35
38
  defaultUserLanguage = props.defaultUserLanguage;
36
39
  var _React$useState = React.useState(defaultUserLanguage),
37
40
  userLanguage = _React$useState[0],
@@ -42,9 +45,12 @@ export function UserLanguageProvider(props) {
42
45
  setUserLanguage: setUserLanguage
43
46
  };
44
47
  }, [userLanguage]);
45
- return /*#__PURE__*/_jsx(UserLanguageContext.Provider, {
46
- value: contextValue,
47
- children: children
48
+ return /*#__PURE__*/_jsx(TranslationsProvider, {
49
+ translations: translations,
50
+ children: /*#__PURE__*/_jsx(UserLanguageContext.Provider, {
51
+ value: contextValue,
52
+ children: children
53
+ })
48
54
  });
49
55
  }
50
56
  process.env.NODE_ENV !== "production" ? UserLanguageProvider.propTypes = {
@@ -60,6 +66,7 @@ export function useSetUserLanguage() {
60
66
  var warnedOnce = {};
61
67
  export function useTranslate() {
62
68
  var userLanguage = useUserLanguage();
69
+ var translations = React.useContext(TranslationsContext);
63
70
  return React.useMemo(function () {
64
71
  return function translate(key) {
65
72
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -82,5 +89,17 @@ export function useTranslate() {
82
89
  }
83
90
  return translation;
84
91
  };
85
- }, [userLanguage]);
92
+ }, [userLanguage, translations]);
93
+ }
94
+ export function mapTranslations(req) {
95
+ var result = {};
96
+ req.keys().forEach(function (filename) {
97
+ var match = filename.match(/-([a-z]{2}).json$/);
98
+ if (match) {
99
+ result[match[1]] = req(filename);
100
+ } else {
101
+ result.en = req(filename);
102
+ }
103
+ });
104
+ return result;
86
105
  }
@@ -0,0 +1,4 @@
1
+ import en from './translations.json';
2
+ export default {
3
+ en: en
4
+ };
@@ -14,12 +14,14 @@ const DocsConfigContext = /*#__PURE__*/React.createContext(null);
14
14
  function DocsProvider({
15
15
  config,
16
16
  defaultUserLanguage,
17
+ translations,
17
18
  children
18
19
  }) {
19
20
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(DocsConfigContext.Provider, {
20
21
  value: config,
21
22
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_i18n.UserLanguageProvider, {
22
23
  defaultUserLanguage: defaultUserLanguage,
24
+ translations: translations,
23
25
  children: children
24
26
  })
25
27
  });
package/node/i18n/i18n.js CHANGED
@@ -5,28 +5,29 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.UserLanguageProvider = UserLanguageProvider;
8
+ exports.mapTranslations = mapTranslations;
8
9
  exports.useSetUserLanguage = useSetUserLanguage;
9
10
  exports.useTranslate = useTranslate;
10
11
  exports.useUserLanguage = useUserLanguage;
11
12
  var React = _interopRequireWildcard(require("react"));
12
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
14
+ var _utils = require("@mui/utils");
15
+ var _translations = _interopRequireDefault(require("../translations"));
13
16
  var _jsxRuntime = require("react/jsx-runtime");
14
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function mapTranslations(req) {
17
- const translations = {};
18
- req.keys().forEach(filename => {
19
- const match = filename.match(/-([a-z]{2}).json$/);
20
- if (match) {
21
- translations[match[1]] = req(filename);
22
- } else {
23
- translations.en = req(filename);
24
- }
19
+ const TranslationsContext = /*#__PURE__*/React.createContext(_translations.default);
20
+ function TranslationsProvider({
21
+ translations = {},
22
+ children
23
+ }) {
24
+ const currentTranslations = React.useContext(TranslationsContext);
25
+ const mergedTranslations = React.useMemo(() => (0, _utils.deepmerge)(currentTranslations, translations), [currentTranslations, translations]);
26
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TranslationsContext.Provider, {
27
+ value: mergedTranslations,
28
+ children: children
25
29
  });
26
- return translations;
27
30
  }
28
- const req = require.context('docs/translations', false, /translations.*\.json$/);
29
- const translations = mapTranslations(req);
30
31
  function getPath(obj, path) {
31
32
  if (!path || typeof path !== 'string') {
32
33
  return null;
@@ -43,6 +44,7 @@ if (process.env.NODE_ENV !== 'production') {
43
44
  function UserLanguageProvider(props) {
44
45
  const {
45
46
  children,
47
+ translations,
46
48
  defaultUserLanguage
47
49
  } = props;
48
50
  const [userLanguage, setUserLanguage] = React.useState(defaultUserLanguage);
@@ -52,9 +54,12 @@ function UserLanguageProvider(props) {
52
54
  setUserLanguage
53
55
  };
54
56
  }, [userLanguage]);
55
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(UserLanguageContext.Provider, {
56
- value: contextValue,
57
- children: children
57
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TranslationsProvider, {
58
+ translations: translations,
59
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(UserLanguageContext.Provider, {
60
+ value: contextValue,
61
+ children: children
62
+ })
58
63
  });
59
64
  }
60
65
  process.env.NODE_ENV !== "production" ? UserLanguageProvider.propTypes = {
@@ -70,6 +75,7 @@ function useSetUserLanguage() {
70
75
  const warnedOnce = {};
71
76
  function useTranslate() {
72
77
  const userLanguage = useUserLanguage();
78
+ const translations = React.useContext(TranslationsContext);
73
79
  return React.useMemo(() => function translate(key, options = {}) {
74
80
  const {
75
81
  ignoreWarning = false
@@ -90,5 +96,17 @@ function useTranslate() {
90
96
  return getPath(translations.en, key);
91
97
  }
92
98
  return translation;
93
- }, [userLanguage]);
99
+ }, [userLanguage, translations]);
100
+ }
101
+ function mapTranslations(req) {
102
+ const result = {};
103
+ req.keys().forEach(filename => {
104
+ const match = filename.match(/-([a-z]{2}).json$/);
105
+ if (match) {
106
+ result[match[1]] = req(filename);
107
+ } else {
108
+ result.en = req(filename);
109
+ }
110
+ });
111
+ return result;
94
112
  }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _translations = _interopRequireDefault(require("./translations.json"));
9
+ var _default = exports.default = {
10
+ en: _translations.default
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/docs",
3
- "version": "5.15.11",
3
+ "version": "5.15.12",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "MUI Docs - Documentation building blocks.",
@@ -27,14 +27,14 @@
27
27
  "clsx": "^2.1.0",
28
28
  "nprogress": "^0.2.0",
29
29
  "prop-types": "^15.8.1",
30
- "@mui/base": "5.0.0-beta.37",
31
- "@mui/utils": "^5.15.11"
30
+ "@mui/base": "5.0.0-beta.38",
31
+ "@mui/utils": "^5.15.12"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@types/react": "^17.0.0 || ^18.0.0",
35
35
  "next": "^13.5.1",
36
36
  "react": "^17.0.0 || ^18.0.0",
37
- "@mui/material": "^5.15.11"
37
+ "@mui/material": "^5.15.12"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@types/react": {
@@ -48,6 +48,5 @@
48
48
  "engines": {
49
49
  "node": ">=12.0.0"
50
50
  },
51
- "module": "./index.js",
52
- "types": "./index.d.ts"
51
+ "module": "./index.js"
53
52
  }
@@ -0,0 +1,3 @@
1
+ import type { Translations } from '../i18n';
2
+ declare const _default: Record<string, Translations>;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import en from './translations.json';
2
+ export default {
3
+ en
4
+ };
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/translations/index.js",
5
+ "types": "./index.d.ts"
6
+ }