@mui/docs 6.0.0-alpha.3 → 6.0.0-alpha.5

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,98 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## v6.0.0-alpha.5
4
+
5
+ <!-- generated comparing v6.0.0-alpha.4..next -->
6
+
7
+ _May 1, 2024_
8
+
9
+ A big thanks to the 9 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ ### `@mui/material@6.0.0-alpha.5`
12
+
13
+ - [FormControlLabel] Deprecate `componentsProps` (#41767) @sai6855
14
+ - [PaginationItem] Deprecate components prop (#41777) @sai6855
15
+ - [SvgIcon] Convert to support CSS extraction (#41779) @aarongarciah
16
+
17
+ ### `@mui/base@5.0.0-beta.43`
18
+
19
+ - [TextareaAutosize] Fix resizing instability (#41638) @ZeeshanTamboli
20
+
21
+ ### Docs
22
+
23
+ - Fix small SEO issues @oliviertassinari
24
+ - [material-ui] Fix minor spelling error in the "About the lab" page (#42073) @ryanhartwig
25
+ - [material-ui] Update Figma plugin name (#41967) @danilo-leal
26
+ - [material-ui][templates] Fix input props attributes in Landing Page template (#42013) @5-tom
27
+ - [system] Update typo on the sx prop page (#42035) @bricker
28
+
29
+ ### Core
30
+
31
+ - [docs-infra] Clean up branding theme file and improve font-face readibility (#42023) @danilo-leal
32
+ - [docs-infra] Simplify docs demo (#42016) @oliviertassinari
33
+ - [website] Add content about the Sync plugin in the Material UI page (#40515) @danilo-leal
34
+ - [website] Sync career roles (#42058) @oliviertassinari
35
+ - [website] Add Nadja on the about page (#42021) @mnajdova
36
+ - [website] Fix code block design by changing the `MarkdownElement` import (#42022) @danilo-leal
37
+ - [wesbite] Remove duplicate MarkdownElement component (#42028) @danilo-leal
38
+
39
+ All contributors of this release in alphabetical order: @5-tom, @aarongarciah, @bricker, @danilo-leal, @mnajdova, @oliviertassinari, @ryanhartwig, @sai6855, @ZeeshanTamboli
40
+
41
+ ## v6.0.0-alpha.4
42
+
43
+ <!-- generated comparing v6.0.0-alpha.3..next -->
44
+
45
+ _Apr 24, 2024_
46
+
47
+ A big thanks to the 15 contributors who made this release possible. Here are some highlights ✨:
48
+
49
+ - 🔥 Converted 3 more Material UI components to use Pigment CSS.
50
+ - ℹ️ Pigment CSS now lives in [its own repository](https://github.com/mui/pigment-css)! From now on, all future development will happen there.
51
+
52
+ ### `@mui/material@6.0.0-alpha.4`
53
+
54
+ - [Checkbox] Convert to support CSS extraction (#41957) @lhilgert9
55
+ - [IconButton] Convert to support CSS extraction (#41850) @gijsbotje
56
+ - [Radio] Convert to support CSS extraction (#41840) @lhilgert9
57
+ - [Typography] Fix ownerState prop placement (#41903) @sai6855
58
+ - Generate typography tokens (#41703) @siriwatknp
59
+ - Move typography CSS variables to `font` (#42003) @siriwatknp
60
+ - Fix getOverlayAlpha type (#41995) @oliviertassinari
61
+ - Support CSS Extraction using codemod (#41935) @siriwatknp
62
+
63
+ ### `@mui/icons-material@6.0.0-alpha.4`
64
+
65
+ - &#8203;<!-- 08 -->[icons] Update the icons package (#41937) @danilo-leal
66
+
67
+ ### Docs
68
+
69
+ - [material-ui] Remove react-swipeable-views from demos as it's no longer maintained (#41912) @soler1212
70
+ - [material-ui] Add dark theme thumbnails for templates (#41947) @zanivan
71
+ - [material-ui] Remove links and interdependencies from free templates (#41941) @zanivan
72
+ - [material-ui] Add missing backticks to HTML tag in the installation page (#41972) @Miguelrom
73
+ - Fix 301 Toolpad links @oliviertassinari
74
+ - Fix 301 image redirections @oliviertassinari
75
+
76
+ ### Core
77
+
78
+ - pnpm docs:zipRules && vale sync @oliviertassinari
79
+ - Remove @pigment-css/\* packages (#41965) @mnajdova
80
+ - [code-infra] Move the HighlightedCode component to @mui/docs (#41859) @Janpot
81
+ - [code-infra] Move the HighlightedCode component to @mui/docs (#41859) @Janpot
82
+ - [code-infra] Make Babel config path configurable in API docs builder (#41999) @michaldudak
83
+ - [docs-infra] Fix flex-shrink pro-plan (#41990) @oliviertassinari
84
+ - [docs-infra] Allow more value uses of MUI (#41706) @oliviertassinari
85
+ - [docs-infra] Move CPU to shared config (#41901) @oliviertassinari
86
+ - [docs-infra] Improve Twitter OG:image (#41860) @oliviertassinari
87
+ - [docs-infra] Adapt docs infra to Base UI docs needs (#41963) @michaldudak
88
+ - [docs-infra] Add demo container design refinements (#41948) @danilo-leal
89
+ - [docs-infra] Use the `getLayout` on the material demo pages (#41936) @alexfauquette
90
+ - [test] Update browser versions in karma config (#42008) @ZeeshanTamboli
91
+ - [website] Remove customer support agent role from website (#41969) @rluzists1
92
+ - [website] Fix grid usage and add stray improvements (#41930) @danilo-leal
93
+
94
+ All contributors of this release in alphabetical order: @alexfauquette, @danilo-leal, @gijsbotje, @Janpot, @lhilgert9, @michaldudak, @Miguelrom, @mnajdova, @oliviertassinari, @rluzists1, @sai6855, @siriwatknp, @soler1212, @zanivan, @ZeeshanTamboli
95
+
3
96
  ## v6.0.0-alpha.3
4
97
 
5
98
  <!-- 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,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
+ preComponent?: React.ElementType;
11
+ plainStyle?: boolean;
12
+ sx?: SxProps;
13
+ }
14
+ export declare const HighlightedCode: React.ForwardRefExoticComponent<HighlightedCodeProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,68 @@
1
+ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
+ const _excluded = ["copyButtonHidden", "copyButtonProps", "code", "language", "plainStyle", "parentComponent", "preComponent"];
4
+ import * as React from 'react';
5
+ import prism from '@mui/internal-markdown/prism';
6
+ import { NoSsr } from '@mui/base/NoSsr';
7
+ import { styled } from '@mui/material/styles';
8
+ import { useCodeCopy, CodeCopyButton } from '../CodeCopy';
9
+ import { MarkdownElement } from '../MarkdownElement';
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ const Pre = styled('pre')(({
12
+ theme
13
+ }) => ({
14
+ margin: 0,
15
+ color: 'hsl(60deg 30% 96.08%)',
16
+ // fallback color until Prism's theme is loaded
17
+ WebkitOverflowScrolling: 'touch',
18
+ // iOS momentum scrolling.
19
+ maxWidth: 'calc(100vw - 32px)',
20
+ [theme.breakpoints.up('md')]: {
21
+ maxWidth: 'calc(100vw - 32px - 16px)'
22
+ },
23
+ '& code': _extends({}, theme.typography.caption, {
24
+ fontFamily: theme.typography.fontFamilyCode,
25
+ fontWeight: 400,
26
+ WebkitFontSmoothing: 'subpixel-antialiased'
27
+ // Reset for Safari
28
+ // https://github.com/necolas/normalize.css/blob/master/normalize.css#L102
29
+ })
30
+ }));
31
+ export const HighlightedCode = /*#__PURE__*/React.forwardRef(function HighlightedCode(props, ref) {
32
+ const {
33
+ copyButtonHidden = false,
34
+ copyButtonProps,
35
+ code,
36
+ language,
37
+ plainStyle,
38
+ parentComponent: Component = plainStyle ? 'div' : MarkdownElement,
39
+ preComponent: PreComponent = plainStyle ? Pre : 'pre'
40
+ } = props,
41
+ other = _objectWithoutPropertiesLoose(props, _excluded);
42
+ const renderedCode = React.useMemo(() => {
43
+ return prism(code.trim(), language);
44
+ }, [code, language]);
45
+ const handlers = useCodeCopy();
46
+ return /*#__PURE__*/_jsx(Component, _extends({
47
+ ref: ref
48
+ }, other, {
49
+ children: /*#__PURE__*/_jsxs("div", _extends({
50
+ className: "MuiCode-root"
51
+ }, handlers, {
52
+ children: [copyButtonHidden ? null : /*#__PURE__*/_jsx(NoSsr, {
53
+ children: /*#__PURE__*/_jsx(CodeCopyButton, _extends({
54
+ code: code
55
+ }, copyButtonProps))
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';
@@ -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>>;