@mui/codemod 5.8.7 → 5.9.3

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/codemod.js CHANGED
File without changes
@@ -5,13 +5,19 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = transformer;
7
7
 
8
+ /* eslint-disable no-template-curly-in-string */
9
+
8
10
  /**
9
11
  * @param {import('jscodeshift').FileInfo} file
10
12
  */
11
13
  function transformer(file) {
12
- return file.source // `${theme.spacing(2)}px` -> theme.spacing(2)
13
- .replace(/`(-?)\${(-?)(theme\.spacing|spacing)\(([^{}]*)\)}px`/gm, '$3($1$2$4)') // `${theme.spacing(2)}px ${theme.spacing(4)}px` -> `${theme.spacing(2)} ${theme.spacing(4)}`
14
- .replace(/(?<={(theme\.spacing|spacing)\([^]*.*[^]*\)})px/gm, '').replace(/((theme\.spacing|spacing)\(.*\))\s*\+\s*'px'/gm, '$1').replace(/\${(theme.spacing|spacing)(\(.*\))\s*([+-])\s*([\d.]+)\s*}px/gm, // eslint-disable-next-line no-template-curly-in-string
15
- 'calc(${$1$2} $3 $4px)').replace(/\${(theme.spacing|spacing)(\(.*\))\s*([*/])\s*([\d.]+)\s*}px/gm, // eslint-disable-next-line no-template-curly-in-string
16
- 'calc(${$1$2} $3 $4)');
14
+ return file.source.replace( // handle cases like: `-${theme.spacing(1)}px`
15
+ /`(-?)\${(-?)(theme\.spacing|spacing)\(([^{}]*)\)}px`/gm, '$3($1$2$4)').replace( // handle cases like: theme.spacing(gap) + 'px'
16
+ /((theme\.spacing|spacing)\(.*\))\s*\+\s*'px'/gm, '$1').replace( // handle cases like: theme.spacing(gap) + "px"
17
+ /((theme\.spacing|spacing)\(.*\))\s*\+\s*"px"/gm, '$1').replace( // handle cases like: `calc(${theme.spacing(2)} - 1px) 0`
18
+ /\${(theme\.spacing|spacing)(\([^)]+\))\s*([+-])\s*([\d.]+)\s*}px/gm, 'calc(${$1$2} $3 $4px)').replace( // handle cases like: calc(${theme.spacing(itemHorzPadding)} * 0.3)
19
+ /\${(theme\.spacing|spacing)(\([^)]+\))\s*([*/])\s*([\d.]+)\s*}px/gm, 'calc(${$1$2} $3 $4)').replace( // handle common cases like:
20
+ // `${theme.spacing(2)}px`
21
+ // `${theme.spacing(2)}px ${theme.spacing(1)}px ${theme.spacing(2)}px ${theme.spacing(2)}px`
22
+ /(spacing\([^)]+\)\})px(.)/gm, '$1$2');
17
23
  }
@@ -2,6 +2,8 @@
2
2
 
3
3
  `${theme.spacing(2)}px``${spacing(2)}px``${theme.spacing(1 / 2)}px``${theme.spacing(0.5)}px``${theme.spacing(1 / 2)}px ${theme.spacing(4)}px`;
4
4
  theme.spacing(gap) + 'px';
5
- spacing(gap) + 'px'`calc(100% - ${spacing(itemHorzPadding * 2)}px)``calc(100% - ${theme.spacing(itemHorzPadding * 2)}px)`;
5
+ spacing(gap) + 'px';
6
+ theme.spacing(gap) + "px";
7
+ spacing(gap) + "px"`calc(100% - ${spacing(itemHorzPadding * 2)}px)``calc(100% - ${theme.spacing(itemHorzPadding * 2)}px)`;
6
8
 
7
9
  padding: `${theme.spacing(2) - 1}px 0``calc(100% - ${theme.spacing(itemHorzPadding) * 0.3}px)``${-theme.spacing(1)}px``-${theme.spacing(1)}px``${theme.spacing(2)}px ${theme.spacing(1)}px ${theme.spacing(2)}px ${theme.spacing(2)}px`;
@@ -5,6 +5,8 @@ spacing(2);
5
5
  theme.spacing(1 / 2);
6
6
  theme.spacing(0.5)`${theme.spacing(1 / 2)} ${theme.spacing(4)}`;
7
7
  theme.spacing(gap);
8
+ spacing(gap);
9
+ theme.spacing(gap);
8
10
  spacing(gap)`calc(100% - ${spacing(itemHorzPadding * 2)})``calc(100% - ${theme.spacing(itemHorzPadding * 2)})`;
9
11
 
10
12
  padding: `calc(${theme.spacing(2)} - 1px) 0``calc(100% - calc(${theme.spacing(itemHorzPadding)} * 0.3))`;
@@ -0,0 +1,606 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = AppSearch;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var React = _interopRequireWildcard(require("react"));
13
+
14
+ var _reactDom = require("react-dom");
15
+
16
+ var _helpers = require("docs/src/modules/utils/helpers");
17
+
18
+ var _server = _interopRequireDefault(require("react-dom/server"));
19
+
20
+ var _propTypes = _interopRequireDefault(require("prop-types"));
21
+
22
+ var _link = _interopRequireDefault(require("next/link"));
23
+
24
+ var _router = require("next/router");
25
+
26
+ var _react2 = require("@docsearch/react");
27
+
28
+ var _Chip = _interopRequireDefault(require("@mui/material/Chip"));
29
+
30
+ var _ArticleRounded = _interopRequireDefault(require("@mui/icons-material/ArticleRounded"));
31
+
32
+ var _ToggleOffRounded = _interopRequireDefault(require("@mui/icons-material/ToggleOffRounded"));
33
+
34
+ var _EditRounded = _interopRequireDefault(require("@mui/icons-material/EditRounded"));
35
+
36
+ var _HandymanRounded = _interopRequireDefault(require("@mui/icons-material/HandymanRounded"));
37
+
38
+ var _KeyboardArrowRightRounded = _interopRequireDefault(require("@mui/icons-material/KeyboardArrowRightRounded"));
39
+
40
+ var _Search = _interopRequireDefault(require("@mui/icons-material/Search"));
41
+
42
+ var _GlobalStyles = _interopRequireDefault(require("@mui/material/GlobalStyles"));
43
+
44
+ var _styles = require("@mui/material/styles");
45
+
46
+ var _constants = require("docs/src/modules/constants");
47
+
48
+ var _Link = _interopRequireDefault(require("docs/src/modules/components/Link"));
49
+
50
+ var _i18n = require("docs/src/modules/utils/i18n");
51
+
52
+ var _useLazyCSS = _interopRequireDefault(require("docs/src/modules/utils/useLazyCSS"));
53
+
54
+ var _getUrlProduct = _interopRequireDefault(require("docs/src/modules/utils/getUrlProduct"));
55
+
56
+ var _jsxRuntime = require("react/jsx-runtime");
57
+
58
+ var _ArticleRoundedIcon, _ToggleOffRoundedIcon, _EditRoundedIcon, _HandymanRoundedIcon, _KeyboardArrowRightRo, _NewStartScreen;
59
+
60
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
61
+
62
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
63
+
64
+ const SearchButton = (0, _styles.styled)('button')(({
65
+ theme
66
+ }) => {
67
+ return {
68
+ minHeight: 34,
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ paddingLeft: `${theme.spacing(1)}px`,
72
+ [theme.breakpoints.only('xs')]: {
73
+ backgroundColor: 'transparent',
74
+ padding: 0,
75
+ minWidth: 34,
76
+ justifyContent: 'center',
77
+ '& > *:not(.MuiSvgIcon-root)': {
78
+ display: 'none'
79
+ }
80
+ },
81
+ [theme.breakpoints.up('sm')]: {
82
+ minWidth: 200
83
+ },
84
+ fontFamily: theme.typography.fontFamily,
85
+ position: 'relative',
86
+ backgroundColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[900] : theme.palette.grey[50],
87
+ color: theme.palette.text.secondary,
88
+ fontSize: theme.typography.pxToRem(14),
89
+ border: `1px solid ${theme.palette.mode === 'dark' ? theme.palette.primaryDark[700] : theme.palette.grey[200]}`,
90
+ borderRadius: 10,
91
+ cursor: 'pointer',
92
+ transitionProperty: 'all',
93
+ transitionDuration: '150ms',
94
+ '&:hover': {
95
+ background: theme.palette.mode === 'dark' ? (0, _styles.alpha)(theme.palette.primaryDark[700], 0.4) : (0, _styles.alpha)(theme.palette.grey[100], 0.7),
96
+ borderColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[600] : theme.palette.grey[300]
97
+ }
98
+ };
99
+ });
100
+ const SearchLabel = (0, _styles.styled)('span')(({
101
+ theme
102
+ }) => {
103
+ return {
104
+ marginLeft: `${theme.spacing(1)}px`,
105
+ marginRight: 'auto'
106
+ };
107
+ });
108
+ const Shortcut = (0, _styles.styled)('div')(({
109
+ theme
110
+ }) => {
111
+ return {
112
+ fontSize: theme.typography.pxToRem(12),
113
+ fontWeight: 700,
114
+ lineHeight: '20px',
115
+ marginLeft: `${theme.spacing(0.5)}px`,
116
+ border: `1px solid ${theme.palette.mode === 'dark' ? theme.palette.primaryDark[500] : theme.palette.grey[200]}`,
117
+ backgroundColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[800] : '#FFF',
118
+ padding: `${theme.spacing(0, 0.8)}px`,
119
+ borderRadius: 5
120
+ };
121
+ });
122
+
123
+ const NewStartScreen = () => {
124
+ const startScreenOptions = [{
125
+ category: {
126
+ name: 'Getting started',
127
+ icon: _ArticleRoundedIcon || (_ArticleRoundedIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArticleRounded.default, {
128
+ className: "DocSearch-NewStartScreenTitleIcon"
129
+ }))
130
+ },
131
+ items: [{
132
+ name: 'Installation',
133
+ href: '/material-ui/getting-started/installation/'
134
+ }, {
135
+ name: 'Usage',
136
+ href: '/material-ui/getting-started/usage/'
137
+ }, {
138
+ name: 'Learn',
139
+ href: '/material-ui/getting-started/learn/'
140
+ }]
141
+ }, {
142
+ category: {
143
+ name: 'Popular searches',
144
+ icon: _ToggleOffRoundedIcon || (_ToggleOffRoundedIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleOffRounded.default, {
145
+ className: "DocSearch-NewStartScreenTitleIcon"
146
+ }))
147
+ },
148
+ items: [{
149
+ name: 'Material Icons',
150
+ href: '/material-ui/material-icons/'
151
+ }, {
152
+ name: 'Text field',
153
+ href: '/material-ui/react-text-field/'
154
+ }, {
155
+ name: 'Button',
156
+ href: '/material-ui/react-button/'
157
+ }]
158
+ }, {
159
+ category: {
160
+ name: 'Customization',
161
+ icon: _EditRoundedIcon || (_EditRoundedIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditRounded.default, {
162
+ className: "DocSearch-NewStartScreenTitleIcon"
163
+ }))
164
+ },
165
+ items: [{
166
+ name: 'How to customize',
167
+ href: '/material-ui/customization/how-to-customize/'
168
+ }, {
169
+ name: 'Theming',
170
+ href: '/material-ui/customization/theming/'
171
+ }, {
172
+ name: 'Default Theme',
173
+ href: '/material-ui/customization/default-theme/'
174
+ }]
175
+ }, {
176
+ category: {
177
+ name: 'System',
178
+ icon: _HandymanRoundedIcon || (_HandymanRoundedIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_HandymanRounded.default, {
179
+ className: "DocSearch-NewStartScreenTitleIcon"
180
+ }))
181
+ },
182
+ items: [{
183
+ name: 'Basics',
184
+ href: '/system/basics/'
185
+ }, {
186
+ name: 'Properties',
187
+ href: '/system/properties/'
188
+ }, {
189
+ name: 'The sx prop',
190
+ href: '/system/the-sx-prop/'
191
+ }]
192
+ }];
193
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
194
+ className: "DocSearch-NewStartScreen",
195
+ children: startScreenOptions.map(({
196
+ category,
197
+ items
198
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
199
+ className: "DocSearch-NewStartScreenCategory",
200
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
201
+ className: "DocSearch-NewStartScreenTitle",
202
+ children: [category.icon, category.name]
203
+ }), items.map(({
204
+ name,
205
+ href
206
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_link.default, {
207
+ href: href,
208
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("a", {
209
+ href: href,
210
+ className: "DocSearch-NewStartScreenItem",
211
+ children: [name, _KeyboardArrowRightRo || (_KeyboardArrowRightRo = /*#__PURE__*/(0, _jsxRuntime.jsx)(_KeyboardArrowRightRounded.default, {
212
+ className: "DocSearch-NewStartScreenItemIcon"
213
+ }))]
214
+ })
215
+ }, name))]
216
+ }, category.name))
217
+ });
218
+ };
219
+
220
+ function DocSearcHit(props) {
221
+ const {
222
+ children,
223
+ hit
224
+ } = props;
225
+
226
+ function displayTag(pathname) {
227
+ // does not need to show product label for MUI X because they are grouped by the product name in the search
228
+ // ie. Data Grid, Date Picker
229
+ if (!pathname.match(/^\/(material-ui|joy-ui|base)\//)) {
230
+ return null;
231
+ }
232
+
233
+ let text = '';
234
+
235
+ if (pathname.startsWith('/material-ui/')) {
236
+ text = 'Material UI';
237
+ }
238
+
239
+ if (pathname.startsWith('/joy-ui/')) {
240
+ text = 'Joy UI';
241
+ }
242
+
243
+ if (pathname.startsWith('/base/')) {
244
+ text = 'MUI Base';
245
+ }
246
+
247
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Chip.default, {
248
+ label: text,
249
+ size: "small",
250
+ variant: "outlined",
251
+ sx: {
252
+ mr: 1
253
+ }
254
+ });
255
+ }
256
+
257
+ if (hit.pathname) {
258
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Link.default, {
259
+ href: hit.pathname,
260
+ as: hit.as,
261
+ sx: {
262
+ display: 'flex !important',
263
+ '& .DocSearch-Hit-Container': {
264
+ flex: 1,
265
+ minWidth: 0
266
+ }
267
+ },
268
+ children: [children, displayTag(hit.pathname)]
269
+ });
270
+ } // DocSearch stores the old results in its cache
271
+ // hit.pathname won't be defined for them.
272
+
273
+
274
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Link.default, {
275
+ href: hit.url,
276
+ children: children
277
+ });
278
+ }
279
+
280
+ process.env.NODE_ENV !== "production" ? DocSearcHit.propTypes = {
281
+ children: _propTypes.default.node,
282
+ hit: _propTypes.default.object.isRequired
283
+ } : void 0;
284
+
285
+ function AppSearch() {
286
+ (0, _useLazyCSS.default)('https://cdn.jsdelivr.net/npm/@docsearch/css@3.0.0-alpha.40/dist/style.min.css', '#app-search');
287
+ const FADE_DURATION = 100; // ms
288
+
289
+ const t = (0, _i18n.useTranslate)();
290
+ const userLanguage = (0, _i18n.useUserLanguage)();
291
+ const searchButtonRef = React.useRef(null);
292
+ const [isOpen, setIsOpen] = React.useState(false);
293
+ const [initialQuery, setInitialQuery] = React.useState(undefined);
294
+ const facetFilterLanguage = _constants.LANGUAGES_SSR.indexOf(userLanguage) !== -1 ? `language:${userLanguage}` : `language:en`;
295
+ const macOS = window.navigator.platform.toUpperCase().indexOf('MAC') >= 0;
296
+ const onOpen = React.useCallback(() => {
297
+ setIsOpen(true);
298
+ }, [setIsOpen]);
299
+ const router = (0, _router.useRouter)();
300
+ const productSpace = (0, _getUrlProduct.default)(router.asPath);
301
+ const keyboardNavigator = {
302
+ navigate({
303
+ item
304
+ }) {
305
+ const as = item.userLanguage !== 'en' ? `/${item.userLanguage}${item.as}` : item.as;
306
+ router.push(item.pathname, as);
307
+ }
308
+
309
+ };
310
+ const onClose = React.useCallback(() => {
311
+ const modal = document.querySelector('.DocSearch-Container');
312
+
313
+ if (modal) {
314
+ // fade out transition
315
+ modal.style.opacity = 0;
316
+ }
317
+
318
+ setIsOpen(false); // DO NOT call setIsOpen inside a timeout (it causes scroll issue).
319
+ }, [setIsOpen]);
320
+ const onInput = React.useCallback(event => {
321
+ setIsOpen(true);
322
+ setInitialQuery(event.key);
323
+ }, [setIsOpen, setInitialQuery]);
324
+ (0, _react2.useDocSearchKeyboardEvents)({
325
+ isOpen,
326
+ onOpen,
327
+ onClose,
328
+ onInput,
329
+ searchButtonRef
330
+ });
331
+ React.useEffect(() => {
332
+ const addStartScreen = () => {
333
+ const dropDown = document.querySelector('.DocSearch-Dropdown');
334
+ const isExisting = document.querySelector('.DocSearch-NewStartScreen');
335
+
336
+ if (dropDown && !isExisting) {
337
+ dropDown.insertAdjacentHTML('beforeend', _server.default.renderToStaticMarkup(_NewStartScreen || (_NewStartScreen = /*#__PURE__*/(0, _jsxRuntime.jsx)(NewStartScreen, {}))));
338
+ }
339
+ }; // add transition to Modal
340
+
341
+
342
+ if (isOpen) {
343
+ const modal = document.querySelector('.DocSearch-Container');
344
+ const searchInput = document.querySelector('.DocSearch-Input');
345
+
346
+ if (modal) {
347
+ modal.style.opacity = 1;
348
+ addStartScreen();
349
+ }
350
+
351
+ if (searchInput) {
352
+ const handleInput = event => {
353
+ const newStartScreen = document.querySelector('.DocSearch-NewStartScreen');
354
+
355
+ if (newStartScreen) {
356
+ newStartScreen.style.display = event.target.value !== '' ? 'none' : 'grid';
357
+ }
358
+ };
359
+
360
+ searchInput.addEventListener('input', handleInput);
361
+ return () => {
362
+ searchInput.removeEventListener('input', handleInput);
363
+ };
364
+ }
365
+ }
366
+
367
+ return () => {};
368
+ }, [isOpen]);
369
+ const search = `${t('algoliaSearch')}…`;
370
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
371
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(SearchButton, {
372
+ ref: searchButtonRef,
373
+ onClick: onOpen,
374
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Search.default, {
375
+ fontSize: "small",
376
+ sx: {
377
+ color: theme => theme.palette.mode === 'dark' ? theme.palette.primary[300] : theme.palette.primary[500]
378
+ }
379
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(SearchLabel, {
380
+ children: search
381
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(Shortcut, {
382
+ children: [macOS ? '⌘' : 'Ctrl+', "K"]
383
+ })]
384
+ }), isOpen && /*#__PURE__*/(0, _reactDom.createPortal)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_react2.DocSearchModal, {
385
+ initialQuery: initialQuery,
386
+ appId: 'TZGZ85B9TB',
387
+ apiKey: '8177dfb3e2be72b241ffb8c5abafa899',
388
+ indexName: "material-ui",
389
+ searchParameters: {
390
+ facetFilters: ['version:master', facetFilterLanguage],
391
+ optionalFilters: [`product:${productSpace}`],
392
+ hitsPerPage: 40
393
+ },
394
+ placeholder: search,
395
+ transformItems: items => {
396
+ return items.map(item => {
397
+ // `url` contains the domain
398
+ // but we want to link to the current domain e.g. deploy-preview-1--material-ui.netlify.app
399
+ const parseUrl = document.createElement('a');
400
+ parseUrl.href = item.url;
401
+ const {
402
+ canonicalAs,
403
+ canonicalPathname
404
+ } = (0, _helpers.pathnameToLanguage)(`${parseUrl.pathname}${parseUrl.hash}`);
405
+ return (0, _extends2.default)({}, item, {
406
+ pathname: canonicalPathname,
407
+ as: canonicalAs,
408
+ userLanguage
409
+ });
410
+ });
411
+ },
412
+ hitComponent: DocSearcHit,
413
+ initialScrollY: typeof window !== 'undefined' ? window.scrollY : undefined,
414
+ onClose: onClose,
415
+ navigator: keyboardNavigator
416
+ }), document.body), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GlobalStyles.default, {
417
+ styles: theme => ({
418
+ html: {
419
+ ':root': {
420
+ '--docsearch-primary-color': theme.palette.mode === 'dark' ? theme.palette.primaryDark[300] : theme.palette.primary[500],
421
+ '--docsearch-text-color': theme.palette.text.primary,
422
+ '--docsearch-muted-color': theme.palette.grey[600],
423
+ '--docsearch-searchbox-shadow': 0,
424
+ '--docsearch-hit-shadow': 0,
425
+ '--docsearch-footer-shadow': 0,
426
+ '--docsearch-spacing': `${theme.spacing(1.5)}px`,
427
+ '--docsearch-hit-active-color': theme.palette.mode === 'dark' ? theme.palette.primary[300] : theme.palette.primary[600],
428
+ '--docsearch-logo-color': theme.palette.grey[600],
429
+ '--docsearch-searchbox-focus-background': 'unset',
430
+ '--docsearch-footer-background': 'unset',
431
+ '--docsearch-modal-background': theme.palette.background.paper
432
+ }
433
+ },
434
+ body: {
435
+ '.DocSearch-Container': {
436
+ transition: `opacity ${FADE_DURATION}ms`,
437
+ opacity: 0,
438
+ zIndex: theme.zIndex.tooltip + 100,
439
+ backgroundColor: theme.palette.mode === 'dark' ? (0, _styles.alpha)(theme.palette.grey[900], 0.7) : (0, _styles.alpha)(theme.palette.grey[600], 0.2),
440
+ backdropFilter: 'blur(4px)'
441
+ },
442
+ '& .DocSearch-StartScreen': {
443
+ display: 'none'
444
+ },
445
+ '& .DocSearch-NewStartScreen': {
446
+ display: 'grid',
447
+ gridTemplateColumns: 'repeat(2, 1fr)',
448
+ gap: `${theme.spacing(2)}px`,
449
+ padding: `${theme.spacing(2, 1)}px`
450
+ },
451
+ '& .DocSearch-NewStartScreenCategory': {
452
+ display: 'flex',
453
+ flexDirection: 'column'
454
+ },
455
+ '& .DocSearch-NewStartScreenTitle': {
456
+ display: 'flex',
457
+ alignItems: 'center',
458
+ padding: `${theme.spacing(1, 1)}px`,
459
+ fontSize: theme.typography.pxToRem(14),
460
+ color: theme.palette.text.secondary
461
+ },
462
+ '& .DocSearch-NewStartScreenTitleIcon': {
463
+ color: theme.palette.mode === 'dark' ? theme.palette.primaryDark[300] : theme.palette.primary[500],
464
+ marginRight: `${theme.spacing(1.5)}px`,
465
+ fontSize: theme.typography.pxToRem(16)
466
+ },
467
+ '& .DocSearch-NewStartScreenItem': {
468
+ display: 'flex',
469
+ alignItems: 'center',
470
+ cursor: 'pointer',
471
+ width: '100%',
472
+ padding: `${theme.spacing(0.5, 4.6)}px`,
473
+ color: theme.palette.mode === 'dark' ? theme.palette.primaryDark[300] : theme.palette.primary[500],
474
+ fontWeight: 500,
475
+ fontSize: theme.typography.pxToRem(14),
476
+ '&:hover, &:focus': {
477
+ '.DocSearch-NewStartScreenItemIcon': {
478
+ marginLeft: `${theme.spacing(1)}px`
479
+ }
480
+ }
481
+ },
482
+ '& .DocSearch-NewStartScreenItemIcon': {
483
+ marginLeft: `${theme.spacing(0.5)}px`,
484
+ transition: 'margin 0.2s',
485
+ fontSize: theme.typography.pxToRem(16)
486
+ },
487
+ '& .DocSearch-Modal': (0, _extends2.default)({
488
+ maxWidth: '700px',
489
+ boxShadow: `0px 4px 20px ${theme.palette.mode === 'dark' ? (0, _styles.alpha)(theme.palette.background.paper, 0.7) : (0, _styles.alpha)(theme.palette.grey[700], 0.2)}`
490
+ }, theme.palette.mode === 'dark' && {
491
+ border: '1px solid',
492
+ borderColor: theme.palette.primaryDark[700]
493
+ }, {
494
+ // docsearch.css: <= 750px will be full screen modal
495
+ borderRadius: `clamp(0px, (100vw - 750px) * 9999, ${theme.shape.borderRadius}px)`
496
+ }),
497
+ '& .DocSearch-SearchBar': {
498
+ borderBottom: '1px solid',
499
+ borderColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[700] : theme.palette.grey[200],
500
+ padding: `${theme.spacing(1)}px`
501
+ },
502
+ '& .DocSearch-Form': {
503
+ '& .DocSearch-Reset': {
504
+ display: 'none'
505
+ },
506
+ '& .DocSearch-Input': {
507
+ paddingLeft: `${theme.spacing(2.5)}px`
508
+ },
509
+ '& .DocSearch-Search-Icon': {
510
+ width: '20px',
511
+ height: '20px'
512
+ }
513
+ },
514
+ '& .DocSearch-Cancel': {
515
+ display: 'block',
516
+ alignSelf: 'center',
517
+ height: '1.5rem',
518
+ marginRight: `${theme.spacing(1)}px`,
519
+ padding: `${theme.spacing(0.3, 0.8, 0.6, 0.8)}px`,
520
+ fontSize: 0,
521
+ borderRadius: 5,
522
+ backgroundColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[800] : theme.palette.grey[50],
523
+ border: '1px solid',
524
+ borderColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[600] : theme.palette.grey[300],
525
+ '&::before': {
526
+ content: '"esc"',
527
+ fontSize: theme.typography.pxToRem(12),
528
+ letterSpacing: '.08rem',
529
+ fontWeight: 700,
530
+ color: theme.palette.text.secondary
531
+ }
532
+ },
533
+ '& .DocSearch-Dropdown': {
534
+ minHeight: 384,
535
+ // = StartScreen height, to prevent layout shift when first char
536
+ '&::-webkit-scrollbar-thumb': {
537
+ borderColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[900] : theme.palette.background.paper,
538
+ backgroundColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[700] : theme.palette.grey[500]
539
+ },
540
+ '&::-webkit-scrollbar-track': {
541
+ backgroundColor: theme.palette.background.paper
542
+ }
543
+ },
544
+ '& .DocSearch-Dropdown-Container': {
545
+ '& .DocSearch-Hits:first-of-type': {
546
+ '& .DocSearch-Hit-source': {
547
+ paddingTop: `${theme.spacing(1)}px`
548
+ }
549
+ }
550
+ },
551
+ '& .DocSearch-Hit-source': {
552
+ top: 'initial',
553
+ paddingTop: `${theme.spacing(2)}px`,
554
+ background: theme.palette.background.paper,
555
+ fontSize: theme.typography.pxToRem(13),
556
+ fontWeight: 500,
557
+ color: theme.palette.text.secondary
558
+ },
559
+ '& .DocSearch-Hit': {
560
+ paddingBottom: 0,
561
+ '&:not(:first-of-type)': {
562
+ marginTop: -1
563
+ }
564
+ },
565
+ '& .DocSearch-Hit a': {
566
+ backgroundColor: 'transparent',
567
+ padding: `${theme.spacing(0.25, 0)}px`,
568
+ paddingLeft: `${theme.spacing(2)}px`,
569
+ border: '1px solid transparent',
570
+ borderBottomColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[700] : theme.palette.grey[100]
571
+ },
572
+ '& .DocSearch-Hit-content-wrapper': {
573
+ paddingLeft: `${theme.spacing(2)}px`
574
+ },
575
+ '& .DocSearch-Hit-title': {
576
+ fontSize: theme.typography.pxToRem(14),
577
+ color: `${theme.palette.text.primary}`
578
+ },
579
+ '& .DocSearch-Hit-path': {
580
+ fontSize: theme.typography.pxToRem(12),
581
+ color: `${theme.palette.text.secondary}`
582
+ },
583
+ '& .DocSearch-Hit-Select-Icon': {
584
+ height: '15px',
585
+ width: '15px'
586
+ },
587
+ '& .DocSearch-Hit[aria-selected="true"] a': {
588
+ backgroundColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[800] : theme.palette.primary[50],
589
+ borderColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[400] : theme.palette.primary[500],
590
+ borderRadius: theme.shape.borderRadius
591
+ },
592
+ '& .DocSearch-Hit-action, & .DocSearch-Hits mark': {
593
+ color: `${theme.palette.mode === 'dark' ? theme.palette.primary[400] : theme.palette.primary[500]}`
594
+ },
595
+ '& .DocSearch-Footer': {
596
+ borderTop: '1px solid',
597
+ borderColor: theme.palette.mode === 'dark' ? theme.palette.primaryDark[700] : theme.palette.grey[200],
598
+ '& .DocSearch-Commands': {
599
+ display: 'none'
600
+ }
601
+ }
602
+ }
603
+ })
604
+ })]
605
+ });
606
+ }