@mui/docs 9.0.0-alpha.1 → 9.0.0-alpha.2
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 +28 -0
- package/IconImage/IconImage.d.mts +11 -0
- package/IconImage/IconImage.d.ts +11 -0
- package/IconImage/IconImage.js +91 -0
- package/IconImage/IconImage.mjs +83 -0
- package/IconImage/index.d.mts +1 -0
- package/IconImage/index.d.ts +1 -0
- package/IconImage/index.js +13 -0
- package/IconImage/index.mjs +1 -0
- package/SectionHeadline/SectionHeadline.d.mts +13 -0
- package/SectionHeadline/SectionHeadline.d.ts +13 -0
- package/SectionHeadline/SectionHeadline.js +89 -0
- package/SectionHeadline/SectionHeadline.mjs +81 -0
- package/SectionHeadline/index.d.mts +2 -0
- package/SectionHeadline/index.d.ts +2 -0
- package/SectionHeadline/index.js +25 -0
- package/SectionHeadline/index.mjs +2 -0
- package/ThemeContext/ThemeContext.d.mts +92 -0
- package/ThemeContext/ThemeContext.d.ts +92 -0
- package/ThemeContext/ThemeContext.js +212 -0
- package/ThemeContext/ThemeContext.mjs +200 -0
- package/ThemeContext/index.d.mts +1 -0
- package/ThemeContext/index.d.ts +1 -0
- package/ThemeContext/index.js +42 -0
- package/ThemeContext/index.mjs +1 -0
- package/package.json +59 -1
- package/useLazyCSS/index.d.mts +1 -0
- package/useLazyCSS/index.d.ts +1 -0
- package/useLazyCSS/index.js +13 -0
- package/useLazyCSS/index.mjs +1 -0
- package/useLazyCSS/useLazyCSS.d.mts +11 -0
- package/useLazyCSS/useLazyCSS.d.ts +11 -0
- package/useLazyCSS/useLazyCSS.js +76 -0
- package/useLazyCSS/useLazyCSS.mjs +70 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ThemeOptionsContext = exports.DispatchContext = void 0;
|
|
9
|
+
exports.ThemeProvider = ThemeProvider;
|
|
10
|
+
exports.highDensity = void 0;
|
|
11
|
+
exports.useChangeTheme = useChangeTheme;
|
|
12
|
+
exports.useColorSchemeShim = useColorSchemeShim;
|
|
13
|
+
var React = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
var _styles = require("@mui/material/styles");
|
|
16
|
+
var _utils = require("@mui/material/utils");
|
|
17
|
+
var _useMediaQuery = _interopRequireDefault(require("@mui/material/useMediaQuery"));
|
|
18
|
+
var _useLocalStorageState = _interopRequireDefault(require("@mui/utils/useLocalStorageState"));
|
|
19
|
+
var _useLazyCSS = _interopRequireDefault(require("../useLazyCSS"));
|
|
20
|
+
var _branding = require("../branding");
|
|
21
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const themeInitialOptions = {
|
|
23
|
+
dense: false,
|
|
24
|
+
direction: 'ltr',
|
|
25
|
+
paletteMode: 'light'
|
|
26
|
+
};
|
|
27
|
+
const highDensity = exports.highDensity = {
|
|
28
|
+
components: {
|
|
29
|
+
MuiButton: {
|
|
30
|
+
defaultProps: {
|
|
31
|
+
size: 'small'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
MuiFilledInput: {
|
|
35
|
+
defaultProps: {
|
|
36
|
+
margin: 'dense'
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
MuiFormControl: {
|
|
40
|
+
defaultProps: {
|
|
41
|
+
margin: 'dense'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
MuiFormHelperText: {
|
|
45
|
+
defaultProps: {
|
|
46
|
+
margin: 'dense'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
MuiIconButton: {
|
|
50
|
+
defaultProps: {
|
|
51
|
+
size: 'small'
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
MuiInputBase: {
|
|
55
|
+
defaultProps: {
|
|
56
|
+
margin: 'dense'
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
MuiInputLabel: {
|
|
60
|
+
defaultProps: {
|
|
61
|
+
margin: 'dense'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
MuiListItem: {
|
|
65
|
+
defaultProps: {
|
|
66
|
+
dense: true
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
MuiOutlinedInput: {
|
|
70
|
+
defaultProps: {
|
|
71
|
+
margin: 'dense'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
MuiFab: {
|
|
75
|
+
defaultProps: {
|
|
76
|
+
size: 'small'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
MuiTable: {
|
|
80
|
+
defaultProps: {
|
|
81
|
+
size: 'small'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
MuiTextField: {
|
|
85
|
+
defaultProps: {
|
|
86
|
+
margin: 'dense'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
MuiToolbar: {
|
|
90
|
+
defaultProps: {
|
|
91
|
+
variant: 'dense'
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const DispatchContext = exports.DispatchContext = /*#__PURE__*/React.createContext(() => {
|
|
97
|
+
throw new Error('Forgot to wrap component in `ThemeProvider`');
|
|
98
|
+
});
|
|
99
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
100
|
+
DispatchContext.displayName = 'ThemeDispatchContext';
|
|
101
|
+
}
|
|
102
|
+
const ThemeOptionsContext = exports.ThemeOptionsContext = /*#__PURE__*/React.createContext(themeInitialOptions);
|
|
103
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
104
|
+
ThemeOptionsContext.displayName = 'ThemeOptionsContext';
|
|
105
|
+
}
|
|
106
|
+
function ThemeProvider(props) {
|
|
107
|
+
const {
|
|
108
|
+
children
|
|
109
|
+
} = props;
|
|
110
|
+
const [themeOptions, dispatch] = React.useReducer((state, action) => {
|
|
111
|
+
switch (action.type) {
|
|
112
|
+
case 'SET_DENSE':
|
|
113
|
+
return {
|
|
114
|
+
...state,
|
|
115
|
+
dense: action.payload
|
|
116
|
+
};
|
|
117
|
+
case 'RESET_DENSITY':
|
|
118
|
+
return {
|
|
119
|
+
...state,
|
|
120
|
+
dense: themeInitialOptions.dense
|
|
121
|
+
};
|
|
122
|
+
case 'CHANGE':
|
|
123
|
+
// No value changed
|
|
124
|
+
if ((!action.payload.paletteMode || action.payload.paletteMode === state.paletteMode) && (!action.payload.direction || action.payload.direction === state.direction)) {
|
|
125
|
+
return state;
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
...state,
|
|
129
|
+
paletteMode: action.payload.paletteMode || state.paletteMode,
|
|
130
|
+
direction: action.payload.direction || state.direction
|
|
131
|
+
};
|
|
132
|
+
default:
|
|
133
|
+
throw new Error(`Unrecognized type ${action.type}`);
|
|
134
|
+
}
|
|
135
|
+
}, themeInitialOptions);
|
|
136
|
+
const {
|
|
137
|
+
direction,
|
|
138
|
+
paletteMode
|
|
139
|
+
} = themeOptions;
|
|
140
|
+
(0, _useLazyCSS.default)('/static/styles/prism-okaidia.css', '#prismjs');
|
|
141
|
+
|
|
142
|
+
// TODO replace with useColorScheme once all pages support css vars
|
|
143
|
+
const {
|
|
144
|
+
mode,
|
|
145
|
+
systemMode
|
|
146
|
+
} = useColorSchemeShim();
|
|
147
|
+
const calculatedMode = mode === 'system' ? systemMode : mode;
|
|
148
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
149
|
+
dispatch({
|
|
150
|
+
type: 'CHANGE',
|
|
151
|
+
payload: {
|
|
152
|
+
paletteMode: calculatedMode
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}, [calculatedMode]);
|
|
156
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
157
|
+
document.body.setAttribute('dir', direction);
|
|
158
|
+
}, [direction]);
|
|
159
|
+
(0, _utils.unstable_useEnhancedEffect)(() => {
|
|
160
|
+
// To support light and dark mode images in the docs
|
|
161
|
+
if (paletteMode === 'dark') {
|
|
162
|
+
document.body.classList.remove('mode-light');
|
|
163
|
+
document.body.classList.add('mode-dark');
|
|
164
|
+
} else {
|
|
165
|
+
document.body.classList.remove('mode-dark');
|
|
166
|
+
document.body.classList.add('mode-light');
|
|
167
|
+
}
|
|
168
|
+
const metas = document.querySelectorAll('meta[name="theme-color"]');
|
|
169
|
+
metas.forEach(meta => {
|
|
170
|
+
meta.setAttribute('content', (0, _branding.getMetaThemeColor)(paletteMode));
|
|
171
|
+
});
|
|
172
|
+
}, [paletteMode]);
|
|
173
|
+
React.useEffect(() => {
|
|
174
|
+
// Expose the theme as a global variable so people can play with it.
|
|
175
|
+
window.createTheme = _styles.createTheme;
|
|
176
|
+
}, []);
|
|
177
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ThemeOptionsContext.Provider, {
|
|
178
|
+
value: themeOptions,
|
|
179
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(DispatchContext.Provider, {
|
|
180
|
+
value: dispatch,
|
|
181
|
+
children: children
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
|
|
186
|
+
children: _propTypes.default.node
|
|
187
|
+
} : void 0;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @returns {(nextOptions: Partial<typeof themeInitialOptions>) => void}
|
|
191
|
+
*/
|
|
192
|
+
function useChangeTheme() {
|
|
193
|
+
const dispatch = React.useContext(DispatchContext);
|
|
194
|
+
return React.useCallback(options => dispatch({
|
|
195
|
+
type: 'CHANGE',
|
|
196
|
+
payload: options
|
|
197
|
+
}), [dispatch]);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// TODO: remove once all pages support css vars and replace call sites with useColorScheme()
|
|
201
|
+
function useColorSchemeShim() {
|
|
202
|
+
const [mode, setMode] = (0, _useLocalStorageState.default)('mui-mode', 'system');
|
|
203
|
+
const prefersDarkMode = (0, _useMediaQuery.default)('(prefers-color-scheme: dark)', {
|
|
204
|
+
noSsr: true
|
|
205
|
+
});
|
|
206
|
+
const systemMode = prefersDarkMode ? 'dark' : 'light';
|
|
207
|
+
return {
|
|
208
|
+
mode,
|
|
209
|
+
systemMode,
|
|
210
|
+
setMode
|
|
211
|
+
};
|
|
212
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { createTheme as createMdTheme } from '@mui/material/styles';
|
|
4
|
+
import { unstable_useEnhancedEffect as useEnhancedEffect } from '@mui/material/utils';
|
|
5
|
+
import useMediaQuery from '@mui/material/useMediaQuery';
|
|
6
|
+
import useLocalStorageState from '@mui/utils/useLocalStorageState';
|
|
7
|
+
import useLazyCSS from "../useLazyCSS/index.mjs";
|
|
8
|
+
import { getMetaThemeColor } from "../branding/index.mjs";
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
const themeInitialOptions = {
|
|
11
|
+
dense: false,
|
|
12
|
+
direction: 'ltr',
|
|
13
|
+
paletteMode: 'light'
|
|
14
|
+
};
|
|
15
|
+
export const highDensity = {
|
|
16
|
+
components: {
|
|
17
|
+
MuiButton: {
|
|
18
|
+
defaultProps: {
|
|
19
|
+
size: 'small'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
MuiFilledInput: {
|
|
23
|
+
defaultProps: {
|
|
24
|
+
margin: 'dense'
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
MuiFormControl: {
|
|
28
|
+
defaultProps: {
|
|
29
|
+
margin: 'dense'
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
MuiFormHelperText: {
|
|
33
|
+
defaultProps: {
|
|
34
|
+
margin: 'dense'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
MuiIconButton: {
|
|
38
|
+
defaultProps: {
|
|
39
|
+
size: 'small'
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
MuiInputBase: {
|
|
43
|
+
defaultProps: {
|
|
44
|
+
margin: 'dense'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
MuiInputLabel: {
|
|
48
|
+
defaultProps: {
|
|
49
|
+
margin: 'dense'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
MuiListItem: {
|
|
53
|
+
defaultProps: {
|
|
54
|
+
dense: true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
MuiOutlinedInput: {
|
|
58
|
+
defaultProps: {
|
|
59
|
+
margin: 'dense'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
MuiFab: {
|
|
63
|
+
defaultProps: {
|
|
64
|
+
size: 'small'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
MuiTable: {
|
|
68
|
+
defaultProps: {
|
|
69
|
+
size: 'small'
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
MuiTextField: {
|
|
73
|
+
defaultProps: {
|
|
74
|
+
margin: 'dense'
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
MuiToolbar: {
|
|
78
|
+
defaultProps: {
|
|
79
|
+
variant: 'dense'
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export const DispatchContext = /*#__PURE__*/React.createContext(() => {
|
|
85
|
+
throw new Error('Forgot to wrap component in `ThemeProvider`');
|
|
86
|
+
});
|
|
87
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
88
|
+
DispatchContext.displayName = 'ThemeDispatchContext';
|
|
89
|
+
}
|
|
90
|
+
export const ThemeOptionsContext = /*#__PURE__*/React.createContext(themeInitialOptions);
|
|
91
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
92
|
+
ThemeOptionsContext.displayName = 'ThemeOptionsContext';
|
|
93
|
+
}
|
|
94
|
+
export function ThemeProvider(props) {
|
|
95
|
+
const {
|
|
96
|
+
children
|
|
97
|
+
} = props;
|
|
98
|
+
const [themeOptions, dispatch] = React.useReducer((state, action) => {
|
|
99
|
+
switch (action.type) {
|
|
100
|
+
case 'SET_DENSE':
|
|
101
|
+
return {
|
|
102
|
+
...state,
|
|
103
|
+
dense: action.payload
|
|
104
|
+
};
|
|
105
|
+
case 'RESET_DENSITY':
|
|
106
|
+
return {
|
|
107
|
+
...state,
|
|
108
|
+
dense: themeInitialOptions.dense
|
|
109
|
+
};
|
|
110
|
+
case 'CHANGE':
|
|
111
|
+
// No value changed
|
|
112
|
+
if ((!action.payload.paletteMode || action.payload.paletteMode === state.paletteMode) && (!action.payload.direction || action.payload.direction === state.direction)) {
|
|
113
|
+
return state;
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
...state,
|
|
117
|
+
paletteMode: action.payload.paletteMode || state.paletteMode,
|
|
118
|
+
direction: action.payload.direction || state.direction
|
|
119
|
+
};
|
|
120
|
+
default:
|
|
121
|
+
throw new Error(`Unrecognized type ${action.type}`);
|
|
122
|
+
}
|
|
123
|
+
}, themeInitialOptions);
|
|
124
|
+
const {
|
|
125
|
+
direction,
|
|
126
|
+
paletteMode
|
|
127
|
+
} = themeOptions;
|
|
128
|
+
useLazyCSS('/static/styles/prism-okaidia.css', '#prismjs');
|
|
129
|
+
|
|
130
|
+
// TODO replace with useColorScheme once all pages support css vars
|
|
131
|
+
const {
|
|
132
|
+
mode,
|
|
133
|
+
systemMode
|
|
134
|
+
} = useColorSchemeShim();
|
|
135
|
+
const calculatedMode = mode === 'system' ? systemMode : mode;
|
|
136
|
+
useEnhancedEffect(() => {
|
|
137
|
+
dispatch({
|
|
138
|
+
type: 'CHANGE',
|
|
139
|
+
payload: {
|
|
140
|
+
paletteMode: calculatedMode
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}, [calculatedMode]);
|
|
144
|
+
useEnhancedEffect(() => {
|
|
145
|
+
document.body.setAttribute('dir', direction);
|
|
146
|
+
}, [direction]);
|
|
147
|
+
useEnhancedEffect(() => {
|
|
148
|
+
// To support light and dark mode images in the docs
|
|
149
|
+
if (paletteMode === 'dark') {
|
|
150
|
+
document.body.classList.remove('mode-light');
|
|
151
|
+
document.body.classList.add('mode-dark');
|
|
152
|
+
} else {
|
|
153
|
+
document.body.classList.remove('mode-dark');
|
|
154
|
+
document.body.classList.add('mode-light');
|
|
155
|
+
}
|
|
156
|
+
const metas = document.querySelectorAll('meta[name="theme-color"]');
|
|
157
|
+
metas.forEach(meta => {
|
|
158
|
+
meta.setAttribute('content', getMetaThemeColor(paletteMode));
|
|
159
|
+
});
|
|
160
|
+
}, [paletteMode]);
|
|
161
|
+
React.useEffect(() => {
|
|
162
|
+
// Expose the theme as a global variable so people can play with it.
|
|
163
|
+
window.createTheme = createMdTheme;
|
|
164
|
+
}, []);
|
|
165
|
+
return /*#__PURE__*/_jsx(ThemeOptionsContext.Provider, {
|
|
166
|
+
value: themeOptions,
|
|
167
|
+
children: /*#__PURE__*/_jsx(DispatchContext.Provider, {
|
|
168
|
+
value: dispatch,
|
|
169
|
+
children: children
|
|
170
|
+
})
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = {
|
|
174
|
+
children: PropTypes.node
|
|
175
|
+
} : void 0;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @returns {(nextOptions: Partial<typeof themeInitialOptions>) => void}
|
|
179
|
+
*/
|
|
180
|
+
export function useChangeTheme() {
|
|
181
|
+
const dispatch = React.useContext(DispatchContext);
|
|
182
|
+
return React.useCallback(options => dispatch({
|
|
183
|
+
type: 'CHANGE',
|
|
184
|
+
payload: options
|
|
185
|
+
}), [dispatch]);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// TODO: remove once all pages support css vars and replace call sites with useColorScheme()
|
|
189
|
+
export function useColorSchemeShim() {
|
|
190
|
+
const [mode, setMode] = useLocalStorageState('mui-mode', 'system');
|
|
191
|
+
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)', {
|
|
192
|
+
noSsr: true
|
|
193
|
+
});
|
|
194
|
+
const systemMode = prefersDarkMode ? 'dark' : 'light';
|
|
195
|
+
return {
|
|
196
|
+
mode,
|
|
197
|
+
systemMode,
|
|
198
|
+
setMode
|
|
199
|
+
};
|
|
200
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ThemeProvider, ThemeOptionsContext, DispatchContext, highDensity, useChangeTheme, useColorSchemeShim } from "./ThemeContext.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ThemeProvider, ThemeOptionsContext, DispatchContext, highDensity, useChangeTheme, useColorSchemeShim } from "./ThemeContext.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DispatchContext", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _ThemeContext.DispatchContext;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "ThemeOptionsContext", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _ThemeContext.ThemeOptionsContext;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ThemeProvider", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _ThemeContext.ThemeProvider;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "highDensity", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _ThemeContext.highDensity;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "useChangeTheme", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _ThemeContext.useChangeTheme;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "useColorSchemeShim", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _ThemeContext.useColorSchemeShim;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _ThemeContext = require("./ThemeContext");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ThemeProvider, ThemeOptionsContext, DispatchContext, highDensity, useChangeTheme, useColorSchemeShim } from "./ThemeContext.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/docs",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.2",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "MUI Docs - Documentation building blocks.",
|
|
6
6
|
"keywords": [
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"@babel/runtime": "^7.28.6",
|
|
25
25
|
"clipboard-copy": "^4.0.1",
|
|
26
26
|
"clsx": "^2.1.1",
|
|
27
|
+
"fg-loadcss": "^3.1.0",
|
|
27
28
|
"nprogress": "^0.2.0",
|
|
28
29
|
"prop-types": "^15.8.1",
|
|
29
30
|
"@mui/internal-markdown": "^3.0.2"
|
|
@@ -33,6 +34,7 @@
|
|
|
33
34
|
"@mui/icons-material": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^7.0.0-beta",
|
|
34
35
|
"@mui/material": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^7.0.0-beta",
|
|
35
36
|
"@mui/system": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^7.0.0-beta",
|
|
37
|
+
"@mui/utils": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^7.0.0-beta",
|
|
36
38
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
37
39
|
"chai": "^6.0.1",
|
|
38
40
|
"csstype": "^3.1.3",
|
|
@@ -165,6 +167,20 @@
|
|
|
165
167
|
"default": "./HighlightedCodeWithTabs/index.mjs"
|
|
166
168
|
}
|
|
167
169
|
},
|
|
170
|
+
"./IconImage": {
|
|
171
|
+
"import": {
|
|
172
|
+
"types": "./IconImage/index.d.mts",
|
|
173
|
+
"default": "./IconImage/index.mjs"
|
|
174
|
+
},
|
|
175
|
+
"require": {
|
|
176
|
+
"types": "./IconImage/index.d.ts",
|
|
177
|
+
"default": "./IconImage/index.js"
|
|
178
|
+
},
|
|
179
|
+
"default": {
|
|
180
|
+
"types": "./IconImage/index.d.mts",
|
|
181
|
+
"default": "./IconImage/index.mjs"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
168
184
|
"./InfoCard": {
|
|
169
185
|
"import": {
|
|
170
186
|
"types": "./InfoCard/index.d.mts",
|
|
@@ -207,6 +223,34 @@
|
|
|
207
223
|
"default": "./MarkdownElement/index.mjs"
|
|
208
224
|
}
|
|
209
225
|
},
|
|
226
|
+
"./SectionHeadline": {
|
|
227
|
+
"import": {
|
|
228
|
+
"types": "./SectionHeadline/index.d.mts",
|
|
229
|
+
"default": "./SectionHeadline/index.mjs"
|
|
230
|
+
},
|
|
231
|
+
"require": {
|
|
232
|
+
"types": "./SectionHeadline/index.d.ts",
|
|
233
|
+
"default": "./SectionHeadline/index.js"
|
|
234
|
+
},
|
|
235
|
+
"default": {
|
|
236
|
+
"types": "./SectionHeadline/index.d.mts",
|
|
237
|
+
"default": "./SectionHeadline/index.mjs"
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
"./ThemeContext": {
|
|
241
|
+
"import": {
|
|
242
|
+
"types": "./ThemeContext/index.d.mts",
|
|
243
|
+
"default": "./ThemeContext/index.mjs"
|
|
244
|
+
},
|
|
245
|
+
"require": {
|
|
246
|
+
"types": "./ThemeContext/index.d.ts",
|
|
247
|
+
"default": "./ThemeContext/index.js"
|
|
248
|
+
},
|
|
249
|
+
"default": {
|
|
250
|
+
"types": "./ThemeContext/index.d.mts",
|
|
251
|
+
"default": "./ThemeContext/index.mjs"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
210
254
|
"./branding": {
|
|
211
255
|
"import": {
|
|
212
256
|
"types": "./branding/index.d.mts",
|
|
@@ -262,6 +306,20 @@
|
|
|
262
306
|
"types": "./translations/index.d.mts",
|
|
263
307
|
"default": "./translations/index.mjs"
|
|
264
308
|
}
|
|
309
|
+
},
|
|
310
|
+
"./useLazyCSS": {
|
|
311
|
+
"import": {
|
|
312
|
+
"types": "./useLazyCSS/index.d.mts",
|
|
313
|
+
"default": "./useLazyCSS/index.mjs"
|
|
314
|
+
},
|
|
315
|
+
"require": {
|
|
316
|
+
"types": "./useLazyCSS/index.d.ts",
|
|
317
|
+
"default": "./useLazyCSS/index.js"
|
|
318
|
+
},
|
|
319
|
+
"default": {
|
|
320
|
+
"types": "./useLazyCSS/index.d.mts",
|
|
321
|
+
"default": "./useLazyCSS/index.mjs"
|
|
322
|
+
}
|
|
265
323
|
}
|
|
266
324
|
}
|
|
267
325
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./useLazyCSS.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./useLazyCSS.js";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "default", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _useLazyCSS.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _useLazyCSS = _interopRequireDefault(require("./useLazyCSS"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./useLazyCSS.mjs";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced lazy CSS loader that wraps CSS in a layer using fetch to avoid CORS issues
|
|
3
|
+
* @param {string} href - URL of the CSS file to load
|
|
4
|
+
* @param {string} before - CSS selector to insert before
|
|
5
|
+
* @param {object} options - Additional options
|
|
6
|
+
* @param {string} options.layer - Optional CSS layer name to wrap the CSS in
|
|
7
|
+
* @returns {() => void} cleanup function
|
|
8
|
+
*/
|
|
9
|
+
export default function useLazyCSS(href: string, before: string, options?: {
|
|
10
|
+
layer?: string;
|
|
11
|
+
}): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enhanced lazy CSS loader that wraps CSS in a layer using fetch to avoid CORS issues
|
|
3
|
+
* @param {string} href - URL of the CSS file to load
|
|
4
|
+
* @param {string} before - CSS selector to insert before
|
|
5
|
+
* @param {object} options - Additional options
|
|
6
|
+
* @param {string} options.layer - Optional CSS layer name to wrap the CSS in
|
|
7
|
+
* @returns {() => void} cleanup function
|
|
8
|
+
*/
|
|
9
|
+
export default function useLazyCSS(href: string, before: string, options?: {
|
|
10
|
+
layer?: string;
|
|
11
|
+
}): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = useLazyCSS;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _fgLoadcss = require("fg-loadcss");
|
|
10
|
+
/**
|
|
11
|
+
* Enhanced lazy CSS loader that wraps CSS in a layer using fetch to avoid CORS issues
|
|
12
|
+
* @param {string} href - URL of the CSS file to load
|
|
13
|
+
* @param {string} before - CSS selector to insert before
|
|
14
|
+
* @param {object} options - Additional options
|
|
15
|
+
* @param {string} options.layer - Optional CSS layer name to wrap the CSS in
|
|
16
|
+
* @returns {() => void} cleanup function
|
|
17
|
+
*/
|
|
18
|
+
function useLazyCSS(href, before, options = {}) {
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
// If no layer is specified, add style and clean it on unmount
|
|
21
|
+
if (!options.layer) {
|
|
22
|
+
const link = (0, _fgLoadcss.loadCSS)(href, document.querySelector(before));
|
|
23
|
+
return () => {
|
|
24
|
+
link.parentElement?.removeChild(link);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// With layer option, we need to fetch the CSS content and wrap it
|
|
29
|
+
let styleElement = null;
|
|
30
|
+
const abortController = new AbortController();
|
|
31
|
+
|
|
32
|
+
// Fetch the CSS content directly to avoid CORS issues with cssRules
|
|
33
|
+
fetch(href, {
|
|
34
|
+
signal: abortController.signal
|
|
35
|
+
}).then(response => {
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
throw new Error(`Failed to fetch CSS: ${response.statusText}`);
|
|
38
|
+
}
|
|
39
|
+
return response.text();
|
|
40
|
+
}).then(cssText => {
|
|
41
|
+
// Create a style element with the CSS wrapped in the specified layer
|
|
42
|
+
styleElement = document.createElement('style');
|
|
43
|
+
styleElement.setAttribute('data-href', href);
|
|
44
|
+
styleElement.textContent = `@layer ${options.layer} {\n${cssText}\n}`;
|
|
45
|
+
|
|
46
|
+
// Insert at the specified position
|
|
47
|
+
const beforeElement = document.querySelector(before);
|
|
48
|
+
if (beforeElement?.parentNode) {
|
|
49
|
+
beforeElement.parentNode.insertBefore(styleElement, beforeElement);
|
|
50
|
+
} else {
|
|
51
|
+
document.head.appendChild(styleElement);
|
|
52
|
+
}
|
|
53
|
+
}).catch(error => {
|
|
54
|
+
// Ignore abort errors, log others
|
|
55
|
+
if (error !== 'useEffect' && error.name !== 'AbortError') {
|
|
56
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
57
|
+
console.error('Error loading CSS with layer:', error);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Fall back to regular link element if fetch fails
|
|
61
|
+
styleElement = (0, _fgLoadcss.loadCSS)(href, document.querySelector(before));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Cleanup function
|
|
66
|
+
return () => {
|
|
67
|
+
// Cancel any pending fetch
|
|
68
|
+
abortController.abort('useEffect');
|
|
69
|
+
|
|
70
|
+
// Remove the style element if it was created
|
|
71
|
+
if (styleElement && styleElement.parentElement) {
|
|
72
|
+
styleElement.parentElement.removeChild(styleElement);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}, [href, before, options.layer]);
|
|
76
|
+
}
|