Export types and add addBackground function#55
Open
Ciaanh wants to merge 1 commit intonatancabral:mainfrom
Open
Export types and add addBackground function#55Ciaanh wants to merge 1 commit intonatancabral:mainfrom
Ciaanh wants to merge 1 commit intonatancabral:mainfrom
Conversation
Closed
|
This is what this lib needs |
|
I’m really looking forward to this PR merge |
|
@Ciaanh I left two comment to add missing/fix incorrect properties. Also, I suggest to move property comments to JSDoc comments so we have these 'default's available with IDE information. Here's // pdfkit-table.d.ts
declare module 'pdfkit-table' {
import PDFDocument from 'pdfkit';
export interface Rect {
x: number;
y: number;
width: number;
height: number;
}
export interface Header {
label?: string;
property?: string;
width?: number;
/** default 'left' */
align?: string;
valign?: string;
/** default '#BEBEBE' */
headerColor?: string;
/** default '0.5' */
headerOpacity?: number;
/** default 'left' */
headerAlign?: string;
columnColor?: string;
columnOpacity?: number;
backgroundColor?: string;
backgroundOpacity?: number;
background?: { color: string, opacity?: number };
renderer?: (
value: any,
indexColumn?: number,
indexRow?: number,
row?: number,
rectRow?: Rect,
rectCell?: Rect
) => string;
}
export interface DataOptions {
fontSize: number;
fontFamily: string;
separation: boolean;
}
export interface Data {
[key: string]: string | { label: string; options?: DataOptions };
}
export interface Table {
title?: string;
subtitle?: string;
headers?: (string | Header)[];
datas?: Data[];
rows?: string[][];
}
export interface DividerOptions {
disabled?: boolean;
width?: number;
opacity?: number;
}
export interface Divider {
header?: DividerOptions;
horizontal?: DividerOptions;
}
export interface Title {
label: string;
fontSize?: number;
fontFamily?: string;
color?: string;
}
export interface Options {
title?: string | Title;
subtitle?: string | Title;
width?: number;
/** default doc.x */
x?: number;
/** default doc.y */
y?: number;
divider?: Divider;
columnsSize?: number[];
/** default 5 */
columnSpacing?: number;
padding?: number[];
/** default false */
addPage?: boolean;
hideHeader?: boolean;
minRowHeight?: number;
prepareHeader?: () => PDFDocumentWithTables;
prepareRow?: (
row?: any,
indexColumn?: number,
indexRow?: number,
rectRow?: Rect,
rectCell?: Rect
) => PDFDocumentWithTables;
}
class PDFDocumentWithTables extends PDFDocument {
public table(table: Table, options?: Options): Promise<void>;
public addBackground(
rect?: Rect,
fillColor?: string,
fillOpacity?: number,
callback?: Function
);
}
export default PDFDocumentWithTables;
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In order to use the alternating row style with in a Typescript project the declaration for the function addBackground has been added.
Also exported the declared interfaces in order to facilitate the configuration in Typescript projects.