From 89876936d8965da4b251a2b5e84e5fee0b15f990 Mon Sep 17 00:00:00 2001
From: Olivier Tassinari
Date: Mon, 30 Dec 2019 11:29:41 +0100
Subject: [PATCH 01/15] [TableSortLabel] Sort asc by default (#19013)
---
docs/pages/api/table-sort-label.md | 2 +-
.../pages/components/tables/EnhancedTable.js | 6 ++---
.../pages/components/tables/EnhancedTable.tsx | 6 ++---
.../src/TableSortLabel/TableSortLabel.js | 5 ++--
.../src/TableSortLabel/TableSortLabel.test.js | 7 -----
tslint.json | 26 +++++++++----------
6 files changed, 23 insertions(+), 29 deletions(-)
diff --git a/docs/pages/api/table-sort-label.md b/docs/pages/api/table-sort-label.md
index fcd273d9185150..ce80868cb3a170 100644
--- a/docs/pages/api/table-sort-label.md
+++ b/docs/pages/api/table-sort-label.md
@@ -27,7 +27,7 @@ A button based label for placing inside `TableCell` for column sorting.
| active | bool | false | If `true`, the label will have the active styling (should be true for the sorted column). |
| children | node | | Label contents, the arrow will be appended automatically. |
| classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
-| direction | 'asc' | 'desc' | 'desc' | The current sort direction. |
+| direction | 'asc' | 'desc' | 'asc' | The current sort direction. |
| hideSortIcon | bool | false | Hide sort icon when active is false. |
| IconComponent | elementType | ArrowDownwardIcon | Sort icon to use. |
diff --git a/docs/src/pages/components/tables/EnhancedTable.js b/docs/src/pages/components/tables/EnhancedTable.js
index 5edb0b1ee43bf0..d59aa3f73a9f55 100644
--- a/docs/src/pages/components/tables/EnhancedTable.js
+++ b/docs/src/pages/components/tables/EnhancedTable.js
@@ -99,7 +99,7 @@ function EnhancedTableHead(props) {
>
{headCell.label}
@@ -221,8 +221,8 @@ export default function EnhancedTable() {
const [rowsPerPage, setRowsPerPage] = React.useState(5);
const handleRequestSort = (event, property) => {
- const isDesc = orderBy === property && order === 'desc';
- setOrder(isDesc ? 'asc' : 'desc');
+ const isAsc = orderBy === property && order === 'asc';
+ setOrder(isAsc ? 'desc' : 'asc');
setOrderBy(property);
};
diff --git a/docs/src/pages/components/tables/EnhancedTable.tsx b/docs/src/pages/components/tables/EnhancedTable.tsx
index 45ed8603c69f1d..54645d21c50740 100644
--- a/docs/src/pages/components/tables/EnhancedTable.tsx
+++ b/docs/src/pages/components/tables/EnhancedTable.tsx
@@ -134,7 +134,7 @@ function EnhancedTableHead(props: EnhancedTableProps) {
>
{headCell.label}
@@ -249,8 +249,8 @@ export default function EnhancedTable() {
const [rowsPerPage, setRowsPerPage] = React.useState(5);
const handleRequestSort = (event: React.MouseEvent, property: keyof Data) => {
- const isDesc = orderBy === property && order === 'desc';
- setOrder(isDesc ? 'asc' : 'desc');
+ const isAsc = orderBy === property && order === 'asc';
+ setOrder(isAsc ? 'desc' : 'asc');
setOrderBy(property);
};
diff --git a/packages/material-ui/src/TableSortLabel/TableSortLabel.js b/packages/material-ui/src/TableSortLabel/TableSortLabel.js
index fe160a6207d747..c3845ebce2cb9d 100644
--- a/packages/material-ui/src/TableSortLabel/TableSortLabel.js
+++ b/packages/material-ui/src/TableSortLabel/TableSortLabel.js
@@ -20,7 +20,7 @@ export const styles = theme => ({
'&:hover': {
color: theme.palette.text.secondary,
'& $icon': {
- opacity: 1,
+ opacity: 0.5,
},
},
'&$active': {
@@ -36,6 +36,7 @@ export const styles = theme => ({
active: {},
/* Styles applied to the icon component. */
icon: {
+ fontSize: 18,
marginRight: 4,
marginLeft: 4,
opacity: 0,
@@ -63,7 +64,7 @@ const TableSortLabel = React.forwardRef(function TableSortLabel(props, ref) {
children,
classes,
className,
- direction = 'desc',
+ direction = 'asc',
hideSortIcon = false,
IconComponent = ArrowDownwardIcon,
...other
diff --git a/packages/material-ui/src/TableSortLabel/TableSortLabel.test.js b/packages/material-ui/src/TableSortLabel/TableSortLabel.test.js
index 6dc81a39f6bc75..e741d93997a4ff 100644
--- a/packages/material-ui/src/TableSortLabel/TableSortLabel.test.js
+++ b/packages/material-ui/src/TableSortLabel/TableSortLabel.test.js
@@ -48,13 +48,6 @@ describe('', () => {
assert.strictEqual(iconChildren.length, 1);
});
- it('by default should have desc direction class', () => {
- const wrapper = shallow();
- const icon = wrapper.find(`.${classes.icon}`).first();
- assert.strictEqual(icon.hasClass(classes.iconDirectionAsc), false);
- assert.strictEqual(icon.hasClass(classes.iconDirectionDesc), true);
- });
-
it('when given direction desc should have desc direction class', () => {
const wrapper = shallow();
const icon = wrapper.find(`.${classes.icon}`).first();
diff --git a/tslint.json b/tslint.json
index b52e1378e01e9c..d3f9df017d02c4 100644
--- a/tslint.json
+++ b/tslint.json
@@ -1,15 +1,15 @@
{
- "defaultSeverity": "error",
- "extends": ["dtslint/dtslint.json"],
- "jsRules": {},
- "rules": {
- "deprecation": true,
- "file-name-casing": false,
- "no-boolean-literal-compare": false,
- "no-empty-interface": false,
- "no-unnecessary-callback-wrapper": false,
- "no-unnecessary-generics": false,
- "no-redundant-jsdoc": false,
- "semicolon": [true, "always", "ignore-bound-class-methods"]
- }
+ "defaultSeverity": "error",
+ "extends": ["dtslint/dtslint.json"],
+ "jsRules": {},
+ "rules": {
+ "deprecation": true,
+ "file-name-casing": false,
+ "no-boolean-literal-compare": false,
+ "no-empty-interface": false,
+ "no-unnecessary-callback-wrapper": false,
+ "no-unnecessary-generics": false,
+ "no-redundant-jsdoc": false,
+ "semicolon": [true, "always", "ignore-bound-class-methods"]
+ }
}
From c76876cf09ce258f4adc6ed361496159207e76db Mon Sep 17 00:00:00 2001
From: Olivier Tassinari
Date: Mon, 30 Dec 2019 11:42:39 +0100
Subject: [PATCH 02/15] [core] Batch small changes (#19016)
---
docs/pages/api/autocomplete.md | 4 +--
docs/src/modules/components/Ad.js | 36 ++++++++++++-------
.../modules/components/AppTableOfContents.js | 2 +-
docs/src/modules/components/MarkdownDocs.js | 13 ++++++-
.../src/modules/components/MarkdownElement.js | 2 +-
docs/src/modules/components/bootstrap.js | 4 ---
docs/src/pages/components/app-bar/app-bar.md | 8 ++---
.../src/Autocomplete/Autocomplete.js | 4 +--
.../src/useAutocomplete/useAutocomplete.d.ts | 4 +--
.../src/useAutocomplete/useAutocomplete.js | 19 ++++++----
.../src/elementAcceptingRef.test.js | 2 +-
.../src/elementTypeAcceptingRef.test.js | 2 +-
packages/material-ui/src/SvgIcon/SvgIcon.js | 2 +-
.../material-ui/src/SvgIcon/SvgIcon.test.js | 2 +-
14 files changed, 63 insertions(+), 41 deletions(-)
diff --git a/docs/pages/api/autocomplete.md b/docs/pages/api/autocomplete.md
index a5e80992a6812a..d244b1094203d4 100644
--- a/docs/pages/api/autocomplete.md
+++ b/docs/pages/api/autocomplete.md
@@ -59,9 +59,9 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| loadingText | node | 'Loading…' | Text to display when in a loading state. For localization purposes, you can use the provided [translations](/guides/localization/). |
| multiple | bool | false | If `true`, `value` must be an array and the menu will support multiple selections. |
| noOptionsText | node | 'No options' | Text to display when there are no options. For localization purposes, you can use the provided [translations](/guides/localization/). |
-| onChange | func | | Callback fired when the value changes.
**Signature:** `function(event: object, value: any) => void` *event:* The event source of the callback *value:* null |
+| onChange | func | | Callback fired when the value changes.
**Signature:** `function(event: object, value: any) => void` *event:* The event source of the callback. *value:* null |
| onClose | func | | Callback fired when the popup requests to be closed. Use in controlled mode (see open).
**Signature:** `function(event: object) => void` *event:* The event source of the callback. |
-| onInputChange | func | | Callback fired when the input value changes.
**Signature:** `function(event: object, value: string, reason: string) => void` *event:* The event source of the callback. *value:* The new value of the text input *reason:* Can be: "input" (user input), "reset" (programmatic change), `"clear"`. |
+| onInputChange | func | | Callback fired when the input value changes.
**Signature:** `function(event: object, value: string, reason: string) => void` *event:* The event source of the callback. *value:* The new value of the text input. *reason:* Can be: "input" (user input), "reset" (programmatic change), `"clear"`. |
| onOpen | func | | Callback fired when the popup requests to be opened. Use in controlled mode (see open).
**Signature:** `function(event: object) => void` *event:* The event source of the callback. |
| open | bool | | Control the popup` open state. |
| openText | string | 'Open' | Override the default text for the *open popup* icon button. For localization purposes, you can use the provided [translations](/guides/localization/). |
diff --git a/docs/src/modules/components/Ad.js b/docs/src/modules/components/Ad.js
index 1ae7a9d1237403..35ff6f637d4be2 100644
--- a/docs/src/modules/components/Ad.js
+++ b/docs/src/modules/components/Ad.js
@@ -25,9 +25,11 @@ const styles = theme => ({
},
});
-function getAdblock(classes, t) {
+function Adblock(props) {
+ const t = useSelector(state => state.options.t);
+
return (
-
+
{t('likeMui')}
@@ -86,9 +88,9 @@ const inHouseAds = [
function Ad(props) {
const { classes } = props;
- const t = useSelector(state => state.options.t);
const timerAdblock = React.useRef();
+ const { current: randomSplit } = React.useRef(Math.random());
const [adblock, setAdblock] = React.useState(null);
const [carbonOut, setCarbonOut] = React.useState(null);
const [codeFundOut, setCodeFundOut] = React.useState(null);
@@ -157,11 +159,11 @@ function Ad(props) {
children = ;
}
- if (adblock) {
+ if (!children && adblock) {
minHeight = 'auto';
if (Math.random() < 0.2) {
- children = getAdblock(classes, t);
+ children = ;
} else {
children = ;
}
@@ -171,7 +173,7 @@ function Ad(props) {
if (carbonOut || codeFundOut) {
children = ;
minHeight = 'auto';
- } else if (Math.random() < 0.35) {
+ } else if (randomSplit < 0.35) {
children = ;
} else {
children = ;
@@ -180,8 +182,8 @@ function Ad(props) {
React.useEffect(() => {
// Avoid a flood of events.
- if (Math.random < 0.1) {
- return null;
+ if (Math.random() < 0.9) {
+ return undefined;
}
const delay = setTimeout(() => {
@@ -192,9 +194,17 @@ function Ad(props) {
} else if (children.type === AdCarbon) {
type = 'carbon';
} else if (children.type === AdInHouse) {
- type = 'in-house';
+ if (!adblock && codeFundOut) {
+ type = 'in-house-codefund';
+ } else if (!adblock && carbonOut) {
+ type = 'in-house-carbon';
+ } else {
+ type = 'in-house';
+ }
+ } else if (children.type === Adblock) {
+ type = 'in-house-adblock';
} else {
- type = 'disable-adblock';
+ return;
}
window.ga('send', {
@@ -212,12 +222,12 @@ function Ad(props) {
eventLabel: children.props.ad.name,
});
}
- }, 2000);
+ }, 2500);
return () => {
clearTimeout(delay);
};
- }, [children.type, children.props.ad]);
+ }, [children.type, children.props.ad, codeFundOut, carbonOut, adblock]);
return (
@@ -230,4 +240,4 @@ Ad.propTypes = {
classes: PropTypes.object.isRequired,
};
-export default withStyles(styles)(Ad);
+export default React.memo(withStyles(styles)(Ad));
diff --git a/docs/src/modules/components/AppTableOfContents.js b/docs/src/modules/components/AppTableOfContents.js
index dcdb4affcef377..fe2b1b88142cf7 100644
--- a/docs/src/modules/components/AppTableOfContents.js
+++ b/docs/src/modules/components/AppTableOfContents.js
@@ -1,7 +1,7 @@
/* eslint-disable react/no-danger */
import React from 'react';
import PropTypes from 'prop-types';
-import marked from 'marked';
+import marked from 'marked/lib/marked';
import throttle from 'lodash/throttle';
import clsx from 'clsx';
import Box from '@material-ui/core/Box';
diff --git a/docs/src/modules/components/MarkdownDocs.js b/docs/src/modules/components/MarkdownDocs.js
index e9bfe485480100..128135f6794032 100644
--- a/docs/src/modules/components/MarkdownDocs.js
+++ b/docs/src/modules/components/MarkdownDocs.js
@@ -90,6 +90,17 @@ function flattenPages(pages, current = []) {
}, current);
}
+// To replace with .findIndex() once we stop IE 11 support.
+function findIndex(array, comp) {
+ for (let i = 0; i < array.length; i += 1) {
+ if (comp(array[i])) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
function MarkdownDocs(props) {
const {
blog,
@@ -145,7 +156,7 @@ function MarkdownDocs(props) {
const { activePage, pages } = React.useContext(PageContext);
const pageList = flattenPages(pages);
- const currentPageNum = pageList.findIndex(page => page.pathname === activePage.pathname);
+ const currentPageNum = findIndex(pageList, page => page.pathname === activePage.pathname);
const currentPage = pageList[currentPageNum];
const prevPage = pageList[currentPageNum - 1];
const nextPage = pageList[currentPageNum + 1];
diff --git a/docs/src/modules/components/MarkdownElement.js b/docs/src/modules/components/MarkdownElement.js
index 1060b55a3a914b..91a4a90983c91f 100644
--- a/docs/src/modules/components/MarkdownElement.js
+++ b/docs/src/modules/components/MarkdownElement.js
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { useSelector } from 'react-redux';
-import marked from 'marked';
+import marked from 'marked/lib/marked';
import { withStyles } from '@material-ui/core/styles';
import textToHash from 'docs/src/modules/utils/textToHash';
import prism from 'docs/src/modules/components/prism';
diff --git a/docs/src/modules/components/bootstrap.js b/docs/src/modules/components/bootstrap.js
index 388d2055e07a45..c38ff34eba52e2 100644
--- a/docs/src/modules/components/bootstrap.js
+++ b/docs/src/modules/components/bootstrap.js
@@ -1,7 +1,3 @@
-// Use the same helper as Babel to avoid bundle bloat.
-import 'core-js/modules/es6.array.find-index';
-import 'core-js/modules/es6.set';
-
// Disable auto highlighting
// https://github.com/PrismJS/prism/issues/765
if (process.browser) {
diff --git a/docs/src/pages/components/app-bar/app-bar.md b/docs/src/pages/components/app-bar/app-bar.md
index f1974133828bb7..048f6b9221e339 100644
--- a/docs/src/pages/components/app-bar/app-bar.md
+++ b/docs/src/pages/components/app-bar/app-bar.md
@@ -43,7 +43,7 @@ A prominent app bar.
## Bottom App Bar
-{{"demo": "pages/components/app-bar/BottomAppBar.js", "iframe": true, "maxWidth": 500}}
+{{"demo": "pages/components/app-bar/BottomAppBar.js", "iframe": true, "maxWidth": 400}}
## Fixed placement
@@ -93,19 +93,19 @@ You can use the `useScrollTrigger()` hook to respond to user scroll actions.
The app bar hides on scroll down to leave more space for reading.
-{{"demo": "pages/components/app-bar/HideAppBar.js", "iframe": true, "maxWidth": 500}}
+{{"demo": "pages/components/app-bar/HideAppBar.js", "iframe": true}}
### Elevate App Bar
The app bar elevates on scroll to communicate that the user is not at the top of the page.
-{{"demo": "pages/components/app-bar/ElevateAppBar.js", "iframe": true, "maxWidth": 500}}
+{{"demo": "pages/components/app-bar/ElevateAppBar.js", "iframe": true}}
### Back to top
A floating action buttons appears on scroll to make it easy to get back to the top of the page.
-{{"demo": "pages/components/app-bar/BackToTop.js", "iframe": true, "maxWidth": 500}}
+{{"demo": "pages/components/app-bar/BackToTop.js", "iframe": true}}
### `useScrollTrigger([options]) => trigger`
diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
index 791ac759c9e54b..0e8021b84ad31b 100644
--- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
+++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
@@ -636,7 +636,7 @@ Autocomplete.propTypes = {
/**
* Callback fired when the value changes.
*
- * @param {object} event The event source of the callback
+ * @param {object} event The event source of the callback.
* @param {any} value
*/
onChange: PropTypes.func,
@@ -651,7 +651,7 @@ Autocomplete.propTypes = {
* Callback fired when the input value changes.
*
* @param {object} event The event source of the callback.
- * @param {string} value The new value of the text input
+ * @param {string} value The new value of the text input.
* @param {string} reason Can be: "input" (user input), "reset" (programmatic change), `"clear"`.
*/
onInputChange: PropTypes.func,
diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
index 4d0e062c9011b0..1a706f55746125 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.d.ts
@@ -132,7 +132,7 @@ export interface UseAutocompleteProps {
/**
* Callback fired when the value changes.
*
- * @param {object} event The event source of the callback
+ * @param {object} event The event source of the callback.
* @param {any} value
*/
onChange?: (event: React.ChangeEvent<{}>, value: any) => void;
@@ -147,7 +147,7 @@ export interface UseAutocompleteProps {
* Callback fired when the input value changes.
*
* @param {object} event The event source of the callback.
- * @param {string} value The new value of the text input
+ * @param {string} value The new value of the text input.
* @param {string} reason Can be: "input" (user input), "reset" (programmatic change), `"clear"`.
*/
onInputChange?: (event: React.ChangeEvent<{}>, value: any, reason: 'input' | 'reset') => void;
diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index 1b0cd74fc523c9..e17e10b8a95426 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -61,6 +61,17 @@ export function createFilterOptions(config = {}) {
};
}
+// To replace with .findIndex() once we stop IE 11 support.
+function findIndex(array, comp) {
+ for (let i = 0; i < array.length; i += 1) {
+ if (comp(array[i])) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
const defaultFilterOptions = createFilterOptions();
// Number of options to jump in list box when pageup and pagedown keys are used.
@@ -424,13 +435,7 @@ export default function useAutocomplete(props) {
const item = newValue;
newValue = Array.isArray(value) ? [...value] : [];
- let itemIndex = -1;
- // To replace with .findIndex() once we stop IE 11 support.
- for (let i = 0; i < newValue.length; i += 1) {
- if (getOptionSelected(item, newValue[i])) {
- itemIndex = i;
- }
- }
+ const itemIndex = findIndex(newValue, valueItem => getOptionSelected(item, valueItem));
if (itemIndex === -1) {
newValue.push(item);
diff --git a/packages/material-ui-utils/src/elementAcceptingRef.test.js b/packages/material-ui-utils/src/elementAcceptingRef.test.js
index 2fb4053c2016af..d0994ce2f18429 100644
--- a/packages/material-ui-utils/src/elementAcceptingRef.test.js
+++ b/packages/material-ui-utils/src/elementAcceptingRef.test.js
@@ -20,7 +20,7 @@ describe('elementAcceptingRef', () => {
}
before(() => {
- mount = createMount();
+ mount = createMount({ strict: true });
});
after(() => {
diff --git a/packages/material-ui-utils/src/elementTypeAcceptingRef.test.js b/packages/material-ui-utils/src/elementTypeAcceptingRef.test.js
index 0b6a7039c40111..da8f7c8328dac6 100644
--- a/packages/material-ui-utils/src/elementTypeAcceptingRef.test.js
+++ b/packages/material-ui-utils/src/elementTypeAcceptingRef.test.js
@@ -20,7 +20,7 @@ describe('elementTypeAcceptingRef', () => {
}
before(() => {
- mount = createMount();
+ mount = createMount({ strict: true });
});
after(() => {
diff --git a/packages/material-ui/src/SvgIcon/SvgIcon.js b/packages/material-ui/src/SvgIcon/SvgIcon.js
index 93be6ce5923d46..c4a31a818b57d3 100644
--- a/packages/material-ui/src/SvgIcon/SvgIcon.js
+++ b/packages/material-ui/src/SvgIcon/SvgIcon.js
@@ -79,7 +79,7 @@ const SvgIcon = React.forwardRef(function SvgIcon(props, ref) {
focusable="false"
viewBox={viewBox}
color={htmlColor}
- aria-hidden={titleAccess ? 'false' : 'true'}
+ aria-hidden={titleAccess ? null : 'true'}
role={titleAccess ? 'img' : 'presentation'}
ref={ref}
{...other}
diff --git a/packages/material-ui/src/SvgIcon/SvgIcon.test.js b/packages/material-ui/src/SvgIcon/SvgIcon.test.js
index 405fa419c56993..9a73a5072ec684 100644
--- a/packages/material-ui/src/SvgIcon/SvgIcon.test.js
+++ b/packages/material-ui/src/SvgIcon/SvgIcon.test.js
@@ -59,7 +59,7 @@ describe('', () => {
,
);
assert.strictEqual(wrapper.find('title').text(), 'Network');
- assert.strictEqual(wrapper.props()['aria-hidden'], 'false');
+ assert.strictEqual(wrapper.props()['aria-hidden'], null);
});
});
From dcaf13f116743b643a1649f0522fed0a59cf93f2 Mon Sep 17 00:00:00 2001
From: mceIdo <58237675+mceIdo@users.noreply.github.com>
Date: Mon, 30 Dec 2019 12:46:22 +0200
Subject: [PATCH 03/15] [styles] Fix jss StyleSheet attach() call (#19042)
---
packages/material-ui-benchmark/src/styles.js | 3 ++-
packages/material-ui-styles/src/makeStyles/makeStyles.js | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/packages/material-ui-benchmark/src/styles.js b/packages/material-ui-benchmark/src/styles.js
index d61a0d9d7e88b6..07875c14ebd77e 100644
--- a/packages/material-ui-benchmark/src/styles.js
+++ b/packages/material-ui-benchmark/src/styles.js
@@ -128,7 +128,8 @@ suite
const dynamicSheet = jss.createStyleSheet(dynamicStyles, {
link: true,
});
- dynamicSheet.update({}).attach();
+ dynamicSheet.update({});
+ dynamicSheet.attach();
sheetsRegistry.add(dynamicSheet);
}
diff --git a/packages/material-ui-styles/src/makeStyles/makeStyles.js b/packages/material-ui-styles/src/makeStyles/makeStyles.js
index 7ea4c57894fdf0..2ed424f5c5938e 100644
--- a/packages/material-ui-styles/src/makeStyles/makeStyles.js
+++ b/packages/material-ui-styles/src/makeStyles/makeStyles.js
@@ -109,7 +109,8 @@ function attach({ state, theme, stylesOptions, stylesCreator, name }, props) {
...options,
});
- dynamicSheet.update(props).attach();
+ dynamicSheet.update(props);
+ dynamicSheet.attach();
state.dynamicSheet = dynamicSheet;
state.classes = mergeClasses({
From 0c7ca746674cfb47a46cad8ebea21155702fd38c Mon Sep 17 00:00:00 2001
From: Olivier Tassinari
Date: Mon, 30 Dec 2019 11:59:08 +0100
Subject: [PATCH 04/15] v4.8.2
---
CHANGELOG.md | 46 ++++++++++++++++++++++++
package.json | 2 +-
packages/material-ui-lab/package.json | 2 +-
packages/material-ui-styles/package.json | 2 +-
packages/material-ui/package.json | 4 +--
5 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a4e3c6b11a6c7..d6228b31aba3d0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,51 @@
### [Versions](https://material-ui.com/versions/)
+## 4.8.2
+###### *Dec 30, 2019*
+
+Big thanks to the 22 contributors who made this release possible.
+
+### `@material-ui/core@v4.8.2`
+
+- [Badge] Fix doc about anchorOrigin (#18982) @ypresto
+- [DialogContent] Add missing `dividers` class types (#18984) @NickCis
+- [RadioGroup] Add useRadioGroup Hook (#18920) @NMinhNguyen
+- [Slider] Fix discrete mark highlighting (#18993) @ulises-lara
+- [Slider] Improve the pointer event logic (#19010) @oliviertassinari
+- [TablePagination] Fix duplicate key error (#18988) @afzalsayed96
+- [TableSortLabel] Relax IconComponent prop requirements in TypeScript (#18936) @Igorbek
+- [TableSortLabel] Sort asc by default (#19013) @oliviertassinari
+- [l10n] Add Portuguese (pt-PT) locale (#18987) @hrafaelveloso
+
+### `@material-ui/lab@v4.8.2`
+
+- [styles] Fix jss StyleSheet attach() call (#19042) @mceIdo
+
+### `@material-ui/lab@v4.0.0-alpha.38`
+
+- [Skeleton] Add wave animation support (#19014) @oliviertassinari
+- [Autocomplete] Fix option height border-box (#19000) @MariyaVdovenko
+- [Autocomplete] Zero (0) integer key display throws (#18994) @hoop71
+- [Rating] Clear value if selected value is clicked (#18999) @ivowork
+- [Rating] Add a demo with different icons (#19004) @hoop71
+
+### Docs
+
+- [docs] Add TS demo for MenuPopupState (#18998) @eps1lon
+- [docs] Add yarn install instructions in CONTRIBUTING.md (#18970) @hiteshkundal
+- [docs] Clarify not all components have 'component' prop (#19015) @JamieS1211
+- [docs] Fix syntax error in palette customization example (#19008) @mumairofficial
+- [docs] Fix typo in toggle-button.md (#19002) @noahbenham
+- [docs] Update showcase lists (#19039) @typekev
+- [docs] Fix url address in modules/watrerfall/Batcher.js (#18997) @hiteshkundal
+
+### Core
+
+- [core] Don't force a remote when listing prettier changes (#18794) @Janpot
+- [core] Bump handlebars from 4.1.2 to 4.5.3 (#18989) @dependabot-preview
+- [core] Batch small changes (#19016) @oliviertassinari
+- [core] Batch small changes (#19012) @mbrookes
+
## 4.8.1
###### *Dec 24, 2019*
diff --git a/package.json b/package.json
index 472287ecfded1e..e3500251f0d832 100644
--- a/package.json
+++ b/package.json
@@ -1,5 +1,5 @@
{
- "version": "4.8.1",
+ "version": "4.8.2",
"private": true,
"scripts": {
"proptypes": "ts-node --skip-project ./scripts/generateProptypes.ts",
diff --git a/packages/material-ui-lab/package.json b/packages/material-ui-lab/package.json
index f8e347b76b4f49..0f953939cc3427 100644
--- a/packages/material-ui-lab/package.json
+++ b/packages/material-ui-lab/package.json
@@ -1,6 +1,6 @@
{
"name": "@material-ui/lab",
- "version": "4.0.0-alpha.37",
+ "version": "4.0.0-alpha.38",
"private": false,
"author": "Material-UI Team",
"description": "Material-UI Lab - Incubator for Material-UI React components.",
diff --git a/packages/material-ui-styles/package.json b/packages/material-ui-styles/package.json
index cdf0f96d85d322..c78c1f1385d106 100644
--- a/packages/material-ui-styles/package.json
+++ b/packages/material-ui-styles/package.json
@@ -1,6 +1,6 @@
{
"name": "@material-ui/styles",
- "version": "4.7.1",
+ "version": "4.8.2",
"private": false,
"author": "Material-UI Team",
"description": "Material-UI Styles - The styling solution of Material-UI.",
diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json
index 24b368d5bdcf10..87e3f3dc9204bc 100644
--- a/packages/material-ui/package.json
+++ b/packages/material-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "@material-ui/core",
- "version": "4.8.1",
+ "version": "4.8.2",
"private": false,
"author": "Material-UI Team",
"description": "React components that implement Google's Material Design.",
@@ -42,7 +42,7 @@
},
"dependencies": {
"@babel/runtime": "^7.4.4",
- "@material-ui/styles": "^4.7.1",
+ "@material-ui/styles": "^4.8.2",
"@material-ui/system": "^4.7.1",
"@material-ui/types": "^4.1.1",
"@material-ui/utils": "^4.7.1",
From fb0ab9d667a911459a47a66e64d2e27ec7185bc3 Mon Sep 17 00:00:00 2001
From: Paul
Date: Mon, 30 Dec 2019 14:38:04 +0100
Subject: [PATCH 05/15] [Collapse] Add `hidden` class key to Collapse typings
(#19044)
---
packages/material-ui/src/Collapse/Collapse.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/material-ui/src/Collapse/Collapse.d.ts b/packages/material-ui/src/Collapse/Collapse.d.ts
index cedab407a13ce6..19f6be1e45f17a 100644
--- a/packages/material-ui/src/Collapse/Collapse.d.ts
+++ b/packages/material-ui/src/Collapse/Collapse.d.ts
@@ -11,7 +11,7 @@ export interface CollapseProps extends StandardProps;
From 5533914d1cf6ef43c00ff99347c6bc561ac63977 Mon Sep 17 00:00:00 2001
From: Rikpat <33869814+Rikpat@users.noreply.github.com>
Date: Tue, 31 Dec 2019 10:46:59 +0100
Subject: [PATCH 06/15] [Grid] Update TypeScript classes definitions (#19050)
---
packages/material-ui/src/Grid/Grid.d.ts | 2 ++
1 file changed, 2 insertions(+)
diff --git a/packages/material-ui/src/Grid/Grid.d.ts b/packages/material-ui/src/Grid/Grid.d.ts
index d0047cff80a0b6..c71e7afefc1c1b 100644
--- a/packages/material-ui/src/Grid/Grid.d.ts
+++ b/packages/material-ui/src/Grid/Grid.d.ts
@@ -32,6 +32,7 @@ export type GridClassKey =
| 'root'
| 'container'
| 'item'
+ | 'zeroMinWidth'
| 'direction-xs-column'
| 'direction-xs-column-reverse'
| 'direction-xs-row-reverse'
@@ -50,6 +51,7 @@ export type GridClassKey =
| 'justify-xs-flex-end'
| 'justify-xs-space-between'
| 'justify-xs-space-around'
+ | 'justify-xs-space-evenly'
| 'spacing-xs-1'
| 'spacing-xs-2'
| 'spacing-xs-3'
From d3323396f88731548778047625bb0d16f6c3f7a9 Mon Sep 17 00:00:00 2001
From: Ulises Lara
Date: Tue, 31 Dec 2019 04:03:05 -0600
Subject: [PATCH 07/15] [theme] Support breakpoints.between(a, b) with number
(#19003)
---
.../pages/customization/breakpoints/breakpoints.md | 4 ++--
.../material-ui/src/styles/createBreakpoints.js | 13 +++++++++----
.../src/styles/createBreakpoints.test.js | 9 ++++++++-
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/docs/src/pages/customization/breakpoints/breakpoints.md b/docs/src/pages/customization/breakpoints/breakpoints.md
index 4397b96cc896a1..8f8c9072a7795f 100644
--- a/docs/src/pages/customization/breakpoints/breakpoints.md
+++ b/docs/src/pages/customization/breakpoints/breakpoints.md
@@ -171,8 +171,8 @@ const styles = theme => ({
#### Arguments
-1. `start` (*String*): A breakpoint key (`xs`, `sm`, etc.).
-2. `end` (*String*): A breakpoint key (`xs`, `sm`, etc.).
+1. `start` (*String*): A breakpoint key (`xs`, `sm`, etc.) or a screen width number in pixels.
+2. `end` (*String*): A breakpoint key (`xs`, `sm`, etc.) or a screen width number in pixels.
#### Returns
diff --git a/packages/material-ui/src/styles/createBreakpoints.js b/packages/material-ui/src/styles/createBreakpoints.js
index e05d9588f4108c..b1ff2100395e6e 100644
--- a/packages/material-ui/src/styles/createBreakpoints.js
+++ b/packages/material-ui/src/styles/createBreakpoints.js
@@ -38,15 +38,20 @@ export default function createBreakpoints(breakpoints) {
}
function between(start, end) {
- const endIndex = keys.indexOf(end) + 1;
+ const endIndex = keys.indexOf(end);
- if (endIndex === keys.length) {
+ if (endIndex === keys.length - 1) {
return up(start);
}
return (
- `@media (min-width:${values[start]}${unit}) and ` +
- `(max-width:${values[keys[endIndex]] - step / 100}${unit})`
+ `@media (min-width:${
+ typeof values[start] === 'number' ? values[start] : start
+ }${unit}) and ` +
+ `(max-width:${(endIndex !== -1 && typeof values[keys[endIndex + 1]] === 'number'
+ ? values[keys[endIndex + 1]]
+ : end) -
+ step / 100}${unit})`
);
}
diff --git a/packages/material-ui/src/styles/createBreakpoints.test.js b/packages/material-ui/src/styles/createBreakpoints.test.js
index bc01d896b22db6..4668064da44f48 100644
--- a/packages/material-ui/src/styles/createBreakpoints.test.js
+++ b/packages/material-ui/src/styles/createBreakpoints.test.js
@@ -23,7 +23,7 @@ describe('createBreakpoints', () => {
assert.strictEqual(breakpoints.down('md'), '@media (max-width:1279.95px)');
});
- it('should use the specified key if it is not a recognized breakpoint', () => {
+ it('should accept a number', () => {
assert.strictEqual(breakpoints.down(600), '@media (max-width:599.95px)');
});
@@ -40,6 +40,13 @@ describe('createBreakpoints', () => {
);
});
+ it('should accept numbers', () => {
+ assert.strictEqual(
+ breakpoints.between(600, 800),
+ '@media (min-width:600px) and (max-width:799.95px)',
+ );
+ });
+
it('on xl should call up', () => {
assert.strictEqual(breakpoints.between('lg', 'xl'), '@media (min-width:1280px)');
});
From f38c262c009d47dfbb33361a94043bd6975a0ad3 Mon Sep 17 00:00:00 2001
From: Sandra Marcela Herrera Arriaga
Date: Tue, 31 Dec 2019 05:10:41 -0600
Subject: [PATCH 08/15] [Popover] Fix position when changing state or updated
(#19046)
---
packages/material-ui/src/Popover/Popover.js | 73 +++++++++++--------
.../material-ui/src/Popover/Popover.test.js | 8 +-
packages/material-ui/src/Slide/Slide.js | 27 ++++---
.../material-ui/src/Tabs/ScrollbarSize.js | 1 -
4 files changed, 58 insertions(+), 51 deletions(-)
diff --git a/packages/material-ui/src/Popover/Popover.js b/packages/material-ui/src/Popover/Popover.js
index 58e4d23d7a2e7c..7651a5cedb5ac6 100644
--- a/packages/material-ui/src/Popover/Popover.js
+++ b/packages/material-ui/src/Popover/Popover.js
@@ -307,27 +307,30 @@ const Popover = React.forwardRef(function Popover(props, ref) {
],
);
- const setPositioningStyles = React.useCallback(
- element => {
- const positioning = getPositioningStyle(element);
+ const setPositioningStyles = React.useCallback(() => {
+ const element = paperRef.current;
- if (positioning.top !== null) {
- element.style.top = positioning.top;
- }
- if (positioning.left !== null) {
- element.style.left = positioning.left;
- }
- element.style.transformOrigin = positioning.transformOrigin;
- },
- [getPositioningStyle],
- );
+ if (!element) {
+ return;
+ }
+
+ const positioning = getPositioningStyle(element);
+
+ if (positioning.top !== null) {
+ element.style.top = positioning.top;
+ }
+ if (positioning.left !== null) {
+ element.style.left = positioning.left;
+ }
+ element.style.transformOrigin = positioning.transformOrigin;
+ }, [getPositioningStyle]);
const handleEntering = (element, isAppearing) => {
if (onEntering) {
onEntering(element, isAppearing);
}
- setPositioningStyles(element);
+ setPositioningStyles();
};
const handlePaperRef = React.useCallback(instance => {
@@ -335,32 +338,40 @@ const Popover = React.forwardRef(function Popover(props, ref) {
paperRef.current = ReactDOM.findDOMNode(instance);
}, []);
- const updatePosition = React.useMemo(() => {
- if (!open) {
- return undefined;
+ React.useEffect(() => {
+ if (open) {
+ setPositioningStyles();
}
+ });
- return debounce(() => {
- setPositioningStyles(paperRef.current);
- });
- }, [open, setPositioningStyles]);
-
- React.useImperativeHandle(action, () => (open ? { updatePosition } : null), [
- open,
- updatePosition,
- ]);
+ React.useImperativeHandle(
+ action,
+ () =>
+ open
+ ? {
+ updatePosition: () => {
+ setPositioningStyles();
+ },
+ }
+ : null,
+ [open, setPositioningStyles],
+ );
React.useEffect(() => {
- if (!updatePosition) {
+ if (!open) {
return undefined;
}
- window.addEventListener('resize', updatePosition);
+ const handleResize = debounce(() => {
+ setPositioningStyles();
+ });
+
+ window.addEventListener('resize', handleResize);
return () => {
- window.removeEventListener('resize', updatePosition);
- updatePosition.clear();
+ handleResize.clear();
+ window.removeEventListener('rezise', handleResize);
};
- }, [updatePosition]);
+ }, [open, setPositioningStyles]);
let transitionDuration = transitionDurationProp;
diff --git a/packages/material-ui/src/Popover/Popover.test.js b/packages/material-ui/src/Popover/Popover.test.js
index b43630e04dd673..6a576f7c1bcf2d 100644
--- a/packages/material-ui/src/Popover/Popover.test.js
+++ b/packages/material-ui/src/Popover/Popover.test.js
@@ -616,13 +616,14 @@ describe('', () => {
clock = useFakeTimers();
windowInnerHeight = window.innerHeight;
+ window.innerHeight = 8;
+
const mockedAnchor = document.createElement('div');
stub(mockedAnchor, 'getBoundingClientRect').callsFake(() => ({
left: 0,
top: 9,
}));
const handleEntering = spy();
- window.innerHeight = 8;
wrapper = mount(
', () => {
it('should be able to manually recalculate position', () => {
let popoverActions;
wrapper.setProps({
- open: false,
+ open: true,
action: actions => {
popoverActions = actions;
},
});
- wrapper.setProps({
- open: true,
- });
const beforeStyle = {
top: element.style.top,
left: element.style.left,
diff --git a/packages/material-ui/src/Slide/Slide.js b/packages/material-ui/src/Slide/Slide.js
index e8f9873bbd3297..49a6b00efb7874 100644
--- a/packages/material-ui/src/Slide/Slide.js
+++ b/packages/material-ui/src/Slide/Slide.js
@@ -173,22 +173,21 @@ const Slide = React.forwardRef(function Slide(props, ref) {
React.useEffect(() => {
// Skip configuration where the position is screen size invariant.
- if (!inProp && direction !== 'down' && direction !== 'right') {
- const handleResize = debounce(() => {
- if (childrenRef.current) {
- setTranslateValue(direction, childrenRef.current);
- }
- });
-
- window.addEventListener('resize', handleResize);
-
- return () => {
- handleResize.clear();
- window.removeEventListener('resize', handleResize);
- };
+ if (inProp || direction === 'down' || direction === 'right') {
+ return undefined;
}
- return undefined;
+ const handleResize = debounce(() => {
+ if (childrenRef.current) {
+ setTranslateValue(direction, childrenRef.current);
+ }
+ });
+
+ window.addEventListener('resize', handleResize);
+ return () => {
+ handleResize.clear();
+ window.removeEventListener('resize', handleResize);
+ };
}, [direction, inProp]);
React.useEffect(() => {
diff --git a/packages/material-ui/src/Tabs/ScrollbarSize.js b/packages/material-ui/src/Tabs/ScrollbarSize.js
index f0953dfbcb1ab5..432aff9bbb9f06 100644
--- a/packages/material-ui/src/Tabs/ScrollbarSize.js
+++ b/packages/material-ui/src/Tabs/ScrollbarSize.js
@@ -35,7 +35,6 @@ export default function ScrollbarSize(props) {
});
window.addEventListener('resize', handleResize);
-
return () => {
handleResize.clear();
window.removeEventListener('resize', handleResize);
From a07f18029a5532de310f234392c18664817f0dce Mon Sep 17 00:00:00 2001
From: Chris Van Emmerik
Date: Tue, 31 Dec 2019 04:14:23 -0700
Subject: [PATCH 09/15] [Autocomplete] Fix disabled + multiple combination
support (#19041)
---
docs/src/pages/components/autocomplete/FixedTags.js | 2 +-
docs/src/pages/components/autocomplete/FixedTags.tsx | 2 +-
packages/material-ui-lab/src/Autocomplete/Autocomplete.js | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/docs/src/pages/components/autocomplete/FixedTags.js b/docs/src/pages/components/autocomplete/FixedTags.js
index 3039b4801afc52..a76eaaa5a4bcd6 100644
--- a/docs/src/pages/components/autocomplete/FixedTags.js
+++ b/docs/src/pages/components/autocomplete/FixedTags.js
@@ -14,7 +14,7 @@ export default function FixedTags() {
defaultValue={[top100Films[6], top100Films[13]]}
renderTags={(value, getTagProps) =>
value.map((option, index) => (
-
+
))
}
style={{ width: 500 }}
diff --git a/docs/src/pages/components/autocomplete/FixedTags.tsx b/docs/src/pages/components/autocomplete/FixedTags.tsx
index d655dc23f56606..be3aca0eaae2be 100644
--- a/docs/src/pages/components/autocomplete/FixedTags.tsx
+++ b/docs/src/pages/components/autocomplete/FixedTags.tsx
@@ -14,7 +14,7 @@ export default function FixedTags() {
defaultValue={[top100Films[6], top100Films[13]]}
renderTags={(value: FilmOptionType[], getTagProps) =>
value.map((option: FilmOptionType, index: number) => (
-
+
))
}
style={{ width: 500 }}
diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
index 0e8021b84ad31b..e32135663bff74 100644
--- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
+++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
@@ -302,6 +302,7 @@ const Autocomplete = React.forwardRef(function Autocomplete(props, ref) {
className: clsx(classes.tag, {
[classes.tagSizeSmall]: size === 'small',
}),
+ disabled,
...getTagProps(params),
});
From 2a60cfcaeddec8932db9e2b054f0ecada06741b3 Mon Sep 17 00:00:00 2001
From: Matt
Date: Thu, 2 Jan 2020 10:05:58 +0000
Subject: [PATCH 10/15] [docs] Disable in-context translations (#19056)
---
docs/src/modules/components/EditPage.js | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/docs/src/modules/components/EditPage.js b/docs/src/modules/components/EditPage.js
index a1de89b56f56c8..e01f47918a3b59 100644
--- a/docs/src/modules/components/EditPage.js
+++ b/docs/src/modules/components/EditPage.js
@@ -1,9 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
-import { Router, useRouter } from 'next/router';
import Button from '@material-ui/core/Button';
-import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';
const SOURCE_CODE_ROOT_URL = 'https://github.com/mui-org/material-ui/edit/master';
@@ -11,19 +9,19 @@ export default function EditPage(props) {
const { markdownLocation } = props;
const t = useSelector(state => state.options.t);
const userLanguage = useSelector(state => state.options.userLanguage);
- const router = useRouter();
- const { canonical } = pathnameToLanguage(Router._rewriteUrlForNextExport(router.asPath));
+ const LOCALES = { zh: 'zh-CN', pt: 'pt-BR', es: 'es-ES' };
+ const CROWDIN_ROOT_URL = 'https://translate.material-ui.com/project/material-ui-docs/';
+ const crowdInLocale = LOCALES[userLanguage] || userLanguage;
+ const crowdInPath = markdownLocation.substring(0, markdownLocation.lastIndexOf('/'));
return (
-Gold Sponsors are those who have pledged $500/month and more to Material-UI.
+Gold Sponsors are those who have pledged $500/month or more to Material-UI.
### There is more!
diff --git a/docs/src/modules/components/backers.md b/docs/src/modules/components/backers.md
index a0ee6ab6438db4..030063460c0198 100644
--- a/docs/src/modules/components/backers.md
+++ b/docs/src/modules/components/backers.md
@@ -6,7 +6,7 @@ The core of Material-UI is a [crowd-funded](/discover-more/backers/) open-source
*3/3 slots available*
-Diamond Sponsors are those who have pledged $2,000/month and more to Material-UI.
+Diamond Sponsors are those who have pledged $2,000/month or more to Material-UI.
Please contact us at diamond@material-ui.com to subscribe to this tier.
### Gold 🏆
@@ -24,7 +24,7 @@ via [OpenCollective](https://opencollective.com/material-ui)
-Gold Sponsors are those who have pledged $500/month and more to Material-UI.
+Gold Sponsors are those who have pledged $500/month or more to Material-UI.
### There are more!
diff --git a/docs/src/pages/discover-more/backers/backers.md b/docs/src/pages/discover-more/backers/backers.md
index 9c6cef6dd80a46..2b51985d2e4d98 100644
--- a/docs/src/pages/discover-more/backers/backers.md
+++ b/docs/src/pages/discover-more/backers/backers.md
@@ -10,7 +10,7 @@ The core of Material-UI is a crowd-funded open-source project, licensed under th
*3/3 slots available*
-Diamond Sponsors are those who have pledged $2,000/month and more to Material-UI.
+Diamond Sponsors are those who have pledged $2,000/month or more to Material-UI.
Please contact us at diamond@material-ui.com to subscribe to this tier.
### Gold 🏆
@@ -28,7 +28,7 @@ via [OpenCollective](https://opencollective.com/material-ui)
-Gold Sponsors are those who have pledged $500/month and more to Material-UI.
+Gold Sponsors are those who have pledged $500/month or more to Material-UI.
### Silver
From 7f0be941e075100f852b99e7bb2ed6931b5dfc67 Mon Sep 17 00:00:00 2001
From: Matheus Wichman <42154031+m4theushw@users.noreply.github.com>
Date: Fri, 3 Jan 2020 07:07:41 -0300
Subject: [PATCH 13/15] [Autocomplete] Warn when mixing uncontrolled and
controlled (#19060)
---
.../src/useAutocomplete/useAutocomplete.js | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
index e17e10b8a95426..bfa880b3d58ce4 100644
--- a/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
+++ b/packages/material-ui-lab/src/useAutocomplete/useAutocomplete.js
@@ -192,6 +192,25 @@ export default function useAutocomplete(props) {
});
const value = isControlled ? valueProp : valueState;
+ if (process.env.NODE_ENV !== 'production') {
+ // eslint-disable-next-line react-hooks/rules-of-hooks
+ React.useEffect(() => {
+ if (isControlled !== (valueProp !== undefined)) {
+ console.error(
+ [
+ `Material-UI: A component is changing ${
+ isControlled ? 'a ' : 'an un'
+ }controlled useAutocomplete to be ${isControlled ? 'un' : ''}controlled.`,
+ 'Elements should not switch from uncontrolled to controlled (or vice versa).',
+ 'Decide between using a controlled or uncontrolled useAutocomplete ' +
+ 'element for the lifetime of the component.',
+ 'More info: https://fb.me/react-controlled-components',
+ ].join('\n'),
+ );
+ }
+ }, [valueProp, isControlled]);
+ }
+
const { current: isInputValueControlled } = React.useRef(inputValueProp != null);
const [inputValueState, setInputValue] = React.useState('');
const inputValue = isInputValueControlled ? inputValueProp : inputValueState;
From 2f7b71c24e821b40f6ba03e89f71b0ba325cabf3 Mon Sep 17 00:00:00 2001
From: Dimitri Mitropoulos
Date: Fri, 3 Jan 2020 05:11:13 -0500
Subject: [PATCH 14/15] [Alert] Introduce new component (#18702)
---
docs/pages/api/alert-title.js | 7 +
docs/pages/api/alert-title.md | 48 +++
docs/pages/api/alert.js | 7 +
docs/pages/api/alert.md | 83 ++++++
docs/pages/api/snackbar-content.md | 4 +-
docs/pages/api/snackbar.md | 2 +-
docs/pages/api/typography.md | 2 +-
docs/pages/components/alert.js | 14 +
docs/src/pages.js | 1 +
.../pages/components/alert/ActionAlerts.js | 32 ++
.../pages/components/alert/ActionAlerts.tsx | 34 +++
.../src/pages/components/alert/ColorAlerts.js | 24 ++
.../pages/components/alert/ColorAlerts.tsx | 26 ++
.../components/alert/DescriptionAlerts.js | 37 +++
.../components/alert/DescriptionAlerts.tsx | 39 +++
.../pages/components/alert/FilledAlerts.js | 33 +++
.../pages/components/alert/FilledAlerts.tsx | 35 +++
docs/src/pages/components/alert/IconAlerts.js | 32 ++
.../src/pages/components/alert/IconAlerts.tsx | 34 +++
.../pages/components/alert/OutlinedAlerts.js | 33 +++
.../pages/components/alert/OutlinedAlerts.tsx | 35 +++
.../pages/components/alert/SimpleAlerts.js | 25 ++
.../pages/components/alert/SimpleAlerts.tsx | 27 ++
.../components/alert/TransitionAlerts.js | 52 ++++
.../components/alert/TransitionAlerts.tsx | 54 ++++
docs/src/pages/components/alert/alert.md | 78 +++++
.../snackbars/ConsecutiveSnackbars.js | 29 +-
.../snackbars/ConsecutiveSnackbars.tsx | 33 ++-
.../snackbars/CustomizedSnackbars.js | 133 ++-------
.../snackbars/CustomizedSnackbars.tsx | 136 ++-------
.../components/snackbars/LongTextSnackbar.js | 16 +-
.../components/snackbars/LongTextSnackbar.tsx | 16 +-
.../components/snackbars/SimpleSnackbar.js | 32 +-
.../components/snackbars/SimpleSnackbar.tsx | 34 +--
.../pages/discover-more/roadmap/roadmap.md | 2 +-
packages/material-ui-lab/src/Alert/Alert.d.ts | 73 +++++
packages/material-ui-lab/src/Alert/Alert.js | 279 ++++++++++++++++++
.../material-ui-lab/src/Alert/Alert.test.js | 27 ++
packages/material-ui-lab/src/Alert/index.d.ts | 2 +
packages/material-ui-lab/src/Alert/index.js | 1 +
.../src/AlertTitle/AlertTitle.d.ts | 9 +
.../src/AlertTitle/AlertTitle.js | 48 +++
.../src/AlertTitle/AlertTitle.test.js | 26 ++
.../material-ui-lab/src/AlertTitle/index.d.ts | 2 +
.../material-ui-lab/src/AlertTitle/index.js | 1 +
packages/material-ui-lab/src/index.d.ts | 6 +
packages/material-ui-lab/src/index.js | 6 +
.../src/internal/svg-icons/ErrorOutline.js | 10 +
.../src/internal/svg-icons/InfoOutlined.js | 10 +
.../svg-icons/ReportProblemOutlined.js | 10 +
.../src/internal/svg-icons/SuccessOutlined.js | 10 +
packages/material-ui/src/Snackbar/Snackbar.js | 2 +-
.../src/SnackbarContent/SnackbarContent.js | 7 +-
.../material-ui/src/Typography/Typography.js | 2 +-
.../src/internal/svg-icons/Close.js | 10 +
packages/material-ui/src/locale/index.js | 66 ++++-
.../material-ui/src/styles/createPalette.js | 8 +-
57 files changed, 1501 insertions(+), 343 deletions(-)
create mode 100644 docs/pages/api/alert-title.js
create mode 100644 docs/pages/api/alert-title.md
create mode 100644 docs/pages/api/alert.js
create mode 100644 docs/pages/api/alert.md
create mode 100644 docs/pages/components/alert.js
create mode 100644 docs/src/pages/components/alert/ActionAlerts.js
create mode 100644 docs/src/pages/components/alert/ActionAlerts.tsx
create mode 100644 docs/src/pages/components/alert/ColorAlerts.js
create mode 100644 docs/src/pages/components/alert/ColorAlerts.tsx
create mode 100644 docs/src/pages/components/alert/DescriptionAlerts.js
create mode 100644 docs/src/pages/components/alert/DescriptionAlerts.tsx
create mode 100644 docs/src/pages/components/alert/FilledAlerts.js
create mode 100644 docs/src/pages/components/alert/FilledAlerts.tsx
create mode 100644 docs/src/pages/components/alert/IconAlerts.js
create mode 100644 docs/src/pages/components/alert/IconAlerts.tsx
create mode 100644 docs/src/pages/components/alert/OutlinedAlerts.js
create mode 100644 docs/src/pages/components/alert/OutlinedAlerts.tsx
create mode 100644 docs/src/pages/components/alert/SimpleAlerts.js
create mode 100644 docs/src/pages/components/alert/SimpleAlerts.tsx
create mode 100644 docs/src/pages/components/alert/TransitionAlerts.js
create mode 100644 docs/src/pages/components/alert/TransitionAlerts.tsx
create mode 100644 docs/src/pages/components/alert/alert.md
create mode 100644 packages/material-ui-lab/src/Alert/Alert.d.ts
create mode 100644 packages/material-ui-lab/src/Alert/Alert.js
create mode 100644 packages/material-ui-lab/src/Alert/Alert.test.js
create mode 100644 packages/material-ui-lab/src/Alert/index.d.ts
create mode 100644 packages/material-ui-lab/src/Alert/index.js
create mode 100644 packages/material-ui-lab/src/AlertTitle/AlertTitle.d.ts
create mode 100644 packages/material-ui-lab/src/AlertTitle/AlertTitle.js
create mode 100644 packages/material-ui-lab/src/AlertTitle/AlertTitle.test.js
create mode 100644 packages/material-ui-lab/src/AlertTitle/index.d.ts
create mode 100644 packages/material-ui-lab/src/AlertTitle/index.js
create mode 100644 packages/material-ui-lab/src/internal/svg-icons/ErrorOutline.js
create mode 100644 packages/material-ui-lab/src/internal/svg-icons/InfoOutlined.js
create mode 100644 packages/material-ui-lab/src/internal/svg-icons/ReportProblemOutlined.js
create mode 100644 packages/material-ui-lab/src/internal/svg-icons/SuccessOutlined.js
create mode 100644 packages/material-ui/src/internal/svg-icons/Close.js
diff --git a/docs/pages/api/alert-title.js b/docs/pages/api/alert-title.js
new file mode 100644
index 00000000000000..0896cb155e02a6
--- /dev/null
+++ b/docs/pages/api/alert-title.js
@@ -0,0 +1,7 @@
+import React from 'react';
+import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
+import markdown from './alert-title.md';
+
+export default function Page() {
+ return ;
+}
diff --git a/docs/pages/api/alert-title.md b/docs/pages/api/alert-title.md
new file mode 100644
index 00000000000000..7e9fb91014c0e8
--- /dev/null
+++ b/docs/pages/api/alert-title.md
@@ -0,0 +1,48 @@
+---
+filename: /packages/material-ui-lab/src/AlertTitle/AlertTitle.js
+---
+
+
+
+# AlertTitle API
+
+
The API documentation of the AlertTitle React component. Learn more about the props and the CSS customization points.
+
+## Import
+
+```js
+import AlertTitle from '@material-ui/lab/AlertTitle';
+// or
+import { AlertTitle } from '@material-ui/lab';
+```
+
+You can learn more about the difference by [reading this guide](/guides/minimizing-bundle-size/).
+
+
+
+## Props
+
+| Name | Type | Default | Description |
+|:-----|:-----|:--------|:------------|
+| children | node | | The content of the component. |
+| classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
+
+The `ref` is forwarded to the root element.
+
+Any other props supplied will be provided to the root element (native element).
+
+## CSS
+
+- Style sheet name: `MuiAlertTitle`.
+- Style sheet details:
+
+- `root`
+
+You can override the style of the component thanks to one of these customization points:
+
+- With a rule name of the [`classes` object prop](/customization/components/#overriding-styles-with-classes).
+- With a [global class name](/customization/components/#overriding-styles-with-global-class-names).
+- With a theme and an [`overrides` property](/customization/globals/#css).
+
+If that's not sufficient, you can check the [implementation of the component](https://github.com/mui-org/material-ui/blob/master/packages/material-ui-lab/src/AlertTitle/AlertTitle.js) for more detail.
+
diff --git a/docs/pages/api/alert.js b/docs/pages/api/alert.js
new file mode 100644
index 00000000000000..fcdd8f0115652a
--- /dev/null
+++ b/docs/pages/api/alert.js
@@ -0,0 +1,7 @@
+import React from 'react';
+import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
+import markdown from './alert.md';
+
+export default function Page() {
+ return ;
+}
diff --git a/docs/pages/api/alert.md b/docs/pages/api/alert.md
new file mode 100644
index 00000000000000..9e75271b5427ae
--- /dev/null
+++ b/docs/pages/api/alert.md
@@ -0,0 +1,83 @@
+---
+filename: /packages/material-ui-lab/src/Alert/Alert.js
+---
+
+
+
+# Alert API
+
+
The API documentation of the Alert React component. Learn more about the props and the CSS customization points.
+
+## Import
+
+```js
+import Alert from '@material-ui/lab/Alert';
+// or
+import { Alert } from '@material-ui/lab';
+```
+
+You can learn more about the difference by [reading this guide](/guides/minimizing-bundle-size/).
+
+
+
+## Props
+
+| Name | Type | Default | Description |
+|:-----|:-----|:--------|:------------|
+| action | node | | The action to display. It renders after the message, at the end of the alert. |
+| children | node | | The content of the component. |
+| classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
+| closeText | string | 'Close' | Override the default label for the *close popup* icon button. For localization purposes, you can use the provided [translations](/guides/localization/). |
+| color | 'error' | 'info' | 'success' | 'warning' | | The main color for the alert. Unless provided, the value is taken from the `severity` prop. |
+| icon | node | | Override the icon displayed before the children. Unless provided, the icon is mapped to the value of the `severity` prop. |
+| iconMapping | { error?: node, info?: node, success?: node, warning?: node } | { success: <SuccessOutlinedIcon fontSize="inherit" />, warning: <ReportProblemOutlinedIcon fontSize="inherit" />, error: <ErrorOutlineIcon fontSize="inherit" />, info: <InfoOutlinedIcon fontSize="inherit" />,} | The component maps the `severity` prop to a range of different icons, for instance success to ``. If you wish to change this mapping, you can provide your own. Alternatively, you can use the `icon` prop to override the icon displayed. |
+| onClose | func | | Callback fired when the component requests to be closed. When provided and no `action` prop is set, a close icon button is displayed that triggers the callback when clicked.
**Signature:** `function(event: object) => void` *event:* The event source of the callback. |
+| role | string | 'alert' | The ARIA role attribute of the element. |
+| severity | 'error' | 'info' | 'success' | 'warning' | 'success' | The severity of the alert. This defines the color and icon used. |
+| variant | 'filled' | 'outlined' | 'standard' | 'standard' | The variant to use. |
+
+The `ref` is forwarded to the root element.
+
+Any other props supplied will be provided to the root element ([Paper](/api/paper/)).
+
+## CSS
+
+- Style sheet name: `MuiAlert`.
+- Style sheet details:
+
+| Rule name | Global class | Description |
+|:-----|:-------------|:------------|
+| root | .MuiAlert-root | Styles applied to the root element.
+| standardSuccess | .MuiAlert-standardSuccess | Styles applied to the root element if `variant="standard"` and `color="success"`.
+| standardInfo | .MuiAlert-standardInfo | Styles applied to the root element if `variant="standard"` and `color="info"`.
+| standardWarning | .MuiAlert-standardWarning | Styles applied to the root element if `variant="standard"` and `color="warning"`.
+| standardError | .MuiAlert-standardError | Styles applied to the root element if `variant="standard"` and `color="error"`.
+| outlinedSuccess | .MuiAlert-outlinedSuccess | Styles applied to the root element if `variant="outlined"` and `color="success"`.
+| outlinedInfo | .MuiAlert-outlinedInfo | Styles applied to the root element if `variant="outlined"` and `color="info"`.
+| outlinedWarning | .MuiAlert-outlinedWarning | Styles applied to the root element if `variant="outlined"` and `color="warning"`.
+| outlinedError | .MuiAlert-outlinedError | Styles applied to the root element if `variant="outlined"` and `color="error"`.
+| filledSuccess | .MuiAlert-filledSuccess | Styles applied to the root element if `variant="filled"` and `color="success"`.
+| filledInfo | .MuiAlert-filledInfo | Styles applied to the root element if `variant="filled"` and `color="info"`.
+| filledWarning | .MuiAlert-filledWarning | Styles applied to the root element if `variant="filled"` and `color="warning"`.
+| filledError | .MuiAlert-filledError | Styles applied to the root element if `variant="filled"` and `color="error"`.
+| icon | .MuiAlert-icon | Styles applied to the icon wrapper element.
+| message | .MuiAlert-message | Styles applied to the message wrapper element.
+| action | .MuiAlert-action | Styles applied to the action wrapper element if `action` is provided.
+
+You can override the style of the component thanks to one of these customization points:
+
+- With a rule name of the [`classes` object prop](/customization/components/#overriding-styles-with-classes).
+- With a [global class name](/customization/components/#overriding-styles-with-global-class-names).
+- With a theme and an [`overrides` property](/customization/globals/#css).
+
+If that's not sufficient, you can check the [implementation of the component](https://github.com/mui-org/material-ui/blob/master/packages/material-ui-lab/src/Alert/Alert.js) for more detail.
+
+## Inheritance
+
+The props of the [Paper](/api/paper/) component are also available.
+You can take advantage of this behavior to [target nested components](/guides/api/#spread).
+
+## Demos
+
+- [Alert](/components/alert/)
+
diff --git a/docs/pages/api/snackbar-content.md b/docs/pages/api/snackbar-content.md
index e3d55255564999..86b918e2469218 100644
--- a/docs/pages/api/snackbar-content.md
+++ b/docs/pages/api/snackbar-content.md
@@ -24,10 +24,10 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
-| action | node | | The action to display. |
+| action | node | | The action to display. It renders after the message, at the end of the snackbar. |
| classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| message | node | | The message to display. |
-| role | 'alert' | 'alertdialog' | 'alert' | The role of the SnackbarContent. If the Snackbar requires focus to be closed, the `alertdialog` role should be used instead. |
+| role | string | 'alert' | The ARIA role attribute of the element. |
The `ref` is forwarded to the root element.
diff --git a/docs/pages/api/snackbar.md b/docs/pages/api/snackbar.md
index 4384127502c3da..095602ee0399e6 100644
--- a/docs/pages/api/snackbar.md
+++ b/docs/pages/api/snackbar.md
@@ -24,7 +24,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| Name | Type | Default | Description |
|:-----|:-----|:--------|:------------|
-| action | node | | The action to display. |
+| action | node | | The action to display. It renders after the message, at the end of the snackbar. |
| anchorOrigin | { horizontal: 'left' | 'center' | 'right', vertical: 'top' | 'bottom' } | { vertical: 'bottom', horizontal: 'center' } | The anchor of the `Snackbar`. |
| autoHideDuration | number | | The number of milliseconds to wait before automatically calling the `onClose` function. `onClose` should then set the state of the `open` prop to hide the Snackbar. This behavior is disabled by default with the `null` value. |
| children | element | | Replace the `SnackbarContent` component. |
diff --git a/docs/pages/api/typography.md b/docs/pages/api/typography.md
index 9bb6bfd5bab877..62e430719bcfd3 100644
--- a/docs/pages/api/typography.md
+++ b/docs/pages/api/typography.md
@@ -34,7 +34,7 @@ You can learn more about the difference by [reading this guide](/guides/minimizi
| noWrap | bool | false | If `true`, the text will not wrap, but instead will truncate with a text overflow ellipsis. Note that text overflow can only happen with block or inline-block level elements (the element needs to have a width in order to overflow). |
| paragraph | bool | false | If `true`, the text will have a bottom margin. |
| variant | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subtitle1' | 'subtitle2' | 'body1' | 'body2' | 'caption' | 'button' | 'overline' | 'srOnly' | 'inherit' | 'body1' | Applies the theme typography styles. |
-| variantMapping | object | { h1: 'h1', h2: 'h2', h3: 'h3', h4: 'h4', h5: 'h5', h6: 'h6', subtitle1: 'h6', subtitle2: 'h6', body1: 'p', body2: 'p',} | We are empirically mapping the variant prop to a range of different DOM element types. For instance, subtitle1 to `
`. If you wish to change that mapping, you can provide your own. Alternatively, you can use the `component` prop. |
+| variantMapping | object | { h1: 'h1', h2: 'h2', h3: 'h3', h4: 'h4', h5: 'h5', h6: 'h6', subtitle1: 'h6', subtitle2: 'h6', body1: 'p', body2: 'p',} | The component maps the variant prop to a range of different DOM element types. For instance, subtitle1 to `
`. If you wish to change that mapping, you can provide your own. Alternatively, you can use the `component` prop. |
The `ref` is forwarded to the root element.
diff --git a/docs/pages/components/alert.js b/docs/pages/components/alert.js
new file mode 100644
index 00000000000000..1c1d3edeb687cf
--- /dev/null
+++ b/docs/pages/components/alert.js
@@ -0,0 +1,14 @@
+import React from 'react';
+import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
+
+const req = require.context('docs/src/pages/components/alert', false, /\.(md|js|tsx)$/);
+const reqSource = require.context(
+ '!raw-loader!../../src/pages/components/alert',
+ false,
+ /\.(js|tsx)$/,
+);
+const reqPrefix = 'pages/components/alert';
+
+export default function Page() {
+ return ;
+}
diff --git a/docs/src/pages.js b/docs/src/pages.js
index 6fc2eb0c5fe8fd..1ffc153fd34999 100644
--- a/docs/src/pages.js
+++ b/docs/src/pages.js
@@ -114,6 +114,7 @@ const pages = [
subheader: '/components/lab',
children: [
{ pathname: '/components/about-the-lab' },
+ { pathname: '/components/alert' },
{ pathname: '/components/autocomplete' },
{ pathname: '/components/rating' },
{ pathname: '/components/skeleton' },
diff --git a/docs/src/pages/components/alert/ActionAlerts.js b/docs/src/pages/components/alert/ActionAlerts.js
new file mode 100644
index 00000000000000..71a615d6ba0fb7
--- /dev/null
+++ b/docs/src/pages/components/alert/ActionAlerts.js
@@ -0,0 +1,32 @@
+import React from 'react';
+import { makeStyles } from '@material-ui/core/styles';
+import { Alert } from '@material-ui/lab';
+import Button from '@material-ui/core/Button';
+
+const useStyles = makeStyles(theme => ({
+ root: {
+ width: '100%',
+ '& > * + *': {
+ marginTop: theme.spacing(2),
+ },
+ },
+}));
+
+export default function ActionAlerts() {
+ const classes = useStyles();
+
+ return (
+
+ {}}>This is a success alert — check it out!
+
+ UNDO
+
+ }
+ >
+ This is a success alert — check it out!
+
+
+
+ Error
+ This is an error alert — check it out!
+
+
+ Warning
+ This is a warning alert — check it out!
+
+
+ Info
+ This is an info alert — check it out!
+
+
+ Success
+ This is a success alert — check it out!
+
+
+
+ Error
+ This is an error alert — check it out!
+
+
+ Warning
+ This is a warning alert — check it out!
+
+
+ Info
+ This is an info alert — check it out!
+
+
+ Success
+ This is a success alert — check it out!
+
+
+
+ This is an error alert — check it out!
+
+
+ This is a warning alert — check it out!
+
+
+ This is an info alert — check it out!
+
+
+ This is a success alert — check it out!
+
+
+
+ This is an error alert — check it out!
+
+
+ This is a warning alert — check it out!
+
+
+ This is an info alert — check it out!
+
+
+ This is a success alert — check it out!
+
+
+ } severity="success">
+ This is a success alert — check it out!
+
+ }}>
+ This is a success alert — check it out!
+
+
+ This is a success alert — check it out!
+
+
+ } severity="success">
+ This is a success alert — check it out!
+
+ }}>
+ This is a success alert — check it out!
+
+
+ This is a success alert — check it out!
+
+
+
+ This is an error alert — check it out!
+
+
+ This is a warning alert — check it out!
+
+
+ This is an info alert — check it out!
+
+
+ This is a success alert — check it out!
+
+
+
+ This is an error alert — check it out!
+
+
+ This is a warning alert — check it out!
+
+
+ This is an info alert — check it out!
+
+
+ This is a success alert — check it out!
+
+
+ This is an error alert — check it out!
+ This is a warning alert — check it out!
+ This is an info alert — check it out!
+ This is a success alert — check it out!
+
+ This is an error alert — check it out!
+ This is a warning alert — check it out!
+ This is an info alert — check it out!
+ This is a success alert — check it out!
+
An alert displays a short, important message in a way that attracts the user's attention without interrupting the user's task.
+
+## Simple alerts
+
+The alert offers four severity levels that set a distinctive icon and color.
+
+{{"demo": "pages/components/alert/SimpleAlerts.js"}}
+
+## Description
+
+You can use the `AlertTitle` component to display a formatted title above the content.
+
+{{"demo": "pages/components/alert/DescriptionAlerts.js"}}
+
+## Actions
+
+An alert can have an action, such as a close or undo button.
+It is rendered after the message, at the end of the alert.
+
+If an `onClose` callback is provided and no `action` prop is set, a close icon is displayed. The `action` prop can be used to provide an alternative action, for example using a Button or IconButton.
+
+{{"demo": "pages/components/alert/ActionAlerts.js"}}
+
+### Transition
+
+You can use a [transition component](/components/transitions/) such as `Collapse` to transition the appearance of the alert.
+
+{{"demo": "pages/components/alert/TransitionAlerts.js"}}
+
+## Icons
+
+The `icon` prop allows you to add an icon to the beginning of the alert component.
+This will override the default icon for the specified severity.
+
+You can change the default severity to icon mapping with the `iconMapping` prop. This can be defined globally using [theme customization](/customization/globals/#default-props).
+
+Setting the icon prop to false will remove the icon altogether.
+
+{{"demo": "pages/components/alert/IconAlerts.js"}}
+
+## Variants
+
+Two additional variants are available – outlined, and filled:
+
+### Outlined
+
+{{"demo": "pages/components/alert/OutlinedAlerts.js"}}
+
+### Filled
+
+{{"demo": "pages/components/alert/FilledAlerts.js"}}
+
+## Toast
+
+You can use the Snackbar to [display a toast](/components/snackbars/#customized-snackbars) with the Alert.
+
+## Color
+
+The `color` prop will override the default color for the specified severity.
+
+{{"demo": "pages/components/alert/ColorAlerts.js"}}
+
+## Accessibility
+
+(WAI-ARIA: https://www.w3.org/TR/wai-aria-practices/#alert)
+
+When the component is dynamically displayed, the content is automatically announced by most screen readers. At this time, screen readers do not inform users of alerts that are present when the page loads.
+
+Using color to add meaning only provides a visual indication, which will not be conveyed to users of assistive technologies such as screen readers. Ensure that information denoted by the color is either obvious from the content itself (for example the visible text), or is included through alternative means, such as additional hidden text.
+
+Actions must have a tab index of 0 so that they can be reached by keyboard-only users.
diff --git a/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js b/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js
index eee3ff37af5a6d..637aa8e099a932 100644
--- a/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js
+++ b/docs/src/pages/components/snackbars/ConsecutiveSnackbars.js
@@ -68,20 +68,21 @@ export default function ConsecutiveSnackbars() {
'aria-describedby': 'message-id',
}}
message={{messageInfo ? messageInfo.message : undefined}}
- action={[
- ,
-
-
- ,
- ]}
+ action={
+
+
+
+
+
+
+ }
/>
);
diff --git a/docs/src/pages/components/snackbars/ConsecutiveSnackbars.tsx b/docs/src/pages/components/snackbars/ConsecutiveSnackbars.tsx
index 97cf86b17577e8..383f3e98a9cba5 100644
--- a/docs/src/pages/components/snackbars/ConsecutiveSnackbars.tsx
+++ b/docs/src/pages/components/snackbars/ConsecutiveSnackbars.tsx
@@ -1,4 +1,4 @@
-import React, { SyntheticEvent } from 'react';
+import React from 'react';
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Snackbar from '@material-ui/core/Snackbar';
@@ -50,7 +50,7 @@ export default function ConsecutiveSnackbars() {
}
};
- const handleClose = (event: SyntheticEvent | MouseEvent, reason?: string) => {
+ const handleClose = (event: React.SyntheticEvent | MouseEvent, reason?: string) => {
if (reason === 'clickaway') {
return;
}
@@ -80,20 +80,21 @@ export default function ConsecutiveSnackbars() {
'aria-describedby': 'message-id',
}}
message={{messageInfo ? messageInfo.message : undefined}}
- action={[
- ,
-
-
- ,
- ]}
+ action={
+
+
+
+
+
+
+ }
/>
);
diff --git a/docs/src/pages/components/snackbars/CustomizedSnackbars.js b/docs/src/pages/components/snackbars/CustomizedSnackbars.js
index 59b663c9f2f6bc..72e318c8110dec 100644
--- a/docs/src/pages/components/snackbars/CustomizedSnackbars.js
+++ b/docs/src/pages/components/snackbars/CustomizedSnackbars.js
@@ -1,91 +1,24 @@
import React from 'react';
-import PropTypes from 'prop-types';
-import clsx from 'clsx';
import Button from '@material-ui/core/Button';
-import CheckCircleIcon from '@material-ui/icons/CheckCircle';
-import ErrorIcon from '@material-ui/icons/Error';
-import InfoIcon from '@material-ui/icons/Info';
-import CloseIcon from '@material-ui/icons/Close';
-import { amber, green } from '@material-ui/core/colors';
-import IconButton from '@material-ui/core/IconButton';
import Snackbar from '@material-ui/core/Snackbar';
-import SnackbarContent from '@material-ui/core/SnackbarContent';
-import WarningIcon from '@material-ui/icons/Warning';
+import MuiAlert from '@material-ui/lab/Alert';
import { makeStyles } from '@material-ui/core/styles';
-const variantIcon = {
- success: CheckCircleIcon,
- warning: WarningIcon,
- error: ErrorIcon,
- info: InfoIcon,
-};
-
-const useStyles1 = makeStyles(theme => ({
- success: {
- backgroundColor: green[600],
- },
- error: {
- backgroundColor: theme.palette.error.dark,
- },
- info: {
- backgroundColor: theme.palette.primary.main,
- },
- warning: {
- backgroundColor: amber[700],
- },
- icon: {
- fontSize: 20,
- },
- iconVariant: {
- opacity: 0.9,
- marginRight: theme.spacing(1),
- },
- message: {
- display: 'flex',
- alignItems: 'center',
- },
-}));
-
-function MySnackbarContentWrapper(props) {
- const classes = useStyles1();
- const { className, message, onClose, variant, ...other } = props;
- const Icon = variantIcon[variant];
-
- return (
-
-
- {message}
-
- }
- action={[
-
-
- ,
- ]}
- {...other}
- />
- );
+function Alert(props) {
+ return ;
}
-MySnackbarContentWrapper.propTypes = {
- className: PropTypes.string,
- message: PropTypes.string,
- onClose: PropTypes.func,
- variant: PropTypes.oneOf(['error', 'info', 'success', 'warning']).isRequired,
-};
-
-const useStyles2 = makeStyles(theme => ({
- margin: {
- margin: theme.spacing(1),
+const useStyles = makeStyles(theme => ({
+ root: {
+ width: '100%',
+ '& > * + *': {
+ marginTop: theme.spacing(2),
+ },
},
}));
export default function CustomizedSnackbars() {
- const classes = useStyles2();
+ const classes = useStyles();
const [open, setOpen] = React.useState(false);
const handleClick = () => {
@@ -101,45 +34,19 @@ export default function CustomizedSnackbars() {
};
return (
-