Skip to content
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

feat(menu-surface): upgrade to mdc web v1 #751

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
84043a3
fix(tab): Set initial tabIndex state to -1 (#690) (#691)
Feb 23, 2019
66d36b6
docs(text-field): fix duplicated "from" in example (#687)
eligao Feb 23, 2019
84b6395
feat(top-app-bar): add children components for composition
mgr34 Feb 27, 2019
5174677
fix(chips): update classnames version to 2.2.6 (#702)
kittle31 Mar 1, 2019
f7f3d72
fix(ripple): Use mdc-dom.matches instead of `getMatchesProperty()` (#…
julien1619 Mar 1, 2019
30e2caf
docs(layout-grid): typo regarding the number of rows in mobile and ta…
vzaidman Mar 2, 2019
33b29af
docs(dialog): Fix import in Dialog readme (#712)
lucasecdb Mar 6, 2019
152f37d
fix(snackbar): Add missing mdcw snackbar dependency (#714)
lucasecdb Mar 6, 2019
1827385
docs(snackbar): Incorrect snackbar import (#715)
aluminick Mar 6, 2019
9665f7f
fix(dialog): should extend HTMLElement (#723)
mgr34 Mar 8, 2019
8f78660
fix(select): prop value should be string only (#725)
mgr34 Mar 8, 2019
30d7c7e
fix(select): pass state.value to NativeControl as prop.value (#726)
mgr34 Mar 8, 2019
20acb19
feat(line-ripple): mdc-web typescript support (#716)
gugu Mar 8, 2019
ce10503
feat(tab): implement setFocusOnActivate (#722)
Mar 12, 2019
894d591
fix(text-field): make props optional (#735)
Mar 12, 2019
8c04520
docs(top-app-bar): Fix typos and closing tag (#739)
lucasecdb Mar 12, 2019
d54ae23
fix(infrastructure): remove duplicate tsconfig properties (#736)
Mar 13, 2019
280166b
fix: make require props optional (#737)
Mar 13, 2019
743d00c
feat(ripple) mdc-web typescript conversion (#711)
gugu Mar 14, 2019
e0cac1b
fix(tab-indicator): upgrade mdc-web to 1.0.0 (#742)
gugu Mar 14, 2019
efbd849
fix(tab-scroller): upgrade mdc-web to 1.0.0 (#743)
gugu Mar 14, 2019
df2790f
feat(menu-surface): upgrade to mdc web v1
Mar 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
627 changes: 590 additions & 37 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"test:unit": "npm run clean && cross-env NODE_ENV=test karma start karma.local.js --single-run",
"test:unit-ci": "karma start karma.ci.js --single-run",
"test:image-diff": "MDC_COMMIT_HASH=$(git rev-parse --short HEAD) MDC_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) mocha --require ts-node/register --require babel-core/register --ui tdd --timeout 30000 test/screenshot/diff-suite.tsx",
"test:screenshots": "docker run -it --rm --cap-add=SYS_ADMIN -e MDC_GCLOUD_SERVICE_ACCOUNT_KEY=\"${MDC_GCLOUD_SERVICE_ACCOUNT_KEY}\" mdcreact/screenshots /bin/sh -c 'git checkout .; git checkout master; git pull; npm i; /home/pptruser/material-components-web-react/test/screenshot/start.sh; sleep 35s; npm run test:image-diff'",
"test:screenshots": "docker run -it --rm --cap-add=SYS_ADMIN -e MDC_GCLOUD_SERVICE_ACCOUNT_KEY=\"${MDC_GCLOUD_SERVICE_ACCOUNT_KEY}\" mdcreact/screenshots /bin/sh -c 'git checkout .; git checkout master; git pull; npm i; /home/pptruser/material-components-web-react/test/screenshot/start.sh; sleep 40s; npm run test:image-diff'",
"upload:screenshots": "node ./test/screenshot/upload-screenshots.js"
},
"config": {
Expand Down Expand Up @@ -60,6 +60,7 @@
},
"devDependencies": {
"@google-cloud/storage": "^1.6.0",
"@material/base": "^1.0.0",
"@material/button": "^0.43.0",
"@material/card": "^0.41.0",
"@material/checkbox": "^0.41.0",
Expand All @@ -71,20 +72,20 @@
"@material/floating-label": "^0.41.0",
"@material/icon-button": "^0.41.0",
"@material/layout-grid": "^0.41.0",
"@material/line-ripple": "^0.41.0",
"@material/line-ripple": "^1.0.0",
"@material/linear-progress": "^0.41.0",
"@material/list": "^0.41.0",
"@material/menu-surface": "^0.41.0",
"@material/menu-surface": "^1.0.1",
"@material/notched-outline": "^0.41.0",
"@material/radio": "^0.41.0",
"@material/ripple": "^0.41.0",
"@material/ripple": "^1.0.0",
"@material/select": "^0.40.1",
"@material/snackbar": "^0.43.0",
"@material/switch": "^0.41.0",
"@material/tab": "^0.41.0",
"@material/tab-bar": "^0.41.0",
"@material/tab-indicator": "^0.41.0",
"@material/tab-scroller": "^0.41.0",
"@material/tab-indicator": "^1.0.0",
"@material/tab-scroller": "^1.0.0",
"@material/textfield": "^0.41.0",
"@material/top-app-bar": "^0.41.0",
"@material/typography": "^0.41.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/NativeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import * as React from 'react';
export interface NativeControlProps extends React.HTMLProps<HTMLInputElement>{
checked: boolean;
disabled: boolean;
id: string;
id?: string;
rippleActivatorRef: React.RefObject<HTMLInputElement>;
onChange: (evt: React.ChangeEvent<HTMLInputElement>) => void;
};
Expand Down
22 changes: 11 additions & 11 deletions packages/chips/ChipSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ import {ChipProps} from './Chip'; // eslint-disable-line no-unused-vars
type ChipType = React.ReactElement<ChipProps>;

export interface ChipSetProps {
className: string;
selectedChipIds: string[];
handleSelect: (selectedChipIds: string[]) => void;
updateChips: (chips: Partial<ChipProps>[]) => void;
choice: boolean;
filter: boolean;
input: boolean;
className?: string;
selectedChipIds?: string[];
handleSelect?: (selectedChipIds: string[]) => void;
updateChips?: (chips: Partial<ChipProps>[]) => void;
choice?: boolean;
filter?: boolean;
input?: boolean;
children: ChipType | ChipType[];
};

Expand All @@ -50,7 +50,7 @@ export default class ChipSet extends React.Component<ChipSetProps, ChipSetState>
constructor(props: ChipSetProps) {
super(props);
this.state = {
selectedChipIds: props.selectedChipIds,
selectedChipIds: props.selectedChipIds!,
foundation: null,
hasInitialized: false,
};
Expand Down Expand Up @@ -78,7 +78,7 @@ export default class ChipSet extends React.Component<ChipSetProps, ChipSetState>
this.initChipSelection();
}
if (selectedChipIds !== prevProps.selectedChipIds) {
this.setState({selectedChipIds});
this.setState({selectedChipIds: selectedChipIds!});
}
}

Expand All @@ -101,7 +101,7 @@ export default class ChipSet extends React.Component<ChipSetProps, ChipSetState>
setSelected: () => {
const selectedChipIds = this.state.foundation.getSelectedChipIds().slice();
this.setState({selectedChipIds}, () => {
this.props.handleSelect(selectedChipIds);
this.props.handleSelect!(selectedChipIds);
});
},
removeChip: this.removeChip,
Expand Down Expand Up @@ -143,7 +143,7 @@ export default class ChipSet extends React.Component<ChipSetProps, ChipSetState>
}
}
const chipsArray = chips.length ? chips.map((chip) => chip.props) : [];
updateChips(chipsArray);
updateChips!(chipsArray);
};

setCheckmarkWidth = (checkmark: ChipCheckmark | null) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/chips/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dependencies": {
"@material/chips": "^0.41.0",
"@material/react-ripple": "^0.10.0",
"classnames": "^2.2.5",
"classnames": "^2.2.6",
"react": "^16.4.2"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/DialogContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface DialogContentProps<T> extends React.HTMLProps<T> {
id?: string,
};

const DialogContent: <T extends {} = HTMLDivElement>(props: DialogContentProps<T>) =>
const DialogContent: <T extends HTMLElement = HTMLDivElement>(props: DialogContentProps<T>) =>
React.ReactElement<T> = ({
/* eslint-disable react/prop-types */
className = '',
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/DialogFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface DialogFooterProps<T> extends React.HTMLProps<T> {
};


const DialogFooter: <T extends {} = HTMLElement>(props: DialogFooterProps<T>) =>
const DialogFooter: <T extends HTMLElement = HTMLElement>(props: DialogFooterProps<T>) =>
React.ReactElement<T> = ({
/* eslint-disable react/prop-types */
className = '',
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/DialogTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface DialogTitleProps<T> extends React.HTMLProps<T> {
id?: string,
};

const DialogTitle: <T extends {} = HTMLHeadingElement>(props: DialogTitleProps<T>) =>
const DialogTitle: <T extends HTMLElement = HTMLHeadingElement>(props: DialogTitleProps<T>) =>
React.ReactElement<T> = ({
/* eslint-disable react/prop-types */
className = '',
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ The Simple Dialog contains a list of potential actions. It does not contain butt
```js
import React, {Component} from 'react';
import Dialog, {DialogTitle, DialogContent} from '@material/react-dialog';
import List, {ListItem, ListItemGraphic, ListItemText} from '@material/react-dialog';
import List, {ListItem, ListItemGraphic, ListItemText} from '@material/react-list';
import MaterialIcon from '@material/react-material-icon';

class Simple extends Component {
Expand Down
2 changes: 1 addition & 1 deletion packages/dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function isDialogContent(element: any): element is DialogContent<any> {
return element.type === DialogContent;
}

class Dialog<T extends {} = HTMLElement> extends React.Component<
class Dialog<T extends HTMLElement = HTMLElement> extends React.Component<
DialogProps<T>,
DialogState
> {
Expand Down
20 changes: 9 additions & 11 deletions packages/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ import {FocusTrap} from 'focus-trap';
const {cssClasses: listCssClasses} = MDCListFoundation;

export interface DrawerProps extends React.HTMLProps<HTMLElement>{
className: string;
open: boolean;
onOpen: () => void;
onClose: () => void;
onTransitionEnd: React.TransitionEventHandler<HTMLElement>;
onKeyDown: React.KeyboardEventHandler<HTMLElement>;
tag: string;
dismissible: boolean;
modal: boolean;
className?: string;
open?: boolean;
onOpen?: () => void;
onClose?: () => void;
tag?: string;
dismissible?: boolean;
modal?: boolean;
};

interface DrawerState {
Expand Down Expand Up @@ -184,13 +182,13 @@ class Drawer extends React.Component<DrawerProps, DrawerState> {
}

handleKeyDown = (evt: React.KeyboardEvent<HTMLElement>) => {
this.props.onKeyDown(evt);
this.props.onKeyDown!(evt);
if (!this.foundation) return;
this.foundation.handleKeydown(evt);
};

handleTransitionEnd = (evt: React.TransitionEvent<HTMLElement>) => {
this.props.onTransitionEnd(evt);
this.props.onTransitionEnd!(evt);
if (!this.foundation) return;
this.foundation.handleTransitionEnd(evt);
};
Expand Down
4 changes: 2 additions & 2 deletions packages/layout-grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ className | String | Classes to be applied to the root element
columns | Number (1-12) | The width of the cell on all devices
desktopColumns | Number (1-12) | The width of the cell on desktop
order | Number (1-12) | The order that the cell is displayed in
phoneColumns | Number (1-8) | The width of the cell on phones
tabletColumns | Number (1-4) | The width of the cell on tablets
phoneColumns | Number (1-4) | The width of the cell on phones
tabletColumns | Number (1-8) | The width of the cell on tablets
tag | String | The tag type to render (default `'div'`)

## Sass Mixins
Expand Down
14 changes: 8 additions & 6 deletions packages/line-ripple/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
// THE SOFTWARE.
import * as React from 'react';
import * as classnames from 'classnames';
// @ts-ignore no mdc .d.ts
import {MDCLineRippleFoundation} from '@material/line-ripple/dist/mdc.lineRipple';
import {MDCLineRippleFoundation} from '@material/line-ripple/foundation';
import {MDCLineRippleAdapter} from '@material/line-ripple/adapter';

export interface LineRippleProps extends React.HTMLProps<HTMLDivElement> {
className?: string;
Expand All @@ -46,7 +46,7 @@ export default class LineRipple extends React.Component<
rippleCenter: 0,
};

foundation_?: MDCLineRippleFoundation;
foundation_!: MDCLineRippleFoundation;

state: LineRippleState = {
classList: new Set(),
Expand Down Expand Up @@ -85,7 +85,7 @@ export default class LineRipple extends React.Component<
this.foundation_.destroy();
}

get adapter() {
get adapter(): MDCLineRippleAdapter {
return {
addClass: (className: string) =>
this.setState({classList: this.state.classList.add(className)}),
Expand All @@ -96,6 +96,8 @@ export default class LineRipple extends React.Component<
},
hasClass: (className: string) => this.state.classList.has(className),
setStyle: this.setStyle,
registerEventHandler: () => null,
deregisterEventHandler: () => null,
};
}

Expand All @@ -105,7 +107,7 @@ export default class LineRipple extends React.Component<
return classnames('mdc-line-ripple', Array.from(classList), className);
}

setStyle = (varName: string, value: React.CSSProperties) => {
setStyle = (varName: string, value: string) => {
const styleName = varName.replace(/-(\w)/g, (_, v) => v.toUpperCase());
const updatedStyle: any = Object.assign({}, this.state.style);
updatedStyle[styleName] = value;
Expand All @@ -119,7 +121,7 @@ export default class LineRipple extends React.Component<
return Object.assign({}, style, wrappedStyle);
};

onTransitionEnd = (evt: React.TransitionEvent) => this.foundation_.handleTransitionEnd(evt);
onTransitionEnd = (evt: React.TransitionEvent<Element>) => this.foundation_.handleTransitionEnd(evt.nativeEvent);

render() {
const {
Expand Down
2 changes: 1 addition & 1 deletion packages/line-ripple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"url": "https://github.com/material-components/material-components-web-react.git"
},
"dependencies": {
"@material/line-ripple": "^0.41.0",
"@material/line-ripple": "^1.0.0",
"classnames": "^2.2.5",
"react": "^16.4.2"
},
Expand Down
16 changes: 8 additions & 8 deletions packages/linear-progress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ import * as React from 'react';
import {MDCLinearProgressFoundation} from '@material/linear-progress/dist/mdc.linearProgress';

export interface LinearProgressProps<T> extends React.HTMLProps<T> {
buffer: number;
bufferingDots: boolean;
className: string;
closed: boolean;
indeterminate: boolean;
progress: number;
reversed: boolean;
tag: string;
buffer?: number;
bufferingDots?: boolean;
className?: string;
closed?: boolean;
indeterminate?: boolean;
progress?: number;
reversed?: boolean;
tag?: string;
};

interface LinearProgressState {
Expand Down
4 changes: 0 additions & 4 deletions packages/list/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export interface ListItemProps<T> extends React.HTMLProps<T> {
shouldFocus: boolean;
shouldFollowHref: boolean;
shouldToggleCheckbox: boolean;
onKeyDown: React.KeyboardEventHandler<T>;
onClick: React.MouseEventHandler<T>;
onFocus: React.FocusEventHandler<T>;
onBlur: React.FocusEventHandler<T>;
tag: string;
children: React.ReactNode;
};
Expand Down
32 changes: 16 additions & 16 deletions packages/list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ const VERTICAL = 'vertical';
const CHECKBOX_TYPE = 'checkbox';

export interface ListProps<T> extends React.HTMLProps<HTMLElement> {
className: string;
nonInteractive: boolean;
dense: boolean;
avatarList: boolean;
twoLine: boolean;
singleSelection: boolean;
selectedIndex: number;
handleSelect: (selectedIndex: number) => void;
wrapFocus: boolean;
tag: string;
className?: string;
nonInteractive?: boolean;
dense?: boolean;
avatarList?: boolean;
twoLine?: boolean;
singleSelection?: boolean;
selectedIndex?: number;
handleSelect?: (selectedIndex: number) => void;
wrapFocus?: boolean;
tag?: string;
children: ListItem<T> | ListItem<T>[] | React.ReactNode;
};

Expand Down Expand Up @@ -240,7 +240,7 @@ export default class List<T extends HTMLElement = HTMLElement> extends React.Com
e.key === 'Space' ||
e.keyCode === 32)
) {
this.props.handleSelect(index);
this.props.handleSelect!(index);
}
};

Expand All @@ -251,7 +251,7 @@ export default class List<T extends HTMLElement = HTMLElement> extends React.Com
// Work around until MDC Web issue is resolved:
// https://github.com/material-components/material-components-web/issues/4053
if (index >= 0) {
this.props.handleSelect(index);
this.props.handleSelect!(index);
}
};

Expand Down Expand Up @@ -320,19 +320,19 @@ export default class List<T extends HTMLElement = HTMLElement> extends React.Com
const props = {
...otherProps,
onKeyDown: (e: React.KeyboardEvent<T>) => {
onKeyDown(e);
onKeyDown!(e);
this.handleKeyDown(e, index);
},
onClick: (e: React.MouseEvent<T>) => {
onClick(e);
onClick!(e);
this.handleClick(e, index);
},
onFocus: (e: React.FocusEvent<T>) => {
onFocus(e);
onFocus!(e);
this.handleFocus(e, index);
},
onBlur: (e: React.FocusEvent<T>) => {
onBlur(e);
onBlur!(e);
this.handleBlur(e, index);
},
shouldFocus: focusListItemAtIndex === index,
Expand Down
Loading