@mui/system 7.0.0 → 7.0.2

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 (130) hide show
  1. package/CHANGELOG.md +100 -0
  2. package/cssVars/cssVarsParser.d.ts +1 -1
  3. package/esm/cssVars/cssVarsParser.d.ts +1 -1
  4. package/esm/index.js +1 -1
  5. package/esm/memoTheme.d.ts +1 -1
  6. package/esm/useThemeProps/getThemeProps.d.ts +0 -5
  7. package/esm/version/index.js +2 -2
  8. package/index.js +1 -1
  9. package/memoTheme.d.ts +1 -1
  10. package/modern/cssVars/cssVarsParser.d.ts +1 -1
  11. package/modern/memoTheme.d.ts +1 -1
  12. package/modern/useThemeProps/getThemeProps.d.ts +0 -5
  13. package/package.json +6 -14
  14. package/useThemeProps/getThemeProps.d.ts +0 -5
  15. package/version/index.js +2 -2
  16. package/modern/Box/Box.js +0 -30
  17. package/modern/Box/boxClasses.js +0 -3
  18. package/modern/Box/index.js +0 -3
  19. package/modern/Container/Container.js +0 -61
  20. package/modern/Container/ContainerProps.js +0 -1
  21. package/modern/Container/containerClasses.js +0 -7
  22. package/modern/Container/createContainer.js +0 -149
  23. package/modern/Container/index.js +0 -3
  24. package/modern/DefaultPropsProvider/DefaultPropsProvider.js +0 -64
  25. package/modern/DefaultPropsProvider/index.js +0 -1
  26. package/modern/GlobalStyles/GlobalStyles.js +0 -37
  27. package/modern/GlobalStyles/index.js +0 -2
  28. package/modern/Grid/Grid.js +0 -106
  29. package/modern/Grid/GridProps.js +0 -1
  30. package/modern/Grid/createGrid.js +0 -155
  31. package/modern/Grid/deleteLegacyGridProps.js +0 -41
  32. package/modern/Grid/gridClasses.js +0 -19
  33. package/modern/Grid/gridGenerator.js +0 -193
  34. package/modern/Grid/index.js +0 -7
  35. package/modern/Grid/traverseBreakpoints.js +0 -42
  36. package/modern/InitColorSchemeScript/InitColorSchemeScript.js +0 -78
  37. package/modern/InitColorSchemeScript/index.js +0 -1
  38. package/modern/RtlProvider/index.js +0 -24
  39. package/modern/Stack/Stack.js +0 -62
  40. package/modern/Stack/StackProps.js +0 -1
  41. package/modern/Stack/createStack.js +0 -173
  42. package/modern/Stack/index.js +0 -5
  43. package/modern/Stack/stackClasses.js +0 -7
  44. package/modern/ThemeProvider/ThemeProvider.js +0 -97
  45. package/modern/ThemeProvider/index.js +0 -1
  46. package/modern/borders/borders.js +0 -49
  47. package/modern/borders/index.js +0 -2
  48. package/modern/breakpoints/breakpoints.js +0 -171
  49. package/modern/breakpoints/index.js +0 -2
  50. package/modern/colorManipulator/colorManipulator.js +0 -349
  51. package/modern/colorManipulator/index.js +0 -1
  52. package/modern/compose/compose.js +0 -24
  53. package/modern/compose/index.js +0 -1
  54. package/modern/createBox/createBox.js +0 -35
  55. package/modern/createBox/index.js +0 -1
  56. package/modern/createBreakpoints/createBreakpoints.js +0 -81
  57. package/modern/createBreakpoints/index.js +0 -3
  58. package/modern/createStyled/createStyled.js +0 -276
  59. package/modern/createStyled/index.js +0 -2
  60. package/modern/createTheme/applyStyles.js +0 -87
  61. package/modern/createTheme/createSpacing.js +0 -31
  62. package/modern/createTheme/createTheme.js +0 -49
  63. package/modern/createTheme/index.js +0 -3
  64. package/modern/createTheme/shape.js +0 -4
  65. package/modern/cssContainerQueries/cssContainerQueries.js +0 -69
  66. package/modern/cssContainerQueries/index.js +0 -2
  67. package/modern/cssGrid/cssGrid.js +0 -85
  68. package/modern/cssGrid/index.js +0 -2
  69. package/modern/cssVars/createCssVarsProvider.js +0 -338
  70. package/modern/cssVars/createCssVarsTheme.js +0 -21
  71. package/modern/cssVars/createGetCssVar.js +0 -22
  72. package/modern/cssVars/cssVarsParser.js +0 -129
  73. package/modern/cssVars/getColorSchemeSelector.js +0 -26
  74. package/modern/cssVars/index.js +0 -5
  75. package/modern/cssVars/localStorageManager.js +0 -51
  76. package/modern/cssVars/prepareCssVars.js +0 -153
  77. package/modern/cssVars/prepareTypographyVars.js +0 -11
  78. package/modern/cssVars/useCurrentColorScheme.js +0 -228
  79. package/modern/display/display.js +0 -27
  80. package/modern/display/index.js +0 -2
  81. package/modern/flexbox/flexbox.js +0 -43
  82. package/modern/flexbox/index.js +0 -2
  83. package/modern/getThemeValue/getThemeValue.js +0 -51
  84. package/modern/getThemeValue/index.js +0 -2
  85. package/modern/index.js +0 -75
  86. package/modern/memoTheme.js +0 -28
  87. package/modern/memoize/index.js +0 -1
  88. package/modern/memoize/memoize.js +0 -9
  89. package/modern/merge/index.js +0 -1
  90. package/modern/merge/merge.js +0 -10
  91. package/modern/package.json +0 -1
  92. package/modern/palette/index.js +0 -2
  93. package/modern/palette/palette.js +0 -26
  94. package/modern/positions/index.js +0 -2
  95. package/modern/positions/positions.js +0 -22
  96. package/modern/preprocessStyles.js +0 -25
  97. package/modern/propsToClassKey/index.js +0 -1
  98. package/modern/propsToClassKey/propsToClassKey.js +0 -25
  99. package/modern/responsivePropType/index.js +0 -1
  100. package/modern/responsivePropType/responsivePropType.js +0 -3
  101. package/modern/shadows/index.js +0 -1
  102. package/modern/shadows/shadows.js +0 -6
  103. package/modern/sizing/index.js +0 -2
  104. package/modern/sizing/sizing.js +0 -64
  105. package/modern/spacing/index.js +0 -2
  106. package/modern/spacing/spacing.js +0 -157
  107. package/modern/style/index.js +0 -2
  108. package/modern/style/style.js +0 -75
  109. package/modern/styleFunctionSx/AliasesCSSProperties.js +0 -1
  110. package/modern/styleFunctionSx/OverwriteCSSProperties.js +0 -1
  111. package/modern/styleFunctionSx/StandardCssProperties.js +0 -1
  112. package/modern/styleFunctionSx/defaultSxConfig.js +0 -294
  113. package/modern/styleFunctionSx/extendSxProp.js +0 -51
  114. package/modern/styleFunctionSx/index.js +0 -4
  115. package/modern/styleFunctionSx/styleFunctionSx.js +0 -127
  116. package/modern/styled/index.js +0 -1
  117. package/modern/styled/styled.js +0 -3
  118. package/modern/typography/index.js +0 -2
  119. package/modern/typography/typography.js +0 -37
  120. package/modern/useMediaQuery/index.js +0 -2
  121. package/modern/useMediaQuery/useMediaQuery.js +0 -118
  122. package/modern/useTheme/index.js +0 -2
  123. package/modern/useTheme/useTheme.js +0 -9
  124. package/modern/useThemeProps/getThemeProps.js +0 -12
  125. package/modern/useThemeProps/index.js +0 -2
  126. package/modern/useThemeProps/useThemeProps.js +0 -20
  127. package/modern/useThemeWithoutDefault/index.js +0 -1
  128. package/modern/useThemeWithoutDefault/useThemeWithoutDefault.js +0 -12
  129. package/modern/version/index.js +0 -6
  130. package/tsconfig.build.tsbuildinfo +0 -1
@@ -1,62 +0,0 @@
1
- 'use client';
2
-
3
- import PropTypes from 'prop-types';
4
- import createStack from "./createStack.js";
5
- /**
6
- *
7
- * Demos:
8
- *
9
- * - [Stack (Joy UI)](https://mui.com/joy-ui/react-stack/)
10
- * - [Stack (Material UI)](https://mui.com/material-ui/react-stack/)
11
- * - [Stack (MUI System)](https://mui.com/system/react-stack/)
12
- *
13
- * API:
14
- *
15
- * - [Stack API](https://mui.com/system/api/stack/)
16
- */
17
- const Stack = createStack();
18
- process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ = {
19
- // ┌────────────────────────────── Warning ──────────────────────────────┐
20
- // │ These PropTypes are generated from the TypeScript type definitions. │
21
- // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
22
- // └─────────────────────────────────────────────────────────────────────┘
23
- /**
24
- * The content of the component.
25
- */
26
- children: PropTypes.node,
27
- /**
28
- * The component used for the root node.
29
- * Either a string to use a HTML element or a component.
30
- */
31
- component: PropTypes.elementType,
32
- /**
33
- * Defines the `flex-direction` style property.
34
- * It is applied for all screen sizes.
35
- * @default 'column'
36
- */
37
- direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
38
- /**
39
- * Add an element between each child.
40
- */
41
- divider: PropTypes.node,
42
- /**
43
- * Defines the space between immediate children.
44
- * @default 0
45
- */
46
- spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
47
- /**
48
- * The system prop, which allows defining system overrides as well as additional CSS styles.
49
- */
50
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
51
- /**
52
- * If `true`, the CSS flexbox `gap` is used instead of applying `margin` to children.
53
- *
54
- * While CSS `gap` removes the [known limitations](https://mui.com/joy-ui/react-stack/#limitations),
55
- * it is not fully supported in some browsers. We recommend checking https://caniuse.com/?search=flex%20gap before using this flag.
56
- *
57
- * To enable this flag globally, follow the theme's default props configuration.
58
- * @default false
59
- */
60
- useFlexGap: PropTypes.bool
61
- } : void 0;
62
- export default Stack;
@@ -1 +0,0 @@
1
- export {};
@@ -1,173 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import PropTypes from 'prop-types';
5
- import clsx from 'clsx';
6
- import deepmerge from '@mui/utils/deepmerge';
7
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
8
- import composeClasses from '@mui/utils/composeClasses';
9
- import systemStyled from "../styled/index.js";
10
- import useThemePropsSystem from "../useThemeProps/index.js";
11
- import { extendSxProp } from "../styleFunctionSx/index.js";
12
- import createTheme from "../createTheme/index.js";
13
- import { handleBreakpoints, mergeBreakpointsInOrder, resolveBreakpointValues } from "../breakpoints/index.js";
14
- import { createUnarySpacing, getValue } from "../spacing/index.js";
15
- import { jsx as _jsx } from "react/jsx-runtime";
16
- const defaultTheme = createTheme();
17
- // widening Theme to any so that the consumer can own the theme structure.
18
- const defaultCreateStyledComponent = systemStyled('div', {
19
- name: 'MuiStack',
20
- slot: 'Root',
21
- overridesResolver: (props, styles) => styles.root
22
- });
23
- function useThemePropsDefault(props) {
24
- return useThemePropsSystem({
25
- props,
26
- name: 'MuiStack',
27
- defaultTheme
28
- });
29
- }
30
-
31
- /**
32
- * Return an array with the separator React element interspersed between
33
- * each React node of the input children.
34
- *
35
- * > joinChildren([1,2,3], 0)
36
- * [1,0,2,0,3]
37
- */
38
- function joinChildren(children, separator) {
39
- const childrenArray = React.Children.toArray(children).filter(Boolean);
40
- return childrenArray.reduce((output, child, index) => {
41
- output.push(child);
42
- if (index < childrenArray.length - 1) {
43
- output.push(/*#__PURE__*/React.cloneElement(separator, {
44
- key: `separator-${index}`
45
- }));
46
- }
47
- return output;
48
- }, []);
49
- }
50
- const getSideFromDirection = direction => {
51
- return {
52
- row: 'Left',
53
- 'row-reverse': 'Right',
54
- column: 'Top',
55
- 'column-reverse': 'Bottom'
56
- }[direction];
57
- };
58
- export const style = ({
59
- ownerState,
60
- theme
61
- }) => {
62
- let styles = {
63
- display: 'flex',
64
- flexDirection: 'column',
65
- ...handleBreakpoints({
66
- theme
67
- }, resolveBreakpointValues({
68
- values: ownerState.direction,
69
- breakpoints: theme.breakpoints.values
70
- }), propValue => ({
71
- flexDirection: propValue
72
- }))
73
- };
74
- if (ownerState.spacing) {
75
- const transformer = createUnarySpacing(theme);
76
- const base = Object.keys(theme.breakpoints.values).reduce((acc, breakpoint) => {
77
- if (typeof ownerState.spacing === 'object' && ownerState.spacing[breakpoint] != null || typeof ownerState.direction === 'object' && ownerState.direction[breakpoint] != null) {
78
- acc[breakpoint] = true;
79
- }
80
- return acc;
81
- }, {});
82
- const directionValues = resolveBreakpointValues({
83
- values: ownerState.direction,
84
- base
85
- });
86
- const spacingValues = resolveBreakpointValues({
87
- values: ownerState.spacing,
88
- base
89
- });
90
- if (typeof directionValues === 'object') {
91
- Object.keys(directionValues).forEach((breakpoint, index, breakpoints) => {
92
- const directionValue = directionValues[breakpoint];
93
- if (!directionValue) {
94
- const previousDirectionValue = index > 0 ? directionValues[breakpoints[index - 1]] : 'column';
95
- directionValues[breakpoint] = previousDirectionValue;
96
- }
97
- });
98
- }
99
- const styleFromPropValue = (propValue, breakpoint) => {
100
- if (ownerState.useFlexGap) {
101
- return {
102
- gap: getValue(transformer, propValue)
103
- };
104
- }
105
- return {
106
- // The useFlexGap={false} implement relies on each child to give up control of the margin.
107
- // We need to reset the margin to avoid double spacing.
108
- '& > :not(style):not(style)': {
109
- margin: 0
110
- },
111
- '& > :not(style) ~ :not(style)': {
112
- [`margin${getSideFromDirection(breakpoint ? directionValues[breakpoint] : ownerState.direction)}`]: getValue(transformer, propValue)
113
- }
114
- };
115
- };
116
- styles = deepmerge(styles, handleBreakpoints({
117
- theme
118
- }, spacingValues, styleFromPropValue));
119
- }
120
- styles = mergeBreakpointsInOrder(theme.breakpoints, styles);
121
- return styles;
122
- };
123
- export default function createStack(options = {}) {
124
- const {
125
- // This will allow adding custom styled fn (for example for custom sx style function)
126
- createStyledComponent = defaultCreateStyledComponent,
127
- useThemeProps = useThemePropsDefault,
128
- componentName = 'MuiStack'
129
- } = options;
130
- const useUtilityClasses = () => {
131
- const slots = {
132
- root: ['root']
133
- };
134
- return composeClasses(slots, slot => generateUtilityClass(componentName, slot), {});
135
- };
136
- const StackRoot = createStyledComponent(style);
137
- const Stack = /*#__PURE__*/React.forwardRef(function Grid(inProps, ref) {
138
- const themeProps = useThemeProps(inProps);
139
- const props = extendSxProp(themeProps); // `color` type conflicts with html color attribute.
140
- const {
141
- component = 'div',
142
- direction = 'column',
143
- spacing = 0,
144
- divider,
145
- children,
146
- className,
147
- useFlexGap = false,
148
- ...other
149
- } = props;
150
- const ownerState = {
151
- direction,
152
- spacing,
153
- useFlexGap
154
- };
155
- const classes = useUtilityClasses();
156
- return /*#__PURE__*/_jsx(StackRoot, {
157
- as: component,
158
- ownerState: ownerState,
159
- ref: ref,
160
- className: clsx(classes.root, className),
161
- ...other,
162
- children: divider ? joinChildren(children, divider) : children
163
- });
164
- });
165
- process.env.NODE_ENV !== "production" ? Stack.propTypes /* remove-proptypes */ = {
166
- children: PropTypes.node,
167
- direction: PropTypes.oneOfType([PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row']), PropTypes.arrayOf(PropTypes.oneOf(['column-reverse', 'column', 'row-reverse', 'row'])), PropTypes.object]),
168
- divider: PropTypes.node,
169
- spacing: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.string]),
170
- sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object])
171
- } : void 0;
172
- return Stack;
173
- }
@@ -1,5 +0,0 @@
1
- export { default } from "./Stack.js";
2
- export { default as createStack } from "./createStack.js";
3
- export * from "./StackProps.js";
4
- export { default as stackClasses } from "./stackClasses.js";
5
- export * from "./stackClasses.js";
@@ -1,7 +0,0 @@
1
- import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
2
- import generateUtilityClass from '@mui/utils/generateUtilityClass';
3
- export function getStackUtilityClass(slot) {
4
- return generateUtilityClass('MuiStack', slot);
5
- }
6
- const stackClasses = generateUtilityClasses('MuiStack', ['root']);
7
- export default stackClasses;
@@ -1,97 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import PropTypes from 'prop-types';
5
- import { ThemeProvider as MuiThemeProvider, useTheme as usePrivateTheme } from '@mui/private-theming';
6
- import exactProp from '@mui/utils/exactProp';
7
- import { ThemeContext as StyledEngineThemeContext } from '@mui/styled-engine';
8
- import useThemeWithoutDefault from "../useThemeWithoutDefault/index.js";
9
- import RtlProvider from "../RtlProvider/index.js";
10
- import DefaultPropsProvider from "../DefaultPropsProvider/index.js";
11
- import { jsx as _jsx } from "react/jsx-runtime";
12
- const EMPTY_THEME = {};
13
- function useThemeScoping(themeId, upperTheme, localTheme, isPrivate = false) {
14
- return React.useMemo(() => {
15
- const resolvedTheme = themeId ? upperTheme[themeId] || upperTheme : upperTheme;
16
- if (typeof localTheme === 'function') {
17
- const mergedTheme = localTheme(resolvedTheme);
18
- const result = themeId ? {
19
- ...upperTheme,
20
- [themeId]: mergedTheme
21
- } : mergedTheme;
22
- // must return a function for the private theme to NOT merge with the upper theme.
23
- // see the test case "use provided theme from a callback" in ThemeProvider.test.js
24
- if (isPrivate) {
25
- return () => result;
26
- }
27
- return result;
28
- }
29
- return themeId ? {
30
- ...upperTheme,
31
- [themeId]: localTheme
32
- } : {
33
- ...upperTheme,
34
- ...localTheme
35
- };
36
- }, [themeId, upperTheme, localTheme, isPrivate]);
37
- }
38
-
39
- /**
40
- * This component makes the `theme` available down the React tree.
41
- * It should preferably be used at **the root of your component tree**.
42
- *
43
- * <ThemeProvider theme={theme}> // existing use case
44
- * <ThemeProvider theme={{ id: theme }}> // theme scoping
45
- */
46
- function ThemeProvider(props) {
47
- const {
48
- children,
49
- theme: localTheme,
50
- themeId
51
- } = props;
52
- const upperTheme = useThemeWithoutDefault(EMPTY_THEME);
53
- const upperPrivateTheme = usePrivateTheme() || EMPTY_THEME;
54
- if (process.env.NODE_ENV !== 'production') {
55
- if (upperTheme === null && typeof localTheme === 'function' || themeId && upperTheme && !upperTheme[themeId] && typeof localTheme === 'function') {
56
- console.error(['MUI: You are providing a theme function prop to the ThemeProvider component:', '<ThemeProvider theme={outerTheme => outerTheme} />', '', 'However, no outer theme is present.', 'Make sure a theme is already injected higher in the React tree ' + 'or provide a theme object.'].join('\n'));
57
- }
58
- }
59
- const engineTheme = useThemeScoping(themeId, upperTheme, localTheme);
60
- const privateTheme = useThemeScoping(themeId, upperPrivateTheme, localTheme, true);
61
- const rtlValue = (themeId ? engineTheme[themeId] : engineTheme).direction === 'rtl';
62
- return /*#__PURE__*/_jsx(MuiThemeProvider, {
63
- theme: privateTheme,
64
- children: /*#__PURE__*/_jsx(StyledEngineThemeContext.Provider, {
65
- value: engineTheme,
66
- children: /*#__PURE__*/_jsx(RtlProvider, {
67
- value: rtlValue,
68
- children: /*#__PURE__*/_jsx(DefaultPropsProvider, {
69
- value: themeId ? engineTheme[themeId].components : engineTheme.components,
70
- children: children
71
- })
72
- })
73
- })
74
- });
75
- }
76
- process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes /* remove-proptypes */ = {
77
- // ┌────────────────────────────── Warning ──────────────────────────────┐
78
- // │ These PropTypes are generated from the TypeScript type definitions. │
79
- // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
80
- // └─────────────────────────────────────────────────────────────────────┘
81
- /**
82
- * Your component tree.
83
- */
84
- children: PropTypes.node,
85
- /**
86
- * A theme object. You can provide a function to extend the outer theme.
87
- */
88
- theme: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
89
- /**
90
- * The design system's unique id for getting the corresponded theme when there are multiple design systems.
91
- */
92
- themeId: PropTypes.string
93
- } : void 0;
94
- if (process.env.NODE_ENV !== 'production') {
95
- process.env.NODE_ENV !== "production" ? ThemeProvider.propTypes = exactProp(ThemeProvider.propTypes) : void 0;
96
- }
97
- export default ThemeProvider;
@@ -1 +0,0 @@
1
- export { default } from "./ThemeProvider.js";
@@ -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,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";