Skip to content
Closed
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
@@ -1,6 +1,6 @@
import * as React from 'react';

export interface InternalDropdownItemProps extends React.HTMLProps<HTMLAnchorElement> {
export interface InternalDropdownItemProps extends React.HTMLProps<HTMLDivElement> {
/** Anything which can be rendered as dropdown item */
children?: React.ReactNode;
/** Classes applied to root element of dropdown item */
Expand All @@ -25,5 +25,5 @@ export interface InternalDropdownItemProps extends React.HTMLProps<HTMLAnchorEle
sendRef?: (index: number, ref: any, isDisabled: boolean) => void
};
/** Callback for click event */
onClick?: (event:React.MouseEvent<HTMLAnchorElement>|React.KeyboardEvent) => void;
onClick?: (event: any) => void;
}
24 changes: 15 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 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"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
Expand All @@ -59,12 +62,15 @@
"@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",
"typescript": "3.4.5"
}
}

This file was deleted.

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

//todo: export from react-core as enum
export enum DropdownPosition {
right = 'right',
left= 'left'
}

//todo: export from react-core as enum
export enum DropdownDirection {
up = 'up',
down = 'down',
}

export interface ActionsItem extends Omit<DropdownItemProps, 'title'> {
isSeparator?: boolean;
itemKey?: string;
title?: string | React.ReactNode;
}

export interface ActionsColumnProps {
children?: React.ReactNode;
items: ActionsItem[];
isDisabled?: boolean;
dropdownPosition?: DropdownPosition;
dropdownDirection?: DropdownDirection;
rowData?: object | undefined;
extraData?: { rowIndex: number, columnIndex: number, column: object, property: string };
};

export interface ActionsColumnState {
isOpen: boolean;
}

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

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

onSelect = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>,
onClick: ((event: React.MouseEvent<HTMLAnchorElement, MouseEvent>, rowIndex: number | undefined, rowData: object | undefined, extraData: object | undefined) => void) | undefined): void => {
const { rowData, extraData } = this.props;
event.preventDefault();
onClick && onClick(event, 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>
);
}
}

export default ActionsColumn;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FunctionComponent } from 'react';

declare const BodyCell: FunctionComponent<any>;

export default BodyCell;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Component } from 'react';

declare const BodyWrapper: Component<any>;

export default BodyWrapper;

This file was deleted.

38 changes: 0 additions & 38 deletions packages/patternfly-4/react-table/src/components/Table/Header.js

This file was deleted.

32 changes: 32 additions & 0 deletions packages/patternfly-4/react-table/src/components/Table/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import { Header } from './base';
import { IHeaderRow, TableContext } from './Table';
import { RowsType } from './base/types';

interface ContextHeaderProps {
className?: string;
headerRows?: IHeaderRow[];
}

const ContextHeader: React.FunctionComponent<ContextHeaderProps> = ({
className = '',
headerRows = undefined as IHeaderRow[],
...props
} : ContextHeaderProps ) => (
// note: IHeader[] can be made to extend RowsTypes[] in the future so base types are consistent
<Header {...props} headerRows={headerRows as RowsType[]} className={className} />
);

export interface HeaderProps extends React.HTMLProps<HTMLTableRowElement> {
className?: string;
}

const TableHeader: React.FunctionComponent<HeaderProps> = ({
...props
} : HeaderProps ) => (
<TableContext.Consumer>
{({ headerRows }) => <ContextHeader {...props} headerRows={headerRows} />}
</TableContext.Consumer>
);

export default TableHeader;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { FunctionComponent } from 'react';

declare const HeaderCell: FunctionComponent<any>;

export default HeaderCell;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import * as React from 'react';
import { mount } from 'enzyme';
import RowWrapper from './RowWrapper';

Expand Down
Loading