@mui/system 5.4.1 → 5.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Box/Box.d.ts +1 -1
- package/Box/Box.spec.d.ts +1 -1
- package/CHANGELOG.md +177 -0
- package/createBox.d.ts +2 -0
- package/createBox.js +3 -2
- package/createBox.spec.d.ts +1 -1
- package/createStyled.d.ts +2 -1
- package/createStyled.js +12 -6
- package/createTheme/createBreakpoints.js +21 -6
- package/createTheme/createSpacing.d.ts +10 -10
- package/cssVars/createCssVarsProvider.d.ts +59 -95
- package/cssVars/createCssVarsProvider.js +32 -15
- package/cssVars/createCssVarsProvider.spec.d.ts +1 -1
- package/cssVars/createGetCssVar.d.ts +5 -5
- package/cssVars/createGetCssVar.js +7 -1
- package/cssVars/cssVarsParser.d.ts +70 -68
- package/cssVars/cssVarsParser.js +21 -20
- package/cssVars/getInitColorSchemeScript.d.ts +12 -12
- package/cssVars/index.d.ts +1 -2
- package/cssVars/useCurrentColorScheme.d.ts +50 -50
- package/esm/createBox.js +3 -2
- package/esm/createStyled.js +10 -4
- package/esm/createTheme/createBreakpoints.js +20 -4
- package/esm/cssVars/createCssVarsProvider.js +32 -16
- package/esm/cssVars/createGetCssVar.js +7 -1
- package/esm/cssVars/cssVarsParser.js +21 -20
- package/esm/getThemeValue.js +1 -1
- package/esm/index.js +1 -1
- package/esm/styleFunctionSx/index.js +1 -0
- package/esm/styleFunctionSx/styleFunctionSx.js +78 -51
- package/getThemeValue.js +2 -1
- package/index.d.ts +1 -0
- package/index.js +8 -1
- package/index.spec.d.ts +1 -1
- package/legacy/createBox.js +4 -2
- package/legacy/createStyled.js +11 -4
- package/legacy/createTheme/createBreakpoints.js +23 -4
- package/legacy/cssVars/createCssVarsProvider.js +35 -18
- package/legacy/cssVars/createGetCssVar.js +7 -1
- package/legacy/cssVars/cssVarsParser.js +23 -22
- package/legacy/getThemeValue.js +1 -1
- package/legacy/index.js +2 -2
- package/legacy/styleFunctionSx/index.js +1 -0
- package/legacy/styleFunctionSx/styleFunctionSx.js +76 -51
- package/modern/createBox.js +3 -2
- package/modern/createStyled.js +10 -4
- package/modern/createTheme/createBreakpoints.js +20 -4
- package/modern/cssVars/createCssVarsProvider.js +32 -16
- package/modern/cssVars/createGetCssVar.js +7 -1
- package/modern/cssVars/cssVarsParser.js +21 -20
- package/modern/getThemeValue.js +1 -1
- package/modern/index.js +2 -2
- package/modern/styleFunctionSx/index.js +1 -0
- package/modern/styleFunctionSx/styleFunctionSx.js +78 -51
- package/package.json +6 -6
- package/style.d.ts +1 -1
- package/styleFunctionSx/index.js +12 -2
- package/styleFunctionSx/styleFunctionSx.d.ts +25 -3
- package/styleFunctionSx/styleFunctionSx.js +79 -54
- package/styleFunctionSx/styleFunctionSx.spec.d.ts +1 -1
package/Box/Box.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export type PropsFor<SomeStyleFunction> = SomeStyleFunction extends StyleFunctio
|
|
|
15
15
|
export type StyleFunction<Props> = (props: Props) => any;
|
|
16
16
|
export type SimpleStyleFunction<PropKey extends keyof any> = StyleFunction<
|
|
17
17
|
Partial<Record<PropKey, any>>
|
|
18
|
-
|
|
18
|
+
> & { filterProps: string[] };
|
|
19
19
|
|
|
20
20
|
// borders.js
|
|
21
21
|
export const borders: SimpleStyleFunction<
|
package/Box/Box.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,182 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## 5.4.4
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v5.4.3..master -->
|
|
6
|
+
|
|
7
|
+
_Feb 28, 2022_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 17 contributors who made this release possible. Here are some highlights ✨:
|
|
10
|
+
|
|
11
|
+
- ✨ New `Input` and `Sheet` components were added in the experimental Joy design system by @hbjORbj (#31124, #31086) @hbjORbj
|
|
12
|
+
- Several 🐛 bug fixes and 📚 documentation improvements
|
|
13
|
+
|
|
14
|
+
### `@mui/material@5.4.4`
|
|
15
|
+
|
|
16
|
+
- ​<!-- 28 -->[Autocomplete] Have Autocomplete with multiline textfield log a warning instead of an error (#30680) @iclaude3
|
|
17
|
+
- ​<!-- 27 -->[Chip] Fix ellipsis when the children is too long (#31087) @PunitSoniME
|
|
18
|
+
- ​<!-- 14 -->[Input] Export InputBase's classes from the classes const (#31186) @mnajdova
|
|
19
|
+
- ​<!-- 29 -->[TextField] Fix Horizontal scroll when label too long (#31187) @RedHeadphone
|
|
20
|
+
- ​<!-- 08 -->[styles] Fix typo in import error (#31167) @davwheat
|
|
21
|
+
|
|
22
|
+
### `@mui/system@5.4.4`
|
|
23
|
+
|
|
24
|
+
- ​<!-- 07 -->[system] Fix executing server-side Emotion component as function interpolation 2 (#31024) @Andarist
|
|
25
|
+
- ​<!-- 06 -->[system] Fix sx prop types when CSS variables are used with nested selectors (#31163) @mnajdova
|
|
26
|
+
- ​<!-- 05 -->[system] Fix `CssVarsProvider` theme mutation (#31148) @siriwatknp
|
|
27
|
+
|
|
28
|
+
### `@mui/codemod@5.4.4`
|
|
29
|
+
|
|
30
|
+
- ​<!-- 26 -->[codemods] Add v5.0.0/top-level-imports codemod (#31195) @greengiraffe
|
|
31
|
+
|
|
32
|
+
### `@mui/base@5.0.0-alpha.70`
|
|
33
|
+
|
|
34
|
+
- ​<!-- 31 -->[SelectUnstyled, MultiSelectUnstyled, ButtonUnstyled] Export additional types to make customization easier (#31172) @michaldudak
|
|
35
|
+
|
|
36
|
+
### `@mui/joy@5.0.0-alpha.17`
|
|
37
|
+
|
|
38
|
+
- ​<!-- 13 -->[Joy] Add nested list components (#31159) @siriwatknp
|
|
39
|
+
- ​<!-- 12 -->[Joy] Improve color customization on `Switch` (#31137) @siriwatknp
|
|
40
|
+
- ​<!-- 11 -->[Joy] Add `Sheet` component (#31124) @hbjORbj
|
|
41
|
+
- ​<!-- 10 -->[Joy] add `Input` component (#31086) @siriwatknp
|
|
42
|
+
- ​<!-- 09 -->[Joy] Fix Button missing slot type (#31166) @siriwatknp
|
|
43
|
+
|
|
44
|
+
### Docs
|
|
45
|
+
|
|
46
|
+
- ​<!-- 22 -->[docs] Fix 404 link to the blog (#31234) @oliviertassinari
|
|
47
|
+
- ​<!-- 21 -->[docs] Use `material-ui` for product name (#31200) @siriwatknp
|
|
48
|
+
- ​<!-- 20 -->[docs] Add Base installation page (#30969) @siriwatknp
|
|
49
|
+
- ​<!-- 19 -->[docs] Use new Algolia app for new structure (#31178) @siriwatknp
|
|
50
|
+
- ​<!-- 18 -->[docs] Typo in the `FormControl` API documentation (#31169) @bonellia
|
|
51
|
+
- ​<!-- 17 -->[docs] Fix typo in Stack documentation (#31176) @adriancampos
|
|
52
|
+
- ​<!-- 16 -->[docs] Update interoperability.md broken tailwind links (#31182) @robertwt7
|
|
53
|
+
- ​<!-- 15 -->[docs] Add missing import into tss-react migration guide (#31162) @sviande
|
|
54
|
+
- ​<!-- 03 -->[website] The role is filled (#31216) @oliviertassinari
|
|
55
|
+
- ​<!-- 02 -->[website] Revise the row grouping blog post (#31101) @samuelsycamore
|
|
56
|
+
- ​<!-- 01 -->[website] Fix a few SEO issues (#31150) @oliviertassinari
|
|
57
|
+
|
|
58
|
+
### Core
|
|
59
|
+
|
|
60
|
+
- ​<!-- 30 -->[core] Add group for the @fortawesome dependencies (#31193) @mnajdova
|
|
61
|
+
- ​<!-- 25 -->[core] Update playwright docker to match the specified version (#31236) @siriwatknp
|
|
62
|
+
- ​<!-- 24 -->[core] Remove parallel on buildTypes (#31189) @siriwatknp
|
|
63
|
+
- ​<!-- 23 -->[core] Fix propTypes generation for optional any props (#31141) @m4theushw
|
|
64
|
+
- ​<!-- 04 -->[Typescript] Remove variants deprecation (#31239) @siriwatknp
|
|
65
|
+
|
|
66
|
+
All contributors of this release in alphabetical order: @adriancampos, @Andarist, @bonellia, @davwheat, @greengiraffe, @hbjORbj, @iclaude3, @m4theushw, @michaldudak, @mnajdova, @oliviertassinari, @PunitSoniME, @RedHeadphone, @robertwt7, @samuelsycamore, @siriwatknp, @sviande
|
|
67
|
+
|
|
68
|
+
## 5.4.3
|
|
69
|
+
|
|
70
|
+
<!-- generated comparing v5.4.2..master -->
|
|
71
|
+
|
|
72
|
+
_Feb 21, 2022_
|
|
73
|
+
|
|
74
|
+
A big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
75
|
+
|
|
76
|
+
- 🛠 @hbjORbj made components use theme duration/easing values by default (#30894)
|
|
77
|
+
- A meaningful number of 🐛 bug fixes and 📚 documentation improvements
|
|
78
|
+
|
|
79
|
+
### `@mui/material@5.4.3`
|
|
80
|
+
|
|
81
|
+
- ​<!-- 18 -->[ButtonBase] Fix typo (#31135) @Jastor11
|
|
82
|
+
- ​<!-- 05 -->[Stepper] Export useStepContext (#31021) @michaldudak
|
|
83
|
+
- ​<!-- 04 -->[Transitions] Some components do not use transition duration/easing values from theme (#30894) @hbjORbj
|
|
84
|
+
|
|
85
|
+
### `@mui/icons-material@5.4.3`
|
|
86
|
+
|
|
87
|
+
- ​<!-- 11 -->[icons] Add "circle" icon synonyms (#31118) @gnowland
|
|
88
|
+
|
|
89
|
+
### `@mui/joy@5.0.0-alpha.16`
|
|
90
|
+
|
|
91
|
+
- ​<!-- 10 -->[Joy] `List` second iteration (#31134) @siriwatknp
|
|
92
|
+
- ​<!-- 09 -->[Joy] Fix typings (#31120) @siriwatknp
|
|
93
|
+
- ​<!-- 08 -->[Joy] Add initial `List` components (#30987) @siriwatknp
|
|
94
|
+
|
|
95
|
+
### Docs
|
|
96
|
+
|
|
97
|
+
- ​<!-- 19 -->[website] Improve full-stack role job description (#31160) @Janpot
|
|
98
|
+
- ​<!-- 14 -->[docs] Fix typo of migration guides v4 (#31136) @pppp606
|
|
99
|
+
- ​<!-- 13 -->[docs] Update on the support page to account for v4 LTS support (#31029) @danilo-leal
|
|
100
|
+
- ​<!-- 12 -->[docs] Fix small typo in chips.md (#31092) @cameliaben
|
|
101
|
+
- ​<!-- 07 -->[l10n] Add it-IT translation for labelDisplayedRows (#31131) @frab90
|
|
102
|
+
- ​<!-- 06 -->[l10n] Add pl-PL translation for labelDisplayedRows (#31088) @ThomasTheHuman
|
|
103
|
+
- ​<!-- 03 -->[website] Sync MUI X table feature (#30913) @alexfauquette
|
|
104
|
+
- ​<!-- 02 -->[website] Prefill source in job application links (#31036) @oliviertassinari
|
|
105
|
+
- ​<!-- 01 -->[website] Fix a grammar mistake (#31099) @huyenltnguyen
|
|
106
|
+
|
|
107
|
+
### Core
|
|
108
|
+
|
|
109
|
+
- ​<!-- 17 -->[core] Add jsx, html, css and prisma to prettier extensions (#31161) @Janpot
|
|
110
|
+
- ​<!-- 16 -->[core] Allow to run material-ui.com/store alongside mui.com/store (#31065) @oliviertassinari
|
|
111
|
+
- ​<!-- 15 -->[core] Polish design tokens (#31095) @oliviertassinari
|
|
112
|
+
|
|
113
|
+
All contributors of this release in alphabetical order: @alexfauquette, @cameliaben, @danilo-leal, @frab90, @gnowland, @hbjORbj, @huyenltnguyen, @Janpot, @Jastor11, @michaldudak, @oliviertassinari, @pppp606, @siriwatknp, @ThomasTheHuman
|
|
114
|
+
|
|
115
|
+
## 5.4.2
|
|
116
|
+
|
|
117
|
+
_Feb 15, 2022_
|
|
118
|
+
|
|
119
|
+
A big thanks to the 16 contributors who made this release possible. Here are some highlights ✨:
|
|
120
|
+
|
|
121
|
+
- 🛠 @sydneyjodon-wk improved propTypes of the ToggleButton components (#30883)
|
|
122
|
+
- Several 🐛 bug fixes and 📚 documentation improvements
|
|
123
|
+
|
|
124
|
+
### `@mui/material@5.4.2`
|
|
125
|
+
|
|
126
|
+
- [Select] Allow customizing Select based on its variant (#30788) @michaldudak
|
|
127
|
+
- [Portal] Re-export 'Portal' in material (#31003) @liradb2000
|
|
128
|
+
- [ToggleButton] Add prop types for `onClick` and `onChange` (#30883) @sydneyjodon-wk
|
|
129
|
+
- [Typescript] Added TypeText declaration to the exports file (#30890) @agauravdev
|
|
130
|
+
|
|
131
|
+
### `@mui/system@5.4.2`
|
|
132
|
+
|
|
133
|
+
- [system] Fix broken behavior when breakpoints input are not ordered (#30996) @mnajdova
|
|
134
|
+
|
|
135
|
+
### `@mui/lab@5.0.0-alpha.69`
|
|
136
|
+
|
|
137
|
+
- [DatePicker] Fix passing clearable prop (#30786) @alisasanib
|
|
138
|
+
|
|
139
|
+
### `@mui/joy@5.0.0-alpha.15`
|
|
140
|
+
|
|
141
|
+
- [Joy] Improve variant customization experience (#30878) @siriwatknp
|
|
142
|
+
- [Joy] Make `sx` prop work in Joy (#30955) @siriwatknp
|
|
143
|
+
|
|
144
|
+
### Framer
|
|
145
|
+
|
|
146
|
+
- [design] Remove framer components (#30983) @mbrookes
|
|
147
|
+
- [design] Remove framer leftovers (#31070) @michaldudak
|
|
148
|
+
|
|
149
|
+
### Docs
|
|
150
|
+
|
|
151
|
+
- [docs] Update installation guide of the icons package (#31026) @huyenltnguyen
|
|
152
|
+
- [docs] Improve the indication for the legacy APIs (#30995) @mnajdova
|
|
153
|
+
- [docs] Specify which props are added in the default `shouldForwardProp` option (#30978) @mnajdova
|
|
154
|
+
- [docs] Fix layout shift on loading (#31017) @oliviertassinari
|
|
155
|
+
- [docs] Increase scroll affordance in wide tables (#30713) @danilo-leal
|
|
156
|
+
- [docs] Fix look & feel of the Masonry demos (#30971) @oliviertassinari
|
|
157
|
+
- [docs] Improve Base component demos (#30884) @danilo-leal
|
|
158
|
+
- [docs] Use full product names (Material UI, MUI System) (#30960) @oliviertassinari
|
|
159
|
+
- [docs] Prefer useEnhancedEffect to avoid server side warnings (#30977) @mnajdova
|
|
160
|
+
- [docs] Fix force redirection to a different locale (#30967) @oliviertassinari
|
|
161
|
+
- [docs] Add live Tailwind CSS demo (#30966) @oliviertassinari
|
|
162
|
+
- [website] Add banner for promoting priority open roles (#31076) @danilo-leal
|
|
163
|
+
- [website] Open Full-stack Engineer role for studio (#31038) @newguy-123
|
|
164
|
+
- [website] Minor security improvements (#31062) @oliviertassinari
|
|
165
|
+
- [website] Improve title of open roles (#30963) @DanailH
|
|
166
|
+
- [website] Add BIMI avatar (#30444) @oliviertassinari
|
|
167
|
+
- [website] Add Sycamore to About page (#31000) @samuelsycamore
|
|
168
|
+
|
|
169
|
+
### Core
|
|
170
|
+
|
|
171
|
+
- [benchmark] Add missing dependency (#30994) @michaldudak
|
|
172
|
+
- [core] Bump date-io version (#31016) @michaldudak
|
|
173
|
+
- [core] Fix typo in useSlider (#31061) @ryohey
|
|
174
|
+
- [core] Remove unused draft-js types package (#30993) @michaldudak
|
|
175
|
+
- [test] Test if certain Base members are exported from Material UI (#31067) @michaldudak
|
|
176
|
+
- [core] Remove dead code (#31064) @oliviertassinari
|
|
177
|
+
|
|
178
|
+
All contributors of this release in alphabetical order: @agauravdev, @alisasanib, @DanailH, @danilo-leal, @huyenltnguyen, @l10nbot, @liradb2000, @mbrookes, @michaldudak, @mnajdova, @newguy-123, @oliviertassinari, @ryohey, @samuelsycamore, @siriwatknp, @sydneyjodon-wk
|
|
179
|
+
|
|
3
180
|
## 5.4.1
|
|
4
181
|
|
|
5
182
|
<!-- generated comparing v5.4.0..master -->
|
package/createBox.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Box from './Box';
|
|
2
|
+
import styleFunctionSx from './styleFunctionSx';
|
|
2
3
|
|
|
3
4
|
export default function createBox(options?: {
|
|
4
5
|
defaultTheme: object;
|
|
5
6
|
defaultClassName?: string;
|
|
6
7
|
generateClassName?: (componentName: string) => string;
|
|
8
|
+
styleFunctionSx?: typeof styleFunctionSx;
|
|
7
9
|
}): typeof Box;
|
package/createBox.js
CHANGED
|
@@ -35,9 +35,10 @@ function createBox(options = {}) {
|
|
|
35
35
|
const {
|
|
36
36
|
defaultTheme,
|
|
37
37
|
defaultClassName = 'MuiBox-root',
|
|
38
|
-
generateClassName
|
|
38
|
+
generateClassName,
|
|
39
|
+
styleFunctionSx = _styleFunctionSx.default
|
|
39
40
|
} = options;
|
|
40
|
-
const BoxRoot = (0, _styledEngine.default)('div')(
|
|
41
|
+
const BoxRoot = (0, _styledEngine.default)('div')(styleFunctionSx);
|
|
41
42
|
const Box = /*#__PURE__*/React.forwardRef(function Box(inProps, ref) {
|
|
42
43
|
const theme = (0, _useTheme.default)(defaultTheme);
|
|
43
44
|
|
package/createBox.spec.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
package/createStyled.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
CreateMUIStyled as CreateMUIStyledStyledEngine,
|
|
4
4
|
CSSInterpolation,
|
|
5
5
|
} from '@mui/styled-engine';
|
|
6
|
-
import { SxProps } from './styleFunctionSx';
|
|
6
|
+
import styleFunctionSx, { SxProps } from './styleFunctionSx';
|
|
7
7
|
import { Theme as DefaultTheme } from './createTheme';
|
|
8
8
|
|
|
9
9
|
export function shouldForwardProp(propName: PropertyKey): boolean;
|
|
@@ -34,4 +34,5 @@ export default function createStyled<T extends object = DefaultTheme>(options?:
|
|
|
34
34
|
defaultTheme?: T;
|
|
35
35
|
rootShouldForwardProp?: (prop: PropertyKey) => boolean;
|
|
36
36
|
slotShouldForwardProp?: (prop: PropertyKey) => boolean;
|
|
37
|
+
styleFunctionSx?: typeof styleFunctionSx;
|
|
37
38
|
}): CreateMUIStyled<T>;
|
package/createStyled.js
CHANGED
|
@@ -19,10 +19,10 @@ var _utils = require("@mui/utils");
|
|
|
19
19
|
|
|
20
20
|
var _createTheme = _interopRequireDefault(require("./createTheme"));
|
|
21
21
|
|
|
22
|
-
var _styleFunctionSx = _interopRequireDefault(require("./styleFunctionSx"));
|
|
23
|
-
|
|
24
22
|
var _propsToClassKey = _interopRequireDefault(require("./propsToClassKey"));
|
|
25
23
|
|
|
24
|
+
var _styleFunctionSx = _interopRequireDefault(require("./styleFunctionSx"));
|
|
25
|
+
|
|
26
26
|
const _excluded = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"],
|
|
27
27
|
_excluded2 = ["theme"],
|
|
28
28
|
_excluded3 = ["theme"];
|
|
@@ -79,7 +79,8 @@ const variantsResolver = (props, styles, theme, name) => {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return variantsStyles;
|
|
82
|
-
};
|
|
82
|
+
}; // Update /system/styled/#api in case if this changes
|
|
83
|
+
|
|
83
84
|
|
|
84
85
|
function shouldForwardProp(prop) {
|
|
85
86
|
return prop !== 'ownerState' && prop !== 'theme' && prop !== 'sx' && prop !== 'as';
|
|
@@ -96,7 +97,8 @@ function createStyled(input = {}) {
|
|
|
96
97
|
const {
|
|
97
98
|
defaultTheme = systemDefaultTheme,
|
|
98
99
|
rootShouldForwardProp = shouldForwardProp,
|
|
99
|
-
slotShouldForwardProp = shouldForwardProp
|
|
100
|
+
slotShouldForwardProp = shouldForwardProp,
|
|
101
|
+
styleFunctionSx = _styleFunctionSx.default
|
|
100
102
|
} = input;
|
|
101
103
|
return (tag, inputOptions = {}) => {
|
|
102
104
|
const {
|
|
@@ -177,7 +179,7 @@ function createStyled(input = {}) {
|
|
|
177
179
|
if (!skipSx) {
|
|
178
180
|
expressionsWithDefaultTheme.push(props => {
|
|
179
181
|
const theme = isEmpty(props.theme) ? defaultTheme : props.theme;
|
|
180
|
-
return (
|
|
182
|
+
return styleFunctionSx((0, _extends2.default)({}, props, {
|
|
181
183
|
theme
|
|
182
184
|
}));
|
|
183
185
|
});
|
|
@@ -190,7 +192,11 @@ function createStyled(input = {}) {
|
|
|
190
192
|
|
|
191
193
|
transformedStyleArg = [...styleArg, ...placeholders];
|
|
192
194
|
transformedStyleArg.raw = [...styleArg.raw, ...placeholders];
|
|
193
|
-
} else if (typeof styleArg === 'function'
|
|
195
|
+
} else if (typeof styleArg === 'function' && // On the server emotion doesn't use React.forwardRef for creating components, so the created
|
|
196
|
+
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
197
|
+
// which are basically components used as a selectors.
|
|
198
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
199
|
+
styleArg.__emotion_real !== styleArg) {
|
|
194
200
|
// If the type is function, we need to define the default theme.
|
|
195
201
|
transformedStyleArg = _ref2 => {
|
|
196
202
|
let {
|
|
@@ -8,17 +8,31 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.breakpointKeys = void 0;
|
|
9
9
|
exports.default = createBreakpoints;
|
|
10
10
|
|
|
11
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
|
|
13
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
14
12
|
|
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
+
|
|
15
15
|
const _excluded = ["values", "unit", "step"];
|
|
16
16
|
// Sorted ASC by size. That's important.
|
|
17
17
|
// It can't be configured as it's used statically for propTypes.
|
|
18
|
-
const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
19
|
-
|
|
18
|
+
const breakpointKeys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
20
19
|
exports.breakpointKeys = breakpointKeys;
|
|
21
20
|
|
|
21
|
+
const sortBreakpointsValues = values => {
|
|
22
|
+
const breakpointsAsArray = Object.keys(values).map(key => ({
|
|
23
|
+
key,
|
|
24
|
+
val: values[key]
|
|
25
|
+
})) || []; // Sort in ascending order
|
|
26
|
+
|
|
27
|
+
breakpointsAsArray.sort((breakpoint1, breakpoint2) => breakpoint1.val - breakpoint2.val);
|
|
28
|
+
return breakpointsAsArray.reduce((acc, obj) => {
|
|
29
|
+
return (0, _extends2.default)({}, acc, {
|
|
30
|
+
[obj.key]: obj.val
|
|
31
|
+
});
|
|
32
|
+
}, {});
|
|
33
|
+
}; // Keep in mind that @media is inclusive by the CSS specification.
|
|
34
|
+
|
|
35
|
+
|
|
22
36
|
function createBreakpoints(breakpoints) {
|
|
23
37
|
const {
|
|
24
38
|
// The breakpoint **start** at this value.
|
|
@@ -39,7 +53,8 @@ function createBreakpoints(breakpoints) {
|
|
|
39
53
|
step = 5
|
|
40
54
|
} = breakpoints,
|
|
41
55
|
other = (0, _objectWithoutPropertiesLoose2.default)(breakpoints, _excluded);
|
|
42
|
-
const
|
|
56
|
+
const sortedValues = sortBreakpointsValues(values);
|
|
57
|
+
const keys = Object.keys(sortedValues);
|
|
43
58
|
|
|
44
59
|
function up(key) {
|
|
45
60
|
const value = typeof values[key] === 'number' ? values[key] : key;
|
|
@@ -81,7 +96,7 @@ function createBreakpoints(breakpoints) {
|
|
|
81
96
|
|
|
82
97
|
return (0, _extends2.default)({
|
|
83
98
|
keys,
|
|
84
|
-
values,
|
|
99
|
+
values: sortedValues,
|
|
85
100
|
up,
|
|
86
101
|
down,
|
|
87
102
|
between,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
|
-
export declare type SpacingArgument = number | string;
|
|
3
|
-
export interface Spacing {
|
|
4
|
-
(): string;
|
|
5
|
-
(value: number): string;
|
|
6
|
-
(topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
|
|
7
|
-
(top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
|
|
8
|
-
(top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
|
|
9
|
-
}
|
|
10
|
-
export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
|
|
1
|
+
export declare type SpacingOptions = number | Spacing | ((abs: number) => number | string) | ((abs: number | string) => number | string) | ReadonlyArray<string | number>;
|
|
2
|
+
export declare type SpacingArgument = number | string;
|
|
3
|
+
export interface Spacing {
|
|
4
|
+
(): string;
|
|
5
|
+
(value: number): string;
|
|
6
|
+
(topBottom: SpacingArgument, rightLeft: SpacingArgument): string;
|
|
7
|
+
(top: SpacingArgument, rightLeft: SpacingArgument, bottom: SpacingArgument): string;
|
|
8
|
+
(top: SpacingArgument, right: SpacingArgument, bottom: SpacingArgument, left: SpacingArgument): string;
|
|
9
|
+
}
|
|
10
|
+
export default function createSpacing(spacingInput?: SpacingOptions): Spacing;
|
|
@@ -2,73 +2,18 @@ import * as React from 'react';
|
|
|
2
2
|
import getInitColorSchemeScript from './getInitColorSchemeScript';
|
|
3
3
|
import { Mode, Result } from './useCurrentColorScheme';
|
|
4
4
|
|
|
5
|
-
export type BuildCssVarsTheme<ThemeInput> = ThemeInput extends {
|
|
6
|
-
colorSchemes: Record<string, infer ColorSystems>;
|
|
7
|
-
}
|
|
8
|
-
? Omit<ThemeInput, 'colorSchemes'> &
|
|
9
|
-
ColorSystems & { vars: Omit<ThemeInput, 'colorSchemes'> & ColorSystems }
|
|
10
|
-
: never;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* DesignSystemColorScheme: is what a design system provide by default. Mostly, `light` and `dark`
|
|
14
|
-
* ApplicationColorScheme: is what developer can extend from a design system. Ex, `comfort` `trueDark` ...any name that they want
|
|
15
|
-
*
|
|
16
|
-
* This type enhance customization experience by checking if developer has extended the colorScheme or not (usually via module augmentation)
|
|
17
|
-
* If yes, they must provide the palette of the extended colorScheme. Otherwise `theme` is optional.
|
|
18
|
-
*/
|
|
19
|
-
type DecideTheme<
|
|
20
|
-
DesignSystemTheme extends { colorSchemes: Record<DesignSystemColorScheme, any> },
|
|
21
|
-
DesignSystemColorScheme extends string,
|
|
22
|
-
ApplicationTheme extends { colorSchemes: Record<ApplicationColorScheme, any> },
|
|
23
|
-
ApplicationColorScheme extends string | never,
|
|
24
|
-
> = [ApplicationColorScheme] extends [never]
|
|
25
|
-
? {
|
|
26
|
-
theme?: Omit<DesignSystemTheme, 'colorSchemes'> & {
|
|
27
|
-
colorSchemes?: Partial<
|
|
28
|
-
Record<
|
|
29
|
-
DesignSystemColorScheme,
|
|
30
|
-
DesignSystemTheme['colorSchemes'][DesignSystemColorScheme]
|
|
31
|
-
>
|
|
32
|
-
>;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
: {
|
|
36
|
-
theme: Omit<ApplicationTheme, 'colorSchemes'> & {
|
|
37
|
-
colorSchemes: Partial<
|
|
38
|
-
Record<
|
|
39
|
-
DesignSystemColorScheme,
|
|
40
|
-
DesignSystemTheme['colorSchemes'][DesignSystemColorScheme]
|
|
41
|
-
>
|
|
42
|
-
> &
|
|
43
|
-
Record<ApplicationColorScheme, ApplicationTheme['colorSchemes'][ApplicationColorScheme]>;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
47
5
|
export interface ColorSchemeContextValue<SupportedColorScheme extends string>
|
|
48
6
|
extends Result<SupportedColorScheme> {
|
|
49
7
|
allColorSchemes: SupportedColorScheme[];
|
|
50
8
|
}
|
|
51
9
|
|
|
52
|
-
export
|
|
53
|
-
DesignSystemThemeInput extends {
|
|
54
|
-
colorSchemes: Record<DesignSystemColorScheme, any>;
|
|
55
|
-
},
|
|
56
|
-
DesignSystemColorScheme extends string,
|
|
57
|
-
ApplicationThemeInput extends {
|
|
58
|
-
colorSchemes: Record<ApplicationColorScheme, any>;
|
|
59
|
-
} = never,
|
|
60
|
-
ApplicationColorScheme extends string = never,
|
|
61
|
-
>(options: {
|
|
10
|
+
export interface CssVarsProviderConfig<ColorScheme extends string> {
|
|
62
11
|
/**
|
|
63
|
-
* Design system default
|
|
12
|
+
* Design system default color scheme.
|
|
13
|
+
* - provides string if the design system has one default color scheme (either light or dark)
|
|
14
|
+
* - provides object if the design system has default light & dark color schemes
|
|
64
15
|
*/
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Design system default color scheme
|
|
68
|
-
*/
|
|
69
|
-
defaultColorScheme:
|
|
70
|
-
| DesignSystemColorScheme
|
|
71
|
-
| { light: DesignSystemColorScheme; dark: DesignSystemColorScheme };
|
|
16
|
+
defaultColorScheme: ColorScheme | { light: ColorScheme; dark: ColorScheme };
|
|
72
17
|
/**
|
|
73
18
|
* Design system default mode
|
|
74
19
|
* @default 'light'
|
|
@@ -89,32 +34,60 @@ export default function createCssVarsProvider<
|
|
|
89
34
|
* @default ''
|
|
90
35
|
*/
|
|
91
36
|
prefix?: string;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default function createCssVarsProvider<
|
|
40
|
+
ColorScheme extends string,
|
|
41
|
+
ThemeInput extends { colorSchemes?: Partial<Record<ColorScheme, any>> },
|
|
42
|
+
>(
|
|
43
|
+
options: CssVarsProviderConfig<ColorScheme> & {
|
|
44
|
+
/**
|
|
45
|
+
* Design system default theme
|
|
46
|
+
*
|
|
47
|
+
* The structure inside `theme.colorSchemes[colorScheme]` should be exactly the same in all color schemes because
|
|
48
|
+
* those object of the color scheme will be used when the color scheme is active.
|
|
49
|
+
*
|
|
50
|
+
* {
|
|
51
|
+
* colorSchemes: {
|
|
52
|
+
* light: { ...lightColorSchemeValues },
|
|
53
|
+
* dark: { ...darkColorSchemeValues }
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
*
|
|
57
|
+
* If colorScheme is 'light', the `lightColorSchemeValues` will be merged to theme as `{ ...theme, ...lightColorSchemeValues }`
|
|
58
|
+
* likewise, if colorScheme is 'dark', the `darkColorSchemeValues` will be merged to theme as `{ ...theme, ...darkColorSchemeValues }`
|
|
59
|
+
*
|
|
60
|
+
* !!! Don't provided the same keys as in colorSchemes to theme because they will be replaced internally when the selected colorScheme is calculated.
|
|
61
|
+
* Ex. {
|
|
62
|
+
* colorSchemes: {
|
|
63
|
+
* light: { palette: { ... } },
|
|
64
|
+
* dark: { palette: { ... } }
|
|
65
|
+
* },
|
|
66
|
+
* palette: { ... }, // This values will be replaced by the `palette` from the light | dark color scheme at runtime.
|
|
67
|
+
* }
|
|
68
|
+
*/
|
|
69
|
+
theme: any;
|
|
70
|
+
/**
|
|
71
|
+
* A function to determine if the key, value should be attached as CSS Variable
|
|
72
|
+
* `keys` is an array that represents the object path keys.
|
|
73
|
+
* Ex, if the theme is { foo: { bar: 'var(--test)' } }
|
|
74
|
+
* then, keys = ['foo', 'bar']
|
|
75
|
+
* value = 'var(--test)'
|
|
76
|
+
*/
|
|
77
|
+
shouldSkipGeneratingVar?: (keys: string[], value: string | number) => boolean;
|
|
78
|
+
/**
|
|
79
|
+
* A function to be called after the CSS variables are attached. The result of this function will be the final theme pass to ThemeProvider.
|
|
80
|
+
*
|
|
81
|
+
* The example usage is the variant generation in Joy. We need to combine the token from user-input and the default theme first, then generate
|
|
82
|
+
* variants from those tokens.
|
|
83
|
+
*/
|
|
84
|
+
resolveTheme?: (theme: any) => any; // the type is any because it depends on the design system.
|
|
85
|
+
},
|
|
86
|
+
): {
|
|
101
87
|
CssVarsProvider: (
|
|
102
88
|
props: React.PropsWithChildren<
|
|
103
|
-
{
|
|
104
|
-
|
|
105
|
-
* Application default mode (overrides design system `defaultMode` if specified)
|
|
106
|
-
*/
|
|
107
|
-
defaultMode?: Mode;
|
|
108
|
-
/**
|
|
109
|
-
* Application default colorScheme (overrides design system `defaultColorScheme` if specified)
|
|
110
|
-
*/
|
|
111
|
-
defaultColorScheme?:
|
|
112
|
-
| DesignSystemColorScheme
|
|
113
|
-
| ApplicationColorScheme
|
|
114
|
-
| {
|
|
115
|
-
light: DesignSystemColorScheme | ApplicationColorScheme;
|
|
116
|
-
dark: DesignSystemColorScheme | ApplicationColorScheme;
|
|
117
|
-
};
|
|
89
|
+
Partial<CssVarsProviderConfig<ColorScheme>> & {
|
|
90
|
+
theme?: ThemeInput;
|
|
118
91
|
/**
|
|
119
92
|
* localStorage key used to store application `mode`
|
|
120
93
|
* @default 'mui-mode'
|
|
@@ -125,19 +98,10 @@ export default function createCssVarsProvider<
|
|
|
125
98
|
* @default 'data-mui-color-scheme'
|
|
126
99
|
*/
|
|
127
100
|
attribute?: string;
|
|
128
|
-
|
|
129
|
-
* CSS variable prefix (overrides design system `prefix` if specified)
|
|
130
|
-
*/
|
|
131
|
-
prefix?: string;
|
|
132
|
-
} & DecideTheme<
|
|
133
|
-
DesignSystemThemeInput,
|
|
134
|
-
DesignSystemColorScheme,
|
|
135
|
-
ApplicationThemeInput,
|
|
136
|
-
ApplicationColorScheme
|
|
137
|
-
>
|
|
101
|
+
}
|
|
138
102
|
>,
|
|
139
103
|
) => React.ReactElement;
|
|
140
|
-
useColorScheme: () => ColorSchemeContextValue<
|
|
104
|
+
useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
|
|
141
105
|
getInitColorSchemeScript: typeof getInitColorSchemeScript;
|
|
142
106
|
};
|
|
143
107
|
|