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

feat: upgrade dependencies to MDC Web v1.x.x #828

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0b674f5
feat(line-ripple): mdc-web typescript support (#716)
gugu Mar 8, 2019
f966714
feat(ripple) mdc-web typescript conversion (#711)
gugu Mar 14, 2019
1b29dd9
fix(tab-indicator): upgrade mdc-web to 1.0.0 (#742)
gugu Mar 14, 2019
ae9b421
fix(tab-scroller): upgrade mdc-web to 1.0.0 (#743)
gugu Mar 14, 2019
09cb8a5
fix: [email protected] --> [email protected] & update imports (#709)
Mar 15, 2019
5f55983
fix(chips): upgrade mdc-web to v1.0.0 (#750)
gugu Mar 15, 2019
a8c64b5
feat(drawer): add innerRef prop (#749)
lucasecdb Mar 18, 2019
9b86474
fix(tab): mdc-web v1.0.0 upgrade (#748)
gugu Mar 18, 2019
dd95b60
feat(snackbar): MDC Web v1.0.0 (#755)
gugu Mar 18, 2019
38e9886
feat(floating-label): update mdc web to v1.0.0 (#741)
Mar 19, 2019
4e99b4c
feat(list): update to MDC Web 1.0.0 (#740)
Mar 19, 2019
45fef89
fix(card): add react-ripple to package json (#773)
Mar 25, 2019
580c850
fix(tab-bar): upgrade mdc-web to v1 (#770)
gugu Mar 26, 2019
44cca84
feat(switch): upgrade to mdc-web v1 (#757)
gugu Mar 26, 2019
1a04f3d
feat(menu-surface): upgrade to mdc web v1 (#774)
Mar 27, 2019
4f523e3
fix(checkbox): upgrade mdc-web to v1 (#769)
gugu Mar 28, 2019
4d6bbc0
feat(radio): upgrade to typescript v1 (#777)
gugu Mar 28, 2019
8ff8695
fix(typography): upgrade to mdc-web v1 (#778)
gugu Mar 28, 2019
bcda111
fix(dialog): mdc-web v1 upgrade (#779)
gugu Mar 29, 2019
b6403e6
fix(fab): upgrade to mdc-web v1.1 (#790)
gugu Apr 1, 2019
37c7269
fix(linear-progress): upgrade mdc-web to v1 (#787)
gugu Apr 1, 2019
bb9e7e4
fix(top-app-bar): mdc-web v1 upgrade (#780)
gugu Apr 1, 2019
9c7bfa7
fix(card): upgrade to mdc-web v1.1 (#788)
gugu Apr 1, 2019
e5b953f
fix(icon-button): upgrade to mdc-web v1.1 (#792)
Apr 2, 2019
74379af
fix(list): maintain classes with state.listItemClassNames (#776)
Apr 2, 2019
034158c
fix: remove .only (#794)
Apr 3, 2019
7b413df
feat(button): update mdc web deps to v1.1.0 (#791)
Apr 8, 2019
ea15a2a
fix(chips): Fix incorrect ripple effect (#804)
Apr 12, 2019
4dbc8b8
feat(notched-outline): update to v1.1.1 (#806)
Apr 16, 2019
509e93e
chore(infrastructure): add esmoduleinterop to tsconfig (#818)
Apr 26, 2019
7e0f877
feat(menu): add component (#786)
Apr 26, 2019
7adc12a
fix(drawer): add missing foundation import in drawer (#821)
Apr 29, 2019
abaa146
feat(select): add option component (#826)
Apr 29, 2019
e22ac2a
feat(select): add helper text (#824)
Apr 29, 2019
beedb23
feat(select): add icon (#825)
Apr 29, 2019
b400013
chore: reduce unused deps in package.json (#819)
Apr 29, 2019
14b22bc
feat(select): enhanced select (#823)
Apr 30, 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
5 changes: 0 additions & 5 deletions docs/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,4 @@ Since `[email protected]` is exporting `default`, we should be importing as such:
```ts
// referenced in https://github.com/basarat/typescript-book/blob/master/docs/project/external-modules.md#default-exportsimports
import classnames from 'classnames';
```

In other cases where we import modules that do not use `default`, we should import like:
```ts
import * as classnames from 'classnames';
```
3,042 changes: 2,440 additions & 602 deletions package-lock.json

Large diffs are not rendered by default.

60 changes: 28 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"pretest": "npm stop",
"test": "npm run lint && npm run test:unit && npm run test:screenshots",
"posttest": "npm stop && istanbul report --root coverage text-summary && istanbul check-coverage --lines 95 --statements 95 --branches 95 --functions 95",
"postinstall": "lerna bootstrap",
"postinstall": "lerna bootstrap && rm node_modules/**/.babelrc -f && rm packages/**/node_modules/.babelrc -f",
"test:watch": "karma start karma.local.js --auto-watch",
"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",
Expand All @@ -41,9 +41,11 @@
"linear-progress",
"list",
"menu-surface",
"notched-outline",
"radio",
"ripple",
"select",
"snackbar",
"top-app-bar",
"switch",
"tab",
Expand All @@ -60,34 +62,27 @@
},
"devDependencies": {
"@google-cloud/storage": "^1.6.0",
"@material/button": "^0.43.0",
"@material/card": "^0.41.0",
"@material/checkbox": "^0.41.0",
"@material/chips": "^0.41.0",
"@material/dialog": "^0.43.0",
"@material/dom": "^0.41.0",
"@material/drawer": "^0.41.0",
"@material/fab": "^0.41.0",
"@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/linear-progress": "^0.41.0",
"@material/list": "^0.41.0",
"@material/menu-surface": "^0.41.0",
"@material/notched-outline": "^0.41.0",
"@material/radio": "^0.41.0",
"@material/ripple": "^0.41.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/base": "^1.0.0",
"@material/button": "^1.1.0",
"@material/card": "^1.1.0",
"@material/checkbox": "^1.0.0",
"@material/chips": "^1.1.1",
"@material/dialog": "^1.1.0",
"@material/drawer": "^1.0.1",
"@material/floating-label": "^1.1.0",
"@material/icon-button": "^1.1.0",
"@material/line-ripple": "^1.0.0",
"@material/list": "1.0.0",
"@material/menu-surface": "^1.0.1",
"@material/notched-outline": "^1.1.1",
"@material/radio": "^1.1.0",
"@material/ripple": "^1.0.0",
"@material/select": "^1.1.1",
"@material/snackbar": "^1.0.0",
"@material/tab": "^1.0.0",
"@material/tab-bar": "^1.0.0",
"@material/textfield": "^0.41.0",
"@material/top-app-bar": "^0.41.0",
"@material/typography": "^0.41.0",
"@material/typography": "^1.0.0",
"@types/chai": "^4.1.7",
"@types/classnames": "^2.2.6",
"@types/enzyme": "^3.1.15",
Expand Down Expand Up @@ -119,8 +114,9 @@
"cp-file": "^6.0.0",
"cross-env": "^5.2.0",
"css-loader": "^0.28.10",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.11.2",
"enzyme-adapter-utils": "^1.10.1",
"eslint": "^5.9.0",
"eslint-config-google": "^0.9.1",
"eslint-plugin-react": "^7.7.0",
Expand All @@ -146,13 +142,13 @@
"react-dom": "^16.4.2",
"react-router-dom": "^4.3.1",
"remap-istanbul": "^0.12.0",
"rimraf": "^2.6.3",
"resemblejs": "^3.0.1",
"rimraf": "^2.6.3",
"sass-loader": "^6.0.7",
"testdouble": "^3.6.0",
"ts-loader": "^3.5.0",
"ts-node": "^7.0.1",
"typescript": "^3.2.2",
"typescript": "^3.3.3",
"typescript-eslint-parser": "^21.0.1",
"utility-types": "^2.1.0",
"uuid": "^3.3.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';
import * as Ripple from '@material/react-ripple';
import {withRipple, InjectedProps} from '@material/react-ripple';

const BUTTON_CLASS_NAME = 'mdc-button__icon';

type ButtonTypes = HTMLAnchorElement | HTMLButtonElement;

export interface ButtonProps<T extends ButtonTypes>
extends Ripple.InjectedProps<T>, React.AnchorHTMLAttributes<T>, React.ButtonHTMLAttributes<T> {
extends InjectedProps<T>, React.AnchorHTMLAttributes<T>, React.ButtonHTMLAttributes<T> {
raised?: boolean;
unelevated?: boolean;
outlined?: boolean;
Expand Down Expand Up @@ -109,5 +109,5 @@ Button.defaultProps = {
initRipple: () => {},
};

export default Ripple.withRipple<ButtonProps<ButtonTypes>, ButtonTypes>(Button);
export default withRipple<ButtonProps<ButtonTypes>, ButtonTypes>(Button);

2 changes: 1 addition & 1 deletion packages/button/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/button": "^0.43.0",
"@material/button": "^1.1.0",
"@material/react-ripple": "^0.11.0",
"classnames": "^2.2.6",
"react": "^16.4.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/card/ActionButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';

type ChildType = React.ReactElement<React.HTMLProps<HTMLButtonElement|HTMLAnchorElement>>;
Expand Down
2 changes: 1 addition & 1 deletion packages/card/ActionIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';

type ChildType = React.ReactElement<React.HTMLProps<HTMLImageElement|HTMLOrSVGElement>>;
Expand Down
2 changes: 1 addition & 1 deletion packages/card/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';

export interface ActionsProps extends React.HTMLProps<HTMLDivElement> {
Expand Down
2 changes: 1 addition & 1 deletion packages/card/Media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';

export interface MediaProps extends React.HTMLProps<HTMLDivElement> {
Expand Down
8 changes: 4 additions & 4 deletions packages/card/PrimaryContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';
import * as Ripple from '@material/react-ripple';
import {withRipple, InjectedProps} from '@material/react-ripple';

export interface PrimaryContentBaseProps extends React.HTMLProps<HTMLDivElement>, Ripple.InjectedProps<HTMLDivElement>{
export interface PrimaryContentBaseProps extends React.HTMLProps<HTMLDivElement>, InjectedProps<HTMLDivElement>{
className: string;
unbounded?: boolean;
};
Expand All @@ -47,4 +47,4 @@ export const PrimaryContentBase: React.FunctionComponent<PrimaryContentBaseProps
);
};

export default Ripple.withRipple<PrimaryContentBaseProps, HTMLDivElement>(PrimaryContentBase);
export default withRipple<PrimaryContentBaseProps, HTMLDivElement>(PrimaryContentBase);
2 changes: 1 addition & 1 deletion packages/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';
import ActionButtons from './ActionButtons';
import ActionIcons from './ActionIcons';
Expand Down
2 changes: 1 addition & 1 deletion packages/card/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/card": "^0.41.0",
"@material/card": "^1.1.0",
"@material/react-ripple": "^0.11.0",
"classnames": "^2.2.6",
"react": "^16.4.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/NativeControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import * as React from 'react';
import React from 'react';

export interface NativeControlProps extends React.HTMLProps<HTMLInputElement>{
checked: boolean;
Expand Down
43 changes: 26 additions & 17 deletions packages/checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

import * as React from 'react';
import React from 'react';
import classnames from 'classnames';
// @ts-ignore no mdc .d.ts file
import {MDCCheckboxFoundation, MDCCheckboxAdapter} from '@material/checkbox/dist/mdc.checkbox';
import * as Ripple from '@material/react-ripple';
import {MDCCheckboxFoundation} from '@material/checkbox/foundation';
import {MDCCheckboxAdapter} from '@material/checkbox/adapter';
import {cssClasses} from '@material/checkbox/constants';
import {withRipple, InjectedProps} from '@material/react-ripple';

import NativeControl from './NativeControl';

export interface CheckboxProps extends Ripple.InjectedProps<HTMLDivElement, HTMLInputElement> {
export interface CheckboxProps extends InjectedProps<HTMLDivElement, HTMLInputElement> {
checked?: boolean;
className?: string;
disabled?: boolean;
Expand All @@ -45,20 +46,22 @@ interface CheckboxState {
checked?: boolean;
indeterminate?: boolean;
classList: Set<string>;
'aria-checked': boolean;
'aria-checked': string;
disabled: boolean;
};

export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
inputElement: React.RefObject<HTMLInputElement> = React.createRef();
foundation = MDCCheckboxFoundation;
foundation!: MDCCheckboxFoundation;

constructor(props: CheckboxProps) {
super(props);
this.state = {
'checked': props.checked,
'indeterminate': props.indeterminate,
'classList': new Set(),
'aria-checked': false,
'aria-checked': 'false',
'disabled': props.disabled!,
};
}

Expand All @@ -74,7 +77,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
componentDidMount() {
this.foundation = new MDCCheckboxFoundation(this.adapter);
this.foundation.init();
this.foundation.setDisabled(this.props.disabled);
this.foundation.setDisabled(this.props.disabled!);
// indeterminate property on checkboxes is not supported:
// https://github.com/facebook/react/issues/1798#issuecomment-333414857
if (this.inputElement.current) {
Expand All @@ -91,7 +94,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
this.handleChange(checked!, indeterminate!);
}
if (disabled !== prevProps.disabled) {
this.foundation.setDisabled(disabled);
this.foundation.setDisabled(disabled!);
}
}

Expand All @@ -118,7 +121,9 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
get classes(): string {
const {classList} = this.state;
const {className} = this.props;
return classnames('mdc-checkbox', Array.from(classList), className);
return classnames(
'mdc-checkbox', Array.from(classList),
this.state.disabled ? cssClasses.DISABLED : null, className);
}

updateState = (key: keyof CheckboxState, value: string | boolean) => {
Expand Down Expand Up @@ -146,10 +151,14 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
// isAttachedToDOM will likely be removed
// https://github.com/material-components/material-components-web/issues/3691
isAttachedToDOM: () => true,
isChecked: () => this.state.checked,
isIndeterminate: () => this.state.indeterminate,
isChecked: () => this.state.checked!,
isIndeterminate: () => this.state.indeterminate!,
setNativeControlAttr: this.updateState,
setNativeControlDisabled: (disabled) => {
this.updateState('disabled', disabled);
},
removeNativeControlAttr: this.removeState,
forceLayout: () => null,
};
}

Expand All @@ -169,8 +178,8 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
initRipple,
onChange,
unbounded,
/* eslint-enable no-unused-vars */
disabled,
/* eslint-enable no-unused-vars */
nativeControlId,
name,
...otherProps
Expand All @@ -186,8 +195,8 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
<NativeControl
id={nativeControlId}
checked={this.state.checked}
disabled={disabled}
aria-checked={this.state['aria-checked']}
disabled={this.state.disabled}
aria-checked={(this.state['aria-checked'] || this.state.checked!.toString()) as ('true' | 'false')}
name={name}
onChange={this.onChange}
rippleActivatorRef={this.inputElement}
Expand All @@ -211,4 +220,4 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
}
}

export default Ripple.withRipple<CheckboxProps, HTMLDivElement, HTMLInputElement>(Checkbox);
export default withRipple<CheckboxProps, HTMLDivElement, HTMLInputElement>(Checkbox);
2 changes: 1 addition & 1 deletion packages/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"url": "https://github.com/material-components/material-components-web-react.git"
},
"dependencies": {
"@material/checkbox": "^0.41.0",
"@material/checkbox": "^1.1.0",
"@material/react-ripple": "^0.11.0",
"classnames": "^2.2.6",
"react": "^16.3.2"
Expand Down
Loading