feat: Excel component API and docs improvements

This commit is contained in:
Demenech
2024-04-09 15:44:37 -03:00
parent 8b292a9bf2
commit 22038fbd4f
2 changed files with 12 additions and 6 deletions

View File

@@ -4,12 +4,14 @@ import { read, utils } from 'xlsx';
import { AgGridReact } from 'ag-grid-react'; import { AgGridReact } from 'ag-grid-react';
import 'ag-grid-community/styles/ag-grid.css'; import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css'; import 'ag-grid-community/styles/ag-theme-alpine.css';
import { Data } from '../types/properties';
export type ExcelProps = { export type ExcelProps = {
url: string; data: Pick<Data, 'url'>;
}; };
export function Excel({ url }: ExcelProps) { export function Excel({ data }: ExcelProps) {
const url = data.url;
const [isLoading, setIsLoading] = useState<boolean>(false); const [isLoading, setIsLoading] = useState<boolean>(false);
const [activeSheetName, setActiveSheetName] = useState<string>(); const [activeSheetName, setActiveSheetName] = useState<string>();
const [workbook, setWorkbook] = useState<any>(); const [workbook, setWorkbook] = useState<any>();

View File

@@ -8,9 +8,9 @@ const meta: Meta = {
component: Excel, component: Excel,
tags: ['autodocs'], tags: ['autodocs'],
argTypes: { argTypes: {
url: { data: {
description: description:
'Url of the file to be displayed e.g.: "https://url.to/data.csv"', 'Object with a `url` property pointing to the Excel file to be displayed, e.g.: `{ url: "https://url.to/data.csv" }`',
}, },
}, },
}; };
@@ -22,13 +22,17 @@ type Story = StoryObj<ExcelProps>;
export const SingleSheet: Story = { export const SingleSheet: Story = {
name: 'Excel file with just one sheet', name: 'Excel file with just one sheet',
args: { args: {
data: {
url: 'https://sheetjs.com/pres.xlsx', url: 'https://sheetjs.com/pres.xlsx',
}, },
},
}; };
export const MultipleSheet: Story = { export const MultipleSheet: Story = {
name: 'Excel file with multiple sheets', name: 'Excel file with multiple sheets',
args: { args: {
data: {
url: 'https://storage.portaljs.org/IC-Gantt-Chart-Project-Template-8857.xlsx', url: 'https://storage.portaljs.org/IC-Gantt-Chart-Project-Template-8857.xlsx',
}, },
},
}; };