@mui/docs 6.0.0-alpha.1 → 6.0.0-alpha.10
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.
- package/CHANGELOG.md +462 -4
- package/CodeCopy/CodeCopy.d.ts +20 -0
- package/CodeCopy/CodeCopy.js +172 -0
- package/CodeCopy/CodeCopyButton.d.ts +5 -0
- package/CodeCopy/CodeCopyButton.js +41 -0
- package/CodeCopy/index.d.ts +3 -0
- package/CodeCopy/index.js +3 -0
- package/CodeCopy/package.json +6 -0
- package/CodeCopy/useClipboardCopy.d.ts +4 -0
- package/CodeCopy/useClipboardCopy.js +21 -0
- package/ComponentLinkHeader/ComponentLinkHeader.d.ts +9 -0
- package/ComponentLinkHeader/ComponentLinkHeader.js +179 -0
- package/ComponentLinkHeader/index.d.ts +2 -0
- package/ComponentLinkHeader/index.js +2 -0
- package/ComponentLinkHeader/package.json +6 -0
- package/HighlightedCode/HighlightedCode.d.ts +14 -0
- package/HighlightedCode/HighlightedCode.js +68 -0
- package/HighlightedCode/index.d.ts +1 -0
- package/HighlightedCode/index.js +1 -0
- package/HighlightedCode/package.json +6 -0
- package/InfoCard/InfoCard.d.ts +0 -1
- package/InfoCard/InfoCard.js +45 -44
- package/Link/Link.js +40 -38
- package/MarkdownElement/MarkdownElement.d.ts +6 -0
- package/MarkdownElement/MarkdownElement.js +825 -0
- package/MarkdownElement/index.d.ts +1 -0
- package/MarkdownElement/index.js +1 -0
- package/MarkdownElement/package.json +6 -0
- package/NProgressBar/NProgressBar.js +6 -7
- package/SectionTitle/SectionTitle.d.ts +7 -0
- package/SectionTitle/SectionTitle.js +30 -0
- package/SectionTitle/index.d.ts +1 -0
- package/SectionTitle/index.js +1 -0
- package/SectionTitle/package.json +6 -0
- package/branding/brandingTheme.js +569 -369
- package/node/CodeCopy/CodeCopy.js +188 -0
- package/node/CodeCopy/CodeCopyButton.js +50 -0
- package/node/CodeCopy/index.js +40 -0
- package/node/CodeCopy/useClipboardCopy.js +30 -0
- package/node/ComponentLinkHeader/ComponentLinkHeader.js +189 -0
- package/node/ComponentLinkHeader/index.js +24 -0
- package/node/HighlightedCode/HighlightedCode.js +77 -0
- package/node/HighlightedCode/index.js +16 -0
- package/node/InfoCard/InfoCard.js +45 -44
- package/node/Link/Link.js +43 -40
- package/node/MarkdownElement/MarkdownElement.js +837 -0
- package/node/MarkdownElement/index.js +16 -0
- package/node/NProgressBar/NProgressBar.js +6 -7
- package/node/SectionTitle/SectionTitle.js +38 -0
- package/node/SectionTitle/index.js +16 -0
- package/node/branding/brandingTheme.js +569 -369
- package/node/svgIcons/AdobeXDIcon.js +22 -0
- package/node/svgIcons/BundleSizeIcon.js +22 -0
- package/node/svgIcons/FigmaIcon.js +31 -0
- package/node/svgIcons/FileDownload.js +3 -3
- package/node/svgIcons/JavaScript.js +3 -3
- package/node/svgIcons/MaterialDesignIcon.js +27 -0
- package/node/svgIcons/SketchIcon.js +36 -0
- package/node/svgIcons/TypeScript.js +3 -3
- package/node/svgIcons/W3CIcon.js +24 -0
- package/node/translations/translations.json +4 -2
- package/package.json +6 -4
- package/svgIcons/AdobeXDIcon.d.ts +4 -0
- package/svgIcons/AdobeXDIcon.js +14 -0
- package/svgIcons/BundleSizeIcon.d.ts +4 -0
- package/svgIcons/BundleSizeIcon.js +14 -0
- package/svgIcons/FigmaIcon.d.ts +4 -0
- package/svgIcons/FigmaIcon.js +23 -0
- package/svgIcons/FileDownload.d.ts +7 -0
- package/svgIcons/FileDownload.js +3 -3
- package/svgIcons/JavaScript.d.ts +7 -0
- package/svgIcons/JavaScript.js +3 -3
- package/svgIcons/MaterialDesignIcon.d.ts +4 -0
- package/svgIcons/MaterialDesignIcon.js +19 -0
- package/svgIcons/SketchIcon.d.ts +4 -0
- package/svgIcons/SketchIcon.js +28 -0
- package/svgIcons/TypeScript.d.ts +7 -0
- package/svgIcons/TypeScript.js +3 -3
- package/svgIcons/W3CIcon.d.ts +4 -0
- package/svgIcons/W3CIcon.js +16 -0
- package/translations/translations.json +4 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/legacy/DocsProvider/DocsProvider.js +0 -25
- package/legacy/DocsProvider/index.js +0 -1
- package/legacy/InfoCard/InfoCard.js +0 -86
- package/legacy/InfoCard/index.js +0 -1
- package/legacy/Link/Link.js +0 -101
- package/legacy/Link/index.js +0 -1
- package/legacy/NProgressBar/NProgressBar.js +0 -80
- package/legacy/NProgressBar/index.js +0 -1
- package/legacy/branding/BrandingProvider.js +0 -17
- package/legacy/branding/brandingTheme.js +0 -1168
- package/legacy/branding/index.js +0 -2
- package/legacy/i18n/i18n.js +0 -105
- package/legacy/i18n/index.js +0 -1
- package/legacy/svgIcons/FileDownload.js +0 -14
- package/legacy/svgIcons/JavaScript.js +0 -14
- package/legacy/svgIcons/TypeScript.js +0 -14
- package/legacy/translations/index.js +0 -4
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
var _InitCodeCopy;
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import clipboardCopy from 'clipboard-copy';
|
|
5
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
const CodeBlockContext = /*#__PURE__*/React.createContext({
|
|
7
|
+
current: null
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How to use: spread the handlers to the .MuiCode-root
|
|
12
|
+
*
|
|
13
|
+
* The html structure should be:
|
|
14
|
+
* <div className="MuiCode-root">
|
|
15
|
+
* <pre>...</pre>
|
|
16
|
+
* <button className="MuiCode-copy">...</button>
|
|
17
|
+
* </div>
|
|
18
|
+
*/
|
|
19
|
+
export function useCodeCopy() {
|
|
20
|
+
const rootNode = React.useContext(CodeBlockContext);
|
|
21
|
+
return {
|
|
22
|
+
onMouseEnter: event => {
|
|
23
|
+
rootNode.current = event.currentTarget;
|
|
24
|
+
},
|
|
25
|
+
onMouseLeave: event => {
|
|
26
|
+
if (rootNode.current === event.currentTarget) {
|
|
27
|
+
rootNode.current.querySelector('.MuiCode-copy')?.blur();
|
|
28
|
+
rootNode.current = null;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
onFocus: event => {
|
|
32
|
+
rootNode.current = event.currentTarget;
|
|
33
|
+
},
|
|
34
|
+
onBlur: event => {
|
|
35
|
+
if (rootNode.current === event.currentTarget) {
|
|
36
|
+
rootNode.current = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function InitCodeCopy() {
|
|
42
|
+
const rootNode = React.useContext(CodeBlockContext);
|
|
43
|
+
const router = useRouter();
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
let key = 'Ctrl + ';
|
|
46
|
+
if (typeof window !== 'undefined') {
|
|
47
|
+
const macOS = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
48
|
+
if (macOS) {
|
|
49
|
+
key = '⌘';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const codeRoots = document.getElementsByClassName('MuiCode-root');
|
|
53
|
+
if (codeRoots !== null) {
|
|
54
|
+
const listeners = [];
|
|
55
|
+
Array.from(codeRoots).forEach(elm => {
|
|
56
|
+
const handleMouseEnter = () => {
|
|
57
|
+
rootNode.current = elm;
|
|
58
|
+
};
|
|
59
|
+
elm.addEventListener('mouseenter', handleMouseEnter);
|
|
60
|
+
listeners.push(() => elm.removeEventListener('mouseenter', handleMouseEnter));
|
|
61
|
+
const handleMouseLeave = () => {
|
|
62
|
+
if (rootNode.current === elm) {
|
|
63
|
+
rootNode.current.querySelector('.MuiCode-copy')?.blur();
|
|
64
|
+
rootNode.current = null;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
elm.addEventListener('mouseleave', handleMouseLeave);
|
|
68
|
+
listeners.push(() => elm.removeEventListener('mouseleave', handleMouseLeave));
|
|
69
|
+
const handleFocusin = () => {
|
|
70
|
+
// use `focusin` because it bubbles from the copy button
|
|
71
|
+
rootNode.current = elm;
|
|
72
|
+
};
|
|
73
|
+
elm.addEventListener('focusin', handleFocusin);
|
|
74
|
+
listeners.push(() => elm.removeEventListener('focusin', handleFocusin));
|
|
75
|
+
const handleFocusout = () => {
|
|
76
|
+
// use `focusout` because it bubbles from the copy button
|
|
77
|
+
if (rootNode.current === elm) {
|
|
78
|
+
rootNode.current = null;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
elm.addEventListener('focusout', handleFocusout);
|
|
82
|
+
listeners.push(() => elm.removeEventListener('focusout', handleFocusout));
|
|
83
|
+
async function handleClick(event) {
|
|
84
|
+
const trigger = event.currentTarget;
|
|
85
|
+
const pre = event.currentTarget?.previousElementSibling;
|
|
86
|
+
const textNode = trigger.childNodes[0];
|
|
87
|
+
textNode.nodeValue = textNode.textContent?.replace('Copy', 'Copied') || null;
|
|
88
|
+
trigger.dataset.copied = 'true';
|
|
89
|
+
setTimeout(() => {
|
|
90
|
+
if (trigger) {
|
|
91
|
+
textNode.nodeValue = textNode.textContent?.replace('Copied', 'Copy') || null;
|
|
92
|
+
delete trigger.dataset.copied;
|
|
93
|
+
}
|
|
94
|
+
}, 2000);
|
|
95
|
+
try {
|
|
96
|
+
if (pre.textContent) {
|
|
97
|
+
await clipboardCopy(pre.textContent);
|
|
98
|
+
}
|
|
99
|
+
// eslint-disable-next-line no-empty
|
|
100
|
+
} catch (error) {}
|
|
101
|
+
}
|
|
102
|
+
const btn = elm.querySelector('.MuiCode-copy');
|
|
103
|
+
if (btn) {
|
|
104
|
+
const keyNode = btn.querySelector('.MuiCode-copyKeypress')?.childNodes[1];
|
|
105
|
+
if (!keyNode) {
|
|
106
|
+
// skip the logic if the btn is not generated from the markdown.
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
keyNode.textContent = keyNode?.textContent?.replace('$key', key) || null;
|
|
110
|
+
btn.addEventListener('click', handleClick);
|
|
111
|
+
listeners.push(() => btn.removeEventListener('click', handleClick));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return () => {
|
|
115
|
+
listeners.forEach(removeEventListener => {
|
|
116
|
+
removeEventListener();
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
}, [rootNode, router.pathname]);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
function hasNativeSelection(element) {
|
|
125
|
+
if (window.getSelection()?.toString()) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// window.getSelection() returns an empty string in Firefox for selections inside a form element.
|
|
130
|
+
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=85686.
|
|
131
|
+
// Instead, we can use element.selectionStart that is only defined on form elements.
|
|
132
|
+
if (element && (element.selectionEnd || 0) - (element.selectionStart || 0) > 0) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Place <CodeCopyProvider> at the page level. It will check the keydown event and try to initiate copy click if rootNode exist.
|
|
139
|
+
* Any code block inside the tree can set the rootNode when mouse enter to leverage keyboard copy.
|
|
140
|
+
*/
|
|
141
|
+
export function CodeCopyProvider({
|
|
142
|
+
children
|
|
143
|
+
}) {
|
|
144
|
+
const rootNode = React.useRef(null);
|
|
145
|
+
React.useEffect(() => {
|
|
146
|
+
document.addEventListener('keydown', event => {
|
|
147
|
+
if (!rootNode.current) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Skip if user is highlighting a text.
|
|
152
|
+
if (hasNativeSelection(event.target)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Skip if it's not a copy keyboard event
|
|
157
|
+
if (!((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'c' && !event.shiftKey && !event.altKey)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const copyBtn = rootNode.current.querySelector('.MuiCode-copy');
|
|
161
|
+
const initialEventAction = copyBtn.getAttribute('data-ga-event-action');
|
|
162
|
+
// update the 'data-ga-event-action' on the button to track keyboard interaction
|
|
163
|
+
copyBtn.dataset.gaEventAction = initialEventAction?.replace('click', 'keyboard') || 'copy-keyboard';
|
|
164
|
+
copyBtn.click(); // let the GA setup in GoogleAnalytics.js do the job
|
|
165
|
+
copyBtn.dataset.gaEventAction = initialEventAction; // reset the 'data-ga-event-action' back to initial
|
|
166
|
+
});
|
|
167
|
+
}, []);
|
|
168
|
+
return /*#__PURE__*/_jsxs(CodeBlockContext.Provider, {
|
|
169
|
+
value: rootNode,
|
|
170
|
+
children: [_InitCodeCopy || (_InitCodeCopy = /*#__PURE__*/_jsx(InitCodeCopy, {})), children]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var _span, _span2;
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import useClipboardCopy from './useClipboardCopy';
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export function CodeCopyButton(props) {
|
|
6
|
+
const {
|
|
7
|
+
code,
|
|
8
|
+
...other
|
|
9
|
+
} = props;
|
|
10
|
+
const {
|
|
11
|
+
copy,
|
|
12
|
+
isCopied
|
|
13
|
+
} = useClipboardCopy();
|
|
14
|
+
// This component is designed to be wrapped in NoSsr
|
|
15
|
+
const macOS = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
16
|
+
const key = macOS ? '⌘' : 'Ctrl + ';
|
|
17
|
+
return /*#__PURE__*/_jsx("div", {
|
|
18
|
+
className: "MuiCode-copy-container",
|
|
19
|
+
children: /*#__PURE__*/_jsxs("button", {
|
|
20
|
+
...other,
|
|
21
|
+
"aria-label": "Copy the code",
|
|
22
|
+
type: "button",
|
|
23
|
+
className: "MuiCode-copy",
|
|
24
|
+
onClick: async () => {
|
|
25
|
+
// event.stopPropagation();
|
|
26
|
+
await copy(code);
|
|
27
|
+
},
|
|
28
|
+
children: [isCopied ? 'Copied' : 'Copy', /*#__PURE__*/_jsxs("span", {
|
|
29
|
+
className: "MuiCode-copyKeypress",
|
|
30
|
+
style: {
|
|
31
|
+
opacity: isCopied ? 0 : 1
|
|
32
|
+
},
|
|
33
|
+
children: [_span || (_span = /*#__PURE__*/_jsx("span", {
|
|
34
|
+
children: "(or"
|
|
35
|
+
})), " ", key, "C", _span2 || (_span2 = /*#__PURE__*/_jsx("span", {
|
|
36
|
+
children: ")"
|
|
37
|
+
}))]
|
|
38
|
+
})]
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import clipboardCopy from 'clipboard-copy';
|
|
3
|
+
export default function useClipboardCopy() {
|
|
4
|
+
const [isCopied, setIsCopied] = React.useState(false);
|
|
5
|
+
const timeout = React.useRef();
|
|
6
|
+
React.useEffect(() => () => {
|
|
7
|
+
clearTimeout(timeout.current);
|
|
8
|
+
}, []);
|
|
9
|
+
const copy = async text => {
|
|
10
|
+
await clipboardCopy(text);
|
|
11
|
+
setIsCopied(true);
|
|
12
|
+
clearTimeout(timeout.current);
|
|
13
|
+
timeout.current = setTimeout(() => {
|
|
14
|
+
setIsCopied(false);
|
|
15
|
+
}, 1200);
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
copy,
|
|
19
|
+
isCopied
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { MarkdownHeaders } from '@mui/internal-markdown';
|
|
3
|
+
export interface ComponentLinkHeaderProps {
|
|
4
|
+
design?: boolean;
|
|
5
|
+
markdown: {
|
|
6
|
+
headers: MarkdownHeaders;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function ComponentLinkHeader(props: ComponentLinkHeaderProps): React.JSX.Element;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
var _ChatRounded, _BundleSizeIcon, _W3CIcon, _MaterialDesignIcon, _li, _React$Fragment;
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import Chip from '@mui/material/Chip';
|
|
4
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
5
|
+
import ChatRounded from '@mui/icons-material/ChatRounded';
|
|
6
|
+
import { styled } from '@mui/material/styles';
|
|
7
|
+
import SketchIcon from '../svgIcons/SketchIcon';
|
|
8
|
+
import FigmaIcon from '../svgIcons/FigmaIcon';
|
|
9
|
+
import AdobeXDIcon from '../svgIcons/AdobeXDIcon';
|
|
10
|
+
import BundleSizeIcon from '../svgIcons/BundleSizeIcon';
|
|
11
|
+
import W3CIcon from '../svgIcons/W3CIcon';
|
|
12
|
+
import MaterialDesignIcon from '../svgIcons/MaterialDesignIcon';
|
|
13
|
+
import { useTranslate } from '../i18n';
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
const Root = styled('ul')({
|
|
16
|
+
margin: 0,
|
|
17
|
+
padding: 0,
|
|
18
|
+
listStyle: 'none',
|
|
19
|
+
display: 'flex',
|
|
20
|
+
flexWrap: 'wrap',
|
|
21
|
+
gap: 8,
|
|
22
|
+
'& .MuiChip-root': {
|
|
23
|
+
height: 26,
|
|
24
|
+
padding: '0 8px',
|
|
25
|
+
gap: 6,
|
|
26
|
+
'& .MuiChip-label': {
|
|
27
|
+
padding: 0
|
|
28
|
+
},
|
|
29
|
+
'& .MuiChip-iconSmall': {
|
|
30
|
+
margin: 0,
|
|
31
|
+
fontSize: 14
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const defaultPackageNames = {
|
|
36
|
+
'material-ui': '@mui/material',
|
|
37
|
+
'joy-ui': '@mui/joy',
|
|
38
|
+
'base-ui': '@mui/base',
|
|
39
|
+
system: '@mui/system'
|
|
40
|
+
};
|
|
41
|
+
export function ComponentLinkHeader(props) {
|
|
42
|
+
const {
|
|
43
|
+
markdown: {
|
|
44
|
+
headers
|
|
45
|
+
},
|
|
46
|
+
design
|
|
47
|
+
} = props;
|
|
48
|
+
const t = useTranslate();
|
|
49
|
+
const packageName = headers.packageName ?? defaultPackageNames[headers.productId] ?? '@mui/material';
|
|
50
|
+
return /*#__PURE__*/_jsxs(Root, {
|
|
51
|
+
children: [headers.githubLabel ? /*#__PURE__*/_jsx("li", {
|
|
52
|
+
children: /*#__PURE__*/_jsx(Chip, {
|
|
53
|
+
clickable: true,
|
|
54
|
+
role: undefined,
|
|
55
|
+
component: "a",
|
|
56
|
+
size: "small",
|
|
57
|
+
variant: "outlined",
|
|
58
|
+
rel: "nofollow",
|
|
59
|
+
href: `${process.env.SOURCE_CODE_REPO}/labels/${encodeURIComponent(headers.githubLabel)}`,
|
|
60
|
+
icon: _ChatRounded || (_ChatRounded = /*#__PURE__*/_jsx(ChatRounded, {
|
|
61
|
+
color: "primary"
|
|
62
|
+
})),
|
|
63
|
+
"data-ga-event-category": "ComponentLinkHeader",
|
|
64
|
+
"data-ga-event-action": "click",
|
|
65
|
+
"data-ga-event-label": t('githubLabel'),
|
|
66
|
+
"data-ga-event-split": "0.1",
|
|
67
|
+
label: t('githubLabel')
|
|
68
|
+
})
|
|
69
|
+
}) : null, /*#__PURE__*/_jsx("li", {
|
|
70
|
+
children: /*#__PURE__*/_jsx(Tooltip, {
|
|
71
|
+
title: t('bundleSizeTooltip'),
|
|
72
|
+
describeChild: true,
|
|
73
|
+
children: /*#__PURE__*/_jsx(Chip, {
|
|
74
|
+
clickable: true,
|
|
75
|
+
role: undefined,
|
|
76
|
+
component: "a",
|
|
77
|
+
size: "small",
|
|
78
|
+
variant: "outlined",
|
|
79
|
+
rel: "nofollow",
|
|
80
|
+
href: `https://bundlephobia.com/package/${packageName}@latest`,
|
|
81
|
+
icon: _BundleSizeIcon || (_BundleSizeIcon = /*#__PURE__*/_jsx(BundleSizeIcon, {
|
|
82
|
+
color: "primary"
|
|
83
|
+
})),
|
|
84
|
+
"data-ga-event-category": "ComponentLinkHeader",
|
|
85
|
+
"data-ga-event-action": "click",
|
|
86
|
+
"data-ga-event-label": t('bundleSize'),
|
|
87
|
+
"data-ga-event-split": "0.1",
|
|
88
|
+
label: t('bundleSize')
|
|
89
|
+
})
|
|
90
|
+
})
|
|
91
|
+
}), headers.waiAria ? /*#__PURE__*/_jsx("li", {
|
|
92
|
+
children: /*#__PURE__*/_jsx(Chip, {
|
|
93
|
+
clickable: true,
|
|
94
|
+
role: undefined,
|
|
95
|
+
component: "a",
|
|
96
|
+
size: "small",
|
|
97
|
+
variant: "outlined",
|
|
98
|
+
rel: "nofollow",
|
|
99
|
+
href: headers.waiAria,
|
|
100
|
+
icon: _W3CIcon || (_W3CIcon = /*#__PURE__*/_jsx(W3CIcon, {
|
|
101
|
+
color: "primary"
|
|
102
|
+
})),
|
|
103
|
+
"data-ga-event-category": "ComponentLinkHeader",
|
|
104
|
+
"data-ga-event-action": "click",
|
|
105
|
+
"data-ga-event-label": "WAI-ARIA",
|
|
106
|
+
"data-ga-event-split": "0.1",
|
|
107
|
+
label: "WAI-ARIA"
|
|
108
|
+
})
|
|
109
|
+
}) : null, headers.materialDesign ? /*#__PURE__*/_jsx("li", {
|
|
110
|
+
children: /*#__PURE__*/_jsx(Chip, {
|
|
111
|
+
clickable: true,
|
|
112
|
+
role: undefined,
|
|
113
|
+
component: "a",
|
|
114
|
+
size: "small",
|
|
115
|
+
variant: "outlined",
|
|
116
|
+
rel: "nofollow",
|
|
117
|
+
href: headers.materialDesign,
|
|
118
|
+
icon: _MaterialDesignIcon || (_MaterialDesignIcon = /*#__PURE__*/_jsx(MaterialDesignIcon, {})),
|
|
119
|
+
"data-ga-event-category": "ComponentLinkHeader",
|
|
120
|
+
"data-ga-event-action": "click",
|
|
121
|
+
"data-ga-event-label": "Material Design",
|
|
122
|
+
"data-ga-event-split": "0.1",
|
|
123
|
+
label: "Material Design"
|
|
124
|
+
})
|
|
125
|
+
}) : null, design === false ? null : /*#__PURE__*/_jsxs(React.Fragment, {
|
|
126
|
+
children: [_li || (_li = /*#__PURE__*/_jsx("li", {
|
|
127
|
+
children: /*#__PURE__*/_jsx(Chip, {
|
|
128
|
+
clickable: true,
|
|
129
|
+
role: undefined,
|
|
130
|
+
component: "a",
|
|
131
|
+
size: "small",
|
|
132
|
+
variant: "outlined",
|
|
133
|
+
rel: "nofollow",
|
|
134
|
+
href: "https://mui.com/store/items/figma-react/?utm_source=docs&utm_medium=referral&utm_campaign=component-link-header",
|
|
135
|
+
icon: /*#__PURE__*/_jsx(FigmaIcon, {}),
|
|
136
|
+
"data-ga-event-category": "ComponentLinkHeader",
|
|
137
|
+
"data-ga-event-action": "click",
|
|
138
|
+
"data-ga-event-label": "Figma",
|
|
139
|
+
"data-ga-event-split": "0.1",
|
|
140
|
+
label: "Figma"
|
|
141
|
+
})
|
|
142
|
+
})), packageName === '@mui/joy' ? null : _React$Fragment || (_React$Fragment = /*#__PURE__*/_jsxs(React.Fragment, {
|
|
143
|
+
children: [/*#__PURE__*/_jsx("li", {
|
|
144
|
+
children: /*#__PURE__*/_jsx(Chip, {
|
|
145
|
+
clickable: true,
|
|
146
|
+
role: undefined,
|
|
147
|
+
component: "a",
|
|
148
|
+
size: "small",
|
|
149
|
+
variant: "outlined",
|
|
150
|
+
rel: "nofollow",
|
|
151
|
+
href: "https://mui.com/store/items/adobe-xd-react/?utm_source=docs&utm_medium=referral&utm_campaign=component-link-header",
|
|
152
|
+
icon: /*#__PURE__*/_jsx(AdobeXDIcon, {}),
|
|
153
|
+
"data-ga-event-category": "ComponentLinkHeader",
|
|
154
|
+
"data-ga-event-action": "click",
|
|
155
|
+
"data-ga-event-label": "Adobe XD",
|
|
156
|
+
"data-ga-event-split": "0.1",
|
|
157
|
+
label: "Adobe"
|
|
158
|
+
})
|
|
159
|
+
}), /*#__PURE__*/_jsx("li", {
|
|
160
|
+
children: /*#__PURE__*/_jsx(Chip, {
|
|
161
|
+
clickable: true,
|
|
162
|
+
role: undefined,
|
|
163
|
+
component: "a",
|
|
164
|
+
size: "small",
|
|
165
|
+
variant: "outlined",
|
|
166
|
+
rel: "nofollow",
|
|
167
|
+
href: "https://mui.com/store/items/sketch-react/?utm_source=docs&utm_medium=referral&utm_campaign=component-link-header",
|
|
168
|
+
icon: /*#__PURE__*/_jsx(SketchIcon, {}),
|
|
169
|
+
"data-ga-event-category": "ComponentLinkHeader",
|
|
170
|
+
"data-ga-event-action": "click",
|
|
171
|
+
"data-ga-event-label": "Sketch",
|
|
172
|
+
"data-ga-event-split": "0.1",
|
|
173
|
+
label: "Sketch"
|
|
174
|
+
})
|
|
175
|
+
})]
|
|
176
|
+
}))]
|
|
177
|
+
})]
|
|
178
|
+
});
|
|
179
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ButtonProps } from '@mui/material/Button';
|
|
3
|
+
import { SxProps } from '@mui/material/styles';
|
|
4
|
+
export interface HighlightedCodeProps {
|
|
5
|
+
code: string;
|
|
6
|
+
copyButtonHidden?: boolean;
|
|
7
|
+
copyButtonProps?: ButtonProps;
|
|
8
|
+
language: string;
|
|
9
|
+
parentComponent?: React.ElementType;
|
|
10
|
+
plainStyle?: boolean;
|
|
11
|
+
preComponent?: React.ElementType;
|
|
12
|
+
sx?: SxProps;
|
|
13
|
+
}
|
|
14
|
+
export declare const HighlightedCode: React.ForwardRefExoticComponent<HighlightedCodeProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import prism from '@mui/internal-markdown/prism';
|
|
3
|
+
import { NoSsr } from '@mui/base/NoSsr';
|
|
4
|
+
import { styled } from '@mui/material/styles';
|
|
5
|
+
import { useCodeCopy, CodeCopyButton } from '../CodeCopy';
|
|
6
|
+
import { MarkdownElement } from '../MarkdownElement';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
const Pre = styled('pre')(({
|
|
9
|
+
theme
|
|
10
|
+
}) => ({
|
|
11
|
+
margin: 0,
|
|
12
|
+
color: 'hsl(60deg 30% 96.08%)',
|
|
13
|
+
// fallback color until Prism's theme is loaded
|
|
14
|
+
WebkitOverflowScrolling: 'touch',
|
|
15
|
+
// iOS momentum scrolling.
|
|
16
|
+
maxWidth: 'calc(100vw - 32px)',
|
|
17
|
+
[theme.breakpoints.up('md')]: {
|
|
18
|
+
maxWidth: 'calc(100vw - 32px - 16px)'
|
|
19
|
+
},
|
|
20
|
+
'& code': {
|
|
21
|
+
// Avoid layout jump after hydration (style injected by Prism)
|
|
22
|
+
...theme.typography.caption,
|
|
23
|
+
fontFamily: theme.typography.fontFamilyCode,
|
|
24
|
+
fontWeight: 400,
|
|
25
|
+
WebkitFontSmoothing: 'subpixel-antialiased'
|
|
26
|
+
// Reset for Safari
|
|
27
|
+
// https://github.com/necolas/normalize.css/blob/master/normalize.css#L102
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
export const HighlightedCode = /*#__PURE__*/React.forwardRef(function HighlightedCode(props, ref) {
|
|
31
|
+
const {
|
|
32
|
+
code,
|
|
33
|
+
copyButtonHidden = false,
|
|
34
|
+
copyButtonProps,
|
|
35
|
+
language,
|
|
36
|
+
plainStyle,
|
|
37
|
+
parentComponent: Component = plainStyle ? 'div' : MarkdownElement,
|
|
38
|
+
preComponent: PreComponent = plainStyle ? Pre : 'pre',
|
|
39
|
+
...other
|
|
40
|
+
} = props;
|
|
41
|
+
const renderedCode = React.useMemo(() => {
|
|
42
|
+
return prism(code.trim(), language);
|
|
43
|
+
}, [code, language]);
|
|
44
|
+
const handlers = useCodeCopy();
|
|
45
|
+
return /*#__PURE__*/_jsx(Component, {
|
|
46
|
+
ref: ref,
|
|
47
|
+
...other,
|
|
48
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
49
|
+
className: "MuiCode-root",
|
|
50
|
+
...handlers,
|
|
51
|
+
children: [copyButtonHidden ? null : /*#__PURE__*/_jsx(NoSsr, {
|
|
52
|
+
children: /*#__PURE__*/_jsx(CodeCopyButton, {
|
|
53
|
+
code: code,
|
|
54
|
+
...copyButtonProps
|
|
55
|
+
})
|
|
56
|
+
}), /*#__PURE__*/_jsx(PreComponent, {
|
|
57
|
+
children: /*#__PURE__*/_jsx("code", {
|
|
58
|
+
className: `language-${language}`
|
|
59
|
+
// eslint-disable-next-line react/no-danger
|
|
60
|
+
,
|
|
61
|
+
dangerouslySetInnerHTML: {
|
|
62
|
+
__html: renderedCode
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
})]
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HighlightedCode';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HighlightedCode';
|
package/InfoCard/InfoCard.d.ts
CHANGED