@mui/system 5.15.7 → 5.15.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +89 -9
- package/colorManipulator.d.ts +1 -0
- package/colorManipulator.js +20 -0
- package/createStyled.js +80 -160
- package/esm/colorManipulator.js +19 -0
- package/esm/createStyled.js +81 -161
- package/index.js +1 -1
- package/legacy/colorManipulator.js +22 -0
- package/legacy/createStyled.js +85 -167
- package/legacy/index.js +1 -1
- package/modern/colorManipulator.js +19 -0
- package/modern/createStyled.js +80 -160
- package/modern/index.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## v5.15.8<!-- generated comparing v5.15.7..master -->
|
|
4
|
+
|
|
5
|
+
_Feb 6, 2024_
|
|
6
|
+
|
|
7
|
+
A big thanks to the 17 contributors who made this release possible. Here are some highlights ✨:
|
|
8
|
+
|
|
9
|
+
- 💫 Added a redesigned [landing page template](https://mui.com/material-ui/getting-started/templates/landing-page/) (#37557) @zanivan
|
|
10
|
+
- ✨ Added support for Arrow Down/Up + Shift and Page Up/Down keys for faster stepping in the Slider component (#40676) @mnajdova
|
|
11
|
+
- many 🐛 bug fixes and 📚 documentation improvements
|
|
12
|
+
|
|
13
|
+
### `@mui/material@5.15.8`
|
|
14
|
+
|
|
15
|
+
- ​<!-- 36 -->[Avatar] Simplify valid children assertion (#40834) @oliviertassinari
|
|
16
|
+
|
|
17
|
+
### `@mui/codemod@5.15.8`
|
|
18
|
+
|
|
19
|
+
- ​<!-- 37 -->[Accordion] Update props actual.js test case (#40879) @DiegoAndai
|
|
20
|
+
- ​<!-- 12 -->Fix `findComponentJSX` util (#40855) @sai6855
|
|
21
|
+
|
|
22
|
+
### `@mui/system@5.15.8`
|
|
23
|
+
|
|
24
|
+
- ​<!-- 10 -->Add blend color manipulator (#40258) @romgrk
|
|
25
|
+
- ​<!-- 38 -->Support variants in `theme.styleOverrides` (#40690) @siriwatknp
|
|
26
|
+
- ​<!-- 02 -->[zero] Always replace the `createUseThemeProps` call (#40885) @siriwatknp
|
|
27
|
+
- ​<!-- 01 -->[zero] Add README with installation and basic usage (#40761) @brijeshb42
|
|
28
|
+
|
|
29
|
+
### `@mui/base@5.0.0-beta.34`
|
|
30
|
+
|
|
31
|
+
- ​<!-- 35 -->[Button] Add support for `hostElementName` prop to improve SSR (#40507) @mj12albert
|
|
32
|
+
- ​<!-- 30 -->[Menu] Use Popup instead of Popper (#40731) @michaldudak
|
|
33
|
+
- ​<!-- 29 -->[useNumberInput] Integrate useNumberInput with useControllableReducer (#40206) @mj12albert
|
|
34
|
+
- ​<!-- 11 -->[Slider] Add support for Arrow Down/Up + Shift and Page Up/Down keys (#40676) @mnajdova
|
|
35
|
+
|
|
36
|
+
### Docs
|
|
37
|
+
|
|
38
|
+
- ​<!-- 34 -->[base-ui] Update usage.md (#40916) @adebiyial
|
|
39
|
+
- ​<!-- 33 -->[base-ui] Improve Base UI traffic from Material UI (#40875) @oliviertassinari
|
|
40
|
+
- ​<!-- 32 -->[base-ui] Change Radio component terminology from Button to Group (#40888) @danilo-leal
|
|
41
|
+
- ​<!-- 42 -->[base-ui] Remove redundant "Styled" prefix (#40478) @oliviertassinari
|
|
42
|
+
- ​<!-- 48 -->[base-ui] Update listbox slot style in demo (#40952) @sai6855
|
|
43
|
+
- ​<!-- 14 -->[material-ui] Fix createTheme import and markdown format in the Next.js guide (#40895) @hsmtkk
|
|
44
|
+
- ​<!-- 13 -->[material-ui] Correct Google font CDN URL as Roboto 600 weight is not used (#40852) @xuhdev
|
|
45
|
+
- ​<!-- 14 -->[material-ui] Replace the Album template with a landing page (#37557) @zanivan
|
|
46
|
+
- ​<!-- 21 -->[material-ui] Add deprecations migration guide (#40767) @DiegoAndai
|
|
47
|
+
- ​<!-- 22 -->[material-ui] Improve aria-label throughout the Button Group demos (#40892) @danilo-leal
|
|
48
|
+
- ​<!-- 17 -->[joy-ui] Update the Overview callout (#40900) @danilo-leal
|
|
49
|
+
- ​<!-- 22 -->Fix image size and dark mode @oliviertassinari
|
|
50
|
+
- ​<!-- 21 -->Migrate links from legacy.reactjs.org to react.dev @oliviertassinari
|
|
51
|
+
- ​<!-- 20 -->Fix 301 links @oliviertassinari
|
|
52
|
+
- ​<!-- 19 -->Fix outdated link @oliviertassinari
|
|
53
|
+
- ​<!-- 18 -->Fix URL and typo in CONTRIBUTING.md (#40899) @Smileek
|
|
54
|
+
|
|
55
|
+
### Core
|
|
56
|
+
|
|
57
|
+
- ​<!-- 28 -->[blog] Optimize images for /blog/mui-x-v7-beta/ @oliviertassinari
|
|
58
|
+
- ​<!-- 27 -->[blog] Clarify barrel index tree-shaking @oliviertassinari
|
|
59
|
+
- ​<!-- 26 -->[code-infra] Simplify bug reproduction (#40833) @oliviertassinari
|
|
60
|
+
- ​<!-- 25 -->[code-infra] Prepare publishing @mui-internal/typescript-to-proptypes to npm (#40842) @michaldudak
|
|
61
|
+
- ​<!-- 40 -->[code-infra] Remove babel alias from the docs (#40792) @Janpot
|
|
62
|
+
- ​<!-- 24 -->[core] Use Google Font v2 API @oliviertassinari
|
|
63
|
+
- ​<!-- 23 -->[core] Add missing change to v5.15.7 changelog (#40872) @DiegoAndai
|
|
64
|
+
- ​<!-- 31 -->[core] Normalize `<meta name="viewport" />`` @oliviertassinari
|
|
65
|
+
- ​<!-- 28 -->[dependencies] Do not update envinfo test dependencies (#40950) @michaldudak
|
|
66
|
+
- ​<!-- 17 -->[docs-infra] Fix arbitrary gap between paragraphs in callouts (#40911) @oliviertassinari
|
|
67
|
+
- ​<!-- 16 -->[docs-infra] Allow developers to build their CodeSandbox export (#40878) @oliviertassinari
|
|
68
|
+
- ​<!-- 15 -->[docs-infra] Improve StackBlitz support (#40832) @oliviertassinari
|
|
69
|
+
- ​<!-- 21 -->[docs-infra] Improve support for absolute locale URL (#40940) @oliviertassinari
|
|
70
|
+
- ​<!-- 31 -->[Menu][base-ui] Fix improperly merged tests (#40896) @michaldudak
|
|
71
|
+
- ​<!-- 09 -->[utils] Use consistent build approach (#40837) @siriwatknp
|
|
72
|
+
- ​<!-- 08 -->[website] Fix React missing key console error @oliviertassinari
|
|
73
|
+
- ​<!-- 07 -->[website] Fix broken link @oliviertassinari
|
|
74
|
+
- ​<!-- 06 -->[website] Fix heading structure (#40912) @oliviertassinari
|
|
75
|
+
- ​<!-- 05 -->[website] Add Customer Support Agent role to careers page (#40890) @rluzists1
|
|
76
|
+
- ​<!-- 04 -->[website] Refine the Material UI homepage demo (#40881) @danilo-leal
|
|
77
|
+
- ​<!-- 03 -->[website] Use em-dash when relevant over hyphen @oliviertassinari
|
|
78
|
+
- ​<!-- 03 -->[zero] Fix build for demo next.js app (#40854) @brijeshb42
|
|
79
|
+
|
|
80
|
+
All contributors of this release in alphabetical order: @adebiyial, @brijeshb42, @danilo-leal, @DiegoAndai, @hsmtkk, @Janpot, @michaldudak, @mj12albert, @mnajdova, @oliviertassinari, @rluzists1, @romgrk, @sai6855, @siriwatknp, @Smileek, @xuhdev, @zanivan
|
|
81
|
+
|
|
3
82
|
## v5.15.7
|
|
4
83
|
|
|
5
84
|
<!-- generated comparing v5.15.6..master -->
|
|
@@ -48,6 +127,7 @@ This release was mostly about 🐛 bug fixes and 📚 documentation improvements
|
|
|
48
127
|
|
|
49
128
|
### Docs
|
|
50
129
|
|
|
130
|
+
- ​<!-- 57 -->[material-ui] Fix the icon preview dialog (#40863) @danilo-leal
|
|
51
131
|
- ​<!-- 53 -->[material-ui] Fix typo on styled-components guide (#40858) @dancielos
|
|
52
132
|
- ​<!-- 49 -->[base-ui] Fix CSS vars from the plain CSS theme stylesheet (#40762) @zanivan
|
|
53
133
|
- ​<!-- 31 -->[material-ui][Divider] Remove light prop references from docs (#40782) @sai6855
|
|
@@ -149,7 +229,7 @@ This release was mostly about 🐛 bug fixes and 📚 documentation improvements
|
|
|
149
229
|
- ​<!-- 19 -->[core] Polish issue templates @oliviertassinari
|
|
150
230
|
- ​<!-- 13 -->[docs-infra] Support markdown link in slots descriptions (#40679) @alexfauquette
|
|
151
231
|
- ​<!-- 08 -->[examples] Simplify Next.js example (#40661) @oliviertassinari
|
|
152
|
-
- ​<!-- 03 -->[website] Fix broken styles on Base
|
|
232
|
+
- ​<!-- 03 -->[website] Fix broken styles on Base UI page (#40683) @michaldudak
|
|
153
233
|
|
|
154
234
|
All contributors of this release in alphabetical order: @alexfauquette, @anle9650, @ANUGLYPLUGIN, @brijeshb42, @danilo-leal, @devhik0, @DiegoAndai, @DonikaV, @joserodolfofreitas, @michaldudak, @mj12albert, @mnajdova, @mohamedsaiedd, @oliviertassinari, @pcorpet, @sai6855, @zanivan
|
|
155
235
|
|
|
@@ -1630,7 +1710,7 @@ A big thanks to the 21 contributors who made this release possible. Here are som
|
|
|
1630
1710
|
### Core
|
|
1631
1711
|
|
|
1632
1712
|
- [changelog] Fix issues in highlight @oliviertassinari
|
|
1633
|
-
- [core] Remove redundant `@material-ui/` aliases from regression test
|
|
1713
|
+
- [core] Remove redundant `@material-ui/` aliases from regression test Webpack config (#38574) @ZeeshanTamboli
|
|
1634
1714
|
- [core] Fix CI error @oliviertassinari
|
|
1635
1715
|
- [core] Remove unnecessary Box (#38461) @oliviertassinari
|
|
1636
1716
|
- [core] Set GitHub Action top level permission @oliviertassinari
|
|
@@ -4767,7 +4847,7 @@ A big thanks to the 21 contributors who made this release possible. Here are som
|
|
|
4767
4847
|
- [docs] Fix typo in `Grid` docs (#34475) @Dustin-Digitar
|
|
4768
4848
|
- [docs] Fix typo in `Back to top` section in AppBar docs (#34479) @Dustin-Digitar
|
|
4769
4849
|
- [docs] Standardize all "Installation" pages (#34168) @samuelsycamore
|
|
4770
|
-
- [docs] Fix
|
|
4850
|
+
- [docs] Fix Webpack file name to the standard: `webpack.config.js` (#34446) @CodingItWrong
|
|
4771
4851
|
- [docs] Fix Select `onChange` call (#34408) @siriwatknp
|
|
4772
4852
|
- [docs] Notification for pickers blog - v5 stable (#34400) @joserodolfofreitas
|
|
4773
4853
|
- [docs] Improve social sharing of docs pages (#34346) @oliviertassinari
|
|
@@ -5442,7 +5522,7 @@ A big thanks to the 19 contributors who made this release possible. Here are som
|
|
|
5442
5522
|
- [docs] Update to React 18 (#33196) @mnajdova
|
|
5443
5523
|
- [docs] Simplify "Upload button" demo (#33326) @baharalidurrani
|
|
5444
5524
|
- [docs] Add "refine" demo to showcase (#33240) @omeraplak
|
|
5445
|
-
- [docs] Add
|
|
5525
|
+
- [docs] Add Webpack alias for legacy utils package (#33376) @jgbae
|
|
5446
5526
|
- [docs] Improve external link icons synonyms (#33257) @davidgarciab
|
|
5447
5527
|
- [examples] Update Base UI with Tailwind CSS to use the latest versions of the dependencies (#33401) @mnajdova
|
|
5448
5528
|
- [examples] Add Base UI example (#33154) @siriwatknp
|
|
@@ -8209,7 +8289,7 @@ A big thanks to the 14 contributors who made this release possible. Here are som
|
|
|
8209
8289
|
- ​<!-- 42 -->[core] Remove code handling JSS components (#28421) @eps1lon
|
|
8210
8290
|
- ​<!-- 41 -->[core] Remove unused dependencies (#28468) @eps1lon
|
|
8211
8291
|
- ​<!-- 40 -->[core] Ensure both docs bundles are analyzeable (#28410) @eps1lon
|
|
8212
|
-
- ​<!-- 39 -->[core] Switch to
|
|
8292
|
+
- ​<!-- 39 -->[core] Switch to Webpack 5 (#28248) @eps1lon
|
|
8213
8293
|
- ​<!-- 38 -->[core] Batch small changes (#28177) @oliviertassinari
|
|
8214
8294
|
- ​<!-- 37 -->[core] Update publish tag to latest (#28382) @mnajdova
|
|
8215
8295
|
- ​<!-- 19 -->[framer] Update @mui/\* dependencies (#28469) @eps1lon
|
|
@@ -8957,7 +9037,7 @@ A big thanks to the 17 contributors who made this release possible. Here are som
|
|
|
8957
9037
|
- [docs] Sort the size in a more logical order (#27186) @oliviertassinari
|
|
8958
9038
|
- [docs] Use actual link to paperbase (#27063) @eps1lon
|
|
8959
9039
|
- [docs] Use custom markdown loader for landing page (#27065) @eps1lon
|
|
8960
|
-
- [docs] Use
|
|
9040
|
+
- [docs] Use Webpack 5 (#27077) @eps1lon
|
|
8961
9041
|
- [examples] Fix CDN warning (#27229) @oliviertassinari
|
|
8962
9042
|
- [examples] Remove `StyledEngineProvider` as JSS is not used (#27133) @mnajdova
|
|
8963
9043
|
- [examples] Remove forgotten StyledEngineProvider (#27163) @oliviertassinari
|
|
@@ -9087,7 +9167,7 @@ A big thanks to the 13 contributors who made this release possible. Here are som
|
|
|
9087
9167
|
- ​<!-- 35 -->[docs] Fix /components/hidden merge conflict (#26997) @eps1lon
|
|
9088
9168
|
- ​<!-- 26 -->[docs] Fix 404 links (#26963) @oliviertassinari
|
|
9089
9169
|
- ​<!-- 24 -->[docs] Remove link that points to v4 blog post (#26960) @steveafrost
|
|
9090
|
-
- ​<!-- 16 -->[docs] Use custom
|
|
9170
|
+
- ​<!-- 16 -->[docs] Use custom Webpack loader for markdown (#26774) @eps1lon
|
|
9091
9171
|
- ​<!-- 11 -->[docs] Fix 301 links (#26942) @oliviertassinari
|
|
9092
9172
|
- ​<!-- 01 -->[docs] Add page for the `sx` prop (#26769) @mnajdova
|
|
9093
9173
|
- ​<!-- 52 -->[docs] pre-fill issue when a demo crashes (#27034) @eps1lon
|
|
@@ -11938,7 +12018,7 @@ A big thanks to the 18 contributors who made this release possible. Here are som
|
|
|
11938
12018
|
);
|
|
11939
12019
|
```
|
|
11940
12020
|
|
|
11941
|
-
This enforces emotion being injected first. [More details](https://mui.com/material-ui/
|
|
12021
|
+
This enforces emotion being injected first. [More details](https://mui.com/material-ui/integrations/interoperability/#css-injection-order) in the documentation.
|
|
11942
12022
|
|
|
11943
12023
|
- [Autocomplete] Rename `closeIcon` prop with `clearIcon` to avoid confusion (#23617) @akhilmhdh.
|
|
11944
12024
|
|
|
@@ -13187,7 +13267,7 @@ Here are some highlights ✨:
|
|
|
13187
13267
|
#### Breaking changes
|
|
13188
13268
|
|
|
13189
13269
|
- [Modal] Remove `onRendered` prop from Modal and Portal (#22464) @eps1lon
|
|
13190
|
-
Depending on your use case either use a [callback ref](https://
|
|
13270
|
+
Depending on your use case either use a [callback ref](https://react.dev/learn/manipulating-the-dom-with-refs#how-to-manage-a-list-of-refs-using-a-ref-callback) on the child element or an effect hook in the child component.
|
|
13191
13271
|
|
|
13192
13272
|
#### Changes
|
|
13193
13273
|
|
package/colorManipulator.d.ts
CHANGED
|
@@ -27,3 +27,4 @@ export function darken(color: string, coefficient: number): string;
|
|
|
27
27
|
export function private_safeDarken(color: string, coefficient: number, warning?: string): string;
|
|
28
28
|
export function lighten(color: string, coefficient: number): string;
|
|
29
29
|
export function private_safeLighten(color: string, coefficient: number, warning?: string): string;
|
|
30
|
+
export function blend(background: string, overlay: string, opacity: number, gamma?: number): string;
|
package/colorManipulator.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.alpha = alpha;
|
|
8
|
+
exports.blend = blend;
|
|
8
9
|
exports.colorChannel = void 0;
|
|
9
10
|
exports.darken = darken;
|
|
10
11
|
exports.decomposeColor = decomposeColor;
|
|
@@ -349,4 +350,23 @@ function private_safeEmphasize(color, coefficient, warning) {
|
|
|
349
350
|
}
|
|
350
351
|
return color;
|
|
351
352
|
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Blend a transparent overlay color with a background color, resulting in a single
|
|
357
|
+
* RGB color.
|
|
358
|
+
* @param {string} background - CSS color
|
|
359
|
+
* @param {string} overlay - CSS color
|
|
360
|
+
* @param {number} opacity - Opacity multiplier in the range 0 - 1
|
|
361
|
+
* @param {number} [gamma=1.0] - Gamma correction factor. For gamma-correct blending, 2.2 is usual.
|
|
362
|
+
*/
|
|
363
|
+
function blend(background, overlay, opacity, gamma = 1.0) {
|
|
364
|
+
const blendChannel = (b, o) => Math.round((b ** (1 / gamma) * (1 - opacity) + o ** (1 / gamma) * opacity) ** gamma);
|
|
365
|
+
const backgroundColor = decomposeColor(background);
|
|
366
|
+
const overlayColor = decomposeColor(overlay);
|
|
367
|
+
const rgb = [blendChannel(backgroundColor.values[0], overlayColor.values[0]), blendChannel(backgroundColor.values[1], overlayColor.values[1]), blendChannel(backgroundColor.values[2], overlayColor.values[2])];
|
|
368
|
+
return recomposeColor({
|
|
369
|
+
type: 'rgb',
|
|
370
|
+
values: rgb
|
|
371
|
+
});
|
|
352
372
|
}
|
package/createStyled.js
CHANGED
|
@@ -7,14 +7,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = createStyled;
|
|
8
8
|
exports.shouldForwardProp = shouldForwardProp;
|
|
9
9
|
exports.systemDefaultTheme = void 0;
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var _styledEngine = _interopRequireWildcard(require("@mui/styled-engine"));
|
|
13
13
|
var _utils = require("@mui/utils");
|
|
14
14
|
var _createTheme = _interopRequireDefault(require("./createTheme"));
|
|
15
|
-
var _propsToClassKey = _interopRequireDefault(require("./propsToClassKey"));
|
|
16
15
|
var _styleFunctionSx = _interopRequireDefault(require("./styleFunctionSx"));
|
|
17
|
-
const _excluded = ["
|
|
16
|
+
const _excluded = ["ownerState"],
|
|
17
|
+
_excluded2 = ["variants"],
|
|
18
|
+
_excluded3 = ["name", "slot", "skipVariantsResolver", "skipSx", "overridesResolver"];
|
|
18
19
|
/* eslint-disable no-underscore-dangle */
|
|
19
20
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
20
21
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -30,74 +31,6 @@ function isStringTag(tag) {
|
|
|
30
31
|
// it's a lowercase character
|
|
31
32
|
tag.charCodeAt(0) > 96;
|
|
32
33
|
}
|
|
33
|
-
const getStyleOverrides = (name, theme) => {
|
|
34
|
-
if (theme.components && theme.components[name] && theme.components[name].styleOverrides) {
|
|
35
|
-
return theme.components[name].styleOverrides;
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
39
|
-
const transformVariants = variants => {
|
|
40
|
-
let numOfCallbacks = 0;
|
|
41
|
-
const variantsStyles = {};
|
|
42
|
-
if (variants) {
|
|
43
|
-
variants.forEach(definition => {
|
|
44
|
-
let key = '';
|
|
45
|
-
if (typeof definition.props === 'function') {
|
|
46
|
-
key = `callback${numOfCallbacks}`;
|
|
47
|
-
numOfCallbacks += 1;
|
|
48
|
-
} else {
|
|
49
|
-
key = (0, _propsToClassKey.default)(definition.props);
|
|
50
|
-
}
|
|
51
|
-
variantsStyles[key] = definition.style;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return variantsStyles;
|
|
55
|
-
};
|
|
56
|
-
const getVariantStyles = (name, theme) => {
|
|
57
|
-
let variants = [];
|
|
58
|
-
if (theme && theme.components && theme.components[name] && theme.components[name].variants) {
|
|
59
|
-
variants = theme.components[name].variants;
|
|
60
|
-
}
|
|
61
|
-
return transformVariants(variants);
|
|
62
|
-
};
|
|
63
|
-
const variantsResolver = (props, styles, variants) => {
|
|
64
|
-
const {
|
|
65
|
-
ownerState = {}
|
|
66
|
-
} = props;
|
|
67
|
-
const variantsStyles = [];
|
|
68
|
-
let numOfCallbacks = 0;
|
|
69
|
-
if (variants) {
|
|
70
|
-
variants.forEach(variant => {
|
|
71
|
-
let isMatch = true;
|
|
72
|
-
if (typeof variant.props === 'function') {
|
|
73
|
-
const propsToCheck = (0, _extends2.default)({}, props, ownerState);
|
|
74
|
-
isMatch = variant.props(propsToCheck);
|
|
75
|
-
} else {
|
|
76
|
-
Object.keys(variant.props).forEach(key => {
|
|
77
|
-
if (ownerState[key] !== variant.props[key] && props[key] !== variant.props[key]) {
|
|
78
|
-
isMatch = false;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (isMatch) {
|
|
83
|
-
if (typeof variant.props === 'function') {
|
|
84
|
-
variantsStyles.push(styles[`callback${numOfCallbacks}`]);
|
|
85
|
-
} else {
|
|
86
|
-
variantsStyles.push(styles[(0, _propsToClassKey.default)(variant.props)]);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (typeof variant.props === 'function') {
|
|
90
|
-
numOfCallbacks += 1;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
return variantsStyles;
|
|
95
|
-
};
|
|
96
|
-
const themeVariantsResolver = (props, styles, theme, name) => {
|
|
97
|
-
var _theme$components;
|
|
98
|
-
const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[name]) == null ? void 0 : _theme$components.variants;
|
|
99
|
-
return variantsResolver(props, styles, themeVariants);
|
|
100
|
-
};
|
|
101
34
|
|
|
102
35
|
// Update /system/styled/#api in case if this changes
|
|
103
36
|
function shouldForwardProp(prop) {
|
|
@@ -123,29 +56,51 @@ function defaultOverridesResolver(slot) {
|
|
|
123
56
|
}
|
|
124
57
|
return (props, styles) => styles[slot];
|
|
125
58
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let optionalVariants;
|
|
139
|
-
if (resolvedStyles && resolvedStyles.variants) {
|
|
140
|
-
optionalVariants = resolvedStyles.variants;
|
|
141
|
-
delete resolvedStyles.variants;
|
|
59
|
+
function processStyleArg(callableStyle, _ref) {
|
|
60
|
+
let {
|
|
61
|
+
ownerState
|
|
62
|
+
} = _ref,
|
|
63
|
+
props = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
64
|
+
const resolvedStylesArg = typeof callableStyle === 'function' ? callableStyle((0, _extends2.default)({
|
|
65
|
+
ownerState
|
|
66
|
+
}, props)) : callableStyle;
|
|
67
|
+
if (Array.isArray(resolvedStylesArg)) {
|
|
68
|
+
return resolvedStylesArg.flatMap(resolvedStyle => processStyleArg(resolvedStyle, (0, _extends2.default)({
|
|
69
|
+
ownerState
|
|
70
|
+
}, props)));
|
|
142
71
|
}
|
|
143
|
-
if (
|
|
144
|
-
const
|
|
145
|
-
|
|
72
|
+
if (!!resolvedStylesArg && typeof resolvedStylesArg === 'object' && Array.isArray(resolvedStylesArg.variants)) {
|
|
73
|
+
const {
|
|
74
|
+
variants = []
|
|
75
|
+
} = resolvedStylesArg,
|
|
76
|
+
otherStyles = (0, _objectWithoutPropertiesLoose2.default)(resolvedStylesArg, _excluded2);
|
|
77
|
+
let result = otherStyles;
|
|
78
|
+
variants.forEach(variant => {
|
|
79
|
+
let isMatch = true;
|
|
80
|
+
if (typeof variant.props === 'function') {
|
|
81
|
+
isMatch = variant.props((0, _extends2.default)({
|
|
82
|
+
ownerState
|
|
83
|
+
}, props));
|
|
84
|
+
} else {
|
|
85
|
+
Object.keys(variant.props).forEach(key => {
|
|
86
|
+
if ((ownerState == null ? void 0 : ownerState[key]) !== variant.props[key] && props[key] !== variant.props[key]) {
|
|
87
|
+
isMatch = false;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (isMatch) {
|
|
92
|
+
if (!Array.isArray(result)) {
|
|
93
|
+
result = [result];
|
|
94
|
+
}
|
|
95
|
+
result.push(typeof variant.style === 'function' ? variant.style((0, _extends2.default)({
|
|
96
|
+
ownerState
|
|
97
|
+
}, props)) : variant.style);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return result;
|
|
146
101
|
}
|
|
147
|
-
return
|
|
148
|
-
}
|
|
102
|
+
return resolvedStylesArg;
|
|
103
|
+
}
|
|
149
104
|
function createStyled(input = {}) {
|
|
150
105
|
const {
|
|
151
106
|
themeId,
|
|
@@ -174,7 +129,7 @@ function createStyled(input = {}) {
|
|
|
174
129
|
// For more details: https://github.com/mui/material-ui/pull/37908
|
|
175
130
|
overridesResolver = defaultOverridesResolver(lowercaseFirstLetter(componentSlot))
|
|
176
131
|
} = inputOptions,
|
|
177
|
-
options = (0, _objectWithoutPropertiesLoose2.default)(inputOptions,
|
|
132
|
+
options = (0, _objectWithoutPropertiesLoose2.default)(inputOptions, _excluded3);
|
|
178
133
|
|
|
179
134
|
// if skipVariantsResolver option is defined, take the value, otherwise, true for root and false for other slots.
|
|
180
135
|
const skipVariantsResolver = inputSkipVariantsResolver !== undefined ? inputSkipVariantsResolver :
|
|
@@ -207,92 +162,57 @@ function createStyled(input = {}) {
|
|
|
207
162
|
shouldForwardProp: shouldForwardPropOption,
|
|
208
163
|
label
|
|
209
164
|
}, options));
|
|
210
|
-
const
|
|
211
|
-
const expressionsWithDefaultTheme = expressions ? expressions.map(stylesArg => {
|
|
212
|
-
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
213
|
-
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
214
|
-
// which are basically components used as a selectors.
|
|
215
|
-
if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg) {
|
|
216
|
-
return props => muiStyledFunctionResolver({
|
|
217
|
-
styledArg: stylesArg,
|
|
218
|
-
props,
|
|
219
|
-
defaultTheme,
|
|
220
|
-
themeId
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
if ((0, _utils.isPlainObject)(stylesArg)) {
|
|
224
|
-
let transformedStylesArg = stylesArg;
|
|
225
|
-
let styledArgVariants;
|
|
226
|
-
if (stylesArg && stylesArg.variants) {
|
|
227
|
-
styledArgVariants = stylesArg.variants;
|
|
228
|
-
delete transformedStylesArg.variants;
|
|
229
|
-
transformedStylesArg = props => {
|
|
230
|
-
let result = stylesArg;
|
|
231
|
-
const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
|
|
232
|
-
variantStyles.forEach(variantStyle => {
|
|
233
|
-
result = (0, _utils.deepmerge)(result, variantStyle);
|
|
234
|
-
});
|
|
235
|
-
return result;
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
return transformedStylesArg;
|
|
239
|
-
}
|
|
240
|
-
return stylesArg;
|
|
241
|
-
}) : [];
|
|
242
|
-
let transformedStyleArg = styleArg;
|
|
243
|
-
if ((0, _utils.isPlainObject)(styleArg)) {
|
|
244
|
-
let styledArgVariants;
|
|
245
|
-
if (styleArg && styleArg.variants) {
|
|
246
|
-
styledArgVariants = styleArg.variants;
|
|
247
|
-
delete transformedStyleArg.variants;
|
|
248
|
-
transformedStyleArg = props => {
|
|
249
|
-
let result = styleArg;
|
|
250
|
-
const variantStyles = variantsResolver(props, transformVariants(styledArgVariants), styledArgVariants);
|
|
251
|
-
variantStyles.forEach(variantStyle => {
|
|
252
|
-
result = (0, _utils.deepmerge)(result, variantStyle);
|
|
253
|
-
});
|
|
254
|
-
return result;
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
} else if (typeof styleArg === 'function' &&
|
|
165
|
+
const transformStyleArg = stylesArg => {
|
|
258
166
|
// On the server Emotion doesn't use React.forwardRef for creating components, so the created
|
|
259
167
|
// component stays as a function. This condition makes sure that we do not interpolate functions
|
|
260
168
|
// which are basically components used as a selectors.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
});
|
|
169
|
+
if (typeof stylesArg === 'function' && stylesArg.__emotion_real !== stylesArg || (0, _utils.isPlainObject)(stylesArg)) {
|
|
170
|
+
return props => processStyleArg(stylesArg, (0, _extends2.default)({}, props, {
|
|
171
|
+
theme: resolveTheme({
|
|
172
|
+
theme: props.theme,
|
|
173
|
+
defaultTheme,
|
|
174
|
+
themeId
|
|
175
|
+
})
|
|
176
|
+
}));
|
|
269
177
|
}
|
|
178
|
+
return stylesArg;
|
|
179
|
+
};
|
|
180
|
+
const muiStyledResolver = (styleArg, ...expressions) => {
|
|
181
|
+
let transformedStyleArg = transformStyleArg(styleArg);
|
|
182
|
+
const expressionsWithDefaultTheme = expressions ? expressions.map(transformStyleArg) : [];
|
|
270
183
|
if (componentName && overridesResolver) {
|
|
271
184
|
expressionsWithDefaultTheme.push(props => {
|
|
272
185
|
const theme = resolveTheme((0, _extends2.default)({}, props, {
|
|
273
186
|
defaultTheme,
|
|
274
187
|
themeId
|
|
275
188
|
}));
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
const resolvedStyleOverrides = {};
|
|
279
|
-
Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
|
|
280
|
-
resolvedStyleOverrides[slotKey] = typeof slotStyle === 'function' ? slotStyle((0, _extends2.default)({}, props, {
|
|
281
|
-
theme
|
|
282
|
-
})) : slotStyle;
|
|
283
|
-
});
|
|
284
|
-
return overridesResolver(props, resolvedStyleOverrides);
|
|
189
|
+
if (!theme.components || !theme.components[componentName] || !theme.components[componentName].styleOverrides) {
|
|
190
|
+
return null;
|
|
285
191
|
}
|
|
286
|
-
|
|
192
|
+
const styleOverrides = theme.components[componentName].styleOverrides;
|
|
193
|
+
const resolvedStyleOverrides = {};
|
|
194
|
+
// TODO: v7 remove iteration and use `resolveStyleArg(styleOverrides[slot])` directly
|
|
195
|
+
Object.entries(styleOverrides).forEach(([slotKey, slotStyle]) => {
|
|
196
|
+
resolvedStyleOverrides[slotKey] = processStyleArg(slotStyle, (0, _extends2.default)({}, props, {
|
|
197
|
+
theme
|
|
198
|
+
}));
|
|
199
|
+
});
|
|
200
|
+
return overridesResolver(props, resolvedStyleOverrides);
|
|
287
201
|
});
|
|
288
202
|
}
|
|
289
203
|
if (componentName && !skipVariantsResolver) {
|
|
290
204
|
expressionsWithDefaultTheme.push(props => {
|
|
205
|
+
var _theme$components;
|
|
291
206
|
const theme = resolveTheme((0, _extends2.default)({}, props, {
|
|
292
207
|
defaultTheme,
|
|
293
208
|
themeId
|
|
294
209
|
}));
|
|
295
|
-
|
|
210
|
+
const themeVariants = theme == null || (_theme$components = theme.components) == null || (_theme$components = _theme$components[componentName]) == null ? void 0 : _theme$components.variants;
|
|
211
|
+
return processStyleArg({
|
|
212
|
+
variants: themeVariants
|
|
213
|
+
}, (0, _extends2.default)({}, props, {
|
|
214
|
+
theme
|
|
215
|
+
}));
|
|
296
216
|
});
|
|
297
217
|
}
|
|
298
218
|
if (!skipSx) {
|
package/esm/colorManipulator.js
CHANGED
|
@@ -323,4 +323,23 @@ export function private_safeEmphasize(color, coefficient, warning) {
|
|
|
323
323
|
}
|
|
324
324
|
return color;
|
|
325
325
|
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Blend a transparent overlay color with a background color, resulting in a single
|
|
330
|
+
* RGB color.
|
|
331
|
+
* @param {string} background - CSS color
|
|
332
|
+
* @param {string} overlay - CSS color
|
|
333
|
+
* @param {number} opacity - Opacity multiplier in the range 0 - 1
|
|
334
|
+
* @param {number} [gamma=1.0] - Gamma correction factor. For gamma-correct blending, 2.2 is usual.
|
|
335
|
+
*/
|
|
336
|
+
export function blend(background, overlay, opacity, gamma = 1.0) {
|
|
337
|
+
const blendChannel = (b, o) => Math.round((b ** (1 / gamma) * (1 - opacity) + o ** (1 / gamma) * opacity) ** gamma);
|
|
338
|
+
const backgroundColor = decomposeColor(background);
|
|
339
|
+
const overlayColor = decomposeColor(overlay);
|
|
340
|
+
const rgb = [blendChannel(backgroundColor.values[0], overlayColor.values[0]), blendChannel(backgroundColor.values[1], overlayColor.values[1]), blendChannel(backgroundColor.values[2], overlayColor.values[2])];
|
|
341
|
+
return recomposeColor({
|
|
342
|
+
type: 'rgb',
|
|
343
|
+
values: rgb
|
|
344
|
+
});
|
|
326
345
|
}
|