Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { createPortal } from 'react-dom';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { css } from '@patternfly/react-styles';
import { RowWrapper as ReactTableRowWrapper } from '@patternfly/react-table';
import {
combineFunctions,
shallowLeftSideEquals,
Expand All @@ -17,7 +16,6 @@ import { inlineEditCss, inlineEditStyles as styles } from './css/inline-edit-css
inlineEditCss.inject();

const propTypes = {
...ReactTableRowWrapper.propTypes,
trRef: PropTypes.func,
className: PropTypes.string,
onScroll: PropTypes.func,
Expand All @@ -38,7 +36,6 @@ const propTypes = {
};

const defaultProps = {
...ReactTableRowWrapper.defaultProps,
trRef: undefined,
className: '',
onScroll: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const Body = ({ BodyComponent, rows, editConfig, onRowClick, ...props }) => {
};

Body.propTypes = {
BodyComponent: PropTypes.node.isRequired,
BodyComponent: PropTypes.any.isRequired,
rows: PropTypes.array,
editConfig: PropTypes.any,
onRowClick: PropTypes.func
Expand Down
27 changes: 18 additions & 9 deletions packages/patternfly-4/react-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "dist/js/index.js",
"module": "dist/esm/index.js",
"types": "dist/js/index.d.ts",
"patternfly:src": "src/",
"sideEffects": false,
"publishConfig": {
"access": "public",
Expand All @@ -17,8 +18,7 @@
"keywords": [
"react",
"patternfly",
"table",
"reacttabular"
"table"
],
"author": "Red Hat",
"license": "MIT",
Expand All @@ -42,13 +42,16 @@
"react-dom": "^15.6.2 || ^16.4.0"
},
"scripts": {
"build": "yarn build:babel && node ./scripts/copyTS.js && node ./build/copyStyles.js",
"build:babel": "concurrently \"yarn build:babel:esm && yarn build:babel:umd\" \"yarn build:babel:cjs\"",
"build:babel:cjs": "babel --source-maps --extensions \".js,.ts,.tsx\" src --out-dir dist/js --presets=@babel/env",
"build:babel:esm": "babel --source-maps --extensions \".js,.ts,.tsx\" src --out-dir dist/esm",
"build:babel:umd": "babel --source-maps --extensions \".js\" dist/esm --out-dir dist/umd --plugins=transform-es2015-modules-umd",
"build": "yarn typecheck && yarn build:babel && yarn build:types && node ./scripts/copyTS.js && node ./build/copyStyles.js",
"build:babel": "concurrently 'yarn build:babel:esm && yarn build:babel:umd' 'yarn build:babel:cjs'",
"build:babel:cjs": "babel --source-maps --extensions '.js,.ts,.tsx' src --out-dir dist/js --presets=@babel/env",
"build:babel:esm": "babel --source-maps --extensions '.js,.ts,.tsx' src --out-dir dist/esm",
"build:babel:umd": "babel --source-maps --extensions '.js' dist/esm --out-dir dist/umd --plugins=transform-es2015-modules-umd",
"build:types": "tsc -p tsconfig.gen-dts.json",
"clean": "rimraf dist",
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose"
"develop": "yarn build:babel:esm --skip-initial-build --watch --verbose --source-maps",
"lint:ts": "tslint -p tsconfig.typecheck.json",
"typecheck": "tsc -p tsconfig.typecheck.json && yarn lint:ts"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand All @@ -59,12 +62,18 @@
"@babel/plugin-transform-typescript": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@types/classnames": "^2.2.9",
"@types/lodash-es": "^4.17.3",
"babel-plugin-transform-es2015-modules-umd": "^6.24.1",
"babel-plugin-typescript-to-proptypes": "^0.17.1",
"css": "^2.2.3",
"enzyme": "3.9.0",
"fs-extra": "^6.0.1",
"glob": "^7.1.2",
"rimraf": "^2.6.2"
"rimraf": "^2.6.2",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0",
"tslint-react": "^3.6.0",
"typescript": "3.4.5"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import * as React from 'react';
import {
Dropdown,
DropdownPosition,
DropdownDirection,
KebabToggle,
DropdownItem,
DropdownSeparator
} from '@patternfly/react-core';

import { IAction, IExtraData, IRowData } from './Table';

export interface ActionsColumnProps {
children?: React.ReactNode;
items: IAction[];
isDisabled?: boolean;
dropdownPosition?: DropdownPosition;
dropdownDirection?: DropdownDirection;
rowData?: IRowData;
extraData?: IExtraData;
};

export interface ActionsColumnState {
isOpen: boolean;
}

export class ActionsColumn extends React.Component<ActionsColumnProps, ActionsColumnState> {
static defaultProps = {
children: null as React.ReactNode,
items: [] as IAction[],
dropdownPosition: DropdownPosition.right,
dropdownDirection: DropdownDirection.down,
rowData: {} as IRowData,
extraData: {} as IExtraData
}
constructor (props: ActionsColumnProps){
super(props);
this.state = {
isOpen: false
};
}

onToggle = (isOpen: boolean): void => {
this.setState({
isOpen
});
}

onSelect = (event: React.MouseEvent<any> | React.KeyboardEvent | MouseEvent,
onClick: ((event: React.MouseEvent, rowIndex: number | undefined, rowData: IRowData, extraData: IExtraData) => void) | undefined): void => {
const { rowData, extraData } = this.props;
event.preventDefault();
// tslint:disable-next-line:no-unused-expression
onClick && onClick(event as React.MouseEvent, extraData && extraData.rowIndex, rowData, extraData);
this.setState({
isOpen: !this.state.isOpen
});
}

render() {
const { isOpen } = this.state;
const { items, children, dropdownPosition, dropdownDirection, isDisabled } = this.props;
return (
<React.Fragment>
<Dropdown
toggle={<KebabToggle isDisabled={isDisabled} onToggle={this.onToggle} />}
position={dropdownPosition}
direction={dropdownDirection}
isOpen={isOpen}
dropdownItems={items.map(
({ title, itemKey, onClick, isSeparator, ...props }, key) =>
isSeparator ? (
<DropdownSeparator {...props} key={itemKey || key} data-key={itemKey || key} />
) : (
<DropdownItem
onClick={event => this.onSelect(event, onClick)}
{...props}
key={itemKey || key}
data-key={itemKey || key}
>
{title}
</DropdownItem>
)
)}
isPlain
/>
{children}
</React.Fragment>
);
}
}
10 changes: 0 additions & 10 deletions packages/patternfly-4/react-table/src/components/Table/Body.d.ts

This file was deleted.

Loading