Completely updated React, fixed #11, (hopefully)

This commit is contained in:
2018-03-04 19:11:49 -05:00
parent 6e0afd6e2a
commit 34e5f5139a
13674 changed files with 333464 additions and 473223 deletions

View File

@@ -1,14 +1,13 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface TableProps extends StandardProps<
React.TableHTMLAttributes<HTMLTableElement>,
TableClassKey
> {}
export interface TableProps extends StandardProps<TableBaseProps, TableClassKey> {
component?: React.ReactType<TableBaseProps>;
}
export type TableClassKey =
| 'root'
;
export type TableBaseProps = React.TableHTMLAttributes<HTMLTableElement>;
export type TableClassKey = 'root';
declare const Table: React.ComponentType<TableProps>;

View File

@@ -1,9 +1,6 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
@@ -19,7 +16,6 @@ export const styles = theme => ({
});
class Table extends React.Component {
getChildContext() {
// eslint-disable-line class-methods-use-this
return {
@@ -29,26 +25,37 @@ class Table extends React.Component {
render() {
const _props = this.props,
{
classes,
className: classNameProp,
children,
component: ComponentProp
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'children', 'component']);
const className = classNames(classes.root, classNameProp);
{ classes, className: classNameProp, component: Component } = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'component']);
return React.createElement(
ComponentProp,
_extends({ className: className }, other),
children
);
return React.createElement(Component, _extends({ className: classNames(classes.root, classNameProp) }, other));
}
}
Table.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the table, normally `TableHeader` and `TableBody`.
*/
children: PropTypes.node.isRequired,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
} : {};
Table.defaultProps = {
component: 'table'
};
Table.childContextTypes = {
table: PropTypes.object
};

View File

@@ -1,14 +1,10 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface TableBodyProps extends StandardProps<
React.HTMLAttributes<HTMLTableSectionElement>,
TableBodyClassKey
> {}
export interface TableBodyProps extends TableBodyBaseProps {
component?: React.ReactType<TableBodyBaseProps>;
}
export type TableBodyClassKey =
| 'root'
;
export type TableBodyBaseProps = React.HTMLAttributes<HTMLTableSectionElement>;
declare const TableBody: React.ComponentType<TableBodyProps>;

View File

@@ -1,22 +1,8 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => ({
root: {
fontSize: theme.typography.pxToRem(13),
color: theme.palette.text.primary
}
});
class TableBody extends React.Component {
getChildContext() {
// eslint-disable-line class-methods-use-this
return {
@@ -28,28 +14,31 @@ class TableBody extends React.Component {
render() {
const _props = this.props,
{
classes,
className: classNameProp,
children,
component: ComponentProp
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'children', 'component']);
const className = classNames(classes.root, classNameProp);
{ component: Component } = _props,
other = _objectWithoutProperties(_props, ['component']);
return React.createElement(
ComponentProp,
_extends({ className: className }, other),
children
);
return React.createElement(Component, other);
}
}
TableBody.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component, normally `TableRow`.
*/
children: PropTypes.node.isRequired,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
} : {};
TableBody.defaultProps = {
component: 'tbody'
};
TableBody.childContextTypes = {
table: PropTypes.object
};
export default withStyles(styles, { name: 'MuiTableBody' })(TableBody);
export default TableBody;

View File

@@ -9,30 +9,32 @@ import { StandardProps } from '..';
* Since it is not decided via prop, we have create loose typings
* here.
*/
export interface TableCellProps extends StandardProps<
React.ThHTMLAttributes<HTMLTableHeaderCellElement> & React.TdHTMLAttributes<HTMLTableDataCellElement>,
TableCellClassKey
> {
padding?: Padding;
export interface TableCellProps extends StandardProps<TableCellBaseProps, TableCellClassKey> {
component?: React.ReactType<TableCellBaseProps>;
numeric?: boolean;
padding?: Padding;
sortDirection?: SortDirection;
type?: Type;
}
export type Padding =
| 'default'
| 'checkbox'
| 'dense'
| 'none'
;
export type TableCellBaseProps = React.ThHTMLAttributes<HTMLTableHeaderCellElement> &
React.TdHTMLAttributes<HTMLTableDataCellElement>;
export type Padding = 'default' | 'checkbox' | 'dense' | 'none';
export type SortDirection = 'asc' | 'desc' | false;
export type Type = 'head' | 'body' | 'footer';
export type TableCellClassKey =
| 'root'
| 'numeric'
| 'head'
| 'typeHead'
| 'typeBody'
| 'typeFooter'
| 'paddingDefault'
| 'paddingCompact'
| 'paddingCheckbox'
| 'footer'
;
| 'paddingDense'
| 'paddingCheckbox';
declare const TableCell: React.ComponentType<TableCellProps>;

View File

@@ -1,27 +1,39 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
import { capitalizeFirstLetter } from '../utils/helpers';
import { capitalize } from '../utils/helpers';
import { darken, fade, lighten } from '../styles/colorManipulator';
export const styles = theme => ({
root: {
borderBottom: `1px solid ${theme.palette.text.lightDivider}`,
// Workaround for a rendering bug with spanned columns in Chrome 62.0.
// Removes the alpha (sets it to 1), and lightens or darkens the theme color.
borderBottom: `1px solid
${theme.palette.type === 'light' ? lighten(fade(theme.palette.divider, 1), 0.88) : darken(fade(theme.palette.divider, 1), 0.8)}`,
textAlign: 'left'
},
numeric: {
textAlign: 'right',
flexDirection: 'row-reverse' // can be dynamically inherited at runtime by contents
},
head: {
typeHead: {
color: theme.palette.text.secondary,
fontSize: theme.typography.pxToRem(12),
fontWeight: theme.typography.fontWeightMedium,
position: 'relative' // Workaround for Tooltip positioning issue.
},
typeBody: {
fontSize: theme.typography.pxToRem(13),
color: theme.palette.text.primary
},
typeFooter: {
borderBottom: 0,
color: theme.palette.text.secondary,
fontSize: theme.typography.pxToRem(12)
},
paddingDefault: {
padding: `${theme.spacing.unit / 2}px ${theme.spacing.unit * 7}px ${theme.spacing.unit / 2}px ${theme.spacing.unit * 3}px`,
'&:last-child': {
@@ -33,23 +45,22 @@ export const styles = theme => ({
},
paddingCheckbox: {
padding: '0 12px'
},
footer: {
borderBottom: 0
}
});
function TableCell(props, context) {
const {
children,
classes,
className: classNameProp,
children,
component,
sortDirection,
numeric,
padding,
component
scope: scopeProp,
variant
} = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'children', 'numeric', 'padding', 'component']);
other = _objectWithoutProperties(props, ['children', 'classes', 'className', 'component', 'sortDirection', 'numeric', 'padding', 'scope', 'variant']);
const { table } = context;
let Component;
if (component) {
@@ -58,21 +69,73 @@ function TableCell(props, context) {
Component = table && table.head ? 'th' : 'td';
}
let scope = scopeProp;
if (!scope && table && table.head) {
scope = 'col';
}
const className = classNames(classes.root, {
[classes.numeric]: numeric,
[classes[`padding${capitalizeFirstLetter(padding)}`]]: padding !== 'none' && padding !== 'default',
[classes[`padding${capitalize(padding)}`]]: padding !== 'none' && padding !== 'default',
[classes.paddingDefault]: padding !== 'none',
[classes.head]: table && table.head,
[classes.footer]: table && table.footer
[classes.typeHead]: variant ? variant === 'head' : table && table.head,
[classes.typeBody]: variant ? variant === 'body' : table && table.body,
[classes.typeFooter]: variant ? variant === 'footer' : table && table.footer
}, classNameProp);
let ariaSort = null;
if (sortDirection) {
ariaSort = sortDirection === 'asc' ? 'ascending' : 'descending';
}
return React.createElement(
Component,
_extends({ className: className }, other),
_extends({ className: className, 'aria-sort': ariaSort, scope: scope }, other),
children
);
}
TableCell.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The table cell contents.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* If `true`, content will align to the right.
*/
numeric: PropTypes.bool,
/**
* Sets the padding applied to the cell.
*/
padding: PropTypes.oneOf(['default', 'checkbox', 'dense', 'none']),
/**
* Set scope attribute.
*/
scope: PropTypes.string,
/**
* Set aria-sort direction.
*/
sortDirection: PropTypes.oneOf(['asc', 'desc', false]),
/**
* Specify the cell type.
* By default, the TableHead, TableBody or TableFooter parent component set the value.
*/
variant: PropTypes.oneOf(['head', 'body', 'footer'])
} : {};
TableCell.defaultProps = {
numeric: false,
padding: 'default'

View File

@@ -1,14 +1,10 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface TableFooterProps extends StandardProps<
React.HTMLAttributes<HTMLTableSectionElement>,
TableFooterClassKey
> {}
export interface TableFooterProps extends TableFooterBaseProps {
component?: React.ReactType<TableFooterBaseProps>;
}
export type TableFooterClassKey =
| 'root'
;
export type TableFooterBaseProps = React.HTMLAttributes<HTMLTableSectionElement>;
declare const TableFooter: React.ComponentType<TableFooterProps>;

View File

@@ -1,22 +1,8 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => ({
root: {
fontSize: theme.typography.pxToRem(12),
color: theme.palette.text.secondary
}
});
class TableFooter extends React.Component {
getChildContext() {
// eslint-disable-line class-methods-use-this
return {
@@ -28,27 +14,31 @@ class TableFooter extends React.Component {
render() {
const _props = this.props,
{
classes,
className: classNameProp,
children,
component: ComponentProp
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'children', 'component']);
{ component: Component } = _props,
other = _objectWithoutProperties(_props, ['component']);
return React.createElement(
ComponentProp,
_extends({ className: classNames(classes.root, classNameProp) }, other),
children
);
return React.createElement(Component, other);
}
}
TableFooter.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component, normally `TableRow`.
*/
children: PropTypes.node,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
} : {};
TableFooter.defaultProps = {
component: 'tfoot'
};
TableFooter.childContextTypes = {
table: PropTypes.object
};
export default withStyles(styles, { name: 'MuiTableFooter' })(TableFooter);
export default TableFooter;

View File

@@ -1,14 +1,10 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface TableHeadProps extends StandardProps<
React.HTMLAttributes<HTMLTableSectionElement>,
TableHeadClassKey
> {}
export interface TableHeadProps extends TableHeadBaseProps {
component?: React.ReactType<TableHeadBaseProps>;
}
export type TableHeadClassKey =
| 'root'
;
export type TableHeadBaseProps = React.HTMLAttributes<HTMLTableSectionElement>;
declare const TableHead: React.ComponentType<TableHeadProps>;

View File

@@ -1,23 +1,8 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
export const styles = theme => ({
root: {
fontSize: theme.typography.pxToRem(12),
fontWeight: theme.typography.fontWeightMedium,
color: theme.palette.text.secondary
}
});
class TableHead extends React.Component {
getChildContext() {
// eslint-disable-line class-methods-use-this
return {
@@ -29,28 +14,31 @@ class TableHead extends React.Component {
render() {
const _props = this.props,
{
classes,
className: classNameProp,
children,
component: ComponentProp
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'className', 'children', 'component']);
const className = classNames(classes.root, classNameProp);
{ component: Component } = _props,
other = _objectWithoutProperties(_props, ['component']);
return React.createElement(
ComponentProp,
_extends({ className: className }, other),
children
);
return React.createElement(Component, other);
}
}
TableHead.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The content of the component, normally `TableRow`.
*/
children: PropTypes.node.isRequired,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func])
} : {};
TableHead.defaultProps = {
component: 'thead'
};
TableHead.childContextTypes = {
table: PropTypes.object
};
export default withStyles(styles, { name: 'MuiTableHead' })(TableHead);
export default TableHead;

View File

@@ -1,37 +1,41 @@
import * as React from 'react';
import { StandardProps } from '..';
import { TableCellProps, TableCellClassKey } from './TableCell.d'
import { TableCellProps, TableCellClassKey } from './TableCell.d';
import { IconButtonProps } from '../IconButton/IconButton';
interface LabelDisplayedRowsArgs {
export interface LabelDisplayedRowsArgs {
from: number;
to: number;
count: number;
page: number;
}
export interface TablePaginationProps extends StandardProps<
TableCellProps,
TablePaginationClassKey
> {
export interface TablePaginationProps
extends StandardProps<TablePaginationBaseProps, TablePaginationClassKey> {
Actions?: React.ReactType<TablePaginationBaseProps>;
backIconButtonProps?: Partial<IconButtonProps>;
component?: React.ReactType<TablePaginationBaseProps>;
count: number;
labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => Node;
labelRowsPerPage?: Node;
labelDisplayedRows?: (paginationInfo: LabelDisplayedRowsArgs) => React.ReactNode;
labelRowsPerPage?: React.ReactNode;
nextIconButtonProps?: Partial<IconButtonProps>;
onChangePage: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
onChangeRowsPerPage: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
onChangeRowsPerPage?: React.ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
page: number;
rowsPerPage: number;
rowsPerPageOptions?: number[];
}
export type TablePaginationBaseProps = TableCellProps;
export type TablePaginationClassKey =
| TableCellClassKey
| 'cell'
| 'toolbar'
| 'spacer'
| 'select'
| 'caption'
| 'input'
| 'selectRoot'
| 'actions'
;
| 'select';
declare const TablePagination: React.ComponentType<TablePaginationProps>;

View File

@@ -1,21 +1,17 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
// @inheritedComponent TableCell
import React from 'react';
import PropTypes from 'prop-types';
import withStyles from '../styles/withStyles';
import IconButton from '../IconButton';
import Input from '../Input';
import { MenuItem } from '../Menu';
import Select from '../Select';
import TableCell from './TableCell';
import Toolbar from '../Toolbar';
import Typography from '../Typography';
import KeyboardArrowLeft from '../svg-icons/KeyboardArrowLeft';
import KeyboardArrowRight from '../svg-icons/KeyboardArrowRight';
import TablePaginationActions from './TablePaginationActions';
export const styles = theme => ({
root: {
@@ -36,19 +32,20 @@ export const styles = theme => ({
flexShrink: 0
},
input: {
fontSize: 'inherit'
fontSize: 'inherit',
flexShrink: 0
},
selectRoot: {
marginRight: theme.spacing.unit * 4
marginRight: theme.spacing.unit * 4,
marginLeft: theme.spacing.unit,
color: theme.palette.text.secondary
},
select: {
marginLeft: theme.spacing.unit,
width: 34,
textAlign: 'right',
paddingRight: 22,
color: theme.palette.text.secondary,
height: 32,
lineHeight: '32px'
paddingLeft: theme.spacing.unit,
paddingRight: theme.spacing.unit * 2
},
selectIcon: {
top: 1
},
actions: {
flexShrink: 0,
@@ -58,20 +55,11 @@ export const styles = theme => ({
});
/**
* A `TableRow` based component for placing inside `TableFooter` for pagination.
* A `TableCell` based component for placing inside `TableFooter` for pagination.
*/
class TablePagination extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.handleBackButtonClick = event => {
this.props.onChangePage(event, this.props.page - 1);
}, this.handleNextButtonClick = event => {
this.props.onChangePage(event, this.props.page + 1);
}, _temp;
}
componentWillReceiveProps({ count, onChangePage, rowsPerPage }) {
componentWillReceiveProps(nextProps) {
const { count, onChangePage, rowsPerPage } = nextProps;
const newLastPage = Math.max(0, Math.ceil(count / rowsPerPage) - 1);
if (this.props.page > newLastPage) {
onChangePage(null, newLastPage);
@@ -81,25 +69,27 @@ class TablePagination extends React.Component {
render() {
const _props = this.props,
{
Actions,
backIconButtonProps,
classes,
component: Component,
colSpan: colSpanProp,
component: Component,
count,
labelDisplayedRows,
labelRowsPerPage,
nextIconButtonProps,
onChangePage,
onChangeRowsPerPage,
page,
rowsPerPage,
rowsPerPageOptions,
theme
rowsPerPageOptions
} = _props,
other = _objectWithoutProperties(_props, ['classes', 'component', 'colSpan', 'count', 'labelDisplayedRows', 'labelRowsPerPage', 'onChangePage', 'onChangeRowsPerPage', 'page', 'rowsPerPage', 'rowsPerPageOptions', 'theme']);
other = _objectWithoutProperties(_props, ['Actions', 'backIconButtonProps', 'classes', 'colSpan', 'component', 'count', 'labelDisplayedRows', 'labelRowsPerPage', 'nextIconButtonProps', 'onChangePage', 'onChangeRowsPerPage', 'page', 'rowsPerPage', 'rowsPerPageOptions']);
let colSpan;
if (Component === TableCell || Component === 'td') {
colSpan = colSpanProp || 9001; // col-span over everything
colSpan = colSpanProp || 1000; // col-span over everything
}
return React.createElement(
@@ -109,19 +99,25 @@ class TablePagination extends React.Component {
Toolbar,
{ className: classes.toolbar },
React.createElement('div', { className: classes.spacer }),
React.createElement(
rowsPerPageOptions.length > 1 && React.createElement(
Typography,
{ type: 'caption', className: classes.caption },
{ variant: 'caption', className: classes.caption },
labelRowsPerPage
),
React.createElement(
rowsPerPageOptions.length > 1 && React.createElement(
Select,
{
classes: { root: classes.selectRoot, select: classes.select },
InputClasses: {
root: classes.input
classes: {
root: classes.selectRoot,
select: classes.select,
icon: classes.selectIcon
},
input: React.createElement(Input, { disableUnderline: true }),
input: React.createElement(Input, {
classes: {
root: classes.input
},
disableUnderline: true
}),
value: rowsPerPage,
onChange: onChangeRowsPerPage
},
@@ -133,7 +129,7 @@ class TablePagination extends React.Component {
),
React.createElement(
Typography,
{ type: 'caption', className: classes.caption },
{ variant: 'caption', className: classes.caption },
labelDisplayedRows({
from: count === 0 ? 0 : page * rowsPerPage + 1,
to: Math.min(count, (page + 1) * rowsPerPage),
@@ -141,32 +137,93 @@ class TablePagination extends React.Component {
page
})
),
React.createElement(
'div',
{ className: classes.actions },
React.createElement(
IconButton,
{ onClick: this.handleBackButtonClick, disabled: page === 0 },
theme.direction === 'rtl' ? React.createElement(KeyboardArrowRight, null) : React.createElement(KeyboardArrowLeft, null)
),
React.createElement(
IconButton,
{
onClick: this.handleNextButtonClick,
disabled: page >= Math.ceil(count / rowsPerPage) - 1
},
theme.direction === 'rtl' ? React.createElement(KeyboardArrowLeft, null) : React.createElement(KeyboardArrowRight, null)
)
)
React.createElement(Actions, {
backIconButtonProps: backIconButtonProps,
count: count,
nextIconButtonProps: nextIconButtonProps,
onChangePage: onChangePage,
page: page,
rowsPerPage: rowsPerPage
})
)
);
}
}
TablePagination.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* The component used for displaying the actions.
* Either a string to use a DOM element or a component.
*/
Actions: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* Properties applied to the back arrow `IconButton` component.
*/
backIconButtonProps: PropTypes.object,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
colSpan: PropTypes.number,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* The total number of rows.
*/
count: PropTypes.number.isRequired,
/**
* Useful to customize the displayed rows label.
*/
labelDisplayedRows: PropTypes.func,
/**
* Useful to customize the rows per page label. Invoked with a `{ from, to, count, page }`
* object.
*/
labelRowsPerPage: PropTypes.node,
/**
* Properties applied to the next arrow `IconButton` component.
*/
nextIconButtonProps: PropTypes.object,
/**
* Callback fired when the page is changed.
*
* @param {object} event The event source of the callback
* @param {number} page The page selected
*/
onChangePage: PropTypes.func.isRequired,
/**
* Callback fired when the number of rows per page is changed.
*
* @param {object} event The event source of the callback
*/
onChangeRowsPerPage: PropTypes.func,
/**
* The zero-based index of the current page.
*/
page: PropTypes.number.isRequired,
/**
* The number of rows per page.
*/
rowsPerPage: PropTypes.number.isRequired,
/**
* Customizes the options of the rows per page select field. If less than two options are
* available, no select field will be displayed.
*/
rowsPerPageOptions: PropTypes.array
} : {};
TablePagination.defaultProps = {
Actions: TablePaginationActions,
component: TableCell,
labelRowsPerPage: 'Rows per page:',
labelDisplayedRows: ({ from, to, count }) => `${from}-${to} of ${count}`,
labelRowsPerPage: 'Rows per page:',
rowsPerPageOptions: [5, 10, 25]
};
export default withStyles(styles, { withTheme: true, name: 'MuiTablePagination' })(TablePagination);
export default withStyles(styles, { name: 'MuiTablePagination' })(TablePagination);

View File

@@ -0,0 +1,20 @@
import * as React from 'react';
import { StandardProps } from '..';
import { TableCellClassKey } from './TableCell.d';
import { IconButtonProps } from '../IconButton/IconButton';
export interface TablePaginationActionsProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, TablePaginationActionsClassKey> {
backIconButtonProps?: Partial<IconButtonProps>;
count: number;
nextIconButtonProps?: Partial<IconButtonProps>;
onChangePage: (event: React.MouseEvent<HTMLButtonElement> | null, page: number) => void;
page: number;
rowsPerPage: number;
}
export type TablePaginationActionsClassKey = 'root';
declare const TablePaginationActions: React.ComponentType<TablePaginationActionsProps>;
export default TablePaginationActions;

View File

@@ -0,0 +1,116 @@
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import KeyboardArrowLeft from '../internal/svg-icons/KeyboardArrowLeft';
import KeyboardArrowRight from '../internal/svg-icons/KeyboardArrowRight';
import withStyles from '../styles/withStyles';
import IconButton from '../IconButton';
export const styles = theme => ({
root: {
flexShrink: 0,
color: theme.palette.text.secondary,
marginLeft: theme.spacing.unit * 2.5
}
});
/**
* @ignore - internal component.
*/
var _ref = React.createElement(KeyboardArrowRight, null);
var _ref2 = React.createElement(KeyboardArrowLeft, null);
var _ref3 = React.createElement(KeyboardArrowLeft, null);
var _ref4 = React.createElement(KeyboardArrowRight, null);
class TablePaginationActions extends React.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.handleBackButtonClick = event => {
this.props.onChangePage(event, this.props.page - 1);
}, this.handleNextButtonClick = event => {
this.props.onChangePage(event, this.props.page + 1);
}, _temp;
}
render() {
const _props = this.props,
{
backIconButtonProps,
classes,
count,
nextIconButtonProps,
onChangePage,
page,
rowsPerPage,
theme
} = _props,
other = _objectWithoutProperties(_props, ['backIconButtonProps', 'classes', 'count', 'nextIconButtonProps', 'onChangePage', 'page', 'rowsPerPage', 'theme']);
return React.createElement(
'div',
_extends({ className: classes.root }, other),
React.createElement(
IconButton,
_extends({
onClick: this.handleBackButtonClick,
disabled: page === 0
}, backIconButtonProps),
theme.direction === 'rtl' ? _ref : _ref2
),
React.createElement(
IconButton,
_extends({
onClick: this.handleNextButtonClick,
disabled: page >= Math.ceil(count / rowsPerPage) - 1
}, nextIconButtonProps),
theme.direction === 'rtl' ? _ref3 : _ref4
)
);
}
}
TablePaginationActions.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* Properties applied to the back arrow `IconButton` component.
*/
backIconButtonProps: PropTypes.object,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* The total number of rows.
*/
count: PropTypes.number.isRequired,
/**
* Properties applied to the next arrow `IconButton` component.
*/
nextIconButtonProps: PropTypes.object,
/**
* Callback fired when the page is changed.
*
* @param {object} event The event source of the callback
* @param {number} page The page selected
*/
onChangePage: PropTypes.func.isRequired,
/**
* The zero-based index of the current page.
*/
page: PropTypes.number.isRequired,
/**
* The number of rows per page.
*/
rowsPerPage: PropTypes.number.isRequired,
/**
* @ignore
*/
theme: PropTypes.object.isRequired
} : {};
export default withStyles(styles, { name: 'MuiTablePaginationActions', withTheme: true })(TablePaginationActions);

View File

@@ -1,21 +1,15 @@
import * as React from 'react';
import { StandardProps } from '..';
export interface TableRowProps extends StandardProps<
React.HTMLAttributes<HTMLTableRowElement>,
TableRowClassKey
> {
export interface TableRowProps extends StandardProps<TableRowBaseProps, TableRowClassKey> {
component?: React.ReactType<TableRowBaseProps>;
hover?: boolean;
selected?: boolean;
}
export type TableRowClassKey =
| 'root'
| 'head'
| 'footer'
| 'hover'
| 'selected'
;
export type TableRowBaseProps = React.HTMLAttributes<HTMLTableRowElement>;
export type TableRowClassKey = 'root' | 'typeHead' | 'typeFooter' | 'hover' | 'selected';
declare const TableRow: React.ComponentType<TableRowProps>;

View File

@@ -1,9 +1,6 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import withStyles from '../styles/withStyles';
@@ -18,19 +15,21 @@ export const styles = theme => ({
},
verticalAlign: 'middle'
},
head: {
typeHead: {
height: 56
},
footer: {
typeFooter: {
height: 56
},
selected: {
backgroundColor: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.04)' // grey[100]
: 'rgba(255, 255, 255, 0.08)'
},
hover: {
'&:hover': {
background: theme.palette.background.contentFrame
backgroundColor: theme.palette.type === 'light' ? 'rgba(0, 0, 0, 0.07)' // grey[200]
: 'rgba(255, 255, 255, 0.14)'
}
},
selected: {
background: theme.palette.background.appBar
}
});
@@ -42,32 +41,55 @@ function TableRow(props, context) {
const {
classes,
className: classNameProp,
children,
component: Component,
hover,
selected
} = props,
other = _objectWithoutProperties(props, ['classes', 'className', 'children', 'component', 'hover', 'selected']);
other = _objectWithoutProperties(props, ['classes', 'className', 'component', 'hover', 'selected']);
const { table } = context;
const className = classNames(classes.root, {
[classes.head]: table && table.head,
[classes.footer]: table && table.footer,
[classes.typeHead]: table && table.head,
[classes.typeFooter]: table && table.footer,
[classes.hover]: table && hover,
[classes.selected]: table && selected
}, classNameProp);
return React.createElement(
Component,
_extends({ className: className }, other),
children
);
return React.createElement(Component, _extends({ className: className }, other));
}
TableRow.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* Should be valid `<tr>` children such as `TableCell`.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The component used for the root node.
* Either a string to use a DOM element or a component.
*/
component: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
/**
* If `true`, the table row will shade on hover.
*/
hover: PropTypes.bool,
/**
* If `true`, the table row will have the selected shading.
*/
selected: PropTypes.bool
} : {};
TableRow.defaultProps = {
component: 'tr',
hover: false,
selected: false,
component: 'tr'
selected: false
};
TableRow.contextTypes = {

View File

@@ -2,21 +2,13 @@ import * as React from 'react';
import { StandardProps } from '..';
import { ButtonBaseProps, ButtonBaseClassKey } from '../ButtonBase';
export interface TableSortLabelProps extends StandardProps<
ButtonBaseProps,
TableSortLabelClassKey
> {
export interface TableSortLabelProps
extends StandardProps<ButtonBaseProps, TableSortLabelClassKey> {
active?: boolean;
direction?: 'asc' | 'desc';
}
export type TableSortLabelClassKey =
| ButtonBaseClassKey
| 'active'
| 'icon'
| 'desc'
| 'asc'
;
export type TableSortLabelClassKey = ButtonBaseClassKey | 'active' | 'icon' | 'desc' | 'asc';
declare const TableSortLabel: React.ComponentType<TableSortLabelProps>;

View File

@@ -1,15 +1,13 @@
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
import _extends from 'babel-runtime/helpers/extends';
import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
// @inheritedComponent ButtonBase
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import ArrowDownwardIcon from '../internal/svg-icons/ArrowDownward';
import withStyles from '../styles/withStyles';
import ButtonBase from '../ButtonBase';
import ArrowDownwardIcon from '../svg-icons/ArrowDownward';
export const styles = theme => ({
root: {
@@ -72,6 +70,29 @@ function TableSortLabel(props) {
);
}
TableSortLabel.propTypes = process.env.NODE_ENV !== "production" ? {
/**
* If `true`, the label will have the active styling (should be true for the sorted column).
*/
active: PropTypes.bool,
/**
* Label contents, the arrow will be appended automatically.
*/
children: PropTypes.node,
/**
* Useful to extend the style applied to components.
*/
classes: PropTypes.object.isRequired,
/**
* @ignore
*/
className: PropTypes.string,
/**
* The current sort direction.
*/
direction: PropTypes.oneOf(['asc', 'desc'])
} : {};
TableSortLabel.defaultProps = {
active: false,
direction: 'desc'