react-markdown-table-ts 1.3.7 → 1.3.9
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/README.md +39 -0
- package/dist/dark.png +0 -0
- package/dist/index.cjs +69 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +2454 -0
- package/dist/light.png +0 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/validation.d.ts +18 -0
- package/dist/validation.d.ts.map +1 -0
- package/package.json +12 -5
package/dist/light.png
ADDED
Binary file
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Type definitions for the MarkdownTable component including props,
|
3
|
+
* alignment options, and table configuration.
|
4
|
+
*/
|
5
|
+
export interface InputData {
|
6
|
+
inputDataHeader: string[];
|
7
|
+
inputDataBody: readonly string[][];
|
8
|
+
}
|
9
|
+
export interface MarkdownTableProps {
|
10
|
+
/**
|
11
|
+
* The entire table data as a two-dimensional array.
|
12
|
+
* If `hasHeader` is true, the first row is treated as the header.
|
13
|
+
* @default null
|
14
|
+
*/
|
15
|
+
inputData?: string[][] | null;
|
16
|
+
/**
|
17
|
+
* Optional array specifying the alignment for each column.
|
18
|
+
* Acceptable values are 'left', 'center', 'right', or 'none'.
|
19
|
+
* @default []
|
20
|
+
*/
|
21
|
+
columnAlignments?: readonly Alignment[];
|
22
|
+
/**
|
23
|
+
* Disables column width alignment to provide a more compact markdown table string.
|
24
|
+
* @default false
|
25
|
+
*/
|
26
|
+
isCompact?: boolean;
|
27
|
+
/**
|
28
|
+
* Optional flag to add a single space around cell content in the markdown table.
|
29
|
+
* When true, one space is added before and after the content in each cell.
|
30
|
+
* @default true
|
31
|
+
*/
|
32
|
+
hasPadding?: boolean;
|
33
|
+
/**
|
34
|
+
* Optional flag to add tabs as additional padding between column pipes.
|
35
|
+
* When true, adds a tab character after each | and before the content.
|
36
|
+
* @default false
|
37
|
+
*/
|
38
|
+
hasTabs?: boolean;
|
39
|
+
/**
|
40
|
+
* Indicates whether the first row of `data` is a header.
|
41
|
+
* @default true
|
42
|
+
*/
|
43
|
+
hasHeader?: boolean;
|
44
|
+
/**
|
45
|
+
* Optional flag to replace newlines with <br> tags in table cells.
|
46
|
+
* @default false
|
47
|
+
*/
|
48
|
+
convertLineBreaks?: boolean;
|
49
|
+
/**
|
50
|
+
* Optional theme for the Markdown table.
|
51
|
+
* Acceptable values are 'light' or 'dark'.
|
52
|
+
* @default 'light'
|
53
|
+
*/
|
54
|
+
theme?: 'light' | 'dark';
|
55
|
+
/**
|
56
|
+
* Optional CSS class for styling the rendered Markdown table.
|
57
|
+
* This class will be applied to the <pre> element containing the table.
|
58
|
+
* It will be combined with built-in classes for syntax highlighting.
|
59
|
+
* @default undefined
|
60
|
+
* @example
|
61
|
+
* <MarkdownTable
|
62
|
+
* inputData={data}
|
63
|
+
* className="custom-table-style"
|
64
|
+
* />
|
65
|
+
*/
|
66
|
+
className?: string;
|
67
|
+
/**
|
68
|
+
* Optional CSS properties to apply to the pre element containing the Markdown table.
|
69
|
+
* Allows direct styling of the table container using React's style prop.
|
70
|
+
* @default undefined
|
71
|
+
* @example
|
72
|
+
* <MarkdownTable
|
73
|
+
* inputData={data}
|
74
|
+
* preStyle={{
|
75
|
+
* maxHeight: '300px',
|
76
|
+
* overflow: 'auto',
|
77
|
+
* backgroundColor: '#f5f5f5'
|
78
|
+
* }}
|
79
|
+
* />
|
80
|
+
*/
|
81
|
+
preStyle?: React.CSSProperties;
|
82
|
+
/**
|
83
|
+
* Optional callback function to receive the generated Markdown table string.
|
84
|
+
*/
|
85
|
+
onGenerate?: (markdownTableString: string) => void;
|
86
|
+
/**
|
87
|
+
* Optional top padding for the pre element.
|
88
|
+
* @default 0
|
89
|
+
*/
|
90
|
+
topPadding?: number;
|
91
|
+
/**
|
92
|
+
* Optional minimum width in pixels for the pre element containing the Markdown table.
|
93
|
+
* @default undefined
|
94
|
+
* @example
|
95
|
+
* <MarkdownTable
|
96
|
+
* inputData={data}
|
97
|
+
* minWidth={300}
|
98
|
+
* />
|
99
|
+
*/
|
100
|
+
minWidth?: number;
|
101
|
+
/**
|
102
|
+
* Optional flag to show or hide line numbers in the Prism syntax highlighting.
|
103
|
+
* When true, line numbers are displayed on the left side of the code block.
|
104
|
+
* @default true
|
105
|
+
* @example
|
106
|
+
* <MarkdownTable
|
107
|
+
* inputData={data}
|
108
|
+
* showLineNumbers={false}
|
109
|
+
* />
|
110
|
+
*/
|
111
|
+
showLineNumbers?: boolean;
|
112
|
+
}
|
113
|
+
export type Alignment = 'left' | 'right' | 'center' | 'none';
|
114
|
+
export interface TableConfig {
|
115
|
+
columnCount: number;
|
116
|
+
columnAlignments: readonly Alignment[];
|
117
|
+
columnWidths?: readonly number[];
|
118
|
+
useTabs: boolean;
|
119
|
+
replaceNewlines: boolean;
|
120
|
+
hasPadding: boolean;
|
121
|
+
}
|
122
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,SAAS;IACxB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,aAAa,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC;CACpC;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC;IAE9B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAExC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;IAExB;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE/B;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,mBAAmB,EAAE,MAAM,KAAK,IAAI,CAAC;IAEnD;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAE3B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB"}
|
package/dist/utils.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Utility functions and classes for generating formatted markdown
|
3
|
+
* table strings with alignment, padding, and column width adjustments.
|
4
|
+
*/
|
5
|
+
import type { InputData, Alignment } from './types';
|
6
|
+
export declare function generateMarkdownTableString(inputData: InputData, columnAlignments: readonly Alignment[], canAdjustColumnWidths?: boolean, useTabs?: boolean, replaceNewlines?: boolean, hasPadding?: boolean): string;
|
7
|
+
export declare function generateAlphabetHeaders(columnCount: number): string[];
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAe,MAAM,SAAS,CAAC;AAmIjE,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,SAAS,EACpB,gBAAgB,EAAE,SAAS,SAAS,EAAE,EACtC,qBAAqB,UAAO,EAC5B,OAAO,UAAQ,EACf,eAAe,UAAQ,EACvB,UAAU,UAAO,GAChB,MAAM,CAsBR;AAYD,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAErE"}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Validation utilities and custom error class for markdown table
|
3
|
+
* data validation.
|
4
|
+
*/
|
5
|
+
/**
|
6
|
+
* Custom error class for handling Markdown table generation errors.
|
7
|
+
* Supports ES2022 error chaining via the optional `cause` property.
|
8
|
+
*/
|
9
|
+
export declare class MarkdownTableError extends Error {
|
10
|
+
constructor(message: string, options?: ErrorOptions);
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* Validates that the input data is a non-empty two-dimensional array.
|
14
|
+
* @param inputData - The data to validate
|
15
|
+
* @throws {MarkdownTableError} If validation fails
|
16
|
+
*/
|
17
|
+
export declare function validateInputData(inputData: unknown): void;
|
18
|
+
//# sourceMappingURL=validation.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKpD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAQ1D"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-markdown-table-ts",
|
3
|
-
"version": "1.3.
|
3
|
+
"version": "1.3.9",
|
4
4
|
"description": "A React component that converts structured data into Markdown table syntax and displays it within a `<pre>` tag.",
|
5
5
|
"keywords": [
|
6
6
|
"markdown",
|
@@ -32,7 +32,10 @@
|
|
32
32
|
"files": [
|
33
33
|
"dist"
|
34
34
|
],
|
35
|
-
"sideEffects":
|
35
|
+
"sideEffects": [
|
36
|
+
"src/index.tsx",
|
37
|
+
"**/*.css"
|
38
|
+
],
|
36
39
|
"repository": {
|
37
40
|
"type": "git",
|
38
41
|
"url": "git+https://github.com/keithwalsh/react-markdown-table-ts.git"
|
@@ -51,12 +54,16 @@
|
|
51
54
|
"storybook": "storybook dev -p 6006",
|
52
55
|
"build-storybook": "storybook build"
|
53
56
|
},
|
57
|
+
"peerDependencies": {
|
58
|
+
"react": ">=18.0.0",
|
59
|
+
"react-dom": ">=18.0.0"
|
60
|
+
},
|
54
61
|
"dependencies": {
|
55
|
-
"prismjs": "^1.30.0"
|
56
|
-
"react": "^18.3.1",
|
57
|
-
"react-dom": "^18.3.1"
|
62
|
+
"prismjs": "^1.30.0"
|
58
63
|
},
|
59
64
|
"devDependencies": {
|
65
|
+
"react": "^18.3.1",
|
66
|
+
"react-dom": "^18.3.1",
|
60
67
|
"@storybook/react-vite": "^9.1.10",
|
61
68
|
"@testing-library/jest-dom": "^6.6.3",
|
62
69
|
"@testing-library/react": "^16.3.0",
|