react-markdown-table-ts 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts DELETED
@@ -1,144 +0,0 @@
1
- /// <reference types="react" />
2
- /**
3
- * Represents a single cell's data in the table.
4
- */
5
- export interface CellData {
6
- content: string;
7
- alignment?: "left" | "center" | "right" | "inherit" | "justify";
8
- bold?: boolean;
9
- italic?: boolean;
10
- code?: boolean;
11
- link?: string;
12
- }
13
- /**
14
- * Represents a single row in a table, consisting of cells.
15
- */
16
- export type TableRow = readonly CellData[];
17
- /**
18
- * Represents the structure of a Markdown table.
19
- */
20
- export interface InputData {
21
- inputDataHeader: CellData[];
22
- inputDataBody: readonly CellData[][];
23
- }
24
- /**
25
- * Props for the MarkdownTable component.
26
- */
27
- export interface MarkdownTableProps {
28
- /**
29
- * The entire table data as a two-dimensional array of CellData objects.
30
- * If `hasHeader` is true, the first row is treated as the header.
31
- * @default null
32
- */
33
- inputData?: CellData[][] | null;
34
- /**
35
- * Optional array specifying the alignment for each column.
36
- * Acceptable values are 'left', 'center', 'right', or 'none'.
37
- * @default []
38
- */
39
- columnAlignments?: readonly Alignment[];
40
- /**
41
- * Disables column width alignment to provide a more compact markdown table string.
42
- * @default false
43
- */
44
- isCompact?: boolean;
45
- /**
46
- * Optional flag to add a single space around cell content in the markdown table.
47
- * When true, one space is added before and after the content in each cell.
48
- * @default true
49
- */
50
- hasPadding?: boolean;
51
- /**
52
- * Optional flag to add tabs as additional padding between column pipes.
53
- * When true, adds a tab character after each | and before the content.
54
- * @default false
55
- */
56
- hasTabs?: boolean;
57
- /**
58
- * Indicates whether the first row of `data` is a header.
59
- * @default true
60
- */
61
- hasHeader?: boolean;
62
- /**
63
- * Optional flag to replace newlines with <br> tags in table cells.
64
- * @default false
65
- */
66
- convertLineBreaks?: boolean;
67
- /**
68
- * Optional theme for the Markdown table.
69
- * Acceptable values are 'light' or 'dark'.
70
- * @default 'light'
71
- */
72
- theme?: "light" | "dark";
73
- /**
74
- * Optional CSS class for styling the rendered Markdown table.
75
- * This class will be applied to the <pre> element containing the table.
76
- * It will be combined with built-in classes for syntax highlighting.
77
- * @default undefined
78
- * @example
79
- * <MarkdownTable
80
- * inputData={data}
81
- * className="custom-table-style"
82
- * />
83
- */
84
- className?: string;
85
- /**
86
- * Optional CSS properties to apply to the pre element containing the Markdown table.
87
- * Allows direct styling of the table container using React's style prop.
88
- * @default undefined
89
- * @example
90
- * <MarkdownTable
91
- * inputData={data}
92
- * preStyle={{
93
- * maxHeight: '300px',
94
- * overflow: 'auto',
95
- * backgroundColor: '#f5f5f5'
96
- * }}
97
- * />
98
- */
99
- preStyle?: React.CSSProperties;
100
- /**
101
- * Optional callback function to receive the generated Markdown table string.
102
- */
103
- onGenerate?: (markdownTableString: string) => void;
104
- /**
105
- * Optional top padding for the pre element.
106
- * @default 0
107
- */
108
- topPadding?: number;
109
- /**
110
- * Optional minimum width in pixels for the pre element containing the Markdown table.
111
- * @default undefined
112
- * @example
113
- * <MarkdownTable
114
- * inputData={data}
115
- * minWidth={300}
116
- * />
117
- */
118
- minWidth?: number;
119
- }
120
- /**
121
- * Represents the alignment options for table columns.
122
- */
123
- export type Alignment = "left" | "right" | "center" | "none" | "justify";
124
- /**
125
- * Configuration for table formatting.
126
- */
127
- export interface TableConfig {
128
- columnCount: number;
129
- columnAlignments: readonly Alignment[];
130
- columnWidths?: readonly number[];
131
- useTabs: boolean;
132
- replaceNewlines: boolean;
133
- hasPadding: boolean;
134
- }
135
- /**
136
- * Functions to generate alignment indicators for table columns.
137
- */
138
- export interface AlignmentIndicator {
139
- left: (width: number) => string;
140
- right: (width: number) => string;
141
- center: (width: number) => string;
142
- none: (width: number) => string;
143
- justify: (width: number) => string;
144
- }
package/dist/utils.d.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * @fileoverview Utilities for formatting and generating markdown tables with support
3
- * for cell formatting, alignment, and width calculations.
4
- */
5
- import { TableRow, InputData, Alignment, TableConfig, CellData } from "./types";
6
- export declare function calculateColumnWidths(tableRows: readonly TableRow[], maxColumnCount: number, config: TableConfig): number[];
7
- export declare function generateMarkdownTableString(inputData: InputData, columnAlignments: readonly Alignment[], canAdjustColumnWidths?: boolean, useTabs?: boolean, replaceNewlines?: boolean, hasPadding?: boolean): string;
8
- export declare function replaceNewlinesInCell(cell: CellData): CellData;
9
- export declare function getColumnName(index: number): string;
10
- export declare function generateAlphabetHeaders(columnCount: number): string[];
@@ -1,19 +0,0 @@
1
- import { MarkdownTableProps } from "./types";
2
- /**
3
- * Custom error class for handling Markdown table generation errors.
4
- */
5
- export declare class MarkdownTableError extends Error {
6
- constructor(message: string);
7
- }
8
- /**
9
- * Validates that the input data is a non-empty two-dimensional array.
10
- * @param inputData - The data to validate
11
- * @throws {MarkdownTableError} If validation fails
12
- */
13
- export declare function validateInputData(inputData: unknown): void;
14
- /**
15
- * Validates the structure of the table data based on the `hasHeader` flag.
16
- * Throws an error if validation fails.
17
- * @param markdownTableProps - The props to validate.
18
- */
19
- export declare function validateMarkdownTableProps(markdownTableProps: MarkdownTableProps): void;