Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
imsuvesh committed May 16, 2023
1 parent 7d593ac commit 35515cc
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 2 deletions.
144 changes: 144 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/* index.d.ts (C) react-data-export */

// TypeScript Version: 2.2
declare module 'react-data-export' {
import * as React from 'react';

export interface ExcelFileProps {
filename?: string;
fileExtension?: string;
element?: any; //Download Element
children?: Array<React.ReactElement> | React.ReactElement; // Array<ExcelSheetProps>;
}

export interface ExcelSheetProps {
name: string;
data?: Array<object>;
dataSet?: Array<ExcelSheetData>;
value?: Array<string> | Function;
children?: Array<React.ReactElement> | React.ReactElement; // Array<ExcelColumnProps>
}

export interface ExcelSheetData {
xSteps?: number;
ySteps?: number;
columns: Array<string> | Array<ExcelCellHeader>;
data: Array<Array<ExcelCellData>>;
}

export type ExcelCellData = ExcelValue | ExcelCell | Array<ExcelValue>;
export type ExcelValue = string | number | Date | boolean;

export interface ExcelCellHeader {
title: string;
style?: ExcelStyle;
}

export interface ExcelCell {
value: ExcelValue;
style?: ExcelStyle;
}

export interface ExcelColumnProps {
label: string;
value: number | boolean | string | Function;
}

export interface ExcelStyle {
fill?: ExcelCellFillType;
font?: ExcelFont;
numFmt?: ExcelNumFormat;
alignment?: ExcelAlignment;
border?: ExcelBorder;
}

/* ExcelCell Fill Type */
export type ExcelCellPatternType = "solid" | "none";

export interface ExcelColorSpec {
auto?: number; //default 1
rgb?: string; //hex ARGB color
theme?: ExcelTheme;
indexed?: number;
}

export interface ExcelTheme {
theme: string;
tint: string;
}

export interface ExcelCellFillType {
patternType?: ExcelCellPatternType;
fgColor?: ExcelColorSpec;
bgColor?: ExcelColorSpec;
}

/* Excel Font */
export interface ExcelFont {
name?: string; // default `"Calibri"`
sz?: number; //font size in points default 11
color?: ExcelColorSpec;
bold?: boolean;
underline?: boolean;
italic?: boolean;
strike?: boolean;
outline?: boolean;
shadow?: boolean;
vertAlign?: boolean;
}

/* ExcelNumFormat */
export type ExcelNumFormat = "0" | "0.00%" | "0.0%" | "0.00%;\\(0.00%\\);\\-;@" | "m/dd/yy" | string;

/* ExcelAlignment */
export interface ExcelAlignment {
vertical?: ExcelAlignmentType;
horizontal?: ExcelAlignmentType;
wrapText?: boolean;
readingOrder?: ExcelReadingOrder;
textRotation?: ExcelTextRotation;
}

export type ExcelTextRotation = 0 | 45 | 90 | 135 | 180 | 255;

export enum ExcelReadingOrder { LeftToRight = 1, RightToLeft}

export type ExcelAlignmentType = "bottom" | "center" | "top";

/* ExcelBorder */
export interface ExcelBorder {
style: ExcelBorderStyle;
color: ExcelColorSpec;
}

export type ExcelBorderStyle =
"thin"
| "medium"
| "thick"
| "dotted"
| "hair"
| "dashed"
| "mediumDashed"
| "dashDot"
| "mediumDashDot"
| "dashDotDot"
| "mediumDashDotDot"
| "slantDashDot";

export class ExcelColumn extends React.Component<ExcelColumnProps, any> {
}

export class ExcelSheet extends React.Component<ExcelSheetProps, any> {
}

export class ExcelFile extends React.Component<ExcelFileProps, any> {
}

export namespace ReactExport {
export class ExcelFile extends React.Component<ExcelFileProps, any> {
static ExcelSheet: React.ElementType<ExcelSheetProps>;
static ExcelColumn: React.ElementType<ExcelColumnProps>;
}
}
export default ReactExport
}
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* index.d.ts (C) react-data-export */

// TypeScript Version: 2.2
declare module 'react-data-export' {
// declare module 'react-data-export' {
import * as React from 'react';

export interface ExcelFileProps {
Expand Down Expand Up @@ -141,4 +141,4 @@ declare module 'react-data-export' {
}
}
export default ReactExport
}
// }

0 comments on commit 35515cc

Please sign in to comment.