@mui/system 7.0.1 → 7.1.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 (283) hide show
  1. package/Box/Box.d.ts +12 -31
  2. package/CHANGELOG.md +157 -0
  3. package/Grid/createGrid.js +1 -2
  4. package/InitColorSchemeScript/InitColorSchemeScript.js +1 -1
  5. package/Stack/createStack.js +1 -2
  6. package/borders/borders.d.ts +2 -1
  7. package/breakpoints/breakpoints.d.ts +1 -1
  8. package/compose/compose.d.ts +14 -1
  9. package/compose/index.d.ts +1 -1
  10. package/cssGrid/cssGrid.d.ts +2 -1
  11. package/cssVars/cssVarsParser.d.ts +1 -1
  12. package/display/display.d.ts +2 -1
  13. package/esm/Box/Box.d.ts +12 -31
  14. package/esm/Grid/createGrid.js +1 -2
  15. package/esm/InitColorSchemeScript/InitColorSchemeScript.js +1 -1
  16. package/esm/Stack/createStack.js +1 -2
  17. package/esm/borders/borders.d.ts +2 -1
  18. package/esm/breakpoints/breakpoints.d.ts +1 -1
  19. package/esm/compose/compose.d.ts +14 -1
  20. package/esm/compose/index.d.ts +1 -1
  21. package/esm/cssGrid/cssGrid.d.ts +2 -1
  22. package/esm/cssVars/cssVarsParser.d.ts +1 -1
  23. package/esm/display/display.d.ts +2 -1
  24. package/esm/flexbox/flexbox.d.ts +15 -1
  25. package/esm/index.d.ts +10 -0
  26. package/esm/index.js +1 -1
  27. package/esm/memoTheme.d.ts +1 -1
  28. package/esm/palette/palette.d.ts +2 -1
  29. package/esm/positions/positions.d.ts +2 -1
  30. package/esm/shadows/shadows.d.ts +2 -1
  31. package/esm/sizing/sizing.d.ts +2 -1
  32. package/esm/spacing/spacing.d.ts +2 -1
  33. package/esm/style/style.d.ts +5 -1
  34. package/esm/styleFunctionSx/defaultSxConfig.d.ts +1 -2
  35. package/esm/typography/typography.d.ts +2 -1
  36. package/esm/useMediaQuery/useMediaQuery.js +3 -0
  37. package/esm/useThemeProps/getThemeProps.d.ts +0 -5
  38. package/esm/version/index.js +3 -3
  39. package/flexbox/flexbox.d.ts +15 -1
  40. package/index.d.ts +10 -0
  41. package/index.js +1 -1
  42. package/memoTheme.d.ts +1 -1
  43. package/package.json +7 -15
  44. package/palette/palette.d.ts +2 -1
  45. package/positions/positions.d.ts +2 -1
  46. package/shadows/shadows.d.ts +2 -1
  47. package/sizing/sizing.d.ts +2 -1
  48. package/spacing/spacing.d.ts +2 -1
  49. package/style/style.d.ts +5 -1
  50. package/styleFunctionSx/defaultSxConfig.d.ts +1 -2
  51. package/typography/typography.d.ts +2 -1
  52. package/useMediaQuery/useMediaQuery.js +3 -0
  53. package/useThemeProps/getThemeProps.d.ts +0 -5
  54. package/version/index.js +3 -3
  55. package/modern/Box/Box.d.ts +0 -72
  56. package/modern/Box/Box.js +0 -30
  57. package/modern/Box/boxClasses.d.ts +0 -7
  58. package/modern/Box/boxClasses.js +0 -3
  59. package/modern/Box/index.d.ts +0 -4
  60. package/modern/Box/index.js +0 -3
  61. package/modern/CSSProperties.d.ts +0 -7
  62. package/modern/Container/Container.d.ts +0 -13
  63. package/modern/Container/Container.js +0 -61
  64. package/modern/Container/ContainerProps.d.ts +0 -40
  65. package/modern/Container/ContainerProps.js +0 -1
  66. package/modern/Container/containerClasses.d.ts +0 -22
  67. package/modern/Container/containerClasses.js +0 -7
  68. package/modern/Container/createContainer.d.ts +0 -18
  69. package/modern/Container/createContainer.js +0 -149
  70. package/modern/Container/index.d.ts +0 -4
  71. package/modern/Container/index.js +0 -3
  72. package/modern/DefaultPropsProvider/DefaultPropsProvider.d.ts +0 -18
  73. package/modern/DefaultPropsProvider/DefaultPropsProvider.js +0 -64
  74. package/modern/DefaultPropsProvider/index.d.ts +0 -1
  75. package/modern/DefaultPropsProvider/index.js +0 -1
  76. package/modern/GlobalStyles/GlobalStyles.d.ts +0 -17
  77. package/modern/GlobalStyles/GlobalStyles.js +0 -37
  78. package/modern/GlobalStyles/index.d.ts +0 -2
  79. package/modern/GlobalStyles/index.js +0 -2
  80. package/modern/Grid/Grid.d.ts +0 -13
  81. package/modern/Grid/Grid.js +0 -106
  82. package/modern/Grid/GridProps.d.ts +0 -103
  83. package/modern/Grid/GridProps.js +0 -1
  84. package/modern/Grid/createGrid.d.ts +0 -13
  85. package/modern/Grid/createGrid.js +0 -155
  86. package/modern/Grid/deleteLegacyGridProps.d.ts +0 -11
  87. package/modern/Grid/deleteLegacyGridProps.js +0 -41
  88. package/modern/Grid/gridClasses.d.ts +0 -20
  89. package/modern/Grid/gridClasses.js +0 -19
  90. package/modern/Grid/gridGenerator.d.ts +0 -42
  91. package/modern/Grid/gridGenerator.js +0 -193
  92. package/modern/Grid/index.d.ts +0 -7
  93. package/modern/Grid/index.js +0 -7
  94. package/modern/Grid/traverseBreakpoints.d.ts +0 -7
  95. package/modern/Grid/traverseBreakpoints.js +0 -42
  96. package/modern/InitColorSchemeScript/InitColorSchemeScript.d.ts +0 -51
  97. package/modern/InitColorSchemeScript/InitColorSchemeScript.js +0 -78
  98. package/modern/InitColorSchemeScript/index.d.ts +0 -2
  99. package/modern/InitColorSchemeScript/index.js +0 -1
  100. package/modern/RtlProvider/index.d.ts +0 -8
  101. package/modern/RtlProvider/index.js +0 -24
  102. package/modern/Stack/Stack.d.ts +0 -14
  103. package/modern/Stack/Stack.js +0 -62
  104. package/modern/Stack/StackProps.d.ts +0 -53
  105. package/modern/Stack/StackProps.js +0 -1
  106. package/modern/Stack/createStack.d.ts +0 -24
  107. package/modern/Stack/createStack.js +0 -173
  108. package/modern/Stack/index.d.ts +0 -5
  109. package/modern/Stack/index.js +0 -5
  110. package/modern/Stack/stackClasses.d.ts +0 -8
  111. package/modern/Stack/stackClasses.js +0 -7
  112. package/modern/ThemeProvider/ThemeProvider.d.ts +0 -24
  113. package/modern/ThemeProvider/ThemeProvider.js +0 -97
  114. package/modern/ThemeProvider/index.d.ts +0 -2
  115. package/modern/ThemeProvider/index.js +0 -1
  116. package/modern/borders/borders.d.ts +0 -14
  117. package/modern/borders/borders.js +0 -49
  118. package/modern/borders/index.d.ts +0 -2
  119. package/modern/borders/index.js +0 -2
  120. package/modern/breakpoints/breakpoints.d.ts +0 -19
  121. package/modern/breakpoints/breakpoints.js +0 -171
  122. package/modern/breakpoints/index.d.ts +0 -2
  123. package/modern/breakpoints/index.js +0 -2
  124. package/modern/colorManipulator/colorManipulator.d.ts +0 -25
  125. package/modern/colorManipulator/colorManipulator.js +0 -349
  126. package/modern/colorManipulator/index.d.ts +0 -1
  127. package/modern/colorManipulator/index.js +0 -1
  128. package/modern/compose/compose.d.ts +0 -2
  129. package/modern/compose/compose.js +0 -24
  130. package/modern/compose/index.d.ts +0 -1
  131. package/modern/compose/index.js +0 -1
  132. package/modern/createBox/createBox.d.ts +0 -9
  133. package/modern/createBox/createBox.js +0 -35
  134. package/modern/createBox/index.d.ts +0 -1
  135. package/modern/createBox/index.js +0 -1
  136. package/modern/createBreakpoints/createBreakpoints.d.ts +0 -78
  137. package/modern/createBreakpoints/createBreakpoints.js +0 -81
  138. package/modern/createBreakpoints/index.d.ts +0 -3
  139. package/modern/createBreakpoints/index.js +0 -3
  140. package/modern/createStyled/createStyled.d.ts +0 -27
  141. package/modern/createStyled/createStyled.js +0 -276
  142. package/modern/createStyled/index.d.ts +0 -2
  143. package/modern/createStyled/index.js +0 -2
  144. package/modern/createTheme/applyStyles.d.ts +0 -67
  145. package/modern/createTheme/applyStyles.js +0 -87
  146. package/modern/createTheme/createSpacing.d.ts +0 -10
  147. package/modern/createTheme/createSpacing.js +0 -31
  148. package/modern/createTheme/createTheme.d.ts +0 -54
  149. package/modern/createTheme/createTheme.js +0 -49
  150. package/modern/createTheme/index.d.ts +0 -4
  151. package/modern/createTheme/index.js +0 -3
  152. package/modern/createTheme/shape.d.ts +0 -6
  153. package/modern/createTheme/shape.js +0 -4
  154. package/modern/cssContainerQueries/cssContainerQueries.d.ts +0 -23
  155. package/modern/cssContainerQueries/cssContainerQueries.js +0 -69
  156. package/modern/cssContainerQueries/index.d.ts +0 -3
  157. package/modern/cssContainerQueries/index.js +0 -2
  158. package/modern/cssGrid/cssGrid.d.ts +0 -15
  159. package/modern/cssGrid/cssGrid.js +0 -85
  160. package/modern/cssGrid/index.d.ts +0 -2
  161. package/modern/cssGrid/index.js +0 -2
  162. package/modern/cssVars/createCssVarsProvider.d.ts +0 -141
  163. package/modern/cssVars/createCssVarsProvider.js +0 -338
  164. package/modern/cssVars/createCssVarsTheme.d.ts +0 -15
  165. package/modern/cssVars/createCssVarsTheme.js +0 -21
  166. package/modern/cssVars/createGetCssVar.d.ts +0 -5
  167. package/modern/cssVars/createGetCssVar.js +0 -22
  168. package/modern/cssVars/cssVarsParser.d.ts +0 -64
  169. package/modern/cssVars/cssVarsParser.js +0 -129
  170. package/modern/cssVars/getColorSchemeSelector.d.ts +0 -1
  171. package/modern/cssVars/getColorSchemeSelector.js +0 -26
  172. package/modern/cssVars/index.d.ts +0 -8
  173. package/modern/cssVars/index.js +0 -5
  174. package/modern/cssVars/localStorageManager.d.ts +0 -34
  175. package/modern/cssVars/localStorageManager.js +0 -51
  176. package/modern/cssVars/prepareCssVars.d.ts +0 -16
  177. package/modern/cssVars/prepareCssVars.js +0 -153
  178. package/modern/cssVars/prepareTypographyVars.d.ts +0 -4
  179. package/modern/cssVars/prepareTypographyVars.js +0 -11
  180. package/modern/cssVars/useCurrentColorScheme.d.ts +0 -56
  181. package/modern/cssVars/useCurrentColorScheme.js +0 -228
  182. package/modern/display/display.d.ts +0 -3
  183. package/modern/display/display.js +0 -27
  184. package/modern/display/index.d.ts +0 -2
  185. package/modern/display/index.js +0 -2
  186. package/modern/flexbox/flexbox.d.ts +0 -3
  187. package/modern/flexbox/flexbox.js +0 -43
  188. package/modern/flexbox/index.d.ts +0 -2
  189. package/modern/flexbox/index.js +0 -2
  190. package/modern/getThemeValue/getThemeValue.d.ts +0 -1
  191. package/modern/getThemeValue/getThemeValue.js +0 -51
  192. package/modern/getThemeValue/index.d.ts +0 -2
  193. package/modern/getThemeValue/index.js +0 -2
  194. package/modern/index.d.ts +0 -80
  195. package/modern/index.js +0 -75
  196. package/modern/memoTheme.d.ts +0 -12
  197. package/modern/memoTheme.js +0 -28
  198. package/modern/memoize/index.d.ts +0 -1
  199. package/modern/memoize/index.js +0 -1
  200. package/modern/memoize/memoize.d.ts +0 -1
  201. package/modern/memoize/memoize.js +0 -9
  202. package/modern/merge/index.d.ts +0 -1
  203. package/modern/merge/index.js +0 -1
  204. package/modern/merge/merge.d.ts +0 -1
  205. package/modern/merge/merge.js +0 -10
  206. package/modern/package.json +0 -1
  207. package/modern/palette/index.d.ts +0 -2
  208. package/modern/palette/index.js +0 -2
  209. package/modern/palette/palette.d.ts +0 -5
  210. package/modern/palette/palette.js +0 -26
  211. package/modern/positions/index.d.ts +0 -2
  212. package/modern/positions/index.js +0 -2
  213. package/modern/positions/positions.d.ts +0 -3
  214. package/modern/positions/positions.js +0 -22
  215. package/modern/preprocessStyles.d.ts +0 -5
  216. package/modern/preprocessStyles.js +0 -25
  217. package/modern/propsToClassKey/index.d.ts +0 -1
  218. package/modern/propsToClassKey/index.js +0 -1
  219. package/modern/propsToClassKey/propsToClassKey.d.ts +0 -1
  220. package/modern/propsToClassKey/propsToClassKey.js +0 -25
  221. package/modern/responsivePropType/index.d.ts +0 -1
  222. package/modern/responsivePropType/index.js +0 -1
  223. package/modern/responsivePropType/responsivePropType.d.ts +0 -2
  224. package/modern/responsivePropType/responsivePropType.js +0 -3
  225. package/modern/shadows/index.d.ts +0 -1
  226. package/modern/shadows/index.js +0 -1
  227. package/modern/shadows/shadows.d.ts +0 -3
  228. package/modern/shadows/shadows.js +0 -6
  229. package/modern/sizing/index.d.ts +0 -2
  230. package/modern/sizing/index.js +0 -2
  231. package/modern/sizing/sizing.d.ts +0 -12
  232. package/modern/sizing/sizing.js +0 -64
  233. package/modern/spacing/index.d.ts +0 -2
  234. package/modern/spacing/index.js +0 -2
  235. package/modern/spacing/spacing.d.ts +0 -19
  236. package/modern/spacing/spacing.js +0 -157
  237. package/modern/style/index.d.ts +0 -2
  238. package/modern/style/index.js +0 -2
  239. package/modern/style/style.d.ts +0 -19
  240. package/modern/style/style.js +0 -75
  241. package/modern/styleFunctionSx/AliasesCSSProperties.d.ts +0 -269
  242. package/modern/styleFunctionSx/AliasesCSSProperties.js +0 -1
  243. package/modern/styleFunctionSx/OverwriteCSSProperties.d.ts +0 -54
  244. package/modern/styleFunctionSx/OverwriteCSSProperties.js +0 -1
  245. package/modern/styleFunctionSx/StandardCssProperties.d.ts +0 -2
  246. package/modern/styleFunctionSx/StandardCssProperties.js +0 -1
  247. package/modern/styleFunctionSx/defaultSxConfig.d.ts +0 -15
  248. package/modern/styleFunctionSx/defaultSxConfig.js +0 -294
  249. package/modern/styleFunctionSx/extendSxProp.d.ts +0 -4
  250. package/modern/styleFunctionSx/extendSxProp.js +0 -51
  251. package/modern/styleFunctionSx/index.d.ts +0 -9
  252. package/modern/styleFunctionSx/index.js +0 -4
  253. package/modern/styleFunctionSx/styleFunctionSx.d.ts +0 -62
  254. package/modern/styleFunctionSx/styleFunctionSx.js +0 -127
  255. package/modern/styled/index.d.ts +0 -1
  256. package/modern/styled/index.js +0 -1
  257. package/modern/styled/styled.d.ts +0 -3
  258. package/modern/styled/styled.js +0 -3
  259. package/modern/typography/index.d.ts +0 -2
  260. package/modern/typography/index.js +0 -2
  261. package/modern/typography/typography.d.ts +0 -12
  262. package/modern/typography/typography.js +0 -37
  263. package/modern/useMediaQuery/index.d.ts +0 -2
  264. package/modern/useMediaQuery/index.js +0 -2
  265. package/modern/useMediaQuery/useMediaQuery.d.ts +0 -32
  266. package/modern/useMediaQuery/useMediaQuery.js +0 -118
  267. package/modern/useTheme/index.d.ts +0 -2
  268. package/modern/useTheme/index.js +0 -2
  269. package/modern/useTheme/useTheme.d.ts +0 -2
  270. package/modern/useTheme/useTheme.js +0 -9
  271. package/modern/useThemeProps/getThemeProps.d.ts +0 -16
  272. package/modern/useThemeProps/getThemeProps.js +0 -12
  273. package/modern/useThemeProps/index.d.ts +0 -3
  274. package/modern/useThemeProps/index.js +0 -2
  275. package/modern/useThemeProps/useThemeProps.d.ts +0 -14
  276. package/modern/useThemeProps/useThemeProps.js +0 -20
  277. package/modern/useThemeWithoutDefault/index.d.ts +0 -1
  278. package/modern/useThemeWithoutDefault/index.js +0 -1
  279. package/modern/useThemeWithoutDefault/useThemeWithoutDefault.d.ts +0 -1
  280. package/modern/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -12
  281. package/modern/version/index.d.ts +0 -6
  282. package/modern/version/index.js +0 -6
  283. package/tsconfig.build.tsbuildinfo +0 -1
@@ -1,49 +0,0 @@
1
- import responsivePropType from "../responsivePropType/index.js";
2
- import style from "../style/index.js";
3
- import compose from "../compose/index.js";
4
- import { createUnaryUnit, getValue } from "../spacing/index.js";
5
- import { handleBreakpoints } from "../breakpoints/index.js";
6
- export function borderTransform(value) {
7
- if (typeof value !== 'number') {
8
- return value;
9
- }
10
- return `${value}px solid`;
11
- }
12
- function createBorderStyle(prop, transform) {
13
- return style({
14
- prop,
15
- themeKey: 'borders',
16
- transform
17
- });
18
- }
19
- export const border = createBorderStyle('border', borderTransform);
20
- export const borderTop = createBorderStyle('borderTop', borderTransform);
21
- export const borderRight = createBorderStyle('borderRight', borderTransform);
22
- export const borderBottom = createBorderStyle('borderBottom', borderTransform);
23
- export const borderLeft = createBorderStyle('borderLeft', borderTransform);
24
- export const borderColor = createBorderStyle('borderColor');
25
- export const borderTopColor = createBorderStyle('borderTopColor');
26
- export const borderRightColor = createBorderStyle('borderRightColor');
27
- export const borderBottomColor = createBorderStyle('borderBottomColor');
28
- export const borderLeftColor = createBorderStyle('borderLeftColor');
29
- export const outline = createBorderStyle('outline', borderTransform);
30
- export const outlineColor = createBorderStyle('outlineColor');
31
-
32
- // false positive
33
- // eslint-disable-next-line react/function-component-definition
34
- export const borderRadius = props => {
35
- if (props.borderRadius !== undefined && props.borderRadius !== null) {
36
- const transformer = createUnaryUnit(props.theme, 'shape.borderRadius', 4, 'borderRadius');
37
- const styleFromPropValue = propValue => ({
38
- borderRadius: getValue(transformer, propValue)
39
- });
40
- return handleBreakpoints(props, props.borderRadius, styleFromPropValue);
41
- }
42
- return null;
43
- };
44
- borderRadius.propTypes = process.env.NODE_ENV !== 'production' ? {
45
- borderRadius: responsivePropType
46
- } : {};
47
- borderRadius.filterProps = ['borderRadius'];
48
- const borders = compose(border, borderTop, borderRight, borderBottom, borderLeft, borderColor, borderTopColor, borderRightColor, borderBottomColor, borderLeftColor, borderRadius, outline, outlineColor);
49
- export default borders;
@@ -1,2 +0,0 @@
1
- export { default } from "./borders.js";
2
- export * from "./borders.js";
@@ -1,2 +0,0 @@
1
- export { default } from "./borders.js";
2
- export * from "./borders.js";
@@ -1,19 +0,0 @@
1
- import { CSSObject } from '@mui/styled-engine';
2
- import { Breakpoints } from "../createBreakpoints/createBreakpoints.js";
3
- import type { Breakpoint } from "../createTheme/index.js";
4
- import { ResponsiveStyleValue } from "../styleFunctionSx/index.js";
5
- import { StyleFunction } from "../Box/index.js";
6
- export interface ResolveBreakpointValuesOptions<T> {
7
- values: ResponsiveStyleValue<T>;
8
- breakpoints?: Breakpoints['values'];
9
- base?: Record<string, boolean>;
10
- }
11
- export function resolveBreakpointValues<T>(options: ResolveBreakpointValuesOptions<T>): Record<string, T>;
12
- export function mergeBreakpointsInOrder(breakpoints: Breakpoints, styles: CSSObject[]): CSSObject;
13
- export function handleBreakpoints<Props>(props: Props, propValue: any, styleFromPropValue: (value: any, breakpoint?: Breakpoint) => any): any;
14
- type DefaultBreakPoints = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
15
-
16
- /**
17
- * @returns An enhanced stylefunction that considers breakpoints
18
- */
19
- export default function breakpoints<Props, Breakpoints extends string = DefaultBreakPoints>(styleFunction: StyleFunction<Props>): StyleFunction<Partial<Record<Breakpoints, Props>> & Props>;
@@ -1,171 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import deepmerge from '@mui/utils/deepmerge';
3
- import merge from "../merge/index.js";
4
- import { isCqShorthand, getContainerQuery } from "../cssContainerQueries/index.js";
5
-
6
- // The breakpoint **start** at this value.
7
- // For instance with the first breakpoint xs: [xs, sm[.
8
- export const values = {
9
- xs: 0,
10
- // phone
11
- sm: 600,
12
- // tablet
13
- md: 900,
14
- // small laptop
15
- lg: 1200,
16
- // desktop
17
- xl: 1536 // large screen
18
- };
19
- const defaultBreakpoints = {
20
- // Sorted ASC by size. That's important.
21
- // It can't be configured as it's used statically for propTypes.
22
- keys: ['xs', 'sm', 'md', 'lg', 'xl'],
23
- up: key => `@media (min-width:${values[key]}px)`
24
- };
25
- const defaultContainerQueries = {
26
- containerQueries: containerName => ({
27
- up: key => {
28
- let result = typeof key === 'number' ? key : values[key] || key;
29
- if (typeof result === 'number') {
30
- result = `${result}px`;
31
- }
32
- return containerName ? `@container ${containerName} (min-width:${result})` : `@container (min-width:${result})`;
33
- }
34
- })
35
- };
36
- export function handleBreakpoints(props, propValue, styleFromPropValue) {
37
- const theme = props.theme || {};
38
- if (Array.isArray(propValue)) {
39
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
40
- return propValue.reduce((acc, item, index) => {
41
- acc[themeBreakpoints.up(themeBreakpoints.keys[index])] = styleFromPropValue(propValue[index]);
42
- return acc;
43
- }, {});
44
- }
45
- if (typeof propValue === 'object') {
46
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
47
- return Object.keys(propValue).reduce((acc, breakpoint) => {
48
- if (isCqShorthand(themeBreakpoints.keys, breakpoint)) {
49
- const containerKey = getContainerQuery(theme.containerQueries ? theme : defaultContainerQueries, breakpoint);
50
- if (containerKey) {
51
- acc[containerKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
52
- }
53
- }
54
- // key is breakpoint
55
- else if (Object.keys(themeBreakpoints.values || values).includes(breakpoint)) {
56
- const mediaKey = themeBreakpoints.up(breakpoint);
57
- acc[mediaKey] = styleFromPropValue(propValue[breakpoint], breakpoint);
58
- } else {
59
- const cssKey = breakpoint;
60
- acc[cssKey] = propValue[cssKey];
61
- }
62
- return acc;
63
- }, {});
64
- }
65
- const output = styleFromPropValue(propValue);
66
- return output;
67
- }
68
- function breakpoints(styleFunction) {
69
- // false positive
70
- // eslint-disable-next-line react/function-component-definition
71
- const newStyleFunction = props => {
72
- const theme = props.theme || {};
73
- const base = styleFunction(props);
74
- const themeBreakpoints = theme.breakpoints || defaultBreakpoints;
75
- const extended = themeBreakpoints.keys.reduce((acc, key) => {
76
- if (props[key]) {
77
- acc = acc || {};
78
- acc[themeBreakpoints.up(key)] = styleFunction({
79
- theme,
80
- ...props[key]
81
- });
82
- }
83
- return acc;
84
- }, null);
85
- return merge(base, extended);
86
- };
87
- newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? {
88
- ...styleFunction.propTypes,
89
- xs: PropTypes.object,
90
- sm: PropTypes.object,
91
- md: PropTypes.object,
92
- lg: PropTypes.object,
93
- xl: PropTypes.object
94
- } : {};
95
- newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl', ...styleFunction.filterProps];
96
- return newStyleFunction;
97
- }
98
- export function createEmptyBreakpointObject(breakpointsInput = {}) {
99
- const breakpointsInOrder = breakpointsInput.keys?.reduce((acc, key) => {
100
- const breakpointStyleKey = breakpointsInput.up(key);
101
- acc[breakpointStyleKey] = {};
102
- return acc;
103
- }, {});
104
- return breakpointsInOrder || {};
105
- }
106
- export function removeUnusedBreakpoints(breakpointKeys, style) {
107
- return breakpointKeys.reduce((acc, key) => {
108
- const breakpointOutput = acc[key];
109
- const isBreakpointUnused = !breakpointOutput || Object.keys(breakpointOutput).length === 0;
110
- if (isBreakpointUnused) {
111
- delete acc[key];
112
- }
113
- return acc;
114
- }, style);
115
- }
116
- export function mergeBreakpointsInOrder(breakpointsInput, ...styles) {
117
- const emptyBreakpoints = createEmptyBreakpointObject(breakpointsInput);
118
- const mergedOutput = [emptyBreakpoints, ...styles].reduce((prev, next) => deepmerge(prev, next), {});
119
- return removeUnusedBreakpoints(Object.keys(emptyBreakpoints), mergedOutput);
120
- }
121
-
122
- // compute base for responsive values; e.g.,
123
- // [1,2,3] => {xs: true, sm: true, md: true}
124
- // {xs: 1, sm: 2, md: 3} => {xs: true, sm: true, md: true}
125
- export function computeBreakpointsBase(breakpointValues, themeBreakpoints) {
126
- // fixed value
127
- if (typeof breakpointValues !== 'object') {
128
- return {};
129
- }
130
- const base = {};
131
- const breakpointsKeys = Object.keys(themeBreakpoints);
132
- if (Array.isArray(breakpointValues)) {
133
- breakpointsKeys.forEach((breakpoint, i) => {
134
- if (i < breakpointValues.length) {
135
- base[breakpoint] = true;
136
- }
137
- });
138
- } else {
139
- breakpointsKeys.forEach(breakpoint => {
140
- if (breakpointValues[breakpoint] != null) {
141
- base[breakpoint] = true;
142
- }
143
- });
144
- }
145
- return base;
146
- }
147
- export function resolveBreakpointValues({
148
- values: breakpointValues,
149
- breakpoints: themeBreakpoints,
150
- base: customBase
151
- }) {
152
- const base = customBase || computeBreakpointsBase(breakpointValues, themeBreakpoints);
153
- const keys = Object.keys(base);
154
- if (keys.length === 0) {
155
- return breakpointValues;
156
- }
157
- let previous;
158
- return keys.reduce((acc, breakpoint, i) => {
159
- if (Array.isArray(breakpointValues)) {
160
- acc[breakpoint] = breakpointValues[i] != null ? breakpointValues[i] : breakpointValues[previous];
161
- previous = i;
162
- } else if (typeof breakpointValues === 'object') {
163
- acc[breakpoint] = breakpointValues[breakpoint] != null ? breakpointValues[breakpoint] : breakpointValues[previous];
164
- previous = breakpoint;
165
- } else {
166
- acc[breakpoint] = breakpointValues;
167
- }
168
- return acc;
169
- }, {});
170
- }
171
- export default breakpoints;
@@ -1,2 +0,0 @@
1
- export { default } from "./breakpoints.js";
2
- export * from "./breakpoints.js";
@@ -1,2 +0,0 @@
1
- export { default } from "./breakpoints.js";
2
- export * from "./breakpoints.js";
@@ -1,25 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- export type ColorFormat = 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'color';
3
- export interface ColorObject {
4
- type: ColorFormat;
5
- values: [number, number, number] | [number, number, number, number];
6
- colorSpace?: 'srgb' | 'display-p3' | 'a98-rgb' | 'prophoto-rgb' | 'rec-2020';
7
- }
8
- export function hexToRgb(hex: string): string;
9
- export function rgbToHex(color: string): string;
10
- export function hslToRgb(color: string): string;
11
- export function decomposeColor(color: string): ColorObject;
12
- export function colorChannel(color: string): string;
13
- export function private_safeColorChannel(color: string, warning?: string): string;
14
- export function recomposeColor(color: ColorObject): string;
15
- export function getContrastRatio(foreground: string, background: string): number;
16
- export function getLuminance(color: string): number;
17
- export function emphasize(color: string, coefficient?: number): string;
18
- export function private_safeEmphasize(color: string, coefficient?: number, warning?: string): string;
19
- export function alpha(color: string, value: number): string;
20
- export function private_safeAlpha(color: string, value: number, warning?: string): string;
21
- export function darken(color: string, coefficient: number): string;
22
- export function private_safeDarken(color: string, coefficient: number, warning?: string): string;
23
- export function lighten(color: string, coefficient: number): string;
24
- export function private_safeLighten(color: string, coefficient: number, warning?: string): string;
25
- export function blend(background: string, overlay: string, opacity: number, gamma?: number): string;
@@ -1,349 +0,0 @@
1
- import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
2
- /* eslint-disable @typescript-eslint/naming-convention */
3
- import clamp from '@mui/utils/clamp';
4
-
5
- /**
6
- * Returns a number whose value is limited to the given range.
7
- * @param {number} value The value to be clamped
8
- * @param {number} min The lower boundary of the output range
9
- * @param {number} max The upper boundary of the output range
10
- * @returns {number} A number in the range [min, max]
11
- */
12
- function clampWrapper(value, min = 0, max = 1) {
13
- if (process.env.NODE_ENV !== 'production') {
14
- if (value < min || value > max) {
15
- console.error(`MUI: The value provided ${value} is out of range [${min}, ${max}].`);
16
- }
17
- }
18
- return clamp(value, min, max);
19
- }
20
-
21
- /**
22
- * Converts a color from CSS hex format to CSS rgb format.
23
- * @param {string} color - Hex color, i.e. #nnn or #nnnnnn
24
- * @returns {string} A CSS rgb color string
25
- */
26
- export function hexToRgb(color) {
27
- color = color.slice(1);
28
- const re = new RegExp(`.{1,${color.length >= 6 ? 2 : 1}}`, 'g');
29
- let colors = color.match(re);
30
- if (colors && colors[0].length === 1) {
31
- colors = colors.map(n => n + n);
32
- }
33
- if (process.env.NODE_ENV !== 'production') {
34
- if (color.length !== color.trim().length) {
35
- console.error(`MUI: The color: "${color}" is invalid. Make sure the color input doesn't contain leading/trailing space.`);
36
- }
37
- }
38
- return colors ? `rgb${colors.length === 4 ? 'a' : ''}(${colors.map((n, index) => {
39
- return index < 3 ? parseInt(n, 16) : Math.round(parseInt(n, 16) / 255 * 1000) / 1000;
40
- }).join(', ')})` : '';
41
- }
42
- function intToHex(int) {
43
- const hex = int.toString(16);
44
- return hex.length === 1 ? `0${hex}` : hex;
45
- }
46
-
47
- /**
48
- * Returns an object with the type and values of a color.
49
- *
50
- * Note: Does not support rgb % values.
51
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
52
- * @returns {object} - A MUI color object: {type: string, values: number[]}
53
- */
54
- export function decomposeColor(color) {
55
- // Idempotent
56
- if (color.type) {
57
- return color;
58
- }
59
- if (color.charAt(0) === '#') {
60
- return decomposeColor(hexToRgb(color));
61
- }
62
- const marker = color.indexOf('(');
63
- const type = color.substring(0, marker);
64
- if (!['rgb', 'rgba', 'hsl', 'hsla', 'color'].includes(type)) {
65
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI: Unsupported \`${color}\` color.\n` + 'The following formats are supported: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color().' : _formatErrorMessage(9, color));
66
- }
67
- let values = color.substring(marker + 1, color.length - 1);
68
- let colorSpace;
69
- if (type === 'color') {
70
- values = values.split(' ');
71
- colorSpace = values.shift();
72
- if (values.length === 4 && values[3].charAt(0) === '/') {
73
- values[3] = values[3].slice(1);
74
- }
75
- if (!['srgb', 'display-p3', 'a98-rgb', 'prophoto-rgb', 'rec-2020'].includes(colorSpace)) {
76
- throw new Error(process.env.NODE_ENV !== "production" ? `MUI: unsupported \`${colorSpace}\` color space.\n` + 'The following color spaces are supported: srgb, display-p3, a98-rgb, prophoto-rgb, rec-2020.' : _formatErrorMessage(10, colorSpace));
77
- }
78
- } else {
79
- values = values.split(',');
80
- }
81
- values = values.map(value => parseFloat(value));
82
- return {
83
- type,
84
- values,
85
- colorSpace
86
- };
87
- }
88
-
89
- /**
90
- * Returns a channel created from the input color.
91
- *
92
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
93
- * @returns {string} - The channel for the color, that can be used in rgba or hsla colors
94
- */
95
- export const colorChannel = color => {
96
- const decomposedColor = decomposeColor(color);
97
- return decomposedColor.values.slice(0, 3).map((val, idx) => decomposedColor.type.includes('hsl') && idx !== 0 ? `${val}%` : val).join(' ');
98
- };
99
- export const private_safeColorChannel = (color, warning) => {
100
- try {
101
- return colorChannel(color);
102
- } catch (error) {
103
- if (warning && process.env.NODE_ENV !== 'production') {
104
- console.warn(warning);
105
- }
106
- return color;
107
- }
108
- };
109
-
110
- /**
111
- * Converts a color object with type and values to a string.
112
- * @param {object} color - Decomposed color
113
- * @param {string} color.type - One of: 'rgb', 'rgba', 'hsl', 'hsla', 'color'
114
- * @param {array} color.values - [n,n,n] or [n,n,n,n]
115
- * @returns {string} A CSS color string
116
- */
117
- export function recomposeColor(color) {
118
- const {
119
- type,
120
- colorSpace
121
- } = color;
122
- let {
123
- values
124
- } = color;
125
- if (type.includes('rgb')) {
126
- // Only convert the first 3 values to int (i.e. not alpha)
127
- values = values.map((n, i) => i < 3 ? parseInt(n, 10) : n);
128
- } else if (type.includes('hsl')) {
129
- values[1] = `${values[1]}%`;
130
- values[2] = `${values[2]}%`;
131
- }
132
- if (type.includes('color')) {
133
- values = `${colorSpace} ${values.join(' ')}`;
134
- } else {
135
- values = `${values.join(', ')}`;
136
- }
137
- return `${type}(${values})`;
138
- }
139
-
140
- /**
141
- * Converts a color from CSS rgb format to CSS hex format.
142
- * @param {string} color - RGB color, i.e. rgb(n, n, n)
143
- * @returns {string} A CSS rgb color string, i.e. #nnnnnn
144
- */
145
- export function rgbToHex(color) {
146
- // Idempotent
147
- if (color.startsWith('#')) {
148
- return color;
149
- }
150
- const {
151
- values
152
- } = decomposeColor(color);
153
- return `#${values.map((n, i) => intToHex(i === 3 ? Math.round(255 * n) : n)).join('')}`;
154
- }
155
-
156
- /**
157
- * Converts a color from hsl format to rgb format.
158
- * @param {string} color - HSL color values
159
- * @returns {string} rgb color values
160
- */
161
- export function hslToRgb(color) {
162
- color = decomposeColor(color);
163
- const {
164
- values
165
- } = color;
166
- const h = values[0];
167
- const s = values[1] / 100;
168
- const l = values[2] / 100;
169
- const a = s * Math.min(l, 1 - l);
170
- const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
171
- let type = 'rgb';
172
- const rgb = [Math.round(f(0) * 255), Math.round(f(8) * 255), Math.round(f(4) * 255)];
173
- if (color.type === 'hsla') {
174
- type += 'a';
175
- rgb.push(values[3]);
176
- }
177
- return recomposeColor({
178
- type,
179
- values: rgb
180
- });
181
- }
182
- /**
183
- * The relative brightness of any point in a color space,
184
- * normalized to 0 for darkest black and 1 for lightest white.
185
- *
186
- * Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
187
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
188
- * @returns {number} The relative brightness of the color in the range 0 - 1
189
- */
190
- export function getLuminance(color) {
191
- color = decomposeColor(color);
192
- let rgb = color.type === 'hsl' || color.type === 'hsla' ? decomposeColor(hslToRgb(color)).values : color.values;
193
- rgb = rgb.map(val => {
194
- if (color.type !== 'color') {
195
- val /= 255; // normalized
196
- }
197
- return val <= 0.03928 ? val / 12.92 : ((val + 0.055) / 1.055) ** 2.4;
198
- });
199
-
200
- // Truncate at 3 digits
201
- return Number((0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]).toFixed(3));
202
- }
203
-
204
- /**
205
- * Calculates the contrast ratio between two colors.
206
- *
207
- * Formula: https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
208
- * @param {string} foreground - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
209
- * @param {string} background - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
210
- * @returns {number} A contrast ratio value in the range 0 - 21.
211
- */
212
- export function getContrastRatio(foreground, background) {
213
- const lumA = getLuminance(foreground);
214
- const lumB = getLuminance(background);
215
- return (Math.max(lumA, lumB) + 0.05) / (Math.min(lumA, lumB) + 0.05);
216
- }
217
-
218
- /**
219
- * Sets the absolute transparency of a color.
220
- * Any existing alpha values are overwritten.
221
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
222
- * @param {number} value - value to set the alpha channel to in the range 0 - 1
223
- * @returns {string} A CSS color string. Hex input values are returned as rgb
224
- */
225
- export function alpha(color, value) {
226
- color = decomposeColor(color);
227
- value = clampWrapper(value);
228
- if (color.type === 'rgb' || color.type === 'hsl') {
229
- color.type += 'a';
230
- }
231
- if (color.type === 'color') {
232
- color.values[3] = `/${value}`;
233
- } else {
234
- color.values[3] = value;
235
- }
236
- return recomposeColor(color);
237
- }
238
- export function private_safeAlpha(color, value, warning) {
239
- try {
240
- return alpha(color, value);
241
- } catch (error) {
242
- if (warning && process.env.NODE_ENV !== 'production') {
243
- console.warn(warning);
244
- }
245
- return color;
246
- }
247
- }
248
-
249
- /**
250
- * Darkens a color.
251
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
252
- * @param {number} coefficient - multiplier in the range 0 - 1
253
- * @returns {string} A CSS color string. Hex input values are returned as rgb
254
- */
255
- export function darken(color, coefficient) {
256
- color = decomposeColor(color);
257
- coefficient = clampWrapper(coefficient);
258
- if (color.type.includes('hsl')) {
259
- color.values[2] *= 1 - coefficient;
260
- } else if (color.type.includes('rgb') || color.type.includes('color')) {
261
- for (let i = 0; i < 3; i += 1) {
262
- color.values[i] *= 1 - coefficient;
263
- }
264
- }
265
- return recomposeColor(color);
266
- }
267
- export function private_safeDarken(color, coefficient, warning) {
268
- try {
269
- return darken(color, coefficient);
270
- } catch (error) {
271
- if (warning && process.env.NODE_ENV !== 'production') {
272
- console.warn(warning);
273
- }
274
- return color;
275
- }
276
- }
277
-
278
- /**
279
- * Lightens a color.
280
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
281
- * @param {number} coefficient - multiplier in the range 0 - 1
282
- * @returns {string} A CSS color string. Hex input values are returned as rgb
283
- */
284
- export function lighten(color, coefficient) {
285
- color = decomposeColor(color);
286
- coefficient = clampWrapper(coefficient);
287
- if (color.type.includes('hsl')) {
288
- color.values[2] += (100 - color.values[2]) * coefficient;
289
- } else if (color.type.includes('rgb')) {
290
- for (let i = 0; i < 3; i += 1) {
291
- color.values[i] += (255 - color.values[i]) * coefficient;
292
- }
293
- } else if (color.type.includes('color')) {
294
- for (let i = 0; i < 3; i += 1) {
295
- color.values[i] += (1 - color.values[i]) * coefficient;
296
- }
297
- }
298
- return recomposeColor(color);
299
- }
300
- export function private_safeLighten(color, coefficient, warning) {
301
- try {
302
- return lighten(color, coefficient);
303
- } catch (error) {
304
- if (warning && process.env.NODE_ENV !== 'production') {
305
- console.warn(warning);
306
- }
307
- return color;
308
- }
309
- }
310
-
311
- /**
312
- * Darken or lighten a color, depending on its luminance.
313
- * Light colors are darkened, dark colors are lightened.
314
- * @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
315
- * @param {number} coefficient=0.15 - multiplier in the range 0 - 1
316
- * @returns {string} A CSS color string. Hex input values are returned as rgb
317
- */
318
- export function emphasize(color, coefficient = 0.15) {
319
- return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
320
- }
321
- export function private_safeEmphasize(color, coefficient, warning) {
322
- try {
323
- return emphasize(color, coefficient);
324
- } catch (error) {
325
- if (warning && process.env.NODE_ENV !== 'production') {
326
- console.warn(warning);
327
- }
328
- return color;
329
- }
330
- }
331
-
332
- /**
333
- * Blend a transparent overlay color with a background color, resulting in a single
334
- * RGB color.
335
- * @param {string} background - CSS color
336
- * @param {string} overlay - CSS color
337
- * @param {number} opacity - Opacity multiplier in the range 0 - 1
338
- * @param {number} [gamma=1.0] - Gamma correction factor. For gamma-correct blending, 2.2 is usual.
339
- */
340
- export function blend(background, overlay, opacity, gamma = 1.0) {
341
- const blendChannel = (b, o) => Math.round((b ** (1 / gamma) * (1 - opacity) + o ** (1 / gamma) * opacity) ** gamma);
342
- const backgroundColor = decomposeColor(background);
343
- const overlayColor = decomposeColor(overlay);
344
- const rgb = [blendChannel(backgroundColor.values[0], overlayColor.values[0]), blendChannel(backgroundColor.values[1], overlayColor.values[1]), blendChannel(backgroundColor.values[2], overlayColor.values[2])];
345
- return recomposeColor({
346
- type: 'rgb',
347
- values: rgb
348
- });
349
- }
@@ -1 +0,0 @@
1
- export * from "./colorManipulator.js";
@@ -1 +0,0 @@
1
- export * from "./colorManipulator.js";
@@ -1,2 +0,0 @@
1
- import { ComposedStyleFunction, StyleFunction } from "../Box/index.js";
2
- export default function compose<T extends Array<StyleFunction<any>>>(...args: T): ComposedStyleFunction<T>;
@@ -1,24 +0,0 @@
1
- import merge from "../merge/index.js";
2
- function compose(...styles) {
3
- const handlers = styles.reduce((acc, style) => {
4
- style.filterProps.forEach(prop => {
5
- acc[prop] = style;
6
- });
7
- return acc;
8
- }, {});
9
-
10
- // false positive
11
- // eslint-disable-next-line react/function-component-definition
12
- const fn = props => {
13
- return Object.keys(props).reduce((acc, prop) => {
14
- if (handlers[prop]) {
15
- return merge(acc, handlers[prop](props));
16
- }
17
- return acc;
18
- }, {});
19
- };
20
- fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => Object.assign(acc, style.propTypes), {}) : {};
21
- fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
22
- return fn;
23
- }
24
- export default compose;
@@ -1 +0,0 @@
1
- export { default } from "./compose.js";
@@ -1 +0,0 @@
1
- export { default } from "./compose.js";
@@ -1,9 +0,0 @@
1
- import { OverridableComponent } from '@mui/types';
2
- import { BoxTypeMap } from "../Box/index.js";
3
- import { Theme as SystemTheme } from "../createTheme/index.js";
4
- export default function createBox<T extends object = SystemTheme, AdditionalProps extends Record<string, unknown> = {}>(options?: {
5
- themeId?: string;
6
- defaultTheme: T;
7
- defaultClassName?: string;
8
- generateClassName?: (componentName: string) => string;
9
- }): OverridableComponent<BoxTypeMap<AdditionalProps, 'div', T>>;