@mui/docs 6.0.0-alpha.3 → 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 CHANGED
@@ -1,5 +1,60 @@
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
+ - &#8203;<!-- 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
+
3
58
  ## v6.0.0-alpha.3
4
59
 
5
60
  <!-- generated comparing v6.0.0-alpha.2..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,5 @@
1
+ import * as React from 'react';
2
+ export interface CodeCopyButtonProps {
3
+ code: string;
4
+ }
5
+ export declare function CodeCopyButton(props: CodeCopyButtonProps): React.JSX.Element;
@@ -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,3 @@
1
+ export * from './CodeCopy';
2
+ export * from './CodeCopyButton';
3
+ export { default as useClipboardCopy } from './useClipboardCopy';
@@ -0,0 +1,3 @@
1
+ export * from './CodeCopy';
2
+ export * from './CodeCopyButton';
3
+ export { default as useClipboardCopy } from './useClipboardCopy';
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/CodeCopy/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,4 @@
1
+ export default function useClipboardCopy(): {
2
+ copy: (text: string) => Promise<void>;
3
+ isCopied: boolean;
4
+ };
@@ -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';
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "./index.js",
4
+ "main": "../node/HighlightedCode/index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,6 @@
1
+ import * as React from 'react';
2
+ export interface MarkdownElementProps {
3
+ className?: string;
4
+ renderedMarkdown?: string;
5
+ }
6
+ export declare const MarkdownElement: React.ForwardRefExoticComponent<MarkdownElementProps & React.RefAttributes<HTMLDivElement>>;