📝 README updated 📝 👈🏼 ✏️ ☝🏼

This commit is contained in:
abdennour 2016-11-26 07:50:39 +03:00
commit 34fe75070a
7 changed files with 162 additions and 34 deletions

View file

@ -1,21 +0,0 @@
import React from 'react';
import {buildURI} from '../core';
import {defaultProps, PropTypes, PropsNotForwarded} from '../metaProps';
class CSVDownload extends React.Component {
constructor(props) {
super(props);
}
componentDidMount(){
window.open(buildURI(this.props.data));
}
render(){
return (null)
}
}
CSVDownload.defaultProps = defaultProps;
CSVDownload.PropTypes = PropTypes;
CSVDownload.PropsNotForwarded = PropsNotForwarded;
export default CSVDownload;

View file

@ -0,0 +1,31 @@
import React from 'react';
import {buildURI} from '../core';
import {defaultProps as CommonDefaultProps, PropTypes} from '../metaProps';
const defaultProps = {
target: '_blank'
};
class CSVDownload extends React.Component {
constructor(props) {
super(props);
}
componentDidMount(){
this.page = window.open(buildURI(this.props.data, this.props.headers), this.props.target, this.props.specs, this.props.replace);
}
getWindow() {
return this.page;
}
render(){
return (null)
}
}
CSVDownload.defaultProps = Object.assign(
CommonDefaultProps,
defaultProps
);
CSVDownload.PropTypes = PropTypes;
export default CSVDownload;

View file

@ -1,16 +1,17 @@
import React from 'react';
import {buildURI} from '../core';
import {defaultProps, PropTypes, PropsNotForwarded} from '../metaProps';
import XObject from 'x-object/safe';
class CSVLink extends React.Component {
constructor(props) {
super(props);
}
render(){
return (
<a {...this.props} href={buildURI(this.props.data, this.props)}>
<a {...XObject.filter(this.props, (k, v) => !PropsNotForwarded.includes(k))}
href={buildURI(this.props.data, this.props.headers)}>
{this.props.children}
</a>
)
@ -18,6 +19,5 @@ class CSVLink extends React.Component {
}
CSVLink.defaultProps = defaultProps;
CSVLink.PropTypes = PropTypes;
CSVLink.PropsNotForwarded = PropsNotForwarded;
export default CSVLink;

View file

@ -1,5 +1,5 @@
import Download from './Download';
import Link from './Link';
import Download from './components/Download';
import Link from './components/Link';
export const CSVDownload = Download;
export const CSVLink = Link;

View file

@ -1,13 +1,28 @@
import React from 'react';
export const PropTypes = {
data: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.array
]).isRequired,
headers: React.PropTypes.array,
target: React.PropTypes.string
};
export const defaultProps = {
};
export const PropTypes = {
data: React.PropTypes.array.isRequired,
headers: React.PropTypes.array
};
export const PropsNotForwarded = [
`data`
`data`,
`headers`
];
// export const DownloadPropTypes = Object.assign(
// {},
// PropTypes,
// {
// : ,
// }
// );