Merge pull request #29 from Saturate/master

Add TypeScript Definition
This commit is contained in:
Rick van Lieshout 2018-11-28 09:01:50 +01:00 committed by GitHub
commit 04c553fded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 2 deletions

View File

@ -7,7 +7,9 @@
"version": "1.9.0",
"description": "A small, simple and customizable cookie consent bar for use in React applications.",
"main": "build/index.js",
"types": "build/index.d.ts",
"dependencies": {
"copy-webpack-plugin": "^4.6.0",
"js-cookie": "^2.2.0",
"react": "^16.4.0"
},

29
src/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
import * as React from 'react';
import Cookies from "js-cookie";
export interface CookieConsentProps {
location?: "top" | "bottom" | "none",
style?: object,
buttonStyle?: object,
contentStyle?: object,
children?: React.ReactNode,
disableStyles?: boolean,
hideOnAccept?: boolean,
onAccept?: Function,
buttonText?: Function | React.ReactNode,
cookieName?: string,
cookieValue?: string | boolean | number,
debug?: boolean,
expires?: number,
containerClasses?: string,
contentClasses?: string,
buttonClasses?: string,
buttonId?: string,
acceptOnScroll?: boolean,
acceptOnScrollPercentage?: number,
extraCookieOptions?: object
}
export default class CookieConsent extends React.Component<CookieConsentProps, {}> {}
export { Cookies };

View File

@ -1,4 +1,6 @@
var path = require('path');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: './src/index.js',
output: {
@ -23,5 +25,8 @@ module.exports = {
},
externals: {
'react': 'commonjs react' // this line is just to use the React dependency of our parent-testing-project instead of using our own React.
}
};
},
plugins: [
new CopyWebpackPlugin([{ from: 'src/index.d.ts', to: 'index.d.ts' }])
]
};