Skip to content

Commit 0dc302a

Browse files
committed
fix(full package): fixed types
#5
1 parent e0ef1d6 commit 0dc302a

10 files changed

Lines changed: 23 additions & 100 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ yarn add react-xlsx-wrapper@latest
2323

2424
- [Simple Excel Export](examples/simple_excel_export_01.md)
2525
- [Excel Export with Dataset](examples/simple_excel_export_02.md)
26-
- [Excel Export with Custom Download Button](examples/with_custom_download_element.md)
2726
- [Excel Export with custom cells style](examples/styled_excel_sheet.md)
2827

2928
## Excel Props
File renamed without changes.

dist/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ Object.defineProperty(exports, "__esModule", {
99
value: true
1010
});
1111
exports.ExcelColumn = exports.ExcelSheet = void 0;
12-
var ExcelFileNew_1 = __importDefault(require("./ExcelPlugin/components/ExcelFileNew"));
12+
var ExcelFile_1 = __importDefault(require("./ExcelPlugin/components/ExcelFile"));
1313
var ExcelSheet_1 = __importDefault(require("./ExcelPlugin/elements/ExcelSheet"));
1414
exports.ExcelSheet = ExcelSheet_1.default;
1515
var ExcelColumn_1 = __importDefault(require("./ExcelPlugin/elements/ExcelColumn"));
1616
exports.ExcelColumn = ExcelColumn_1.default;
17-
ExcelFileNew_1.default.ExcelSheet = ExcelSheet_1.default;
18-
ExcelFileNew_1.default.ExcelColumn = ExcelColumn_1.default;
19-
exports.default = ExcelFileNew_1.default;
17+
ExcelFile_1.default.ExcelSheet = ExcelSheet_1.default;
18+
ExcelFile_1.default.ExcelColumn = ExcelColumn_1.default;
19+
exports.default = ExcelFile_1.default;

examples/with_custom_download_element.md

Lines changed: 0 additions & 65 deletions
This file was deleted.
File renamed without changes.

src-js/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
44
};
55
Object.defineProperty(exports, "__esModule", { value: true });
66
exports.ExcelColumn = exports.ExcelSheet = void 0;
7-
const ExcelFileNew_1 = __importDefault(require("./ExcelPlugin/components/ExcelFileNew"));
7+
const ExcelFile_1 = __importDefault(require("./ExcelPlugin/components/ExcelFile"));
88
const ExcelSheet_1 = __importDefault(require("./ExcelPlugin/elements/ExcelSheet"));
99
exports.ExcelSheet = ExcelSheet_1.default;
1010
const ExcelColumn_1 = __importDefault(require("./ExcelPlugin/elements/ExcelColumn"));
1111
exports.ExcelColumn = ExcelColumn_1.default;
12-
ExcelFileNew_1.default.ExcelSheet = ExcelSheet_1.default;
13-
ExcelFileNew_1.default.ExcelColumn = ExcelColumn_1.default;
14-
exports.default = ExcelFileNew_1.default;
12+
ExcelFile_1.default.ExcelSheet = ExcelSheet_1.default;
13+
ExcelFile_1.default.ExcelColumn = ExcelColumn_1.default;
14+
exports.default = ExcelFile_1.default;

src/ExcelPlugin/components/ExcelFileNew.tsx renamed to src/ExcelPlugin/components/ExcelFile.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { utils, writeFile } from "xlsx-js-style";
33
import type { BookType, WorkSheet } from "xlsx-js-style";
44
import { excelSheetFromAoA, excelSheetFromDataSet } from "../utils/DataUtil";
55
import type {
6-
DataProps,
76
ExcelColumnProps,
8-
ExcelSheetData,
97
ExcelSheetProps,
108
ExcelValue,
119
} from "react-xlsx-wrapper";
@@ -15,7 +13,7 @@ interface ExcelFileProps {
1513
filename?: string;
1614
fileExtension?: BookType;
1715
element?: React.ReactNode;
18-
children: React.ReactElement<ExcelSheetProps<DataProps, ExcelSheetData>>[];
16+
children: React.ReactElement<ExcelSheetProps>[];
1917
}
2018

2119
class ExcelFile extends React.Component<ExcelFileProps> {
@@ -39,9 +37,7 @@ class ExcelFile extends React.Component<ExcelFileProps> {
3937
}
4038
}
4139

42-
createSheetData = (
43-
sheet: React.ReactElement<ExcelSheetProps<DataProps, ExcelSheetData>>
44-
) => {
40+
createSheetData = (sheet: React.ReactElement<ExcelSheetProps>) => {
4541
const columns = sheet.props.children;
4642
const sheetData = [
4743
React.Children.map(
@@ -52,14 +48,13 @@ class ExcelFile extends React.Component<ExcelFileProps> {
5248

5349
const data = sheet.props.data;
5450
if (!data) throw new Error("No data provided");
55-
data.forEach((row: DataProps) => {
51+
data.forEach((row: any) => {
5652
let sheetRow: ExcelValue[] = [];
5753

5854
React.Children.forEach(
5955
columns,
6056
(column: React.ReactElement<ExcelColumnProps>) => {
61-
const getValue = (row: DataProps) =>
62-
row[column.props.value as string];
57+
const getValue = (row: any) => row[column.props.value as string];
6358
const itemValue = getValue(row);
6459
sheetRow.push(isNaN(Number(itemValue)) ? itemValue || "" : itemValue);
6560
}

src/ExcelPlugin/elements/ExcelSheet.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import React, { Component } from "react";
22
import ExcelColumn from "./ExcelColumn";
3-
import type { DataProps, ExcelValue, ExcelSheetData } from "react-xlsx-wrapper";
3+
import type { ExcelValue, ExcelSheetData } from "react-xlsx-wrapper";
44

5-
export interface ExcelSheetProps<D, DS> {
5+
export interface ExcelSheetProps {
66
name: string;
7-
data?: D[];
8-
dataSet?: DS[];
7+
data?: any[];
8+
dataSet?: ExcelSheetData[];
99
value: ExcelValue[] | (() => void);
1010
children: React.ReactElement<typeof ExcelColumn>[];
1111
}
12-
export default class ExcelSheet extends Component<
13-
ExcelSheetProps<DataProps, ExcelSheetData>
14-
> {
15-
constructor(props: ExcelSheetProps<DataProps, ExcelSheetData>) {
12+
export default class ExcelSheet extends Component<ExcelSheetProps> {
13+
constructor(props: ExcelSheetProps) {
1614
super(props);
1715

1816
if (!props.children.every((child) => child.type === ExcelColumn)) {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ExcelFile from "./ExcelPlugin/components/ExcelFileNew";
1+
import ExcelFile from "./ExcelPlugin/components/ExcelFile";
22
import ExcelSheet from "./ExcelPlugin/elements/ExcelSheet";
33
import ExcelColumn from "./ExcelPlugin/elements/ExcelColumn";
44

types/index.d.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
declare module 'react-xlsx-wrapper' {
22
import * as React from 'react';
3-
4-
export type DataProps = {
5-
[key: string]: ExcelValue;
6-
};
73

84
export interface ExcelFileProps {
95
filename?: string;
@@ -12,10 +8,10 @@ declare module 'react-xlsx-wrapper' {
128
children?: Array<React.ReactElement> | React.ReactElement; // Array<ExcelSheetProps>;
139
}
1410

15-
export interface ExcelSheetProps<D, DS> {
11+
export interface ExcelSheetProps {
1612
name: string;
17-
data?: D[];
18-
dataSet?: DS[];
13+
data?: any[];
14+
dataSet?: ExcelSheetData[];
1915
value: ExcelValue[] | (() => void);
2016
children: React.ReactElement | Array<React.ReactElement>;
2117
}
@@ -140,7 +136,7 @@ declare module 'react-xlsx-wrapper' {
140136
export class ExcelColumn extends React.Component<ExcelColumnProps, any> {
141137
}
142138

143-
export class ExcelSheet extends React.Component<ExcelSheetProps<DataProps|undefined, ExcelSheetData|undefined>, any> {
139+
export class ExcelSheet extends React.Component<ExcelSheetProps, any> {
144140
}
145141

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

0 commit comments

Comments
 (0)