@mui/material 5.2.3 → 5.2.7

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.
Files changed (56) hide show
  1. package/Avatar/Avatar.d.ts +4 -2
  2. package/Badge/Badge.d.ts +25 -0
  3. package/Badge/Badge.js +40 -10
  4. package/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  5. package/ButtonGroup/ButtonGroupContext.d.ts +1 -1
  6. package/CHANGELOG.md +227 -0
  7. package/CssBaseline/CssBaseline.d.ts +1 -1
  8. package/GlobalStyles/GlobalStyles.d.ts +2 -1
  9. package/Grid/Grid.js +74 -66
  10. package/InputBase/InputBase.d.ts +6 -0
  11. package/InputBase/InputBase.js +10 -2
  12. package/ListItem/ListItem.d.ts +1 -1
  13. package/ListItemButton/ListItemButton.d.ts +1 -1
  14. package/MenuItem/MenuItem.d.ts +1 -1
  15. package/OutlinedInput/OutlinedInput.js +14 -1
  16. package/README.md +15 -27
  17. package/Select/SelectInput.js +11 -3
  18. package/SvgIcon/SvgIcon.d.ts +8 -0
  19. package/SvgIcon/SvgIcon.js +19 -3
  20. package/Tabs/Tabs.d.ts +1 -1
  21. package/TextField/TextField.js +2 -9
  22. package/index.js +1 -1
  23. package/legacy/Badge/Badge.js +46 -11
  24. package/legacy/Grid/Grid.js +84 -78
  25. package/legacy/InputBase/InputBase.js +10 -2
  26. package/legacy/OutlinedInput/OutlinedInput.js +14 -1
  27. package/legacy/Select/SelectInput.js +11 -5
  28. package/legacy/SvgIcon/SvgIcon.js +20 -3
  29. package/legacy/TextField/TextField.js +2 -9
  30. package/legacy/index.js +1 -1
  31. package/legacy/locale/index.js +319 -142
  32. package/locale/index.d.ts +2 -0
  33. package/locale/index.js +220 -50
  34. package/modern/Badge/Badge.js +40 -10
  35. package/modern/Grid/Grid.js +74 -66
  36. package/modern/InputBase/InputBase.js +10 -2
  37. package/modern/OutlinedInput/OutlinedInput.js +14 -1
  38. package/modern/Select/SelectInput.js +11 -3
  39. package/modern/SvgIcon/SvgIcon.js +19 -3
  40. package/modern/TextField/TextField.js +2 -7
  41. package/modern/index.js +1 -1
  42. package/modern/locale/index.js +220 -50
  43. package/node/Badge/Badge.js +40 -10
  44. package/node/Grid/Grid.js +75 -65
  45. package/node/InputBase/InputBase.js +10 -2
  46. package/node/OutlinedInput/OutlinedInput.js +15 -1
  47. package/node/Select/SelectInput.js +11 -3
  48. package/node/SvgIcon/SvgIcon.js +19 -3
  49. package/node/TextField/TextField.js +1 -8
  50. package/node/index.js +1 -1
  51. package/node/locale/index.js +223 -51
  52. package/package.json +3 -3
  53. package/styles/createTheme.d.ts +1 -1
  54. package/transitions/transition.d.ts +1 -2
  55. package/umd/material-ui.development.js +278 -171
  56. package/umd/material-ui.production.min.js +21 -21
@@ -6,10 +6,13 @@ import PropTypes from 'prop-types';
6
6
  import { refType } from '@mui/utils';
7
7
  import { unstable_composeClasses as composeClasses } from '@mui/base';
8
8
  import NotchedOutline from './NotchedOutline';
9
+ import useFormControl from '../FormControl/useFormControl';
10
+ import formControlState from '../FormControl/formControlState';
9
11
  import styled, { rootShouldForwardProp } from '../styles/styled';
10
12
  import outlinedInputClasses, { getOutlinedInputUtilityClass } from './outlinedInputClasses';
11
13
  import InputBase, { rootOverridesResolver as inputBaseRootOverridesResolver, inputOverridesResolver as inputBaseInputOverridesResolver, InputBaseRoot, InputBaseComponent as InputBaseInput } from '../InputBase/InputBase';
12
14
  import useThemeProps from '../styles/useThemeProps';
15
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
16
  import { jsx as _jsx } from "react/jsx-runtime";
14
17
 
15
18
  const useUtilityClasses = ownerState => {
@@ -101,6 +104,8 @@ const OutlinedInputInput = styled(InputBaseInput, {
101
104
  paddingRight: 0
102
105
  }));
103
106
  const OutlinedInput = /*#__PURE__*/React.forwardRef(function OutlinedInput(inProps, ref) {
107
+ var _React$Fragment;
108
+
104
109
  const props = useThemeProps({
105
110
  props: inProps,
106
111
  name: 'MuiOutlinedInput'
@@ -118,6 +123,12 @@ const OutlinedInput = /*#__PURE__*/React.forwardRef(function OutlinedInput(inPro
118
123
  other = _objectWithoutPropertiesLoose(props, _excluded);
119
124
 
120
125
  const classes = useUtilityClasses(props);
126
+ const muiFormControl = useFormControl();
127
+ const fcs = formControlState({
128
+ props,
129
+ muiFormControl,
130
+ states: ['required']
131
+ });
121
132
  return /*#__PURE__*/_jsx(InputBase, _extends({
122
133
  components: _extends({
123
134
  Root: OutlinedInputRoot,
@@ -125,7 +136,9 @@ const OutlinedInput = /*#__PURE__*/React.forwardRef(function OutlinedInput(inPro
125
136
  }, components),
126
137
  renderSuffix: state => /*#__PURE__*/_jsx(NotchedOutlineRoot, {
127
138
  className: classes.notchedOutline,
128
- label: label,
139
+ label: label && fcs.required ? _React$Fragment || (_React$Fragment = /*#__PURE__*/_jsxs(React.Fragment, {
140
+ children: [label, "\xA0", '*']
141
+ })) : label,
129
142
  notched: typeof notched !== 'undefined' ? notched : Boolean(state.startAdornment || state.filled || state.focused)
130
143
  }),
131
144
  fullWidth: fullWidth,
@@ -405,10 +405,18 @@ const SelectInput = /*#__PURE__*/React.forwardRef(function SelectInput(props, re
405
405
 
406
406
  if (computeDisplay) {
407
407
  if (multiple) {
408
- if (value.length === 0) {
409
- display = '';
408
+ if (displayMultiple.length === 0) {
409
+ display = null;
410
410
  } else {
411
- display = displayMultiple.reduce((prev, curr) => [prev, ', ', curr]);
411
+ display = displayMultiple.reduce((output, child, index) => {
412
+ output.push(child);
413
+
414
+ if (index < displayMultiple.length - 1) {
415
+ output.push(', ');
416
+ }
417
+
418
+ return output;
419
+ }, []);
412
420
  }
413
421
  } else {
414
422
  display = displaySingle;
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
3
- const _excluded = ["children", "className", "color", "component", "fontSize", "htmlColor", "titleAccess", "viewBox"];
3
+ const _excluded = ["children", "className", "color", "component", "fontSize", "htmlColor", "inheritViewBox", "titleAccess", "viewBox"];
4
4
  import * as React from 'react';
5
5
  import PropTypes from 'prop-types';
6
6
  import clsx from 'clsx';
@@ -72,6 +72,7 @@ const SvgIcon = /*#__PURE__*/React.forwardRef(function SvgIcon(inProps, ref) {
72
72
  component = 'svg',
73
73
  fontSize = 'medium',
74
74
  htmlColor,
75
+ inheritViewBox = false,
75
76
  titleAccess,
76
77
  viewBox = '0 0 24 24'
77
78
  } = props,
@@ -81,21 +82,27 @@ const SvgIcon = /*#__PURE__*/React.forwardRef(function SvgIcon(inProps, ref) {
81
82
  color,
82
83
  component,
83
84
  fontSize,
85
+ inheritViewBox,
84
86
  viewBox
85
87
  });
86
88
 
89
+ const more = {};
90
+
91
+ if (!inheritViewBox) {
92
+ more.viewBox = viewBox;
93
+ }
94
+
87
95
  const classes = useUtilityClasses(ownerState);
88
96
  return /*#__PURE__*/_jsxs(SvgIconRoot, _extends({
89
97
  as: component,
90
98
  className: clsx(classes.root, className),
91
99
  ownerState: ownerState,
92
100
  focusable: "false",
93
- viewBox: viewBox,
94
101
  color: htmlColor,
95
102
  "aria-hidden": titleAccess ? undefined : true,
96
103
  role: titleAccess ? 'img' : undefined,
97
104
  ref: ref
98
- }, other, {
105
+ }, more, other, {
99
106
  children: [children, titleAccess ? /*#__PURE__*/_jsx("title", {
100
107
  children: titleAccess
101
108
  }) : null]
@@ -152,6 +159,15 @@ process.env.NODE_ENV !== "production" ? SvgIcon.propTypes
152
159
  */
153
160
  htmlColor: PropTypes.string,
154
161
 
162
+ /**
163
+ * If `true`, the root node will inherit the custom `component`'s viewBox and the `viewBox`
164
+ * prop will be ignored.
165
+ * Useful when you want to reference a custom `component` and have `SvgIcon` pass that
166
+ * `component`'s viewBox to the root node.
167
+ * @default false
168
+ */
169
+ inheritViewBox: PropTypes.bool,
170
+
155
171
  /**
156
172
  * The shape-rendering attribute. The behavior of the different options is described on the
157
173
  * [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering).
@@ -16,8 +16,8 @@ import FormControl from '../FormControl';
16
16
  import FormHelperText from '../FormHelperText';
17
17
  import Select from '../Select';
18
18
  import { getTextFieldUtilityClass } from './textFieldClasses';
19
- import { jsxs as _jsxs } from "react/jsx-runtime";
20
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { jsxs as _jsxs } from "react/jsx-runtime";
21
21
  const variantComponent = {
22
22
  standard: Input,
23
23
  filled: FilledInput,
@@ -141,12 +141,7 @@ const TextField = /*#__PURE__*/React.forwardRef(function TextField(inProps, ref)
141
141
  InputMore.notched = InputLabelProps.shrink;
142
142
  }
143
143
 
144
- if (label) {
145
- const displayRequired = InputLabelProps?.required ?? required;
146
- InputMore.label = /*#__PURE__*/_jsxs(React.Fragment, {
147
- children: [label, displayRequired && '\u00a0*']
148
- });
149
- }
144
+ InputMore.label = label;
150
145
  }
151
146
 
152
147
  if (select) {
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.2.3
1
+ /** @license MUI v5.2.7
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -641,6 +641,86 @@ export const csCZ = {
641
641
  }
642
642
  }
643
643
  };
644
+ export const daDK = {
645
+ components: {
646
+ MuiBreadcrumbs: {
647
+ defaultProps: {
648
+ expandText: 'Vis sti'
649
+ }
650
+ },
651
+ MuiTablePagination: {
652
+ defaultProps: {
653
+ getItemAriaLabel: type => {
654
+ if (type === 'first') {
655
+ return 'Gå til den første side';
656
+ }
657
+
658
+ if (type === 'last') {
659
+ return 'Gå til den sidste side';
660
+ }
661
+
662
+ if (type === 'next') {
663
+ return 'Gå til den næste side';
664
+ } // if (type === 'previous') {
665
+
666
+
667
+ return 'Gå til den forrige side';
668
+ },
669
+ labelRowsPerPage: 'Rækker pr side:',
670
+ labelDisplayedRows: ({
671
+ from,
672
+ to,
673
+ count
674
+ }) => `${from}-${to} af ${count !== -1 ? count : `mere end ${to}`}`
675
+ }
676
+ },
677
+ MuiRating: {
678
+ defaultProps: {
679
+ getLabelText: value => `${value} Stjern${value !== 1 ? 'er' : ''}`,
680
+ emptyLabelText: 'Tom'
681
+ }
682
+ },
683
+ MuiAutocomplete: {
684
+ defaultProps: {
685
+ clearText: 'Slet',
686
+ closeText: 'Luk',
687
+ loadingText: 'Indlæser…',
688
+ noOptionsText: 'Ingen muligheder',
689
+ openText: 'Åben'
690
+ }
691
+ },
692
+ MuiAlert: {
693
+ defaultProps: {
694
+ closeText: 'Luk'
695
+ }
696
+ },
697
+ MuiPagination: {
698
+ defaultProps: {
699
+ 'aria-label': 'Sideinddelings navigation',
700
+ getItemAriaLabel: (type, page, selected) => {
701
+ if (type === 'page') {
702
+ return `${selected ? '' : 'Go to '}page ${page}`;
703
+ }
704
+
705
+ if (type === 'first') {
706
+ return 'Gå til den første side';
707
+ }
708
+
709
+ if (type === 'last') {
710
+ return 'Gå til den sidste side';
711
+ }
712
+
713
+ if (type === 'next') {
714
+ return 'Gå til den næste side';
715
+ } // if (type === 'previous') {
716
+
717
+
718
+ return 'Gå til den forrige side';
719
+ }
720
+ }
721
+ }
722
+ }
723
+ };
644
724
  export const deDE = {
645
725
  components: {
646
726
  MuiBreadcrumbs: {
@@ -808,7 +888,7 @@ export const enUS = {
808
888
  MuiBreadcrumbs: { defaultProps: {
809
889
  expandText: 'Show path',
810
890
  }},
811
- MuiTablePagination: { defaultProps: {
891
+ MuiTablePagination: { defaultProps: {
812
892
  getItemAriaLabel: (type) => {
813
893
  if (type === 'first') {
814
894
  return 'Go to first page';
@@ -826,21 +906,21 @@ export const enUS = {
826
906
  labelDisplayedRows: ({ from, to, count }) =>
827
907
  `${from}–${to} of ${count !== -1 ? count : `more than ${to}`}`,
828
908
  }},
829
- MuiRating: { defaultProps: {
909
+ MuiRating: { defaultProps: {
830
910
  getLabelText: value => `${value} Star${value !== 1 ? 's' : ''}`,
831
911
  emptyLabelText: 'Empty',
832
912
  }},
833
- MuiAutocomplete: { defaultProps: {
913
+ MuiAutocomplete: { defaultProps: {
834
914
  clearText: 'Clear',
835
915
  closeText: 'Close',
836
916
  loadingText: 'Loading…',
837
917
  noOptionsText: 'No options',
838
918
  openText: 'Open',
839
919
  }},
840
- MuiAlert: { defaultProps: {
920
+ MuiAlert: { defaultProps: {
841
921
  closeText: 'Close',
842
922
  }},
843
- MuiPagination: { defaultProps: {
923
+ MuiPagination: { defaultProps: {
844
924
  'aria-label': 'Pagination navigation',
845
925
  getItemAriaLabel: (type, page, selected) => {
846
926
  if (type === 'page') {
@@ -858,7 +938,7 @@ export const enUS = {
858
938
  // if (type === 'previous') {
859
939
  return 'Go to previous page';
860
940
  },
861
- },
941
+ }},
862
942
  },
863
943
  */
864
944
  };
@@ -1126,9 +1206,12 @@ export const fiFI = {
1126
1206
 
1127
1207
  return 'Mene edelliselle sivulle';
1128
1208
  },
1129
- labelRowsPerPage: 'Rivejä per sivu:' // labelDisplayedRows: ({ from, to, count }) =>
1130
- // `${from}–${to} / ${count !== -1 ? count : `more than ${to}`}`,
1131
-
1209
+ labelRowsPerPage: 'Rivejä per sivu:',
1210
+ labelDisplayedRows: ({
1211
+ from,
1212
+ to,
1213
+ count
1214
+ }) => `${from}–${to} / ${count !== -1 ? count : `enemmän kuin ${to}`}`
1132
1215
  }
1133
1216
  },
1134
1217
  MuiRating: {
@@ -2106,6 +2189,86 @@ export const kzKZ = {
2106
2189
  }
2107
2190
  }
2108
2191
  };
2192
+ export const nbNO = {
2193
+ components: {
2194
+ MuiBreadcrumbs: {
2195
+ defaultProps: {
2196
+ expandText: 'Vis sti'
2197
+ }
2198
+ },
2199
+ MuiTablePagination: {
2200
+ defaultProps: {
2201
+ getItemAriaLabel: type => {
2202
+ if (type === 'first') {
2203
+ return 'Gå til første side';
2204
+ }
2205
+
2206
+ if (type === 'last') {
2207
+ return 'Gå til siste side';
2208
+ }
2209
+
2210
+ if (type === 'next') {
2211
+ return 'Gå til neste side';
2212
+ } // if (type === 'previous') {
2213
+
2214
+
2215
+ return 'Gå til forrige side';
2216
+ },
2217
+ labelRowsPerPage: 'Rader per side:',
2218
+ labelDisplayedRows: ({
2219
+ from,
2220
+ to,
2221
+ count
2222
+ }) => `${from}–${to} av ${count !== -1 ? count : `mer enn ${to}`}`
2223
+ }
2224
+ },
2225
+ MuiRating: {
2226
+ defaultProps: {
2227
+ getLabelText: value => `${value} Stjerne${value !== 1 ? 'r' : ''}`,
2228
+ emptyLabelText: 'Tom'
2229
+ }
2230
+ },
2231
+ MuiAutocomplete: {
2232
+ defaultProps: {
2233
+ clearText: 'Tøm',
2234
+ closeText: 'Lukk',
2235
+ loadingText: 'Laster inn…',
2236
+ noOptionsText: 'Ingen alternativer',
2237
+ openText: 'Åpne'
2238
+ }
2239
+ },
2240
+ MuiAlert: {
2241
+ defaultProps: {
2242
+ closeText: 'Lukk'
2243
+ }
2244
+ },
2245
+ MuiPagination: {
2246
+ defaultProps: {
2247
+ 'aria-label': 'Paginering navigasjon',
2248
+ getItemAriaLabel: (type, page, selected) => {
2249
+ if (type === 'page') {
2250
+ return `${selected ? '' : 'Gå til '}side ${page}`;
2251
+ }
2252
+
2253
+ if (type === 'first') {
2254
+ return 'Gå til første side';
2255
+ }
2256
+
2257
+ if (type === 'last') {
2258
+ return 'Gå til siste side';
2259
+ }
2260
+
2261
+ if (type === 'next') {
2262
+ return 'Gå til neste side';
2263
+ } // if (type === 'previous') {
2264
+
2265
+
2266
+ return 'Gå til forrige side';
2267
+ }
2268
+ }
2269
+ }
2270
+ }
2271
+ };
2109
2272
  export const nlNL = {
2110
2273
  components: {
2111
2274
  MuiBreadcrumbs: {
@@ -3106,26 +3269,29 @@ export const ukUA = {
3106
3269
  };
3107
3270
  export const viVN = {
3108
3271
  components: {
3109
- // MuiBreadcrumbs: {
3110
- // defaultProps: {
3111
- // expandText: 'Show path',
3112
- // },
3113
- // },
3272
+ MuiBreadcrumbs: {
3273
+ defaultProps: {
3274
+ expandText: 'Mở ra'
3275
+ }
3276
+ },
3114
3277
  MuiTablePagination: {
3115
3278
  defaultProps: {
3116
- // getItemAriaLabel: (type) => {
3117
- // if (type === 'first') {
3118
- // return 'Go to first page';
3119
- // }
3120
- // if (type === 'last') {
3121
- // return 'Go to last page';
3122
- // }
3123
- // if (type === 'next') {
3124
- // return 'Go to next page';
3125
- // }
3126
- // // if (type === 'previous') {
3127
- // return 'Go to previous page';
3128
- // },
3279
+ getItemAriaLabel: type => {
3280
+ if (type === 'first') {
3281
+ return 'Tới trang đầu tiên';
3282
+ }
3283
+
3284
+ if (type === 'last') {
3285
+ return 'Tới trang cuối cùng';
3286
+ }
3287
+
3288
+ if (type === 'next') {
3289
+ return 'Tới trang tiếp theo';
3290
+ } // if (type === 'previous') {
3291
+
3292
+
3293
+ return 'Về trang trước đó';
3294
+ },
3129
3295
  labelRowsPerPage: 'Số hàng mỗi trang:',
3130
3296
  labelDisplayedRows: ({
3131
3297
  from,
@@ -3137,7 +3303,7 @@ export const viVN = {
3137
3303
  MuiRating: {
3138
3304
  defaultProps: {
3139
3305
  getLabelText: value => `${value} sao`,
3140
- emptyLabelText: 'Trống'
3306
+ emptyLabelText: 'Không có dữ liệu'
3141
3307
  }
3142
3308
  },
3143
3309
  MuiAutocomplete: {
@@ -3145,7 +3311,7 @@ export const viVN = {
3145
3311
  clearText: 'Xóa',
3146
3312
  closeText: 'Đóng',
3147
3313
  loadingText: 'Đang tải…',
3148
- noOptionsText: 'Không có lựa chọn',
3314
+ noOptionsText: 'Không có lựa chọn nào',
3149
3315
  openText: 'Mở'
3150
3316
  }
3151
3317
  },
@@ -3153,28 +3319,32 @@ export const viVN = {
3153
3319
  defaultProps: {
3154
3320
  closeText: 'Đóng'
3155
3321
  }
3156
- } // MuiPagination: {
3157
- // defaultProps: {
3158
- // 'aria-label': 'Pagination navigation',
3159
- // getItemAriaLabel: (type, page, selected) => {
3160
- // if (type === 'page') {
3161
- // return `${selected ? '' : 'Go to '}page ${page}`;
3162
- // }
3163
- // if (type === 'first') {
3164
- // return 'Go to first page';
3165
- // }
3166
- // if (type === 'last') {
3167
- // return 'Go to last page';
3168
- // }
3169
- // if (type === 'next') {
3170
- // return 'Go to next page';
3171
- // }
3172
- // // if (type === 'previous') {
3173
- // return 'Go to previous page';
3174
- // },
3175
- // },
3176
- // },
3322
+ },
3323
+ MuiPagination: {
3324
+ defaultProps: {
3325
+ 'aria-label': 'Thanh điều khiển trang',
3326
+ getItemAriaLabel: (type, page, selected) => {
3327
+ if (type === 'page') {
3328
+ return `${selected ? '' : 'Tới '}trang ${page}`;
3329
+ }
3177
3330
 
3331
+ if (type === 'first') {
3332
+ return 'Tới trang đầu tiên';
3333
+ }
3334
+
3335
+ if (type === 'last') {
3336
+ return 'Tới trang cuối cùng';
3337
+ }
3338
+
3339
+ if (type === 'next') {
3340
+ return 'Tới trang tiếp theo';
3341
+ } // if (type === 'previous') {
3342
+
3343
+
3344
+ return 'Về trang trước đó';
3345
+ }
3346
+ }
3347
+ }
3178
3348
  }
3179
3349
  };
3180
3350
  export const zhCN = {
@@ -31,13 +31,14 @@ var _capitalize = _interopRequireDefault(require("../utils/capitalize"));
31
31
 
32
32
  var _jsxRuntime = require("react/jsx-runtime");
33
33
 
34
- const _excluded = ["components", "componentsProps", "color", "invisible", "badgeContent", "showZero", "variant"];
34
+ const _excluded = ["anchorOrigin", "component", "components", "componentsProps", "overlap", "color", "invisible", "badgeContent", "showZero", "variant"];
35
35
 
36
36
  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); }
37
37
 
38
38
  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; }
39
39
 
40
- const badgeClasses = (0, _extends2.default)({}, _BadgeUnstyled.badgeUnstyledClasses, (0, _base.generateUtilityClasses)('MuiBadge', ['colorError', 'colorInfo', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorWarning']));
40
+ const badgeClasses = (0, _extends2.default)({}, _BadgeUnstyled.badgeUnstyledClasses, (0, _base.generateUtilityClasses)('MuiBadge', ['colorError', 'colorInfo', 'colorPrimary', 'colorSecondary', 'colorSuccess', 'colorWarning', 'overlapRectangular', 'overlapCircular', // TODO: v6 remove the overlap value from these class keys
41
+ 'anchorOriginTopLeftCircular', 'anchorOriginTopLeftRectangular', 'anchorOriginTopRightCircular', 'anchorOriginTopRightRectangular', 'anchorOriginBottomLeftCircular', 'anchorOriginBottomLeftRectangular', 'anchorOriginBottomRightCircular', 'anchorOriginBottomRightRectangular']));
41
42
  exports.badgeClasses = badgeClasses;
42
43
  const RADIUS_STANDARD = 10;
43
44
  const RADIUS_DOT = 4;
@@ -45,10 +46,12 @@ const RADIUS_DOT = 4;
45
46
  const extendUtilityClasses = ownerState => {
46
47
  const {
47
48
  color,
49
+ anchorOrigin,
50
+ overlap,
48
51
  classes = {}
49
52
  } = ownerState;
50
53
  return (0, _extends2.default)({}, classes, {
51
- badge: (0, _clsx.default)(classes.badge, color !== 'default' && [(0, _BadgeUnstyled.getBadgeUtilityClass)(`color${(0, _capitalize.default)(color)}`), classes[`color${(0, _capitalize.default)(color)}`]])
54
+ badge: (0, _clsx.default)(classes.badge, (0, _BadgeUnstyled.getBadgeUtilityClass)(`anchorOrigin${(0, _capitalize.default)(anchorOrigin.vertical)}${(0, _capitalize.default)(anchorOrigin.horizontal)}${(0, _capitalize.default)(overlap)}`), (0, _BadgeUnstyled.getBadgeUtilityClass)(`overlap${(0, _capitalize.default)(overlap)}`), color !== 'default' && [(0, _BadgeUnstyled.getBadgeUtilityClass)(`color${(0, _capitalize.default)(color)}`), classes[`color${(0, _capitalize.default)(color)}`]])
52
55
  });
53
56
  };
54
57
 
@@ -176,6 +179,11 @@ const BadgeBadge = (0, _styled.default)('span', {
176
179
  duration: theme.transitions.duration.leavingScreen
177
180
  })
178
181
  }));
182
+
183
+ const shouldSpreadAdditionalProps = Slot => {
184
+ return !Slot || !(0, _base.isHostComponent)(Slot);
185
+ };
186
+
179
187
  const Badge = /*#__PURE__*/React.forwardRef(function Badge(inProps, ref) {
180
188
  var _componentsProps$root, _componentsProps$badg;
181
189
 
@@ -184,8 +192,14 @@ const Badge = /*#__PURE__*/React.forwardRef(function Badge(inProps, ref) {
184
192
  name: 'MuiBadge'
185
193
  });
186
194
  const {
195
+ anchorOrigin: anchorOriginProp = {
196
+ vertical: 'top',
197
+ horizontal: 'right'
198
+ },
199
+ component = 'span',
187
200
  components = {},
188
201
  componentsProps = {},
202
+ overlap: overlapProp = 'rectangular',
189
203
  color: colorProp = 'default',
190
204
  invisible: invisibleProp,
191
205
  badgeContent: badgeContentProp,
@@ -194,7 +208,9 @@ const Badge = /*#__PURE__*/React.forwardRef(function Badge(inProps, ref) {
194
208
  } = props,
195
209
  other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
196
210
  const prevProps = (0, _utils.usePreviousProps)({
197
- color: colorProp
211
+ anchorOrigin: anchorOriginProp,
212
+ color: colorProp,
213
+ overlap: overlapProp
198
214
  });
199
215
  let invisible = invisibleProp;
200
216
 
@@ -203,14 +219,19 @@ const Badge = /*#__PURE__*/React.forwardRef(function Badge(inProps, ref) {
203
219
  }
204
220
 
205
221
  const {
206
- color = colorProp
222
+ color = colorProp,
223
+ overlap = overlapProp,
224
+ anchorOrigin = anchorOriginProp
207
225
  } = invisible ? prevProps : props;
208
226
  const ownerState = (0, _extends2.default)({}, props, {
227
+ anchorOrigin,
209
228
  invisible,
210
- color
229
+ color,
230
+ overlap
211
231
  });
212
232
  const classes = extendUtilityClasses(ownerState);
213
233
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BadgeUnstyled.default, (0, _extends2.default)({
234
+ anchorOrigin: anchorOrigin,
214
235
  invisible: invisibleProp,
215
236
  badgeContent: badgeContentProp,
216
237
  showZero: showZero,
@@ -221,14 +242,17 @@ const Badge = /*#__PURE__*/React.forwardRef(function Badge(inProps, ref) {
221
242
  Badge: BadgeBadge
222
243
  }, components),
223
244
  componentsProps: {
224
- root: (0, _extends2.default)({}, componentsProps.root, (!components.Root || !(0, _base.isHostComponent)(components.Root)) && {
245
+ root: (0, _extends2.default)({}, componentsProps.root, shouldSpreadAdditionalProps(components.Root) && {
246
+ as: component,
225
247
  ownerState: (0, _extends2.default)({}, (_componentsProps$root = componentsProps.root) == null ? void 0 : _componentsProps$root.ownerState, {
226
- color
248
+ color,
249
+ overlap
227
250
  })
228
251
  }),
229
- badge: (0, _extends2.default)({}, componentsProps.badge, (!components.Thumb || !(0, _base.isHostComponent)(components.Thumb)) && {
252
+ badge: (0, _extends2.default)({}, componentsProps.badge, shouldSpreadAdditionalProps(components.Badge) && {
230
253
  ownerState: (0, _extends2.default)({}, (_componentsProps$badg = componentsProps.badge) == null ? void 0 : _componentsProps$badg.ownerState, {
231
- color
254
+ color,
255
+ overlap
232
256
  })
233
257
  })
234
258
  },
@@ -279,6 +303,12 @@ process.env.NODE_ENV !== "production" ? Badge.propTypes
279
303
  /* @typescript-to-proptypes-ignore */
280
304
  .oneOfType([_propTypes.default.oneOf(['default', 'primary', 'secondary', 'error', 'info', 'success', 'warning']), _propTypes.default.string]),
281
305
 
306
+ /**
307
+ * The component used for the root node.
308
+ * Either a string to use a HTML element or a component.
309
+ */
310
+ component: _propTypes.default.elementType,
311
+
282
312
  /**
283
313
  * The components used for each slot inside the Badge.
284
314
  * Either a string to use a HTML element or a component.