@mui/docs 6.0.0-alpha.2 → 6.0.0-alpha.4
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 +128 -0
- package/CodeCopy/CodeCopy.d.ts +20 -0
- package/CodeCopy/CodeCopy.js +172 -0
- package/CodeCopy/CodeCopyButton.d.ts +5 -0
- package/CodeCopy/CodeCopyButton.js +50 -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/HighlightedCode/HighlightedCode.d.ts +12 -0
- package/HighlightedCode/HighlightedCode.js +45 -0
- package/HighlightedCode/index.d.ts +1 -0
- package/HighlightedCode/index.js +1 -0
- package/HighlightedCode/package.json +6 -0
- package/InfoCard/InfoCard.js +3 -3
- package/MarkdownElement/MarkdownElement.d.ts +6 -0
- package/MarkdownElement/MarkdownElement.js +826 -0
- package/MarkdownElement/index.d.ts +1 -0
- package/MarkdownElement/index.js +1 -0
- package/MarkdownElement/package.json +6 -0
- package/branding/brandingTheme.js +5 -5
- package/node/CodeCopy/CodeCopy.js +188 -0
- package/node/CodeCopy/CodeCopyButton.js +59 -0
- package/node/CodeCopy/index.js +40 -0
- package/node/CodeCopy/useClipboardCopy.js +30 -0
- package/node/HighlightedCode/HighlightedCode.js +54 -0
- package/node/HighlightedCode/index.js +16 -0
- package/node/InfoCard/InfoCard.js +3 -3
- package/node/MarkdownElement/MarkdownElement.js +838 -0
- package/node/MarkdownElement/index.js +16 -0
- package/node/branding/brandingTheme.js +5 -5
- package/package.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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,133 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## v6.0.0-alpha.4
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v6.0.0-alpha.3..next -->
|
|
6
|
+
|
|
7
|
+
_Apr 24, 2024_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
|
|
10
|
+
|
|
11
|
+
- 🔥 Converted 3 more Material UI components to use Pigment CSS.
|
|
12
|
+
- ℹ️ Pigment CSS now lives in [its own repository](https://github.com/mui/pigment-css)! From now on, all future development will happen there.
|
|
13
|
+
|
|
14
|
+
### `@mui/material@6.0.0-alpha.4`
|
|
15
|
+
|
|
16
|
+
- [Checkbox] Convert to support CSS extraction (#41957) @lhilgert9
|
|
17
|
+
- [IconButton] Convert to support CSS extraction (#41850) @gijsbotje
|
|
18
|
+
- [Radio] Convert to support CSS extraction (#41840) @lhilgert9
|
|
19
|
+
- [Typography] Fix ownerState prop placement (#41903) @sai6855
|
|
20
|
+
- Generate typography tokens (#41703) @siriwatknp
|
|
21
|
+
- Move typography CSS variables to `font` (#42003) @siriwatknp
|
|
22
|
+
- Fix getOverlayAlpha type (#41995) @oliviertassinari
|
|
23
|
+
- Support CSS Extraction using codemod (#41935) @siriwatknp
|
|
24
|
+
|
|
25
|
+
### `@mui/icons-material@6.0.0-alpha.4`
|
|
26
|
+
|
|
27
|
+
- ​<!-- 08 -->[icons] Update the icons package (#41937) @danilo-leal
|
|
28
|
+
|
|
29
|
+
### Docs
|
|
30
|
+
|
|
31
|
+
- [material-ui] Remove react-swipeable-views from demos as it's no longer maintained (#41912) @soler1212
|
|
32
|
+
- [material-ui] Add dark theme thumbnails for templates (#41947) @zanivan
|
|
33
|
+
- [material-ui] Remove links and interdependencies from free templates (#41941) @zanivan
|
|
34
|
+
- [material-ui] Add missing backticks to HTML tag in the installation page (#41972) @Miguelrom
|
|
35
|
+
- Fix 301 Toolpad links @oliviertassinari
|
|
36
|
+
- Fix 301 image redirections @oliviertassinari
|
|
37
|
+
|
|
38
|
+
### Core
|
|
39
|
+
|
|
40
|
+
- pnpm docs:zipRules && vale sync @oliviertassinari
|
|
41
|
+
- Remove @pigment-css/\* packages (#41965) @mnajdova
|
|
42
|
+
- [code-infra] Move the HighlightedCode component to @mui/docs (#41859) @Janpot
|
|
43
|
+
- [code-infra] Move the HighlightedCode component to @mui/docs (#41859) @Janpot
|
|
44
|
+
- [code-infra] Make Babel config path configurable in API docs builder (#41999) @michaldudak
|
|
45
|
+
- [docs-infra] Fix flex-shrink pro-plan (#41990) @oliviertassinari
|
|
46
|
+
- [docs-infra] Allow more value uses of MUI (#41706) @oliviertassinari
|
|
47
|
+
- [docs-infra] Move CPU to shared config (#41901) @oliviertassinari
|
|
48
|
+
- [docs-infra] Improve Twitter OG:image (#41860) @oliviertassinari
|
|
49
|
+
- [docs-infra] Adapt docs infra to Base UI docs needs (#41963) @michaldudak
|
|
50
|
+
- [docs-infra] Add demo container design refinements (#41948) @danilo-leal
|
|
51
|
+
- [docs-infra] Use the `getLayout` on the material demo pages (#41936) @alexfauquette
|
|
52
|
+
- [test] Update browser versions in karma config (#42008) @ZeeshanTamboli
|
|
53
|
+
- [website] Remove customer support agent role from website (#41969) @rluzists1
|
|
54
|
+
- [website] Fix grid usage and add stray improvements (#41930) @danilo-leal
|
|
55
|
+
|
|
56
|
+
All contributors of this release in alphabetical order: @alexfauquette, @danilo-leal, @gijsbotje, @Janpot, @lhilgert9, @michaldudak, @Miguelrom, @mnajdova, @oliviertassinari, @rluzists1, @sai6855, @siriwatknp, @soler1212, @zanivan, @ZeeshanTamboli
|
|
57
|
+
|
|
58
|
+
## v6.0.0-alpha.3
|
|
59
|
+
|
|
60
|
+
<!-- generated comparing v6.0.0-alpha.2..next -->
|
|
61
|
+
|
|
62
|
+
_Apr 17, 2024_
|
|
63
|
+
|
|
64
|
+
A big thanks to the 24 contributors who made this release possible. Here are some highlights ✨:
|
|
65
|
+
|
|
66
|
+
- 🔥 Converted 5 more Material UI components to use Pigment CSS.
|
|
67
|
+
- 🚀 Added container queries utility to the `@mui/system` package (#41674) @siriwatknp.
|
|
68
|
+
|
|
69
|
+
### `@mui/material@6.0.0-alpha.3`
|
|
70
|
+
|
|
71
|
+
- Convert `LinearProgress` to support Pigment CSS (#41816) @siriwatknp
|
|
72
|
+
- [Dialog] Prevent onClick on the root element from being overwritten (#41881) @ryanburr
|
|
73
|
+
- [FloatingActionButton] Convert to support CSS extraction (#41851) @gijsbotje
|
|
74
|
+
- Convert `CircularProgress` to support Pigment CSS (#41776) @siriwatknp
|
|
75
|
+
- [PaginationItem] Convert to support CSS extraction (#41848) @gijsbotje
|
|
76
|
+
- [StepConnector] deprecate composed classes (#41740) @sai6855
|
|
77
|
+
- [StepLabel] Deprecate `StepIconComponent`, `StepIconProps` (#41835) @sai6855
|
|
78
|
+
- [ToggleButton] Convert to support CSS extraction (#41782) @lhilgert9
|
|
79
|
+
- [ToggleButtonGroup] Deprecate composed classes (#41288) @sai6855
|
|
80
|
+
- [Typography] Fix Typography inherit variant styles (#41308) @kealjones-wk
|
|
81
|
+
|
|
82
|
+
### `@mui/system@6.0.0-alpha.3`
|
|
83
|
+
|
|
84
|
+
- Add container queries utility (#41674) @siriwatknp
|
|
85
|
+
|
|
86
|
+
### `@mui/codemod@6.0.0-alpha.3`
|
|
87
|
+
|
|
88
|
+
- Add styled v6 transformation (#41743) @siriwatknp
|
|
89
|
+
|
|
90
|
+
### `@mui/joy@5.0.0-beta.36`
|
|
91
|
+
|
|
92
|
+
- [Button] Disable text highlighting (#41902) @mithun522
|
|
93
|
+
|
|
94
|
+
### `@pigment-css/react@0.0.7`
|
|
95
|
+
|
|
96
|
+
- Patch WyW's WeakRef usage (#41909) @DiegoAndai
|
|
97
|
+
- Implement sx transform for system components (#41861) @brijeshb42
|
|
98
|
+
|
|
99
|
+
### Docs
|
|
100
|
+
|
|
101
|
+
- [material-ui] Add Connect-related content (#40848) @danilo-leal
|
|
102
|
+
- [material-ui] Fix credit comment typo (#41872) @aarongarciah
|
|
103
|
+
- [material-ui] Remove Data Grid v7 beta callout (#41839) @cherniavskii
|
|
104
|
+
- [material-ui] Add stray design tweaks to free templates (#41696) @zanivan
|
|
105
|
+
- [material-ui] Simplify components styling on templates (#41845) @zanivan
|
|
106
|
+
- [material-ui][Button] Add `onChange` event handler to file upload example (#41863) @aarongarciah
|
|
107
|
+
- [material-ui] Fix import statement in migration guide (#41852) @sai6855
|
|
108
|
+
- Fix 301 redirection @oliviertassinari
|
|
109
|
+
- Fix format git diff regression (#41882) @oliviertassinari
|
|
110
|
+
- Fix small SEO issues @oliviertassinari
|
|
111
|
+
- [pigment-css] Fix README typos (#41870) @MohammadShehadeh
|
|
112
|
+
|
|
113
|
+
### Core
|
|
114
|
+
|
|
115
|
+
- Begin removing IE 11-related code (#41709) @iammminzzy
|
|
116
|
+
- [blog] Add post to introduce the Connect plugin (#41763) @danilo-leal
|
|
117
|
+
- [code-infra] Fix require.context with aliases (#41682) @Janpot
|
|
118
|
+
- [code-infra] Allow customizing hooks imports in API docs generator (#41828) @michaldudak
|
|
119
|
+
- [codemod] Add utils for `*Component` and `*Props` props deprecations (#41685) @DiegoAndai
|
|
120
|
+
- Replace bundle size reporter filter (#38979) @Janpot
|
|
121
|
+
- [docs-infra] Make the whole header clickable (#39603) @MoazMirza-13
|
|
122
|
+
- [docs-infra] Improve demo container and related components design (#41827) @danilo-leal
|
|
123
|
+
- [docs-infra] Use edge function for card generation (#41188) (#41836) @alexfauquette
|
|
124
|
+
- [docs-infra] Fix code block layout shift (#41917) @oliviertassinari
|
|
125
|
+
- [docs-infra] Fine-tune the OG card image design (#41862) @danilo-leal
|
|
126
|
+
- [docs-infra] Fix markdown version for material (#41908) @alexfauquette
|
|
127
|
+
- [docs-infra] Support multiple tabs in demos (#40901) @bharatkashyap
|
|
128
|
+
|
|
129
|
+
All contributors of this release in alphabetical order: @aarongarciah, @alexfauquette, @bharatkashyap, @brijeshb42, @cherniavskii, @danilo-leal, @DiegoAndai, @EyaOuenniche, @gijsbotje, @iammminzzy, @Janpot, @kealjones-wk, @lhilgert9, @magnimarels, @michaldudak, @mithun522, @mnajdova, @MoazMirza-13, @MohammadShehadeh, @oliviertassinari, @ryanburr, @sai6855, @siriwatknp, @zanivan
|
|
130
|
+
|
|
3
131
|
## v6.0.0-alpha.2
|
|
4
132
|
|
|
5
133
|
<!-- generated comparing v6.0.0-alpha.1..next -->
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* How to use: spread the handlers to the .MuiCode-root
|
|
4
|
+
*
|
|
5
|
+
* The html structure should be:
|
|
6
|
+
* <div className="MuiCode-root">
|
|
7
|
+
* <pre>...</pre>
|
|
8
|
+
* <button className="MuiCode-copy">...</button>
|
|
9
|
+
* </div>
|
|
10
|
+
*/
|
|
11
|
+
export declare function useCodeCopy(): React.HTMLAttributes<HTMLDivElement>;
|
|
12
|
+
interface CodeCopyProviderProps {
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Place <CodeCopyProvider> at the page level. It will check the keydown event and try to initiate copy click if rootNode exist.
|
|
17
|
+
* Any code block inside the tree can set the rootNode when mouse enter to leverage keyboard copy.
|
|
18
|
+
*/
|
|
19
|
+
export declare function CodeCopyProvider({ children }: CodeCopyProviderProps): React.JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -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,50 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
var _span, _span2;
|
|
4
|
+
const _excluded = ["code"];
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import ContentCopyRoundedIcon from '@mui/icons-material/ContentCopyRounded';
|
|
7
|
+
import LibraryAddCheckRoundedIcon from '@mui/icons-material/LibraryAddCheckRounded';
|
|
8
|
+
import useClipboardCopy from './useClipboardCopy';
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
export function CodeCopyButton(props) {
|
|
11
|
+
const {
|
|
12
|
+
code
|
|
13
|
+
} = props,
|
|
14
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
15
|
+
const {
|
|
16
|
+
copy,
|
|
17
|
+
isCopied
|
|
18
|
+
} = useClipboardCopy();
|
|
19
|
+
// This component is designed to be wrapped in NoSsr
|
|
20
|
+
const macOS = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
|
21
|
+
const key = macOS ? '⌘' : 'Ctrl + ';
|
|
22
|
+
return /*#__PURE__*/_jsx("div", {
|
|
23
|
+
className: "MuiCode-copy-container",
|
|
24
|
+
children: /*#__PURE__*/_jsxs("button", _extends({}, other, {
|
|
25
|
+
"aria-label": "Copy the code",
|
|
26
|
+
type: "button",
|
|
27
|
+
className: "MuiCode-copy",
|
|
28
|
+
onClick: async () => {
|
|
29
|
+
// event.stopPropagation();
|
|
30
|
+
await copy(code);
|
|
31
|
+
},
|
|
32
|
+
children: [isCopied ? /*#__PURE__*/_jsx(LibraryAddCheckRoundedIcon, {
|
|
33
|
+
sx: {
|
|
34
|
+
fontSize: 18
|
|
35
|
+
}
|
|
36
|
+
}) : /*#__PURE__*/_jsx(ContentCopyRoundedIcon, {
|
|
37
|
+
sx: {
|
|
38
|
+
fontSize: 18
|
|
39
|
+
}
|
|
40
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
41
|
+
className: "MuiCode-copyKeypress",
|
|
42
|
+
children: [_span || (_span = /*#__PURE__*/_jsx("span", {
|
|
43
|
+
children: "(or"
|
|
44
|
+
})), " ", key, "C", _span2 || (_span2 = /*#__PURE__*/_jsx("span", {
|
|
45
|
+
children: ")"
|
|
46
|
+
}))]
|
|
47
|
+
})]
|
|
48
|
+
}))
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -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,12 @@
|
|
|
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
|
+
component?: React.ElementType;
|
|
7
|
+
copyButtonHidden?: boolean;
|
|
8
|
+
copyButtonProps?: ButtonProps;
|
|
9
|
+
language: string;
|
|
10
|
+
sx?: SxProps;
|
|
11
|
+
}
|
|
12
|
+
export declare const HighlightedCode: React.ForwardRefExoticComponent<HighlightedCodeProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["copyButtonHidden", "copyButtonProps", "code", "language", "component"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import prism from '@mui/internal-markdown/prism';
|
|
6
|
+
import { NoSsr } from '@mui/base/NoSsr';
|
|
7
|
+
import { useCodeCopy, CodeCopyButton } from '../CodeCopy';
|
|
8
|
+
import { MarkdownElement } from '../MarkdownElement';
|
|
9
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
export const HighlightedCode = /*#__PURE__*/React.forwardRef(function HighlightedCode(props, ref) {
|
|
11
|
+
const {
|
|
12
|
+
copyButtonHidden = false,
|
|
13
|
+
copyButtonProps,
|
|
14
|
+
code,
|
|
15
|
+
language,
|
|
16
|
+
component: Component = MarkdownElement
|
|
17
|
+
} = props,
|
|
18
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
19
|
+
const renderedCode = React.useMemo(() => {
|
|
20
|
+
return prism(code.trim(), language);
|
|
21
|
+
}, [code, language]);
|
|
22
|
+
const handlers = useCodeCopy();
|
|
23
|
+
return /*#__PURE__*/_jsx(Component, _extends({
|
|
24
|
+
ref: ref
|
|
25
|
+
}, other, {
|
|
26
|
+
children: /*#__PURE__*/_jsxs("div", _extends({
|
|
27
|
+
className: "MuiCode-root"
|
|
28
|
+
}, handlers, {
|
|
29
|
+
children: [copyButtonHidden ? null : /*#__PURE__*/_jsx(NoSsr, {
|
|
30
|
+
children: /*#__PURE__*/_jsx(CodeCopyButton, _extends({
|
|
31
|
+
code: code
|
|
32
|
+
}, copyButtonProps))
|
|
33
|
+
}), /*#__PURE__*/_jsx("pre", {
|
|
34
|
+
children: /*#__PURE__*/_jsx("code", {
|
|
35
|
+
className: `language-${language}`
|
|
36
|
+
// eslint-disable-next-line react/no-danger
|
|
37
|
+
,
|
|
38
|
+
dangerouslySetInnerHTML: {
|
|
39
|
+
__html: renderedCode
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
})]
|
|
43
|
+
}))
|
|
44
|
+
}));
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HighlightedCode';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HighlightedCode';
|
package/InfoCard/InfoCard.js
CHANGED
|
@@ -23,11 +23,11 @@ export function GlowingIconContainer({
|
|
|
23
23
|
border: '1px solid',
|
|
24
24
|
borderColor: 'primary.200',
|
|
25
25
|
bgcolor: 'primary.50',
|
|
26
|
-
boxShadow: `0px
|
|
26
|
+
boxShadow: `0px 0 0 2px ${alpha(theme.palette.primary[500], 0.1)}, 0px 2px 12px 0px rgba(234, 237, 241, 0.3) inset`
|
|
27
27
|
}, theme.applyDarkStyles({
|
|
28
28
|
borderColor: alpha(theme.palette.primary[400], 0.25),
|
|
29
|
-
bgcolor: alpha(theme.palette.primary[900], 0.
|
|
30
|
-
boxShadow: `0
|
|
29
|
+
bgcolor: alpha(theme.palette.primary[900], 0.4),
|
|
30
|
+
boxShadow: `0 0 0 2px ${alpha(theme.palette.primary[600], 0.1)}, 0px 2px 12px 0px rgba(0, 0, 0, 0.25) inset`
|
|
31
31
|
})),
|
|
32
32
|
children: icon
|
|
33
33
|
});
|