@mui/utils 5.15.4 → 5.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,103 @@
1
1
  # [Versions](https://mui.com/versions/)
2
2
 
3
+ ## v5.15.5
4
+
5
+ <!-- generated comparing v5.15.4..master -->
6
+
7
+ _Jan 17, 2024_
8
+
9
+ A big thanks to the 18 contributors who made this release possible. Here are some highlights ✨:
10
+
11
+ - Base UI's CSS class prefix is now `base-` (#40205) @michaldudak
12
+ - Bug fixes, and a lot of improvements to code and docs infra
13
+
14
+ ### `@mui/material@5.15.5`
15
+
16
+ - &#8203;<!-- 42 -->[Accordion] Deprecate \*Props props and classes for v6 (#40418) @DiegoAndai
17
+ - &#8203;<!-- 41 -->[Alert] Update TypeScript types to allow color override types to be added to `iconMapping` and `severity` props (#40551) @2metres
18
+ - &#8203;<!-- 27 -->[Dialog] Remove deprecated onBackdropClick from Dialog tests (#40505) @sai6855
19
+ - &#8203;<!-- 26 -->[Divider] Deprecate props and classes for v6 (#40563) @sai6855
20
+
21
+ ### `@mui/material-next@6.0.0-alpha.118`
22
+
23
+ - &#8203;<!-- 36 -->[ButtonGroup] Apply MD3 style to `ButtonGroup` (#40124) @lhilgert9
24
+
25
+ ### `@mui/base@5.0.0-beta.32`
26
+
27
+ #### Breaking changes
28
+
29
+ - &#8203;<!-- 40 -->Change the CSS class prefix to `base-` (#40205) @michaldudak
30
+
31
+ The class prefix of Base UI components have been changed from `Mui-` to `base-`. This only affects codebases that uses class names verbatim, i.e. not exposed by JS objects such as `buttonClasses`, but as plain strings or in CSS stylesheets (`.MuiButton.root`)
32
+
33
+ To adapt your code to the new pattern:
34
+
35
+ - replace all occurrences of the regex `.Mui([A-Z][A-Za-z]*)-` with `.base-$1-` (so `MuiButton-root` becomes `base-Button-root`, etc.),
36
+ - replace all occurrences of the regex `.Mui-([a-z]*)` with `.base--$1` (so `Mui-disabled` becomes `base--disabled`, etc.).
37
+
38
+ #### Changes
39
+
40
+ - &#8203;<!-- 39 -->[Select] Fix screen-reader CSS to avoid body scrollbar (#40599) @brijeshb42
41
+ - &#8203;<!-- 38 -->[Switch] Add border-box to demos (#40638) @zanivan
42
+
43
+ ### `@mui/joy@5.0.0-beta.23`
44
+
45
+ - &#8203;<!-- 11 -->[ModalDialog] Fix ModalDialog layout prop override (#40512) @maakcode
46
+ - &#8203;<!-- 10 -->[RadioGroup] Allow zero number as a value (#40344) @aacevski
47
+
48
+ ### `@mui/codemod@5.15.5`
49
+
50
+ - &#8203;<!-- 31 -->Allow `json` files to be transformed (#40536) @ZeeshanTamboli
51
+
52
+ ### `@mui/lab@5.0.0-alpha.161`
53
+
54
+ - &#8203;<!-- 09 -->Update `@mui/material` peer dependency version (#40528) @ZeeshanTamboli
55
+
56
+ ### `@mui/material-nextjs@5.15.5`
57
+
58
+ - &#8203;<!-- 08 -->Fix release script (#40519) @petrovmiroslav
59
+ - &#8203;<!-- 07 -->Support Nonces in the App Router Provider (#40269) @josh-feldman
60
+ - &#8203;<!-- 06 -->Polish @mui/material-nextjs (#40473) @oliviertassinari
61
+
62
+ ### `@mui/system@5.15.5`
63
+
64
+ - &#8203;<!-- 05 -->Fix import path for @mui/system in vite apps (#40490) @brijeshb42
65
+ - &#8203;<!-- 02 -->Fix css vars generation and simplify the code (#40530) @siriwatknp
66
+ - &#8203;<!-- 01 -->Identify zero runtime styled path (#40555) @brijeshb42
67
+
68
+ ### Docs
69
+
70
+ - &#8203;<!-- 35 -->[joy-ui][Card] Fix text alignment in horizontal aligned card demo (#40562) @ZeeshanTamboli
71
+ - &#8203;<!-- 25 -->Improve instructions about peer dependencies (#40621) @danilo-leal
72
+ - &#8203;<!-- 24 -->Solve page description length @oliviertassinari
73
+ - &#8203;<!-- 23 -->Fix MUI Treasury links (#40561) @siriwatknp
74
+ - &#8203;<!-- 17 -->[material-ui] Update <ListItem button/> to ListItemButton in demos (#40564) @sai6855
75
+ - &#8203;<!-- 16 -->[material-ui] Revise the Snackbar page (#39298) @danilo-leal
76
+ - &#8203;<!-- 15 -->[material-ui] Sharpen Material 3 copy on demo pages (#40546) @samuelsycamore
77
+ - &#8203;<!-- 14 -->[material-ui] Fix typo on Next.js integration guide (#40538) @zanivan
78
+ - &#8203;<!-- 13 -->[material-ui][Snackbar] Remove unused `State` interface from Consecutive Snackbars demo (#40410)
79
+ @zinoroman
80
+ - &#8203;<!-- 12 -->[website] Resolve broken links reported by `docs:link-check` (#40547) @samuelsycamore
81
+
82
+ ### Core
83
+
84
+ - &#8203;<!-- 37 -->[blog] Fix 404 link to MUI Treasury @oliviertassinari
85
+ - &#8203;<!-- 34 -->[code-infra] Add `run` command to deploy docs (#40513) @siriwatknp
86
+ - &#8203;<!-- 32 -->[core] Update the lockfile (#40628) @michaldudak
87
+ - &#8203;<!-- 31 -->[core] Remove dead code and follow standard @oliviertassinari
88
+ - &#8203;<!-- 30 -->[core] Simplify server detection (#40471) @oliviertassinari
89
+ - &#8203;<!-- 29 -->[core] Sync playwright cache between MUI X and Material UI (#40475) @oliviertassinari
90
+ - &#8203;<!-- 28 -->[dependencies] Bump tough-cookie (#40437) @michaldudak
91
+ - &#8203;<!-- 22 -->[docs-infra] Enforce brand name rules (#40525) @oliviertassinari
92
+ - &#8203;<!-- 21 -->[docs-infra] Minimize ad layout shift on mobile (#40582) @oliviertassinari
93
+ - &#8203;<!-- 20 -->[docs-infra] Improve API page deprecation info (#40440) @DiegoAndai
94
+ - &#8203;<!-- 19 -->[docs-infra] Remove old tocs banners (#40537) @oliviertassinari
95
+ - &#8203;<!-- 18 -->[docs-infra] Remove dead code aria-label sponsors (#40526) @oliviertassinari
96
+ - &#8203;<!-- 04 -->[utils] Centralize clamp implementation in utils (#40267) @Kamino0
97
+ - &#8203;<!-- 03 -->[website] Polish the Base UI page demos (#40504) @danilo-leal
98
+
99
+ All contributors of this release in alphabetical order: @2metres, @aacevski, @brijeshb42, @danilo-leal, @DiegoAndai, @josh-feldman, @Kamino0, @lhilgert9, @maakcode, @michaldudak, @oliviertassinari, @petrovmiroslav, @sai6855, @samuelsycamore, @siriwatknp, @zanivan, @ZeeshanTamboli, @zinoroman
100
+
3
101
  ## 5.15.4
4
102
 
5
103
  <!-- generated comparing v5.15.3..master -->
@@ -0,0 +1,2 @@
1
+ declare function clamp(val: number, min?: number, max?: number): number;
2
+ export default clamp;
package/clamp/clamp.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ function clamp(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
8
+ return Math.max(min, Math.min(val, max));
9
+ }
10
+ var _default = exports.default = clamp;
@@ -0,0 +1 @@
1
+ export { default } from './clamp';
package/clamp/index.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "default", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _clamp.default;
11
+ }
12
+ });
13
+ var _clamp = _interopRequireDefault(require("./clamp"));
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "module": "../esm/clamp/index.js",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts"
6
+ }
@@ -0,0 +1,4 @@
1
+ function clamp(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
2
+ return Math.max(min, Math.min(val, max));
3
+ }
4
+ export default clamp;
@@ -0,0 +1 @@
1
+ export { default } from './clamp';
@@ -1,9 +1,5 @@
1
1
  import ClassNameGenerator from '../ClassNameGenerator';
2
-
3
- // If GlobalStateSlot is changed, GLOBAL_STATE_CLASSES in
4
- // \packages\api-docs-builder\utils\parseSlotsAndClasses.ts must be updated accordingly.
5
-
6
- const globalStateClassesMapping = {
2
+ export const globalStateClasses = {
7
3
  active: 'active',
8
4
  checked: 'checked',
9
5
  completed: 'completed',
@@ -18,6 +14,9 @@ const globalStateClassesMapping = {
18
14
  selected: 'selected'
19
15
  };
20
16
  export default function generateUtilityClass(componentName, slot, globalStatePrefix = 'Mui') {
21
- const globalStateClass = globalStateClassesMapping[slot];
17
+ const globalStateClass = globalStateClasses[slot];
22
18
  return globalStateClass ? `${globalStatePrefix}-${globalStateClass}` : `${ClassNameGenerator.generate(componentName)}-${slot}`;
19
+ }
20
+ export function isGlobalState(slot) {
21
+ return globalStateClasses[slot] !== undefined;
23
22
  }
package/esm/index.js CHANGED
@@ -36,6 +36,8 @@ export { default as integerPropType } from './integerPropType';
36
36
  export { default as internal_resolveProps } from './resolveProps';
37
37
  export { default as unstable_composeClasses } from './composeClasses';
38
38
  export { default as unstable_generateUtilityClass } from './generateUtilityClass';
39
+ export { isGlobalState as unstable_isGlobalState } from './generateUtilityClass';
39
40
  export * from './generateUtilityClass';
40
41
  export { default as unstable_generateUtilityClasses } from './generateUtilityClasses';
41
- export { default as unstable_ClassNameGenerator } from './ClassNameGenerator';
42
+ export { default as unstable_ClassNameGenerator } from './ClassNameGenerator';
43
+ export { default as clamp } from './clamp';
@@ -1,2 +1,17 @@
1
- export type GlobalStateSlot = 'active' | 'checked' | 'completed' | 'disabled' | 'error' | 'expanded' | 'focused' | 'focusVisible' | 'open' | 'readOnly' | 'required' | 'selected';
1
+ export type GlobalStateSlot = keyof typeof globalStateClasses;
2
+ export declare const globalStateClasses: {
3
+ active: string;
4
+ checked: string;
5
+ completed: string;
6
+ disabled: string;
7
+ error: string;
8
+ expanded: string;
9
+ focused: string;
10
+ focusVisible: string;
11
+ open: string;
12
+ readOnly: string;
13
+ required: string;
14
+ selected: string;
15
+ };
2
16
  export default function generateUtilityClass(componentName: string, slot: string, globalStatePrefix?: string): string;
17
+ export declare function isGlobalState(slot: string): boolean;
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = generateUtilityClass;
8
+ exports.globalStateClasses = void 0;
9
+ exports.isGlobalState = isGlobalState;
8
10
  var _ClassNameGenerator = _interopRequireDefault(require("../ClassNameGenerator"));
9
- // If GlobalStateSlot is changed, GLOBAL_STATE_CLASSES in
10
- // \packages\api-docs-builder\utils\parseSlotsAndClasses.ts must be updated accordingly.
11
-
12
- const globalStateClassesMapping = {
11
+ const globalStateClasses = exports.globalStateClasses = {
13
12
  active: 'active',
14
13
  checked: 'checked',
15
14
  completed: 'completed',
@@ -24,6 +23,9 @@ const globalStateClassesMapping = {
24
23
  selected: 'selected'
25
24
  };
26
25
  function generateUtilityClass(componentName, slot, globalStatePrefix = 'Mui') {
27
- const globalStateClass = globalStateClassesMapping[slot];
26
+ const globalStateClass = globalStateClasses[slot];
28
27
  return globalStateClass ? `${globalStatePrefix}-${globalStateClass}` : `${_ClassNameGenerator.default.generate(componentName)}-${slot}`;
28
+ }
29
+ function isGlobalState(slot) {
30
+ return globalStateClasses[slot] !== undefined;
29
31
  }
package/index.d.ts CHANGED
@@ -34,6 +34,8 @@ export { default as integerPropType } from './integerPropType';
34
34
  export { default as internal_resolveProps } from './resolveProps';
35
35
  export { default as unstable_composeClasses } from './composeClasses';
36
36
  export { default as unstable_generateUtilityClass } from './generateUtilityClass';
37
+ export { isGlobalState as unstable_isGlobalState } from './generateUtilityClass';
37
38
  export * from './generateUtilityClass';
38
39
  export { default as unstable_generateUtilityClasses } from './generateUtilityClasses';
39
40
  export { default as unstable_ClassNameGenerator } from './ClassNameGenerator';
41
+ export { default as clamp } from './clamp';
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v5.15.4
2
+ * @mui/utils v5.15.5
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -50,8 +50,10 @@ var _exportNames = {
50
50
  internal_resolveProps: true,
51
51
  unstable_composeClasses: true,
52
52
  unstable_generateUtilityClass: true,
53
+ unstable_isGlobalState: true,
53
54
  unstable_generateUtilityClasses: true,
54
- unstable_ClassNameGenerator: true
55
+ unstable_ClassNameGenerator: true,
56
+ clamp: true
55
57
  };
56
58
  Object.defineProperty(exports, "HTMLElementType", {
57
59
  enumerable: true,
@@ -65,6 +67,12 @@ Object.defineProperty(exports, "chainPropTypes", {
65
67
  return _chainPropTypes.default;
66
68
  }
67
69
  });
70
+ Object.defineProperty(exports, "clamp", {
71
+ enumerable: true,
72
+ get: function () {
73
+ return _clamp.default;
74
+ }
75
+ });
68
76
  Object.defineProperty(exports, "deepmerge", {
69
77
  enumerable: true,
70
78
  get: function () {
@@ -203,6 +211,12 @@ Object.defineProperty(exports, "unstable_getScrollbarSize", {
203
211
  return _getScrollbarSize.default;
204
212
  }
205
213
  });
214
+ Object.defineProperty(exports, "unstable_isGlobalState", {
215
+ enumerable: true,
216
+ get: function () {
217
+ return _generateUtilityClass.isGlobalState;
218
+ }
219
+ });
206
220
  Object.defineProperty(exports, "unstable_isMuiElement", {
207
221
  enumerable: true,
208
222
  get: function () {
@@ -335,5 +349,6 @@ Object.keys(_generateUtilityClass).forEach(function (key) {
335
349
  });
336
350
  var _generateUtilityClasses = _interopRequireDefault(require("./generateUtilityClasses"));
337
351
  var _ClassNameGenerator = _interopRequireDefault(require("./ClassNameGenerator"));
352
+ var _clamp = _interopRequireDefault(require("./clamp"));
338
353
  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); }
339
354
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -0,0 +1,6 @@
1
+ function clamp(val) {
2
+ var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MIN_SAFE_INTEGER;
3
+ var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Number.MAX_SAFE_INTEGER;
4
+ return Math.max(min, Math.min(val, max));
5
+ }
6
+ export default clamp;
@@ -0,0 +1 @@
1
+ export { default } from './clamp';
@@ -1,9 +1,5 @@
1
1
  import ClassNameGenerator from '../ClassNameGenerator';
2
-
3
- // If GlobalStateSlot is changed, GLOBAL_STATE_CLASSES in
4
- // \packages\api-docs-builder\utils\parseSlotsAndClasses.ts must be updated accordingly.
5
-
6
- var globalStateClassesMapping = {
2
+ export var globalStateClasses = {
7
3
  active: 'active',
8
4
  checked: 'checked',
9
5
  completed: 'completed',
@@ -19,6 +15,9 @@ var globalStateClassesMapping = {
19
15
  };
20
16
  export default function generateUtilityClass(componentName, slot) {
21
17
  var globalStatePrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Mui';
22
- var globalStateClass = globalStateClassesMapping[slot];
18
+ var globalStateClass = globalStateClasses[slot];
23
19
  return globalStateClass ? "".concat(globalStatePrefix, "-").concat(globalStateClass) : "".concat(ClassNameGenerator.generate(componentName), "-").concat(slot);
20
+ }
21
+ export function isGlobalState(slot) {
22
+ return globalStateClasses[slot] !== undefined;
24
23
  }
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v5.15.4
2
+ * @mui/utils v5.15.5
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -43,6 +43,8 @@ export { default as integerPropType } from './integerPropType';
43
43
  export { default as internal_resolveProps } from './resolveProps';
44
44
  export { default as unstable_composeClasses } from './composeClasses';
45
45
  export { default as unstable_generateUtilityClass } from './generateUtilityClass';
46
+ export { isGlobalState as unstable_isGlobalState } from './generateUtilityClass';
46
47
  export * from './generateUtilityClass';
47
48
  export { default as unstable_generateUtilityClasses } from './generateUtilityClasses';
48
- export { default as unstable_ClassNameGenerator } from './ClassNameGenerator';
49
+ export { default as unstable_ClassNameGenerator } from './ClassNameGenerator';
50
+ export { default as clamp } from './clamp';
@@ -0,0 +1,4 @@
1
+ function clamp(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
2
+ return Math.max(min, Math.min(val, max));
3
+ }
4
+ export default clamp;
@@ -0,0 +1 @@
1
+ export { default } from './clamp';
@@ -1,9 +1,5 @@
1
1
  import ClassNameGenerator from '../ClassNameGenerator';
2
-
3
- // If GlobalStateSlot is changed, GLOBAL_STATE_CLASSES in
4
- // \packages\api-docs-builder\utils\parseSlotsAndClasses.ts must be updated accordingly.
5
-
6
- const globalStateClassesMapping = {
2
+ export const globalStateClasses = {
7
3
  active: 'active',
8
4
  checked: 'checked',
9
5
  completed: 'completed',
@@ -18,6 +14,9 @@ const globalStateClassesMapping = {
18
14
  selected: 'selected'
19
15
  };
20
16
  export default function generateUtilityClass(componentName, slot, globalStatePrefix = 'Mui') {
21
- const globalStateClass = globalStateClassesMapping[slot];
17
+ const globalStateClass = globalStateClasses[slot];
22
18
  return globalStateClass ? `${globalStatePrefix}-${globalStateClass}` : `${ClassNameGenerator.generate(componentName)}-${slot}`;
19
+ }
20
+ export function isGlobalState(slot) {
21
+ return globalStateClasses[slot] !== undefined;
23
22
  }
package/modern/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/utils v5.15.4
2
+ * @mui/utils v5.15.5
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -43,6 +43,8 @@ export { default as integerPropType } from './integerPropType';
43
43
  export { default as internal_resolveProps } from './resolveProps';
44
44
  export { default as unstable_composeClasses } from './composeClasses';
45
45
  export { default as unstable_generateUtilityClass } from './generateUtilityClass';
46
+ export { isGlobalState as unstable_isGlobalState } from './generateUtilityClass';
46
47
  export * from './generateUtilityClass';
47
48
  export { default as unstable_generateUtilityClasses } from './generateUtilityClasses';
48
- export { default as unstable_ClassNameGenerator } from './ClassNameGenerator';
49
+ export { default as unstable_ClassNameGenerator } from './ClassNameGenerator';
50
+ export { default as clamp } from './clamp';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "5.15.4",
3
+ "version": "5.15.5",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -26,7 +26,7 @@
26
26
  "url": "https://opencollective.com/mui-org"
27
27
  },
28
28
  "dependencies": {
29
- "@babel/runtime": "^7.23.7",
29
+ "@babel/runtime": "^7.23.8",
30
30
  "@types/prop-types": "^15.7.11",
31
31
  "prop-types": "^15.8.1",
32
32
  "react-is": "^18.2.0"