react-markdown-table-ts 1.2.0 → 1.2.2

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 CHANGED
@@ -1,26 +1,36 @@
1
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
+ }
2
13
  /**
3
14
  * Represents a single row in a table, consisting of cells.
4
15
  */
5
- export type TableRow = readonly (string | CellData)[];
16
+ export type TableRow = readonly CellData[];
6
17
  /**
7
18
  * Represents the structure of a Markdown table.
8
19
  */
9
20
  export interface InputData {
10
- inputDataHeader: (string | CellData)[];
11
- inputDataBody: readonly (string | CellData)[][];
21
+ inputDataHeader: CellData[];
22
+ inputDataBody: readonly CellData[][];
12
23
  }
13
24
  /**
14
25
  * Props for the MarkdownTable component.
15
26
  */
16
27
  export interface MarkdownTableProps {
17
28
  /**
18
- * The entire table data as a two-dimensional array.
19
- * Can be either string[][] or CellData[][].
29
+ * The entire table data as a two-dimensional array of CellData objects.
20
30
  * If `hasHeader` is true, the first row is treated as the header.
21
31
  * @default null
22
32
  */
23
- inputData?: (string | CellData)[][] | null;
33
+ inputData?: CellData[][] | null;
24
34
  /**
25
35
  * Optional array specifying the alignment for each column.
26
36
  * Acceptable values are 'left', 'center', 'right', or 'none'.
@@ -59,7 +69,7 @@ export interface MarkdownTableProps {
59
69
  * Acceptable values are 'light' or 'dark'.
60
70
  * @default 'light'
61
71
  */
62
- theme?: 'light' | 'dark';
72
+ theme?: "light" | "dark";
63
73
  /**
64
74
  * Optional CSS class for styling the rendered Markdown table.
65
75
  * This class will be applied to the <pre> element containing the table.
@@ -110,18 +120,7 @@ export interface MarkdownTableProps {
110
120
  /**
111
121
  * Represents the alignment options for table columns.
112
122
  */
113
- export type Alignment = 'left' | 'right' | 'center' | 'none' | 'justify';
114
- /**
115
- * Represents cell data with content and formatting options.
116
- */
117
- export interface CellData {
118
- content: string;
119
- alignment?: Alignment;
120
- bold?: boolean;
121
- italic?: boolean;
122
- code?: boolean;
123
- link?: string;
124
- }
123
+ export type Alignment = "left" | "right" | "center" | "none" | "justify";
125
124
  /**
126
125
  * Configuration for table formatting.
127
126
  */
package/dist/utils.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { InputData, Alignment, CellData } from './types';
2
- export declare function calculateColumnWidths(tableRows: readonly (string | CellData)[][], maxColumnCount: number): number[];
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[];
3
7
  export declare function generateMarkdownTableString(inputData: InputData, columnAlignments: readonly Alignment[], canAdjustColumnWidths?: boolean, useTabs?: boolean, replaceNewlines?: boolean, hasPadding?: boolean): string;
4
- export declare function replaceNewlinesInCell(cell: string | CellData): string;
8
+ export declare function replaceNewlinesInCell(cell: CellData): CellData;
5
9
  export declare function getColumnName(index: number): string;
6
10
  export declare function generateAlphabetHeaders(columnCount: number): string[];
7
- export declare function formatMarkdownRow(columnCount: number, currentRow: (string | CellData)[], columnAlignments: readonly Alignment[], columnWidths?: readonly number[], useTabs?: boolean, canReplaceNewlines?: boolean, hasPadding?: boolean): string;
8
- export declare function formatAlignmentRow(columnCount: number, columnAlignments: readonly Alignment[], columnWidths?: readonly number[], useTabs?: boolean, hasPadding?: boolean): string;
@@ -1,4 +1,4 @@
1
- import { MarkdownTableProps } from './types';
1
+ import { MarkdownTableProps } from "./types";
2
2
  /**
3
3
  * Custom error class for handling Markdown table generation errors.
4
4
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-markdown-table-ts",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
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",