📝 README updated 📝 👈🏼 ✏️ ☝🏼
This commit is contained in:
parent
067281b7a3
commit
34fe75070a
7 changed files with 162 additions and 34 deletions
|
|
@ -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;
|
||||
31
src/components/Download.js
Normal file
31
src/components/Download.js
Normal 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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
// {
|
||||
// : ,
|
||||
// }
|
||||
// );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue