Skip to content

Commit 5037a02

Browse files
Merge pull request securedeveloper#83 from daugsbi/master
Typescript definitions for components
2 parents f2fe103 + bc70bc7 commit 5037a02

File tree

2 files changed

+58
-39
lines changed

2 files changed

+58
-39
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "react-data-export",
33
"version": "0.6.0",
44
"main": "dist/index.js",
5+
"types": "types/index.d.ts",
56
"description": "A set of tools to export dataset from react to different formats.",
67
"repository": {
78
"type": "git",

types/index.d.ts

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,75 @@
11
/* index.d.ts (C) react-data-export */
22

33
// TypeScript Version: 2.2
4+
declare module 'react-data-export' {
5+
import * as React from 'react'
46

5-
export interface ExcelFileProps {
7+
export interface ExcelFileProps {
68
filename?: string;
79
fileExtension?: string;
810
element?: any; //Download Element
9-
children?: Array<ExcelSheetProps>;
10-
}
11+
children?: Array<React.ReactChild> | React.ReactChild; // Array<ExcelSheetProps>;
12+
}
1113

12-
export interface ExcelSheetProps {
14+
export interface ExcelSheetProps {
1315
name: string;
1416
data?: Array<object>;
1517
dataSet?: Array<ExcelSheetData>;
1618
value?: Array<string> | Function;
17-
children?: Array<ExcelColumnProps>
18-
}
19+
children?: Array<React.ReactChild> | React.ReactChild; // Array<ExcelColumnProps>
20+
}
1921

20-
export interface ExcelSheetData {
22+
export interface ExcelSheetData {
2123
xSteps?: number;
2224
ySteps?: number;
2325
columns: Array<string>;
2426
data: Array<ExcelCellData>;
25-
}
27+
}
2628

27-
export type ExcelCellData = ExcelValue | ExcelCell;
28-
export type ExcelValue = string | number | Date | boolean;
29+
export type ExcelCellData = ExcelValue | ExcelCell | Array<ExcelValue>;
30+
export type ExcelValue = string | number | Date | boolean;
2931

30-
export interface ExcelCell {
32+
export interface ExcelCell {
3133
value: ExcelCell;
3234
style: ExcelStyle;
33-
}
35+
}
3436

35-
export interface ExcelColumnProps {
37+
export interface ExcelColumnProps {
3638
label: string;
3739
value: number | boolean | string | Function;
38-
}
40+
}
3941

40-
export interface ExcelStyle {
42+
export interface ExcelStyle {
4143
fill?: ExcelCellFillType;
4244
font?: ExcelFont;
4345
numFmt?: ExcelNumFormat;
4446
alignment?: ExcelAlignment;
4547
border?: ExcelBorder;
46-
}
48+
}
4749

48-
/* ExcelCell Fill Type */
49-
export type ExcelCellPatternType = "solid" | "none";
50+
/* ExcelCell Fill Type */
51+
export type ExcelCellPatternType = "solid" | "none";
5052

51-
export interface ExcelColorSpec {
53+
export interface ExcelColorSpec {
5254
auto?: number; //default 1
5355
rgb?: string; //hex ARGB color
5456
theme?: ExcelTheme;
5557
indexed?: number;
56-
}
58+
}
5759

58-
export interface ExcelTheme {
60+
export interface ExcelTheme {
5961
theme: string;
6062
tint: string;
61-
}
63+
}
6264

63-
export interface ExcelCellFillType {
65+
export interface ExcelCellFillType {
6466
patternType?: ExcelCellPatternType;
6567
fgColor?: ExcelColorSpec;
6668
bgColor?: ExcelColorSpec;
67-
}
69+
}
6870

69-
/* Excel Font */
70-
export interface ExcelFont {
71+
/* Excel Font */
72+
export interface ExcelFont {
7173
name?: string; // default `"Calibri"`
7274
sz?: number; //font size in points default 11
7375
color?: ExcelColorSpec;
@@ -78,33 +80,33 @@ export interface ExcelFont {
7880
outline?: boolean;
7981
shadow?: boolean;
8082
vertAlign?: boolean;
81-
}
83+
}
8284

83-
/* ExcelNumFormat */
84-
export type ExcelNumFormat = "0" | "0.00%" | "0.0%" | "0.00%;\\(0.00%\\);\\-;@" | "m/dd/yy" | string;
85+
/* ExcelNumFormat */
86+
export type ExcelNumFormat = "0" | "0.00%" | "0.0%" | "0.00%;\\(0.00%\\);\\-;@" | "m/dd/yy" | string;
8587

86-
/* ExcelAlignment */
87-
export interface ExcelAlignment {
88+
/* ExcelAlignment */
89+
export interface ExcelAlignment {
8890
vertical?: ExcelAlignmentType;
8991
horizontal?: ExcelAlignmentType;
9092
wrapText?: boolean;
9193
readingOrder?: ExcelReadingOrder;
9294
textRotation?: ExcelTextRotation;
93-
}
95+
}
9496

95-
export type ExcelTextRotation = 0 | 45 | 90 | 135 | 180 | 255;
97+
export type ExcelTextRotation = 0 | 45 | 90 | 135 | 180 | 255;
9698

97-
export enum ExcelReadingOrder { LeftToRight = 1, RightToLeft}
99+
export enum ExcelReadingOrder { LeftToRight = 1, RightToLeft}
98100

99-
export type ExcelAlignmentType = "bottom" | "center" | "top";
101+
export type ExcelAlignmentType = "bottom" | "center" | "top";
100102

101-
/* ExcelBorder */
102-
export interface ExcelBorder {
103+
/* ExcelBorder */
104+
export interface ExcelBorder {
103105
style: ExcelBorderStyle;
104106
color: ExcelColorSpec;
105-
}
107+
}
106108

107-
export type ExcelBorderStyle =
109+
export type ExcelBorderStyle =
108110
"thin"
109111
| "medium"
110112
| "thick"
@@ -117,3 +119,19 @@ export type ExcelBorderStyle =
117119
| "dashDotDot"
118120
| "mediumDashDotDot"
119121
| "slantDashDot";
122+
123+
export class ExcelColumn extends React.Component<ExcelColumnProps, any> {
124+
}
125+
126+
export class ExcelSheet extends React.Component<ExcelSheetProps, any> {
127+
}
128+
129+
export class ExcelFile extends React.Component<ExcelFileProps, any> {
130+
}
131+
132+
export namespace ReactExport {
133+
export class ExcelFile extends React.Component<ExcelFileProps, any> {
134+
}
135+
}
136+
export default ReactExport
137+
}

0 commit comments

Comments
 (0)