@mui/docs 6.0.0-alpha.8 → 6.0.0-beta.0

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.
@@ -8,6 +8,7 @@ exports.MarkdownElement = void 0;
8
8
  var React = _interopRequireWildcard(require("react"));
9
9
  var _clsx = _interopRequireDefault(require("clsx"));
10
10
  var _styles = require("@mui/material/styles");
11
+ var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
11
12
  var _branding = require("../branding");
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -18,8 +19,8 @@ const Root = (0, _styles.styled)('div')(({
18
19
  var _theme$shape$borderRa, _theme$shape, _theme$shape$borderRa2, _theme$shape2, _theme$shape$borderRa3, _theme$shape3;
19
20
  return {
20
21
  ..._branding.brandingLightTheme.typography.body1,
21
- lineHeight: 1.6,
22
- // Increased compared to the 1.5 default to make the docs easier to read.
22
+ lineHeight: 1.625,
23
+ // Rounds up to 26px-increased compared to the 1.5 default to make the docs easier to read.
23
24
  color: `var(--muidocs-palette-text-primary, ${_branding.brandingLightTheme.palette.text.primary})`,
24
25
  '& :focus-visible': {
25
26
  outline: `3px solid ${(0, _styles.alpha)(_branding.brandingLightTheme.palette.primary[500], 0.5)}`,
@@ -34,7 +35,7 @@ const Root = (0, _styles.styled)('div')(({
34
35
  // Developers like when the code is dense.
35
36
  margin: theme.spacing(2, 'auto'),
36
37
  padding: theme.spacing(2),
37
- backgroundColor: 'hsl(210, 35%, 9%)',
38
+ backgroundColor: 'hsl(210, 25%, 9%)',
38
39
  // a special, one-off, color tailored for the code blocks using MUI's branding theme blue palette as the starting point. It has a less saturaded color but still maintaining a bit of the blue tint.
39
40
  color: 'hsl(60, 30%, 96%)',
40
41
  colorScheme: 'dark',
@@ -133,6 +134,44 @@ const Root = (0, _styles.styled)('div')(({
133
134
  marginBottom: 6
134
135
  }
135
136
  },
137
+ '& a[target="_blank"]::after': {
138
+ content: '""',
139
+ maskImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' focusable='false' aria-hidden='true' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z'%3E%3C/path%3E%3C/svg%3E")`,
140
+ display: 'inline-flex',
141
+ width: '1em',
142
+ height: '1em',
143
+ color: 'inherit',
144
+ backgroundColor: 'currentColor',
145
+ transform: 'translate(0, 2px)',
146
+ transition: 'transform 0.3s cubic-bezier(0.1, 0.8, 0.3, 1)',
147
+ // bounce effect
148
+ opacity: 0.8
149
+ },
150
+ '& a[target="_blank"]:hover::after': {
151
+ opacity: 1,
152
+ transform: 'translate(1px, 0)'
153
+ },
154
+ '& a.remove-link-arrow::after': {
155
+ // Allows to remove link arrows for images
156
+ display: 'none'
157
+ },
158
+ '& .Ad-root a::after': {
159
+ // Remove link arrow for ads
160
+ display: 'none'
161
+ },
162
+ '& a': {
163
+ // Style taken from the Link component
164
+ color: `var(--muidocs-palette-primary-600, ${_branding.brandingLightTheme.palette.primary[600]})`,
165
+ fontWeight: theme.typography.fontWeightMedium,
166
+ textDecoration: 'underline',
167
+ textDecorationColor: (0, _styles.alpha)(_branding.brandingLightTheme.palette.primary.main, 0.4),
168
+ '&:hover': {
169
+ textDecorationColor: 'inherit'
170
+ }
171
+ },
172
+ '& a code': {
173
+ color: (0, _styles.darken)(_branding.brandingLightTheme.palette.primary.main, 0.2)
174
+ },
136
175
  '& h1, & h2, & h3, & h4': {
137
176
  display: 'flex',
138
177
  alignItems: 'center',
@@ -146,9 +185,12 @@ const Root = (0, _styles.styled)('div')(({
146
185
  '& .title-link-to-anchor': {
147
186
  color: 'inherit',
148
187
  textDecoration: 'none',
188
+ boxShadow: 'none',
189
+ fontWeight: 'inherit',
149
190
  position: 'relative',
150
191
  display: 'flex',
151
- alignItems: 'center'
192
+ alignItems: 'center',
193
+ userSelect: 'text'
152
194
  },
153
195
  '& .anchor-icon': {
154
196
  // To prevent the link to get the focus.
@@ -156,12 +198,6 @@ const Root = (0, _styles.styled)('div')(({
156
198
  alignItems: 'center',
157
199
  visibility: 'hidden'
158
200
  },
159
- '& a:not(.title-link-to-anchor):hover': {
160
- color: 'currentColor',
161
- border: 'none',
162
- boxShadow: '0 1px 0 0 currentColor',
163
- textDecoration: 'none'
164
- },
165
201
  '& .anchor-icon, & .comment-link': {
166
202
  padding: 0,
167
203
  cursor: 'pointer',
@@ -172,11 +208,13 @@ const Root = (0, _styles.styled)('div')(({
172
208
  marginLeft: 8,
173
209
  height: 26,
174
210
  width: 26,
175
- backgroundColor: `var(--muidocs-palette-primary-50, ${_branding.brandingLightTheme.palette.grey[50]})`,
176
211
  color: `var(--muidocs-palette-grey-600, ${_branding.brandingLightTheme.palette.grey[600]})`,
177
- border: '1px solid',
178
- borderColor: `var(--muidocs-palette-divider, ${_branding.brandingLightTheme.palette.divider})`,
212
+ backgroundColor: 'transparent',
213
+ border: '1px solid transparent',
179
214
  borderRadius: 8,
215
+ transition: theme.transitions.create(['visibility', 'background-color', 'color', 'border-color'], {
216
+ duration: theme.transitions.duration.shortest
217
+ }),
180
218
  '&:hover': {
181
219
  backgroundColor: (0, _styles.alpha)(_branding.brandingLightTheme.palette.primary[100], 0.4),
182
220
  borderColor: `var(--muidocs-palette-primary-100, ${_branding.brandingLightTheme.palette.primary[100]})`,
@@ -197,7 +235,7 @@ const Root = (0, _styles.styled)('div')(({
197
235
  display: 'none',
198
236
  // So we can have the comment button opt-in.
199
237
  marginLeft: 'auto',
200
- transition: theme.transitions.create('opacity', {
238
+ transition: theme.transitions.create(['background-color', 'color', 'border-color'], {
201
239
  duration: theme.transitions.duration.shortest
202
240
  }),
203
241
  '& svg': {
@@ -295,44 +333,58 @@ const Root = (0, _styles.styled)('div')(({
295
333
  },
296
334
  '& .MuiCallout-root': {
297
335
  display: 'flex',
298
- gap: 12,
299
- padding: '16px',
336
+ gap: '8px',
337
+ padding: '12px',
300
338
  margin: '16px 0',
301
339
  border: '1px solid',
302
340
  color: `var(--muidocs-palette-text-secondary, ${_branding.brandingLightTheme.palette.text.secondary})`,
303
341
  borderColor: `var(--muidocs-palette-grey-100, ${_branding.brandingLightTheme.palette.grey[100]})`,
304
342
  borderRadius: `var(--muidocs-shape-borderRadius, ${(_theme$shape$borderRa2 = (_theme$shape2 = theme.shape) == null ? void 0 : _theme$shape2.borderRadius) != null ? _theme$shape$borderRa2 : _branding.brandingLightTheme.shape.borderRadius}px)`,
305
- '& > code': {
343
+ '& .MuiCallout-content': {
344
+ minWidth: 0,
345
+ // Allows content to shrink. Useful when callout contains code block
346
+ flexGrow: 1
347
+ },
348
+ '& code': {
306
349
  height: 'fit-content',
307
350
  backgroundColor: `var(--muidocs-palette-grey-100, ${_branding.brandingLightTheme.palette.grey[100]})`,
308
351
  borderColor: `var(--muidocs-palette-grey-300, ${_branding.brandingLightTheme.palette.grey[300]})`
309
352
  },
310
- '& .MuiCallout-content': {
311
- minWidth: 0,
312
- // Allows content to shrink. Useful when callout contains code block
313
- flexGrow: 1,
353
+ '& p': {
354
+ marginBottom: '8px',
314
355
  '& > p:last-child, & > ul:last-child': {
315
356
  // Avoid margin on last child
316
357
  marginBottom: 0
317
358
  },
318
- '& .MuiCode-root': {
319
- '& > pre': {
320
- margin: 0,
321
- marginTop: 4
322
- }
323
- },
324
359
  '& > ul': {
325
360
  // Because of the gap left by the icon, we visually need less padding
326
361
  paddingLeft: 22
327
362
  }
328
363
  },
329
- '& > svg': {
330
- marginTop: 2,
331
- width: 20,
332
- height: 20,
333
- flexShrink: 0
364
+ '& .MuiCode-root': {
365
+ '& pre': {
366
+ margin: '4px 0 0 0',
367
+ borderRadius: '12px 12px 6px 12px',
368
+ borderColor: (0, _styles.alpha)(_branding.brandingLightTheme.palette.primaryDark[600], 0.6),
369
+ '& code': {
370
+ backgroundColor: 'transparent'
371
+ }
372
+ }
373
+ },
374
+ '& .MuiCallout-icon-container': {
375
+ width: 26,
376
+ // to match text's line-height
377
+ height: 26,
378
+ display: 'flex',
379
+ alignItems: 'center',
380
+ justifyContent: 'center',
381
+ flexShrink: 0,
382
+ '& svg': {
383
+ width: 18,
384
+ height: 18
385
+ }
334
386
  },
335
- '& > ul, & > p': {
387
+ '& ul, & p': {
336
388
  '&:last-child': {
337
389
  margin: 0
338
390
  }
@@ -347,7 +399,7 @@ const Root = (0, _styles.styled)('div')(({
347
399
  '& strong': {
348
400
  color: `var(--muidocs-palette-error-800, ${_branding.brandingLightTheme.palette.error[800]})`
349
401
  },
350
- '& > svg': {
402
+ '& svg': {
351
403
  fill: `var(--muidocs-palette-error-500, ${_branding.brandingLightTheme.palette.error[600]})`
352
404
  },
353
405
  '& a': {
@@ -365,7 +417,7 @@ const Root = (0, _styles.styled)('div')(({
365
417
  '& strong': {
366
418
  color: `var(--muidocs-palette-primary-800, ${_branding.brandingLightTheme.palette.primary[800]})`
367
419
  },
368
- '& > svg': {
420
+ '& svg': {
369
421
  fill: `var(--muidocs-palette-grey-600, ${_branding.brandingLightTheme.palette.grey[600]})`
370
422
  }
371
423
  },
@@ -376,7 +428,7 @@ const Root = (0, _styles.styled)('div')(({
376
428
  '& strong': {
377
429
  color: `var(--muidocs-palette-success-900, ${_branding.brandingLightTheme.palette.success[900]})`
378
430
  },
379
- '& > svg': {
431
+ '& svg': {
380
432
  fill: `var(--muidocs-palette-success-600, ${_branding.brandingLightTheme.palette.success[600]})`
381
433
  },
382
434
  '& a': {
@@ -394,7 +446,7 @@ const Root = (0, _styles.styled)('div')(({
394
446
  '& strong': {
395
447
  color: `var(--muidocs-palette-warning-800, ${_branding.brandingLightTheme.palette.warning[800]})`
396
448
  },
397
- '& > svg': {
449
+ '& svg': {
398
450
  fill: `var(--muidocs-palette-warning-600, ${_branding.brandingLightTheme.palette.warning[600]})`
399
451
  },
400
452
  '& a': {
@@ -406,47 +458,6 @@ const Root = (0, _styles.styled)('div')(({
406
458
  }
407
459
  }
408
460
  },
409
- '& a[target="_blank"]::after': {
410
- content: '""',
411
- maskImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' focusable='false' aria-hidden='true' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M6 6v2h8.59L5 17.59 6.41 19 16 9.41V18h2V6z'%3E%3C/path%3E%3C/svg%3E")`,
412
- display: 'inline-flex',
413
- width: '1em',
414
- height: '1em',
415
- color: 'inherit',
416
- backgroundColor: 'currentColor',
417
- transform: 'translate(0, 2px)',
418
- transition: 'transform 0.3s cubic-bezier(0.1, 0.8, 0.3, 1)',
419
- // bounce effect
420
- opacity: 0.8
421
- },
422
- '& a[target="_blank"]:hover::after': {
423
- opacity: 1,
424
- transform: 'translate(1px, 0)'
425
- },
426
- '& a.remove-link-arrow::after': {
427
- // Allows to remove link arrows for images
428
- display: 'none'
429
- },
430
- '& .Ad-root a::after': {
431
- // Remove link arrow for ads
432
- display: 'none'
433
- },
434
- '& a:not(.title-link-to-anchor), & a:not(.title-link-to-anchor) code': {
435
- // Style taken from the Link component
436
- color: `var(--muidocs-palette-primary-600, ${_branding.brandingLightTheme.palette.primary[600]})`,
437
- fontWeight: theme.typography.fontWeightMedium,
438
- textDecoration: 'underline',
439
- textDecorationColor: (0, _styles.alpha)(_branding.brandingLightTheme.palette.primary.main, 0.4),
440
- '&:hover': {
441
- textDecorationColor: 'inherit'
442
- }
443
- },
444
- '& a code': {
445
- color: (0, _styles.darken)(_branding.brandingLightTheme.palette.primary.main, 0.04)
446
- },
447
- '& a:not(.title-link-to-anchor) code': {
448
- color: (0, _styles.darken)(_branding.brandingLightTheme.palette.primary.main, 0.2)
449
- },
450
461
  '& img, & video': {
451
462
  // Use !important so that inline style on <img> or <video> can't win.
452
463
  // This avoid horizontal overflows on mobile.
@@ -550,7 +561,6 @@ const Root = (0, _styles.styled)('div')(({
550
561
  display: 'inline-flex',
551
562
  flexDirection: 'row-reverse',
552
563
  alignItems: 'center',
553
- height: 24,
554
564
  padding: theme.spacing(0.5),
555
565
  paddingBottom: '5px',
556
566
  // optical alignment
@@ -561,7 +571,7 @@ const Root = (0, _styles.styled)('div')(({
561
571
  border: '1px solid',
562
572
  borderColor: (0, _styles.alpha)(_branding.brandingLightTheme.palette.primaryDark[600], 0.5),
563
573
  backgroundColor: (0, _styles.alpha)(_branding.brandingLightTheme.palette.primaryDark[800], 0.5),
564
- color: `var(--muidocs-palette-grey-200, ${_branding.brandingLightTheme.palette.grey[200]})`,
574
+ color: `var(--muidocs-palette-grey-300, ${_branding.brandingLightTheme.palette.grey[300]})`,
565
575
  transition: theme.transitions.create(['background', 'borderColor', 'display'], {
566
576
  duration: theme.transitions.duration.shortest
567
577
  }),
@@ -675,24 +685,26 @@ const Root = (0, _styles.styled)('div')(({
675
685
  '& hr': {
676
686
  backgroundColor: `var(--muidocs-palette-divider, ${_branding.brandingDarkTheme.palette.divider})`
677
687
  },
678
- '& h1, & h2, & h3, & h4, & h5': {
679
- color: `var(--muidocs-palette-grey-50, ${_branding.brandingDarkTheme.palette.grey[50]})`
688
+ '& a': {
689
+ color: `var(--muidocs-palette-primary-300, ${_branding.brandingDarkTheme.palette.primary[300]})`
680
690
  },
681
- '& p, & ul, & ol': {
682
- color: `var(--muidocs-palette-grey-400, ${_branding.brandingDarkTheme.palette.grey[400]})`
691
+ '& a code': {
692
+ color: `var(--muidocs-palette-primary-light, ${_branding.brandingDarkTheme.palette.primary.light})`
683
693
  },
684
- '& h1, & h2, & h3, & h4': {
685
- '&:hover .anchor-icon, & .comment-link': {
686
- color: `var(--muidocs-palette-primary-300, ${_branding.brandingDarkTheme.palette.primaryDark[300]})`,
687
- borderColor: `var(--muidocs-palette-divider, ${_branding.brandingDarkTheme.palette.divider})`,
688
- backgroundColor: (0, _styles.alpha)(_branding.brandingDarkTheme.palette.primaryDark[700], 0.5),
694
+ '& h1, & h2, & h3, & h4, & h5': {
695
+ color: `var(--muidocs-palette-grey-50, ${_branding.brandingDarkTheme.palette.grey[50]})`,
696
+ '& .anchor-icon, & .comment-link': {
697
+ color: `var(--muidocs-palette-primary-300, ${_branding.brandingDarkTheme.palette.primaryDark[400]})`,
689
698
  '&:hover': {
699
+ color: `var(--muidocs-palette-primary-100, ${_branding.brandingDarkTheme.palette.primary[100]})`,
690
700
  borderColor: `var(--muidocs-palette-primary-900, ${_branding.brandingDarkTheme.palette.primary[900]})`,
691
- backgroundColor: (0, _styles.alpha)(_branding.brandingDarkTheme.palette.primary[900], 0.6),
692
- color: `var(--muidocs-palette-primary-100, ${_branding.brandingDarkTheme.palette.primary[100]})`
701
+ backgroundColor: (0, _styles.alpha)(_branding.brandingDarkTheme.palette.primary[900], 0.6)
693
702
  }
694
703
  }
695
704
  },
705
+ '& p, & ul, & ol': {
706
+ color: `var(--muidocs-palette-grey-400, ${_branding.brandingDarkTheme.palette.grey[400]})`
707
+ },
696
708
  '& h1 code, & h2 code, & h3 code': {
697
709
  color: `var(--muidocs-palette-grey-100, ${_branding.brandingDarkTheme.palette.grey[100]})`
698
710
  },
@@ -726,8 +738,7 @@ const Root = (0, _styles.styled)('div')(({
726
738
  },
727
739
  '& .MuiCallout-root': {
728
740
  borderColor: `var(--muidocs-palette-primaryDark-700, ${_branding.brandingDarkTheme.palette.primaryDark[700]})`,
729
- '& > code': {
730
- height: 'fit-content',
741
+ '& code': {
731
742
  backgroundColor: `var(--muidocs-palette-primaryDark-600, ${_branding.brandingDarkTheme.palette.primaryDark[600]})`,
732
743
  borderColor: `var(--muidocs-palette-primaryDark-500, ${_branding.brandingDarkTheme.palette.primaryDark[500]})`
733
744
  },
@@ -738,7 +749,7 @@ const Root = (0, _styles.styled)('div')(({
738
749
  '& strong': {
739
750
  color: `var(--muidocs-palette-error-300, ${_branding.brandingDarkTheme.palette.error[300]})`
740
751
  },
741
- '& > svg': {
752
+ '& svg': {
742
753
  fill: `var(--muidocs-palette-error-500, ${_branding.brandingDarkTheme.palette.error[500]})`
743
754
  },
744
755
  '& a': {
@@ -752,7 +763,7 @@ const Root = (0, _styles.styled)('div')(({
752
763
  '& strong': {
753
764
  color: `var(--muidocs-palette-primary-200, ${_branding.brandingDarkTheme.palette.primary[200]})`
754
765
  },
755
- '& > svg': {
766
+ '& svg': {
756
767
  fill: `var(--muidocs-palette-grey-400, ${_branding.brandingDarkTheme.palette.grey[400]})`
757
768
  }
758
769
  },
@@ -763,7 +774,7 @@ const Root = (0, _styles.styled)('div')(({
763
774
  '& strong': {
764
775
  color: `var(--muidocs-palette-success-200, ${_branding.brandingDarkTheme.palette.success[200]})`
765
776
  },
766
- '& > svg': {
777
+ '& svg': {
767
778
  fill: `var(--muidocs-palette-success-500, ${_branding.brandingDarkTheme.palette.success[500]})`
768
779
  },
769
780
  '& a': {
@@ -777,7 +788,7 @@ const Root = (0, _styles.styled)('div')(({
777
788
  '& strong': {
778
789
  color: `var(--muidocs-palette-warning-200, ${_branding.brandingDarkTheme.palette.warning[200]})`
779
790
  },
780
- '& > svg': {
791
+ '& svg': {
781
792
  fill: `var(--muidocs-palette-warning-400, ${_branding.brandingDarkTheme.palette.warning[400]})`
782
793
  },
783
794
  '& a': {
@@ -785,12 +796,6 @@ const Root = (0, _styles.styled)('div')(({
785
796
  }
786
797
  }
787
798
  },
788
- '& a:not(.title-link-to-anchor), & a:not(.title-link-to-anchor) code': {
789
- color: `var(--muidocs-palette-primary-300, ${_branding.brandingDarkTheme.palette.primary[300]})`
790
- },
791
- '& a:not(.title-link-to-anchor) code': {
792
- color: `var(--muidocs-palette-primary-light, ${_branding.brandingDarkTheme.palette.primary.light})`
793
- },
794
799
  '& kbd.key': {
795
800
  color: `var(--muidocs-palette-text-primary, ${_branding.brandingDarkTheme.palette.text.primary})`,
796
801
  backgroundColor: `var(--muidocs-palette-primaryDark-800, ${_branding.brandingDarkTheme.palette.primaryDark[800]})`,
@@ -814,12 +819,32 @@ const Root = (0, _styles.styled)('div')(({
814
819
  }
815
820
  }
816
821
  }));
822
+ function handleHeaderClick(event) {
823
+ const selection = document.getSelection();
824
+ if (selection === null) {
825
+ return;
826
+ }
827
+ if (selection.type === 'Range') {
828
+ // Disable the <a> behavior to be able to select text.
829
+ event.preventDefault();
830
+ }
831
+ }
817
832
  const MarkdownElement = exports.MarkdownElement = /*#__PURE__*/React.forwardRef(function MarkdownElement(props, ref) {
818
833
  const {
819
834
  className,
820
835
  renderedMarkdown,
821
836
  ...other
822
837
  } = props;
838
+ const rootRef = React.useRef(null);
839
+ const handleRef = (0, _useForkRef.default)(rootRef, ref);
840
+ React.useEffect(() => {
841
+ const elements = rootRef.current.getElementsByClassName('title-link-to-anchor');
842
+ for (let i = 0; i < elements.length; i += 1) {
843
+ // More reliable than `-webkit-user-drag` (https://caniuse.com/webkit-user-drag)
844
+ elements[i].setAttribute('draggable', 'false');
845
+ elements[i].addEventListener('click', handleHeaderClick);
846
+ }
847
+ }, []);
823
848
  const more = {};
824
849
  if (typeof renderedMarkdown === 'string') {
825
850
  // workaround for https://github.com/facebook/react/issues/17170
@@ -832,6 +857,6 @@ const MarkdownElement = exports.MarkdownElement = /*#__PURE__*/React.forwardRef(
832
857
  className: (0, _clsx.default)('markdown-body', className),
833
858
  ...more,
834
859
  ...other,
835
- ref: ref
860
+ ref: handleRef
836
861
  });
837
862
  });