react-markdown-table-ts 1.3.1 → 1.3.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/light.png ADDED
Binary file
@@ -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;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
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,80 +1,80 @@
1
- {
2
- "name": "react-markdown-table-ts",
3
- "version": "1.3.1",
4
- "description": "A React component that converts structured data into Markdown table syntax and displays it within a `<pre>` tag.",
5
- "keywords": [
6
- "markdown",
7
- "md",
8
- "table",
9
- "tables",
10
- "react",
11
- "generate",
12
- "generator",
13
- "convert",
14
- "converter"
15
- ],
16
- "type": "module",
17
- "main": "./dist/index.cjs",
18
- "module": "./dist/index.mjs",
19
- "types": "./dist/index.d.ts",
20
- "exports": {
21
- ".": {
22
- "import": {
23
- "types": "./dist/index.d.ts",
24
- "default": "./dist/index.mjs"
25
- },
26
- "require": {
27
- "types": "./dist/index.d.ts",
28
- "default": "./dist/index.cjs"
29
- }
30
- }
31
- },
32
- "files": [
33
- "dist"
34
- ],
35
- "sideEffects": false,
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/keithwalsh/react-markdown-table-ts.git"
39
- },
40
- "homepage": "https://github.com/keithwalsh/react-markdown-table-ts#readme",
41
- "bugs": {
42
- "url": "https://github.com/keithwalsh/react-markdown-table-ts/issues"
43
- },
44
- "scripts": {
45
- "dev": "vite",
46
- "build": "tsc -p tsconfig.build.json && vite build",
47
- "preview": "vite preview",
48
- "test": "jest",
49
- "test:watch": "jest --watch",
50
- "test:coverage": "jest --coverage",
51
- "storybook": "storybook dev -p 6006",
52
- "build-storybook": "storybook build"
53
- },
54
- "peerDependencies": {
55
- "react": ">=18.0.0",
56
- "react-dom": ">=18.0.0"
57
- },
58
- "dependencies": {
59
- "prismjs": "^1.30.0",
60
- "react": "^19.1.1",
61
- "react-dom": "^19.1.1"
62
- },
63
- "devDependencies": {
64
- "@storybook/react-vite": "^9.1.10",
65
- "@testing-library/jest-dom": "^6.6.3",
66
- "@testing-library/react": "^16.3.0",
67
- "@types/jest": "^29.5.14",
68
- "@types/node": "^24.6.0",
69
- "@types/prismjs": "^1.26.5",
70
- "@types/react": "^19.1.16",
71
- "@types/react-dom": "^19.1.9",
72
- "@vitejs/plugin-react-swc": "^4.1.0",
73
- "jest": "^29.7.0",
74
- "jest-environment-jsdom": "^29.7.0",
75
- "storybook": "^9.1.10",
76
- "ts-jest": "^29.2.5",
77
- "typescript": "~5.9.3",
78
- "vite": "^7.1.7"
79
- }
80
- }
1
+ {
2
+ "name": "react-markdown-table-ts",
3
+ "version": "1.3.2",
4
+ "description": "A React component that converts structured data into Markdown table syntax and displays it within a `<pre>` tag.",
5
+ "keywords": [
6
+ "markdown",
7
+ "md",
8
+ "table",
9
+ "tables",
10
+ "react",
11
+ "generate",
12
+ "generator",
13
+ "convert",
14
+ "converter"
15
+ ],
16
+ "type": "module",
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.mjs",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "import": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.mjs"
25
+ },
26
+ "require": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.cjs"
29
+ }
30
+ }
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "sideEffects": false,
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/keithwalsh/react-markdown-table-ts.git"
39
+ },
40
+ "homepage": "https://github.com/keithwalsh/react-markdown-table-ts#readme",
41
+ "bugs": {
42
+ "url": "https://github.com/keithwalsh/react-markdown-table-ts/issues"
43
+ },
44
+ "scripts": {
45
+ "dev": "vite",
46
+ "build": "tsc -p tsconfig.build.json && vite build",
47
+ "preview": "vite preview",
48
+ "test": "jest",
49
+ "test:watch": "jest --watch",
50
+ "test:coverage": "jest --coverage",
51
+ "storybook": "storybook dev -p 6006",
52
+ "build-storybook": "storybook build"
53
+ },
54
+ "peerDependencies": {
55
+ "react": ">=18.0.0",
56
+ "react-dom": ">=18.0.0"
57
+ },
58
+ "dependencies": {
59
+ "prismjs": "^1.30.0",
60
+ "react": "^19.1.1",
61
+ "react-dom": "^19.1.1"
62
+ },
63
+ "devDependencies": {
64
+ "@storybook/react-vite": "^9.1.10",
65
+ "@testing-library/jest-dom": "^6.6.3",
66
+ "@testing-library/react": "^16.3.0",
67
+ "@types/jest": "^29.5.14",
68
+ "@types/node": "^24.6.0",
69
+ "@types/prismjs": "^1.26.5",
70
+ "@types/react": "^19.1.16",
71
+ "@types/react-dom": "^19.1.9",
72
+ "@vitejs/plugin-react-swc": "^4.1.0",
73
+ "jest": "^29.7.0",
74
+ "jest-environment-jsdom": "^29.7.0",
75
+ "storybook": "^9.1.10",
76
+ "ts-jest": "^29.2.5",
77
+ "typescript": "~5.9.3",
78
+ "vite": "^7.1.7"
79
+ }
80
+ }