Skip to content

Commit 04c553f

Browse files
authored
Merge pull request #29 from Saturate/master
Add TypeScript Definition
2 parents 48995d9 + ef192c0 commit 04c553f

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"version": "1.9.0",
88
"description": "A small, simple and customizable cookie consent bar for use in React applications.",
99
"main": "build/index.js",
10+
"types": "build/index.d.ts",
1011
"dependencies": {
12+
"copy-webpack-plugin": "^4.6.0",
1113
"js-cookie": "^2.2.0",
1214
"react": "^16.4.0"
1315
},

src/index.d.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as React from 'react';
2+
import Cookies from "js-cookie";
3+
4+
export interface CookieConsentProps {
5+
location?: "top" | "bottom" | "none",
6+
style?: object,
7+
buttonStyle?: object,
8+
contentStyle?: object,
9+
children?: React.ReactNode,
10+
disableStyles?: boolean,
11+
hideOnAccept?: boolean,
12+
onAccept?: Function,
13+
buttonText?: Function | React.ReactNode,
14+
cookieName?: string,
15+
cookieValue?: string | boolean | number,
16+
debug?: boolean,
17+
expires?: number,
18+
containerClasses?: string,
19+
contentClasses?: string,
20+
buttonClasses?: string,
21+
buttonId?: string,
22+
acceptOnScroll?: boolean,
23+
acceptOnScrollPercentage?: number,
24+
extraCookieOptions?: object
25+
}
26+
27+
export default class CookieConsent extends React.Component<CookieConsentProps, {}> {}
28+
29+
export { Cookies };

webpack.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
var path = require('path');
2+
var CopyWebpackPlugin = require('copy-webpack-plugin');
3+
24
module.exports = {
35
entry: './src/index.js',
46
output: {
@@ -23,5 +25,8 @@ module.exports = {
2325
},
2426
externals: {
2527
'react': 'commonjs react' // this line is just to use the React dependency of our parent-testing-project instead of using our own React.
26-
}
27-
};
28+
},
29+
plugins: [
30+
new CopyWebpackPlugin([{ from: 'src/index.d.ts', to: 'index.d.ts' }])
31+
]
32+
};

0 commit comments

Comments
 (0)