@mui/system 9.0.0-alpha.4 → 9.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.
Files changed (48) hide show
  1. package/Box/Box.d.mts +1 -1
  2. package/Box/Box.d.ts +1 -1
  3. package/CHANGELOG.md +71 -4
  4. package/Stack/StackProps.d.mts +1 -2
  5. package/Stack/StackProps.d.ts +1 -2
  6. package/Stack/createStack.js +1 -3
  7. package/Stack/createStack.mjs +1 -3
  8. package/breakpoints/breakpoints.d.mts +4 -1
  9. package/breakpoints/breakpoints.d.ts +4 -1
  10. package/breakpoints/breakpoints.js +90 -49
  11. package/breakpoints/breakpoints.mjs +86 -49
  12. package/compose/compose.js +6 -6
  13. package/compose/compose.mjs +6 -6
  14. package/createBox/createBox.js +2 -2
  15. package/createBox/createBox.mjs +2 -2
  16. package/createBreakpoints/createBreakpoints.d.mts +5 -0
  17. package/createBreakpoints/createBreakpoints.d.ts +5 -0
  18. package/createBreakpoints/createBreakpoints.js +5 -0
  19. package/createBreakpoints/createBreakpoints.mjs +5 -0
  20. package/createStyled/createStyled.js +2 -8
  21. package/createStyled/createStyled.mjs +1 -7
  22. package/createTheme/createTheme.js +1 -0
  23. package/createTheme/createTheme.mjs +1 -0
  24. package/cssContainerQueries/cssContainerQueries.d.mts +1 -0
  25. package/cssContainerQueries/cssContainerQueries.d.ts +1 -0
  26. package/cssContainerQueries/cssContainerQueries.js +27 -14
  27. package/cssContainerQueries/cssContainerQueries.mjs +27 -14
  28. package/cssVars/createCssVarsTheme.js +1 -0
  29. package/cssVars/createCssVarsTheme.mjs +1 -0
  30. package/index.js +1 -1
  31. package/index.mjs +1 -1
  32. package/merge/merge.js +4 -3
  33. package/merge/merge.mjs +4 -3
  34. package/package.json +6 -6
  35. package/spacing/spacing.js +45 -45
  36. package/spacing/spacing.mjs +47 -45
  37. package/style/index.d.mts +1 -0
  38. package/style/index.d.ts +1 -0
  39. package/style/index.js +9 -1
  40. package/style/index.mjs +1 -0
  41. package/style/style.d.mts +36 -7
  42. package/style/style.d.ts +36 -7
  43. package/style/style.js +85 -34
  44. package/style/style.mjs +84 -34
  45. package/styleFunctionSx/styleFunctionSx.js +95 -100
  46. package/styleFunctionSx/styleFunctionSx.mjs +98 -102
  47. package/version/index.js +2 -2
  48. package/version/index.mjs +2 -2
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _merge = _interopRequireDefault(require("../merge"));
8
+ var _fastDeepAssign = _interopRequireDefault(require("@mui/utils/fastDeepAssign"));
9
9
  function compose(...styles) {
10
10
  const handlers = styles.reduce((acc, style) => {
11
11
  style.filterProps.forEach(prop => {
@@ -14,15 +14,15 @@ function compose(...styles) {
14
14
  return acc;
15
15
  }, {});
16
16
 
17
- // false positive
18
17
  // eslint-disable-next-line react/function-component-definition
19
18
  const fn = props => {
20
- return Object.keys(props).reduce((acc, prop) => {
19
+ const result = {};
20
+ for (const prop in props) {
21
21
  if (handlers[prop]) {
22
- return (0, _merge.default)(acc, handlers[prop](props));
22
+ (0, _fastDeepAssign.default)(result, handlers[prop](props));
23
23
  }
24
- return acc;
25
- }, {});
24
+ }
25
+ return result;
26
26
  };
27
27
  fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
28
28
  fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
@@ -1,4 +1,4 @@
1
- import merge from "../merge/index.mjs";
1
+ import fastDeepAssign from '@mui/utils/fastDeepAssign';
2
2
  function compose(...styles) {
3
3
  const handlers = styles.reduce((acc, style) => {
4
4
  style.filterProps.forEach(prop => {
@@ -7,15 +7,15 @@ function compose(...styles) {
7
7
  return acc;
8
8
  }, {});
9
9
 
10
- // false positive
11
10
  // eslint-disable-next-line react/function-component-definition
12
11
  const fn = props => {
13
- return Object.keys(props).reduce((acc, prop) => {
12
+ const result = {};
13
+ for (const prop in props) {
14
14
  if (handlers[prop]) {
15
- return merge(acc, handlers[prop](props));
15
+ fastDeepAssign(result, handlers[prop](props));
16
16
  }
17
- return acc;
18
- }, {});
17
+ }
18
+ return result;
19
19
  };
20
20
  fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
21
21
  fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
@@ -10,7 +10,7 @@ exports.default = createBox;
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _clsx = _interopRequireDefault(require("clsx"));
12
12
  var _styledEngine = _interopRequireDefault(require("@mui/styled-engine"));
13
- var _styleFunctionSx = _interopRequireWildcard(require("../styleFunctionSx"));
13
+ var _styleFunctionSx = _interopRequireDefault(require("../styleFunctionSx"));
14
14
  var _useTheme = _interopRequireDefault(require("../useTheme"));
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  function createBox(options = {}) {
@@ -29,7 +29,7 @@ function createBox(options = {}) {
29
29
  className,
30
30
  component = 'div',
31
31
  ...other
32
- } = (0, _styleFunctionSx.extendSxProp)(inProps);
32
+ } = inProps;
33
33
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(BoxRoot, {
34
34
  as: component,
35
35
  ref: ref,
@@ -3,7 +3,7 @@
3
3
  import * as React from 'react';
4
4
  import clsx from 'clsx';
5
5
  import styled from '@mui/styled-engine';
6
- import styleFunctionSx, { extendSxProp } from "../styleFunctionSx/index.mjs";
6
+ import styleFunctionSx from "../styleFunctionSx/index.mjs";
7
7
  import useTheme from "../useTheme/index.mjs";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
  export default function createBox(options = {}) {
@@ -22,7 +22,7 @@ export default function createBox(options = {}) {
22
22
  className,
23
23
  component = 'div',
24
24
  ...other
25
- } = extendSxProp(inProps);
25
+ } = inProps;
26
26
  return /*#__PURE__*/_jsx(BoxRoot, {
27
27
  as: component,
28
28
  ref: ref,
@@ -61,6 +61,11 @@ export interface Breakpoints {
61
61
  * @default 'px'
62
62
  */
63
63
  unit?: string | undefined;
64
+ /**
65
+ * Media query keys
66
+ * @ignore - Do not document.
67
+ */
68
+ internal_mediaKeys: string[];
64
69
  }
65
70
  export interface BreakpointsOptions extends Partial<Breakpoints> {
66
71
  /**
@@ -61,6 +61,11 @@ export interface Breakpoints {
61
61
  * @default 'px'
62
62
  */
63
63
  unit?: string | undefined;
64
+ /**
65
+ * Media query keys
66
+ * @ignore - Do not document.
67
+ */
68
+ internal_mediaKeys: string[];
64
69
  }
65
70
  export interface BreakpointsOptions extends Partial<Breakpoints> {
66
71
  /**
@@ -74,6 +74,10 @@ function createBreakpoints(breakpoints) {
74
74
  }
75
75
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
76
76
  }
77
+ const mediaKeys = [];
78
+ for (let i = 0; i < keys.length; i += 1) {
79
+ mediaKeys.push(up(keys[i]));
80
+ }
77
81
  return {
78
82
  keys,
79
83
  values: sortedValues,
@@ -83,6 +87,7 @@ function createBreakpoints(breakpoints) {
83
87
  only,
84
88
  not,
85
89
  unit,
90
+ internal_mediaKeys: mediaKeys,
86
91
  ...other
87
92
  };
88
93
  }
@@ -67,6 +67,10 @@ export default function createBreakpoints(breakpoints) {
67
67
  }
68
68
  return between(key, keys[keys.indexOf(key) + 1]).replace('@media', '@media not all and');
69
69
  }
70
+ const mediaKeys = [];
71
+ for (let i = 0; i < keys.length; i += 1) {
72
+ mediaKeys.push(up(keys[i]));
73
+ }
70
74
  return {
71
75
  keys,
72
76
  values: sortedValues,
@@ -76,6 +80,7 @@ export default function createBreakpoints(breakpoints) {
76
80
  only,
77
81
  not,
78
82
  unit,
83
+ internal_mediaKeys: mediaKeys,
79
84
  ...other
80
85
  };
81
86
  }
@@ -9,6 +9,7 @@ exports.default = createStyled;
9
9
  exports.shouldForwardProp = shouldForwardProp;
10
10
  exports.systemDefaultTheme = void 0;
11
11
  var _styledEngine = _interopRequireWildcard(require("@mui/styled-engine"));
12
+ var _isObjectEmpty = _interopRequireDefault(require("@mui/utils/isObjectEmpty"));
12
13
  var _deepmerge = require("@mui/utils/deepmerge");
13
14
  var _capitalize = _interopRequireDefault(require("@mui/utils/capitalize"));
14
15
  var _getDisplayName = _interopRequireDefault(require("@mui/utils/getDisplayName"));
@@ -39,7 +40,7 @@ function defaultOverridesResolver(slot) {
39
40
  return (_props, styles) => styles[slot];
40
41
  }
41
42
  function attachTheme(props, themeId, defaultTheme) {
42
- props.theme = isObjectEmpty(props.theme) ? defaultTheme : props.theme[themeId] || props.theme;
43
+ props.theme = (0, _isObjectEmpty.default)(props.theme) ? defaultTheme : props.theme[themeId] || props.theme;
43
44
  }
44
45
  function processStyle(props, style, layerName) {
45
46
  /*
@@ -274,13 +275,6 @@ function generateStyledLabel(componentName, componentSlot) {
274
275
  }
275
276
  return label;
276
277
  }
277
- function isObjectEmpty(object) {
278
- // eslint-disable-next-line
279
- for (const _ in object) {
280
- return false;
281
- }
282
- return true;
283
- }
284
278
 
285
279
  // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
286
280
  function isStringTag(tag) {
@@ -1,4 +1,5 @@
1
1
  import styledEngineStyled, { internal_mutateStyles as mutateStyles, internal_serializeStyles as serializeStyles } from '@mui/styled-engine';
2
+ import isObjectEmpty from '@mui/utils/isObjectEmpty';
2
3
  import { isPlainObject } from '@mui/utils/deepmerge';
3
4
  import capitalize from '@mui/utils/capitalize';
4
5
  import getDisplayName from '@mui/utils/getDisplayName';
@@ -265,13 +266,6 @@ function generateStyledLabel(componentName, componentSlot) {
265
266
  }
266
267
  return label;
267
268
  }
268
- function isObjectEmpty(object) {
269
- // eslint-disable-next-line
270
- for (const _ in object) {
271
- return false;
272
- }
273
- return true;
274
- }
275
269
 
276
270
  // https://github.com/emotion-js/emotion/blob/26ded6109fcd8ca9875cc2ce4564fee678a3f3c5/packages/styled/src/utils.js#L40
277
271
  function isStringTag(tag) {
@@ -51,6 +51,7 @@ function createTheme(options = {}, ...args) {
51
51
  theme: this
52
52
  });
53
53
  };
54
+ muiTheme.internal_cache = {};
54
55
  return muiTheme;
55
56
  }
56
57
  var _default = exports.default = createTheme;
@@ -44,6 +44,7 @@ function createTheme(options = {}, ...args) {
44
44
  theme: this
45
45
  });
46
46
  };
47
+ muiTheme.internal_cache = {};
47
48
  return muiTheme;
48
49
  }
49
50
  export default createTheme;
@@ -10,6 +10,7 @@ export interface CssContainerQueries {
10
10
  containerQueries: ((name: string) => ContainerQueries) & ContainerQueries;
11
11
  }
12
12
  /**
13
+ * WARN: Mutably updates the `css` object.
13
14
  * For using in `sx` prop to sort the breakpoint from low to high.
14
15
  * Note: this function does not work and will not support multiple units.
15
16
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
@@ -10,6 +10,7 @@ export interface CssContainerQueries {
10
10
  containerQueries: ((name: string) => ContainerQueries) & ContainerQueries;
11
11
  }
12
12
  /**
13
+ * WARN: Mutably updates the `css` object.
13
14
  * For using in `sx` prop to sort the breakpoint from low to high.
14
15
  * Note: this function does not work and will not support multiple units.
15
16
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
@@ -7,31 +7,44 @@ exports.default = cssContainerQueries;
7
7
  exports.getContainerQuery = getContainerQuery;
8
8
  exports.isCqShorthand = isCqShorthand;
9
9
  exports.sortContainerQueries = sortContainerQueries;
10
+ const MIN_WIDTH_PATTERN = /min-width:\s*([0-9.]+)/;
11
+
10
12
  /**
13
+ * WARN: Mutably updates the `css` object.
11
14
  * For using in `sx` prop to sort the breakpoint from low to high.
12
15
  * Note: this function does not work and will not support multiple units.
13
16
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
14
17
  * output: { '@container (min-width:40rem)': '2rem', '@container (min-width:300px)': '1rem' } // since 40 < 300 even though 40rem > 300px
15
18
  */
16
19
  function sortContainerQueries(theme, css) {
17
- if (!theme.containerQueries) {
20
+ if (!theme.containerQueries || !hasContainerQuery(css)) {
18
21
  return css;
19
22
  }
20
- const regex = /min-width:\s*([0-9.]+)/;
21
- const sorted = Object.keys(css).filter(key => key.startsWith('@container')).sort((a, b) => {
22
- return +(a.match(regex)?.[1] || 0) - +(b.match(regex)?.[1] || 0);
23
- });
24
- if (!sorted.length) {
25
- return css;
23
+ const keys = [];
24
+ for (const key in css) {
25
+ if (key.startsWith('@container')) {
26
+ keys.push(key);
27
+ }
26
28
  }
27
- return sorted.reduce((acc, key) => {
28
- const value = css[key];
29
- delete acc[key];
30
- acc[key] = value;
31
- return acc;
32
- }, {
33
- ...css
29
+ keys.sort((a, b) => {
30
+ return +(a.match(MIN_WIDTH_PATTERN)?.[1] || 0) - +(b.match(MIN_WIDTH_PATTERN)?.[1] || 0);
34
31
  });
32
+ const result = css;
33
+ for (let i = 0; i < keys.length; i += 1) {
34
+ const key = keys[i];
35
+ const value = result[key];
36
+ delete result[key];
37
+ result[key] = value;
38
+ }
39
+ return result;
40
+ }
41
+ function hasContainerQuery(css) {
42
+ for (const key in css) {
43
+ if (key.startsWith('@container')) {
44
+ return true;
45
+ }
46
+ }
47
+ return false;
35
48
  }
36
49
  function isCqShorthand(breakpointKeys, value) {
37
50
  return value === '@' || value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
@@ -1,28 +1,41 @@
1
+ const MIN_WIDTH_PATTERN = /min-width:\s*([0-9.]+)/;
2
+
1
3
  /**
4
+ * WARN: Mutably updates the `css` object.
2
5
  * For using in `sx` prop to sort the breakpoint from low to high.
3
6
  * Note: this function does not work and will not support multiple units.
4
7
  * e.g. input: { '@container (min-width:300px)': '1rem', '@container (min-width:40rem)': '2rem' }
5
8
  * output: { '@container (min-width:40rem)': '2rem', '@container (min-width:300px)': '1rem' } // since 40 < 300 even though 40rem > 300px
6
9
  */
7
10
  export function sortContainerQueries(theme, css) {
8
- if (!theme.containerQueries) {
11
+ if (!theme.containerQueries || !hasContainerQuery(css)) {
9
12
  return css;
10
13
  }
11
- const regex = /min-width:\s*([0-9.]+)/;
12
- const sorted = Object.keys(css).filter(key => key.startsWith('@container')).sort((a, b) => {
13
- return +(a.match(regex)?.[1] || 0) - +(b.match(regex)?.[1] || 0);
14
- });
15
- if (!sorted.length) {
16
- return css;
14
+ const keys = [];
15
+ for (const key in css) {
16
+ if (key.startsWith('@container')) {
17
+ keys.push(key);
18
+ }
17
19
  }
18
- return sorted.reduce((acc, key) => {
19
- const value = css[key];
20
- delete acc[key];
21
- acc[key] = value;
22
- return acc;
23
- }, {
24
- ...css
20
+ keys.sort((a, b) => {
21
+ return +(a.match(MIN_WIDTH_PATTERN)?.[1] || 0) - +(b.match(MIN_WIDTH_PATTERN)?.[1] || 0);
25
22
  });
23
+ const result = css;
24
+ for (let i = 0; i < keys.length; i += 1) {
25
+ const key = keys[i];
26
+ const value = result[key];
27
+ delete result[key];
28
+ result[key] = value;
29
+ }
30
+ return result;
31
+ }
32
+ function hasContainerQuery(css) {
33
+ for (const key in css) {
34
+ if (key.startsWith('@container')) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
26
39
  }
27
40
  export function isCqShorthand(breakpointKeys, value) {
28
41
  return value === '@' || value.startsWith('@') && (breakpointKeys.some(key => value.startsWith(`@${key}`)) || !!value.match(/^@\d/));
@@ -23,6 +23,7 @@ function createCssVarsTheme({
23
23
  output.generateStyleSheets = result.generateStyleSheets;
24
24
  output.colorSchemeSelector = colorSchemeSelector;
25
25
  output.getColorSchemeSelector = (0, _getColorSchemeSelector.createGetColorSchemeSelector)(colorSchemeSelector);
26
+ output.internal_cache = {};
26
27
  return output;
27
28
  }
28
29
  var _default = exports.default = createCssVarsTheme;
@@ -16,6 +16,7 @@ function createCssVarsTheme({
16
16
  output.generateStyleSheets = result.generateStyleSheets;
17
17
  output.colorSchemeSelector = colorSchemeSelector;
18
18
  output.getColorSchemeSelector = createGetColorSchemeSelector(colorSchemeSelector);
19
+ output.internal_cache = {};
19
20
  return output;
20
21
  }
21
22
  export default createCssVarsTheme;
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v9.0.0-alpha.4
2
+ * @mui/system v9.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/system v9.0.0-alpha.4
2
+ * @mui/system v9.0.0-beta.0
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
package/merge/merge.js CHANGED
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _deepmerge = _interopRequireDefault(require("@mui/utils/deepmerge"));
9
+ const options = {
10
+ clone: false
11
+ };
9
12
  function merge(acc, item) {
10
13
  if (!item) {
11
14
  return acc;
12
15
  }
13
- return (0, _deepmerge.default)(acc, item, {
14
- clone: false // No need to clone deep, it's way faster.
15
- });
16
+ return (0, _deepmerge.default)(acc, item, options);
16
17
  }
17
18
  var _default = exports.default = merge;
package/merge/merge.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  import deepmerge from '@mui/utils/deepmerge';
2
+ const options = {
3
+ clone: false
4
+ };
2
5
  function merge(acc, item) {
3
6
  if (!item) {
4
7
  return acc;
5
8
  }
6
- return deepmerge(acc, item, {
7
- clone: false // No need to clone deep, it's way faster.
8
- });
9
+ return deepmerge(acc, item, options);
9
10
  }
10
11
  export default merge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/system",
3
- "version": "9.0.0-alpha.4",
3
+ "version": "9.0.0-beta.0",
4
4
  "author": "MUI Team",
5
5
  "description": "MUI System is a set of CSS utilities to help you build custom designs more efficiently. It makes it possible to rapidly lay out custom designs.",
6
6
  "keywords": [
@@ -24,14 +24,14 @@
24
24
  "url": "https://opencollective.com/mui-org"
25
25
  },
26
26
  "dependencies": {
27
- "@babel/runtime": "^7.28.6",
27
+ "@babel/runtime": "^7.29.2",
28
28
  "clsx": "^2.1.1",
29
29
  "csstype": "^3.2.3",
30
30
  "prop-types": "^15.8.1",
31
- "@mui/private-theming": "9.0.0-alpha.4",
32
- "@mui/utils": "9.0.0-alpha.4",
33
- "@mui/types": "^9.0.0-alpha.3",
34
- "@mui/styled-engine": "9.0.0-alpha.3"
31
+ "@mui/private-theming": "9.0.0-beta.0",
32
+ "@mui/styled-engine": "9.0.0-beta.0",
33
+ "@mui/types": "^9.0.0-beta.0",
34
+ "@mui/utils": "9.0.0-beta.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@emotion/react": "^11.5.0",
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.createUnarySpacing = createUnarySpacing;
8
8
  exports.createUnaryUnit = createUnaryUnit;
9
9
  exports.default = void 0;
10
- exports.getStyleFromPropValue = getStyleFromPropValue;
11
10
  exports.getValue = getValue;
12
11
  exports.margin = margin;
13
12
  exports.marginKeys = void 0;
@@ -16,8 +15,11 @@ exports.paddingKeys = void 0;
16
15
  var _responsivePropType = _interopRequireDefault(require("../responsivePropType"));
17
16
  var _breakpoints = require("../breakpoints");
18
17
  var _style = require("../style");
19
- var _merge = _interopRequireDefault(require("../merge"));
20
- var _memoize = _interopRequireDefault(require("../memoize"));
18
+ /* eslint-disable guard-for-in */
19
+
20
+ const EMPTY_THEME = {
21
+ internal_cache: {}
22
+ };
21
23
  const properties = {
22
24
  m: 'margin',
23
25
  p: 'padding'
@@ -36,27 +38,24 @@ const aliases = {
36
38
  paddingX: 'px',
37
39
  paddingY: 'py'
38
40
  };
39
-
40
- // memoize() impact:
41
- // From 300,000 ops/sec
42
- // To 350,000 ops/sec
43
- const getCssProperties = (0, _memoize.default)(prop => {
44
- // It's not a shorthand notation.
45
- if (prop.length > 2) {
46
- if (aliases[prop]) {
47
- prop = aliases[prop];
48
- } else {
49
- return [prop];
50
- }
41
+ const CSS_PROPERTIES = {};
42
+ for (const key in properties) {
43
+ CSS_PROPERTIES[key] = [properties[key]];
44
+ }
45
+ for (const keyProperty in properties) {
46
+ for (const keyDirection in directions) {
47
+ const property = properties[keyProperty];
48
+ const direction = directions[keyDirection];
49
+ const value = Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
50
+ CSS_PROPERTIES[keyProperty + keyDirection] = value;
51
51
  }
52
- const [a, b] = prop.split('');
53
- const property = properties[a];
54
- const direction = directions[b] || '';
55
- return Array.isArray(direction) ? direction.map(dir => property + dir) : [property + direction];
56
- });
57
- const marginKeys = exports.marginKeys = ['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd'];
58
- const paddingKeys = exports.paddingKeys = ['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd'];
59
- const spacingKeys = [...marginKeys, ...paddingKeys];
52
+ }
53
+ for (const key in aliases) {
54
+ CSS_PROPERTIES[key] = CSS_PROPERTIES[aliases[key]];
55
+ }
56
+ const marginKeys = exports.marginKeys = new Set(['m', 'mt', 'mr', 'mb', 'ml', 'mx', 'my', 'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginX', 'marginY', 'marginInline', 'marginInlineStart', 'marginInlineEnd', 'marginBlock', 'marginBlockStart', 'marginBlockEnd']);
57
+ const paddingKeys = exports.paddingKeys = new Set(['p', 'pt', 'pr', 'pb', 'pl', 'px', 'py', 'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingX', 'paddingY', 'paddingInline', 'paddingInlineStart', 'paddingInlineEnd', 'paddingBlock', 'paddingBlockStart', 'paddingBlockEnd']);
58
+ const spacingKeys = new Set([...marginKeys, ...paddingKeys]);
60
59
  function createUnaryUnit(theme, themeKey, defaultValue, propName) {
61
60
  const themeSpacing = (0, _style.getPath)(theme, themeKey, true) ?? defaultValue;
62
61
  if (typeof themeSpacing === 'number' || typeof themeSpacing === 'string') {
@@ -124,31 +123,32 @@ function getValue(transformer, propValue) {
124
123
  }
125
124
  return transformer(propValue);
126
125
  }
127
- function getStyleFromPropValue(cssProperties, transformer) {
128
- return propValue => cssProperties.reduce((acc, cssProperty) => {
129
- acc[cssProperty] = getValue(transformer, propValue);
130
- return acc;
131
- }, {});
132
- }
133
- function resolveCssProperty(props, keys, prop, transformer) {
134
- // Using a hash computation over an array iteration could be faster, but with only 28 items,
135
- // it's doesn't worth the bundle size.
136
- if (!keys.includes(prop)) {
137
- return null;
138
- }
139
- const cssProperties = getCssProperties(prop);
140
- const styleFromPropValue = getStyleFromPropValue(cssProperties, transformer);
141
- const propValue = props[prop];
142
- return (0, _breakpoints.handleBreakpoints)(props, propValue, styleFromPropValue);
143
- }
126
+
127
+ // Avoid allocations
128
+ const container = [''];
144
129
  function style(props, keys) {
145
- const transformer = createUnarySpacing(props.theme);
146
- return Object.keys(props).map(prop => resolveCssProperty(props, keys, prop, transformer)).reduce(_merge.default, {});
130
+ const theme = props.theme ?? EMPTY_THEME;
131
+ const transformer = theme?.internal_cache?.unarySpacing ?? createUnarySpacing(theme);
132
+ const result = {};
133
+ for (const prop in props) {
134
+ if (!keys.has(prop)) {
135
+ continue;
136
+ }
137
+ const cssProperties = CSS_PROPERTIES[prop] ?? (container[0] = prop, container);
138
+ const propValue = props[prop];
139
+ (0, _breakpoints.iterateBreakpoints)(result, props.theme, propValue, (mediaKey, value) => {
140
+ const target = mediaKey ? result[mediaKey] : result;
141
+ for (let i = 0; i < cssProperties.length; i += 1) {
142
+ target[cssProperties[i]] = getValue(transformer, value);
143
+ }
144
+ });
145
+ }
146
+ return result;
147
147
  }
148
148
  function margin(props) {
149
149
  return style(props, marginKeys);
150
150
  }
151
- margin.propTypes = process.env.NODE_ENV !== 'production' ? marginKeys.reduce((obj, key) => {
151
+ margin.propTypes = process.env.NODE_ENV !== 'production' ? Array.from(marginKeys).reduce((obj, key) => {
152
152
  obj[key] = _responsivePropType.default;
153
153
  return obj;
154
154
  }, {}) : {};
@@ -156,7 +156,7 @@ margin.filterProps = marginKeys;
156
156
  function padding(props) {
157
157
  return style(props, paddingKeys);
158
158
  }
159
- padding.propTypes = process.env.NODE_ENV !== 'production' ? paddingKeys.reduce((obj, key) => {
159
+ padding.propTypes = process.env.NODE_ENV !== 'production' ? Array.from(paddingKeys).reduce((obj, key) => {
160
160
  obj[key] = _responsivePropType.default;
161
161
  return obj;
162
162
  }, {}) : {};
@@ -164,7 +164,7 @@ padding.filterProps = paddingKeys;
164
164
  function spacing(props) {
165
165
  return style(props, spacingKeys);
166
166
  }
167
- spacing.propTypes = process.env.NODE_ENV !== 'production' ? spacingKeys.reduce((obj, key) => {
167
+ spacing.propTypes = process.env.NODE_ENV !== 'production' ? Array.from(spacingKeys).reduce((obj, key) => {
168
168
  obj[key] = _responsivePropType.default;
169
169
  return obj;
170
170
  }, {}) : {};