react-markdown-table-ts 0.1.0 → 0.1.1
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/package.json +1 -1
- package/dist/types/errors.d.ts +0 -13
- package/dist/types/helpers.d.ts +0 -46
- package/dist/types/index.d.ts +0 -18
- package/dist/types/types.d.ts +0 -44
- package/dist/types/validation.d.ts +0 -29
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-markdown-table-ts",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.1",
|
4
4
|
"description": "A React component that converts structured data into Markdown table syntax and displays it within a `<pre>` tag.",
|
5
5
|
"main": "dist/index.cjs.js",
|
6
6
|
"module": "dist/index.esm.js",
|
package/dist/types/errors.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Defines custom error classes for Markdown table syntax generation.
|
3
|
-
*/
|
4
|
-
/**
|
5
|
-
* Custom error class for handling Markdown table generation errors.
|
6
|
-
*/
|
7
|
-
export declare class MarkdownTableError extends Error {
|
8
|
-
/**
|
9
|
-
* Constructs a new MarkdownTableError.
|
10
|
-
* @param message - The error message.
|
11
|
-
*/
|
12
|
-
constructor(message: string);
|
13
|
-
}
|
package/dist/types/helpers.d.ts
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Contains helper functions for formatting Markdown table syntax and calculating column widths.
|
3
|
-
*/
|
4
|
-
import {TableRow} from './types';
|
5
|
-
/**
|
6
|
-
* Calculates the maximum width for each column based on the content.
|
7
|
-
* @param params - The parameters for column width calculation.
|
8
|
-
* @returns An array of maximum widths for each column.
|
9
|
-
*/
|
10
|
-
export declare function calculateColumnWidths({
|
11
|
-
allRows,
|
12
|
-
maxColumnCount,
|
13
|
-
}: {
|
14
|
-
allRows: readonly TableRow[];
|
15
|
-
maxColumnCount: number;
|
16
|
-
}): number[];
|
17
|
-
/**
|
18
|
-
* Formats a single row into a Markdown-formatted string.
|
19
|
-
* @param params - The parameters for row formatting.
|
20
|
-
* @returns The Markdown string for the row.
|
21
|
-
*/
|
22
|
-
export declare function formatMarkdownRow({
|
23
|
-
columnCount,
|
24
|
-
row,
|
25
|
-
columnAlignments,
|
26
|
-
columnWidths,
|
27
|
-
}: {
|
28
|
-
columnCount: number;
|
29
|
-
row: TableRow;
|
30
|
-
columnAlignments?: readonly ('left' | 'right' | 'center' | 'none')[];
|
31
|
-
columnWidths?: readonly number[];
|
32
|
-
}): string;
|
33
|
-
/**
|
34
|
-
* Generates the alignment row for the Markdown table syntax.
|
35
|
-
* @param params - The parameters for alignment row generation.
|
36
|
-
* @returns The Markdown string for the alignment row.
|
37
|
-
*/
|
38
|
-
export declare function formatAlignmentRow({
|
39
|
-
columnCount,
|
40
|
-
columnAlignments,
|
41
|
-
columnWidths,
|
42
|
-
}: {
|
43
|
-
columnCount: number;
|
44
|
-
columnAlignments?: readonly ('left' | 'right' | 'center' | 'none')[];
|
45
|
-
columnWidths?: readonly number[];
|
46
|
-
}): string;
|
package/dist/types/index.d.ts
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import {CreateMarkdownTableOptions, MarkdownTableProps} from './types';
|
2
|
-
/**
|
3
|
-
* Generates a Markdown-formatted table as a string.
|
4
|
-
* @param options - The parameters for table generation.
|
5
|
-
* @returns The Markdown string for the entire table.
|
6
|
-
* @throws {MarkdownTableError} if input validation fails.
|
7
|
-
*/
|
8
|
-
export declare function generateMarkdownTable({
|
9
|
-
tableData,
|
10
|
-
columnAlignments,
|
11
|
-
adjustColumnWidths,
|
12
|
-
}: CreateMarkdownTableOptions): string;
|
13
|
-
/**
|
14
|
-
* React component that generates and displays Markdown table syntax.
|
15
|
-
* @param props - The input parameters for table generation.
|
16
|
-
* @returns A <pre> element containing the Markdown table syntax or an error message.
|
17
|
-
*/
|
18
|
-
export declare function MarkdownTable(props: MarkdownTableProps): JSX.Element;
|
package/dist/types/types.d.ts
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Defines types and interfaces for generating Markdown table syntax and displaying it in React components.
|
3
|
-
*/
|
4
|
-
/**
|
5
|
-
* Represents a single row in a table, consisting of cells.
|
6
|
-
*/
|
7
|
-
export type TableRow = readonly string[];
|
8
|
-
/**
|
9
|
-
* Represents the structure of a Markdown table.
|
10
|
-
*/
|
11
|
-
export interface MarkdownTableData {
|
12
|
-
/**
|
13
|
-
* The header row of the table.
|
14
|
-
*/
|
15
|
-
readonly header: TableRow;
|
16
|
-
/**
|
17
|
-
* The body rows of the table.
|
18
|
-
*/
|
19
|
-
readonly rows: readonly TableRow[];
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Input parameters for creating a Markdown table syntax.
|
23
|
-
*/
|
24
|
-
export interface CreateMarkdownTableOptions {
|
25
|
-
/**
|
26
|
-
* The table data including headers and body rows.
|
27
|
-
*/
|
28
|
-
readonly tableData: MarkdownTableData;
|
29
|
-
/**
|
30
|
-
* Optional flag to adjust column widths based on content.
|
31
|
-
* @default true
|
32
|
-
*/
|
33
|
-
readonly adjustColumnWidths?: boolean;
|
34
|
-
/**
|
35
|
-
* Optional alignment settings for each column.
|
36
|
-
*/
|
37
|
-
readonly columnAlignments?: readonly ('left' | 'right' | 'center' | 'none')[];
|
38
|
-
}
|
39
|
-
/**
|
40
|
-
* Props for the MarkdownTable component.
|
41
|
-
*/
|
42
|
-
export interface MarkdownTableProps extends CreateMarkdownTableOptions {
|
43
|
-
className?: string;
|
44
|
-
}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @fileoverview Provides validation functions for inputs used in Markdown table syntax generation.
|
3
|
-
*/
|
4
|
-
import {MarkdownTableData, CreateMarkdownTableOptions} from './types';
|
5
|
-
/**
|
6
|
-
* Validates the structure of the table data.
|
7
|
-
* Throws an error if validation fails.
|
8
|
-
* @param tableData - The table data to validate.
|
9
|
-
* @throws {MarkdownTableError} if validation fails.
|
10
|
-
*/
|
11
|
-
export declare function validateTableData(tableData: MarkdownTableData): void;
|
12
|
-
/**
|
13
|
-
* Validates the column alignments array.
|
14
|
-
* Throws an error if validation fails.
|
15
|
-
* @param columnAlignments - The alignment settings to validate.
|
16
|
-
* @throws {MarkdownTableError} if validation fails.
|
17
|
-
*/
|
18
|
-
export declare function validateColumnAlignments(
|
19
|
-
columnAlignments?: readonly ('left' | 'right' | 'center' | 'none')[]
|
20
|
-
): void;
|
21
|
-
/**
|
22
|
-
* Validates the input parameters for generating the Markdown table syntax.
|
23
|
-
* Throws an error if validation fails.
|
24
|
-
* @param options - The input parameters to validate.
|
25
|
-
* @throws {MarkdownTableError} if validation fails.
|
26
|
-
*/
|
27
|
-
export declare function validateCreateMarkdownTableOptions(
|
28
|
-
options: CreateMarkdownTableOptions
|
29
|
-
): void;
|