react-markdown-table-ts 0.5.8 → 0.5.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 CHANGED
@@ -1,65 +1,65 @@
1
- # ⚛️ react-markdown-table-ts 🛡️
2
-
3
- [![NPM Version](https://img.shields.io/npm/v/react-markdown-table-ts.svg)](https://www.npmjs.com/package/react-markdown-table-ts)
4
- ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=flat-square&logo=typescript&logoColor=white)
5
- [![codecov](https://codecov.io/gh/keithwalsh/react-markdown-table-ts/branch/main/graph/badge.svg)](https://codecov.io/gh/keithwalsh/react-markdown-table-ts)
6
- [![Package Quality](https://packagequality.com/shield/react-markdown-table-ts.svg)](https://packagequality.com/#?package=react-markdown-table-ts)
7
- [![Code Climate](https://codeclimate.com/github/keithwalsh/react-markdown-table-ts/badges/gpa.svg)](https://codeclimate.com/github/keithwalsh/react-markdown-table-ts)
8
-
9
- A React component that converts structured data into Markdown table syntax and displays it within a `<pre>` tag.
10
-
11
- ## ✨ Features
12
-
13
- - **Type Safety:** Built with TypeScript to provide strong type guarantees.
14
- - **Easy Integration:** Simple API for converting data arrays into Markdown table strings.
15
- - **Customizable Alignments:** Specify column alignments (left, center, right, or none) with ease.
16
- - **Compact Mode:** Option to generate compact tables with minimal padding.
17
- - **Tab-Separated Columns:** Option to add tabs between columns.
18
- - **Newline Handling: Option** to replace newlines in cells with HTML line breaks.
19
- - **Raw Markdown Access:** Retrieve the generated Markdown string for further processing or usage.
20
- - **Header Options:** Choose whether to include a header row or use default alphabetical headers.
21
- - **Flexible Styling:** Apply custom CSS classes for styling the rendered Markdown.
22
-
23
- ## 📦 Installation
24
-
25
- Install the package via npm:
26
-
27
- ```
28
-
29
- npm install react-markdown-table-ts
30
-
31
- ```
32
-
33
- ## 🔧 API
34
-
35
- ### MarkdownTable Props
36
-
37
- | Prop | Type | Default | Description |
38
- | :------------------: | :-------------------------------------------: | :---------: | :-----------------------------------------: |
39
- | `data` | `string[][]` | `null` | The table data as a 2D array of strings |
40
- | `columnAlignments` | `('left' \| 'center' \| 'right' \| 'none')[]` | `[]` | Alignment for each column |
41
- | `isCompact` | `boolean` | `false` | Use minimal column widths |
42
- | `className` | `string` | `undefined` | CSS class for the `<pre>` tag |
43
- | `hasTabs` | `boolean` | `false` | Add tabs between table columns |
44
- | `canReplaceNewlines` | `boolean` | `false` | Replace newlines in cells with `<br>` tags |
45
- | `onTableCreate` | `(markdownString: string) => void` | `undefined` | Callback to receive the Markdown string |
46
- | `hasHeader` | `boolean` | `true` | Whether the first row of `data` is a header |
47
-
48
- ## 🚀 Usage
49
-
50
- ```jsx
51
- import React from 'react';
52
- import {MarkdownTable} from 'markdown-table-component';
53
-
54
- const App = () => {
55
- const data = [
56
- ['Header 1', 'Header 2', 'Header 3'],
57
- ['Row 1, Col 1', 'Row 1, Col 2', 'Row 1, Col 3'],
58
- ['Row 2, Col 1', 'Row 2, Col 2', 'Row 2, Col 3'],
59
- ];
60
-
61
- return <MarkdownTable data={data} />;
62
- };
63
-
64
- export default App;
65
- ```
1
+ # ⚛️ react-markdown-table-ts 🛡️
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/react-markdown-table-ts.svg)](https://www.npmjs.com/package/react-markdown-table-ts)
4
+ ![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=flat-square&logo=typescript&logoColor=white)
5
+ [![codecov](https://codecov.io/gh/keithwalsh/react-markdown-table-ts/branch/main/graph/badge.svg)](https://codecov.io/gh/keithwalsh/react-markdown-table-ts)
6
+ [![Package Quality](https://packagequality.com/shield/react-markdown-table-ts.svg)](https://packagequality.com/#?package=react-markdown-table-ts)
7
+ [![Code Climate](https://codeclimate.com/github/keithwalsh/react-markdown-table-ts/badges/gpa.svg)](https://codeclimate.com/github/keithwalsh/react-markdown-table-ts)
8
+
9
+ A React component that converts structured data into Markdown table syntax and displays it within a `<pre>` tag.
10
+
11
+ ## ✨ Features
12
+
13
+ - **Type Safety:** Built with TypeScript to provide strong type guarantees.
14
+ - **Easy Integration:** Simple API for converting data arrays into Markdown table strings.
15
+ - **Customizable Alignments:** Specify column alignments (left, center, right, or none) with ease.
16
+ - **Compact Mode:** Option to generate compact tables with minimal padding.
17
+ - **Tab-Separated Columns:** Option to add tabs between columns.
18
+ - **Newline Handling: Option** to replace newlines in cells with HTML line breaks.
19
+ - **Raw Markdown Access:** Retrieve the generated Markdown string for further processing or usage.
20
+ - **Header Options:** Choose whether to include a header row or use default alphabetical headers.
21
+ - **Flexible Styling:** Apply custom CSS classes for styling the rendered Markdown.
22
+
23
+ ## 📦 Installation
24
+
25
+ Install the package via npm:
26
+
27
+ ```
28
+
29
+ npm install react-markdown-table-ts
30
+
31
+ ```
32
+
33
+ ## 🔧 API
34
+
35
+ ### MarkdownTable Props
36
+
37
+ | Prop | Type | Default | Description |
38
+ | :------------------: | :-------------------------------------------: | :---------: | :-----------------------------------------: |
39
+ | `data` | `string[][]` | `null` | The table data as a 2D array of strings |
40
+ | `columnAlignments` | `('left' \| 'center' \| 'right' \| 'none')[]` | `[]` | Alignment for each column |
41
+ | `isCompact` | `boolean` | `false` | Use minimal column widths |
42
+ | `className` | `string` | `undefined` | CSS class for the `<pre>` tag |
43
+ | `hasTabs` | `boolean` | `false` | Add tabs between table columns |
44
+ | `canReplaceNewlines` | `boolean` | `false` | Replace newlines in cells with `<br>` tags |
45
+ | `onTableCreate` | `(markdownString: string) => void` | `undefined` | Callback to receive the Markdown string |
46
+ | `hasHeader` | `boolean` | `true` | Whether the first row of `data` is a header |
47
+
48
+ ## 🚀 Usage
49
+
50
+ ```jsx
51
+ import React from 'react';
52
+ import {MarkdownTable} from 'markdown-table-component';
53
+
54
+ const App = () => {
55
+ const data = [
56
+ ['Header 1', 'Header 2', 'Header 3'],
57
+ ['Row 1, Col 1', 'Row 1, Col 2', 'Row 1, Col 3'],
58
+ ['Row 2, Col 1', 'Row 2, Col 2', 'Row 2, Col 3'],
59
+ ];
60
+
61
+ return <MarkdownTable data={data} />;
62
+ };
63
+
64
+ export default App;
65
+ ```
package/dist/index.cjs.js CHANGED
@@ -4104,7 +4104,7 @@ var MarkdownTableError = /** @class */ (function (_super) {
4104
4104
  function getAdjustedAlignments(columnAlignments, columnCount) {
4105
4105
  var defaultAlignment = 'left';
4106
4106
  return columnAlignments.length < columnCount
4107
- ? __spreadArray(__spreadArray([], columnAlignments, true), Array(columnCount - columnAlignments.length).fill(defaultAlignment), true) : columnAlignments.slice(0, columnCount);
4107
+ ? __spreadArray(__spreadArray([], Array.from(columnAlignments), true), Array(columnCount - columnAlignments.length).fill(defaultAlignment), true) : Array.from(columnAlignments);
4108
4108
  }
4109
4109
  /**
4110
4110
  * Calculates the maximum width for each column based on the content.
@@ -4125,20 +4125,28 @@ function calculateColumnWidths(tableRows, maxColumnCount) {
4125
4125
  }
4126
4126
  /**
4127
4127
  * Formats a single row into a Markdown-formatted string.
4128
- * @param params - Object containing formatting options and row data.
4128
+ * @param columnCount - The number of columns in the table.
4129
+ * @param currentRow - The data of the current row.
4130
+ * @param columnAlignments - Alignment settings for each column.
4131
+ * @param columnWidths - Widths of each column.
4132
+ * @param useTabs - Flag to use tabs between columns.
4133
+ * @param canReplaceNewlines - Flag to replace newlines with <br> tags.
4134
+ * @param hasPadding - Flag to add padding spaces around cell content.
4129
4135
  * @returns The Markdown string for the row.
4130
4136
  */
4131
- function formatMarkdownRow(_a) {
4132
- var _b, _c;
4133
- var columnCount = _a.columnCount, currentRow = _a.currentRow, columnAlignments = _a.columnAlignments, columnWidths = _a.columnWidths, _d = _a.useTabs, useTabs = _d === void 0 ? false : _d, _e = _a.replaceNewlines, replaceNewlines = _e === void 0 ? false : _e, _f = _a.hasPadding, hasPadding = _f === void 0 ? true : _f;
4137
+ function formatMarkdownRow(columnCount, currentRow, columnAlignments, columnWidths, useTabs, canReplaceNewlines, hasPadding) {
4138
+ var _a, _b;
4139
+ if (useTabs === void 0) { useTabs = false; }
4140
+ if (canReplaceNewlines === void 0) { canReplaceNewlines = false; }
4141
+ if (hasPadding === void 0) { hasPadding = true; }
4134
4142
  var adjustedAlignments = getAdjustedAlignments(columnAlignments, columnCount);
4135
4143
  var markdownRow = '|';
4136
4144
  for (var i = 0; i < columnCount; i++) {
4137
- var cell = (_b = currentRow[i]) !== null && _b !== void 0 ? _b : '';
4138
- if (replaceNewlines) {
4145
+ var cell = (_a = currentRow[i]) !== null && _a !== void 0 ? _a : '';
4146
+ if (canReplaceNewlines) {
4139
4147
  cell = replaceNewlinesInCell(cell);
4140
4148
  }
4141
- var alignment = (_c = adjustedAlignments[i]) !== null && _c !== void 0 ? _c : 'left';
4149
+ var alignment = (_b = adjustedAlignments[i]) !== null && _b !== void 0 ? _b : 'left';
4142
4150
  var targetWidth = columnWidths ? columnWidths[i] : cell.length;
4143
4151
  var padding = hasPadding ? ' ' : '';
4144
4152
  if (alignment === 'right') {
@@ -4157,70 +4165,70 @@ function formatMarkdownRow(_a) {
4157
4165
  }
4158
4166
  return markdownRow;
4159
4167
  }
4160
- function getAlignmentIndicator(_a) {
4161
- var _b;
4162
- var alignment = _a.alignment, targetWidth = _a.targetWidth;
4163
- var indicators = {
4164
- left: ":".concat('-'.repeat(targetWidth - 1)),
4165
- center: ":".concat('-'.repeat(targetWidth - 2), ":"),
4166
- right: "".concat('-'.repeat(targetWidth - 1), ":"),
4167
- none: "".concat('-'.repeat(targetWidth)),
4168
- };
4169
- return (_b = indicators[alignment]) !== null && _b !== void 0 ? _b : indicators.none;
4170
- }
4171
- function formatAlignmentRow(_a) {
4172
- var columnCount = _a.columnCount, columnAlignments = _a.columnAlignments, columnWidths = _a.columnWidths, _b = _a.useTabs, useTabs = _b === void 0 ? false : _b, _c = _a.hasPadding, hasPadding = _c === void 0 ? true : _c;
4168
+ /**
4169
+ * Generates the alignment row for the Markdown table syntax.
4170
+ * @param columnCount - The number of columns in the table.
4171
+ * @param columnAlignments - Alignment settings for each column.
4172
+ * @param columnWidths - Widths of each column.
4173
+ * @param useTabs - Flag to use tabs between columns.
4174
+ * @param hasPadding - Flag to add padding spaces around cell content.
4175
+ * @returns The Markdown string for the alignment row.
4176
+ */
4177
+ function formatAlignmentRow(columnCount, columnAlignments, columnWidths, useTabs, hasPadding) {
4178
+ var _a;
4179
+ if (useTabs === void 0) { useTabs = false; }
4180
+ if (hasPadding === void 0) { hasPadding = true; }
4173
4181
  var adjustedAlignments = getAdjustedAlignments(columnAlignments, columnCount);
4174
- var padding = hasPadding ? ' ' : '';
4175
- var alignmentCells = Array.from({ length: columnCount }, function (_, i) {
4176
- var _a, _b;
4182
+ var alignmentRow = '|';
4183
+ for (var i = 0; i < columnCount; i++) {
4177
4184
  var alignment = (_a = adjustedAlignments[i]) !== null && _a !== void 0 ? _a : 'left';
4178
- var targetWidth = (_b = columnWidths === null || columnWidths === void 0 ? void 0 : columnWidths[i]) !== null && _b !== void 0 ? _b : 3;
4179
- var alignIndicator = getAlignmentIndicator({ alignment: alignment, targetWidth: targetWidth });
4180
- return "".concat(useTabs ? '\t' : padding).concat(alignIndicator).concat(useTabs ? '\t' : padding);
4181
- });
4182
- return "|".concat(alignmentCells.join('|'), "|");
4185
+ var targetWidth = columnWidths ? columnWidths[i] : 3;
4186
+ var alignIndicator = '';
4187
+ var padding = hasPadding ? ' ' : '';
4188
+ switch (alignment) {
4189
+ case 'left':
4190
+ alignIndicator = ":".concat('-'.repeat(targetWidth - 1));
4191
+ break;
4192
+ case 'center':
4193
+ alignIndicator = ":".concat('-'.repeat(targetWidth - 2), ":");
4194
+ break;
4195
+ case 'right':
4196
+ alignIndicator = "".concat('-'.repeat(targetWidth - 1), ":");
4197
+ break;
4198
+ default:
4199
+ alignIndicator = "".concat('-'.repeat(targetWidth));
4200
+ break;
4201
+ }
4202
+ alignmentRow += "".concat(useTabs ? '\t' : padding).concat(alignIndicator).concat(useTabs ? '\t' : padding, "|");
4203
+ }
4204
+ return alignmentRow;
4183
4205
  }
4184
4206
  /**
4185
4207
  * Generates a complete Markdown table string from the provided data.
4186
- * @param params - Object containing table data and formatting options.
4208
+ * @param inputData - The table data including headers and rows.
4209
+ * @param columnAlignments - Alignment settings for each column.
4210
+ * @param canAdjustColumnWidths - Flag to adjust column widths based on content.
4211
+ * @param useTabs - Flag to use tabs between columns.
4212
+ * @param replaceNewlines - Flag to replace newlines with <br> tags.
4213
+ * @param hasPadding - Flag to add padding spaces around cell content.
4187
4214
  * @returns The complete Markdown table string.
4188
4215
  */
4189
- function generateMarkdownTableString(_a) {
4190
- var inputData = _a.inputData, columnAlignments = _a.columnAlignments, _b = _a.canAdjustColumnWidths, canAdjustColumnWidths = _b === void 0 ? true : _b, _c = _a.useTabs, useTabs = _c === void 0 ? false : _c, _d = _a.replaceNewlines, replaceNewlines = _d === void 0 ? false : _d, _e = _a.hasPadding, hasPadding = _e === void 0 ? true : _e;
4216
+ function generateMarkdownTableString(inputData, columnAlignments, canAdjustColumnWidths, useTabs, replaceNewlines, hasPadding) {
4217
+ if (canAdjustColumnWidths === void 0) { canAdjustColumnWidths = true; }
4218
+ if (useTabs === void 0) { useTabs = false; }
4219
+ if (replaceNewlines === void 0) { replaceNewlines = false; }
4220
+ if (hasPadding === void 0) { hasPadding = true; }
4191
4221
  var headerColumnCount = inputData.inputDataHeader.length;
4192
4222
  var bodyColumnCounts = inputData.inputDataBody.map(function (currentRow) { return currentRow.length; });
4193
4223
  var maxColumnCount = Math.max.apply(Math, __spreadArray([headerColumnCount], bodyColumnCounts, false));
4194
4224
  var columnWidths = canAdjustColumnWidths
4195
4225
  ? calculateColumnWidths(__spreadArray([inputData.inputDataHeader], inputData.inputDataBody, true), maxColumnCount)
4196
4226
  : undefined;
4197
- var markdownHeaderRow = formatMarkdownRow({
4198
- columnCount: maxColumnCount,
4199
- currentRow: inputData.inputDataHeader,
4200
- columnAlignments: columnAlignments,
4201
- columnWidths: columnWidths,
4202
- useTabs: useTabs,
4203
- replaceNewlines: replaceNewlines,
4204
- hasPadding: hasPadding,
4205
- });
4206
- var markdownAlignmentRow = formatAlignmentRow({
4207
- columnCount: maxColumnCount,
4208
- columnAlignments: columnAlignments,
4209
- columnWidths: columnWidths,
4210
- useTabs: useTabs,
4211
- hasPadding: hasPadding,
4212
- });
4227
+ var markdownHeaderRow = formatMarkdownRow(maxColumnCount, inputData.inputDataHeader, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding);
4228
+ var markdownAlignmentRow = formatAlignmentRow(maxColumnCount, columnAlignments, columnWidths, useTabs, hasPadding);
4213
4229
  var markdownBodyRows = inputData.inputDataBody
4214
4230
  .map(function (currentRow) {
4215
- return formatMarkdownRow({
4216
- columnCount: maxColumnCount,
4217
- currentRow: currentRow,
4218
- columnAlignments: columnAlignments,
4219
- columnWidths: columnWidths,
4220
- useTabs: useTabs,
4221
- replaceNewlines: replaceNewlines,
4222
- hasPadding: hasPadding,
4223
- });
4231
+ return formatMarkdownRow(maxColumnCount, currentRow, columnAlignments, columnWidths, useTabs, replaceNewlines, hasPadding);
4224
4232
  })
4225
4233
  .join('\n');
4226
4234
  return "".concat(markdownHeaderRow, "\n").concat(markdownAlignmentRow, "\n").concat(markdownBodyRows).trimEnd();
@@ -18566,40 +18574,48 @@ var LIGHT_THEME_CSS = "\ncode[class*=language-],pre[class*=language-]{color:#000
18566
18574
  var DARK_THEME_CSS = "\ncode[class*=language-],pre[class*=language-]{color:#f8f8f2;background:0 0;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#282a36}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}pre[class*=language-].line-numbers{position:relative;padding-left:2.4em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.5em;text-align:right}\n";
18567
18575
  var MarkdownTable = function (_a) {
18568
18576
  var _b = _a.inputData, inputData = _b === void 0 ? null : _b, _c = _a.hasHeader, hasHeader = _c === void 0 ? true : _c, _d = _a.columnAlignments, columnAlignments = _d === void 0 ? [] : _d, _e = _a.isCompact, isCompact = _e === void 0 ? false : _e, _f = _a.hasTabs, hasTabs = _f === void 0 ? false : _f, _g = _a.hasPadding, hasPadding = _g === void 0 ? true : _g, _h = _a.canReplaceNewlines, canReplaceNewlines = _h === void 0 ? false : _h, className = _a.className, onTableCreate = _a.onTableCreate, _j = _a.theme, theme = _j === void 0 ? 'light' : _j, preStyle = _a.preStyle, _k = _a.showCopyButton, showCopyButton = _k === void 0 ? false : _k;
18577
+ var adjustColumnWidths = !isCompact;
18569
18578
  var preElementRef = React.useRef(null);
18570
18579
  var _l = React.useState(false), isCopied = _l[0], setIsCopied = _l[1];
18571
- var adjustColumnWidths = !isCompact;
18572
- var convertedInputData = React.useMemo(function () {
18573
- if (!inputData)
18574
- return null;
18575
- var header = inputData[0], body = inputData.slice(1);
18576
- return { inputDataHeader: header, inputDataBody: body };
18577
- }, [inputData]);
18578
18580
  var markdownTableSyntax = React.useMemo(function () {
18579
- return generateMarkdownTableSyntax({
18580
- inputData: convertedInputData,
18581
- hasHeader: hasHeader,
18582
- columnAlignments: columnAlignments,
18583
- adjustColumnWidths: adjustColumnWidths,
18584
- hasTabs: hasTabs,
18585
- hasPadding: hasPadding,
18586
- canReplaceNewlines: canReplaceNewlines,
18587
- });
18581
+ if (inputData === null) {
18582
+ return 'Error: No data provided for the table.';
18583
+ }
18584
+ try {
18585
+ if (!Array.isArray(inputData) || inputData.length === 0) {
18586
+ throw new MarkdownTableError("The 'data' prop must be a non-empty two-dimensional array.");
18587
+ }
18588
+ var _a = hasHeader
18589
+ ? { inputDataHeader: inputData[0], inputDataBody: inputData.slice(1) }
18590
+ : { inputDataHeader: generateAlphabetHeaders(inputData[0].length), inputDataBody: inputData }, inputDataHeader = _a.inputDataHeader, inputDataBody = _a.inputDataBody;
18591
+ return generateMarkdownTableString({ inputDataHeader: inputDataHeader, inputDataBody: inputDataBody }, columnAlignments, adjustColumnWidths, hasTabs, canReplaceNewlines, hasPadding);
18592
+ }
18593
+ catch (error) {
18594
+ return error instanceof MarkdownTableError ? "Error: ".concat(error.message) : (function () { throw error; })();
18595
+ }
18588
18596
  }, [
18589
- convertedInputData,
18597
+ inputData,
18590
18598
  hasHeader,
18591
18599
  columnAlignments,
18592
- adjustColumnWidths,
18600
+ isCompact,
18593
18601
  hasTabs,
18594
- hasPadding,
18595
18602
  canReplaceNewlines,
18603
+ hasPadding,
18596
18604
  ]);
18597
18605
  React.useEffect(function () {
18598
18606
  if (onTableCreate) {
18599
18607
  onTableCreate(markdownTableSyntax);
18600
18608
  }
18601
18609
  }, [markdownTableSyntax, onTableCreate]);
18602
- usePrismHighlight(markdownTableSyntax, preElementRef);
18610
+ React.useEffect(function () {
18611
+ var _a;
18612
+ var codeElement = (_a = preElementRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('code');
18613
+ if (codeElement && markdownTableSyntax) {
18614
+ requestAnimationFrame(function () {
18615
+ Prism$1.highlightElement(codeElement);
18616
+ });
18617
+ }
18618
+ }, [markdownTableSyntax]);
18603
18619
  var handleCopy = function () {
18604
18620
  navigator.clipboard.writeText(markdownTableSyntax);
18605
18621
  setIsCopied(true);
@@ -18607,51 +18623,14 @@ var MarkdownTable = function (_a) {
18607
18623
  };
18608
18624
  return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("style", { children: theme === 'light' ? LIGHT_THEME_CSS : DARK_THEME_CSS }), jsxRuntimeExports.jsxs("div", { style: {
18609
18625
  position: 'relative',
18610
- isolation: 'isolate',
18626
+ isolation: 'isolate'
18611
18627
  }, children: [showCopyButton && (jsxRuntimeExports.jsx(Tooltip$1, { title: isCopied ? 'Copied!' : 'Copy markdown table syntax', placement: "left-end", arrow: true, children: jsxRuntimeExports.jsx(IconButton$1, { onClick: handleCopy, sx: {
18612
18628
  position: 'absolute',
18613
18629
  top: '12px',
18614
18630
  right: '8px',
18615
- zIndex: 1,
18631
+ zIndex: 1
18616
18632
  }, "aria-label": "Copy to clipboard", size: "small", children: jsxRuntimeExports.jsx(ContentCopyIcon, { fontSize: "small" }) }) })), jsxRuntimeExports.jsx("pre", { ref: preElementRef, className: "".concat(className, " language-markdown line-numbers ").concat(theme === 'dark' ? 'dark-theme' : ''), style: preStyle, children: jsxRuntimeExports.jsx("code", { className: "language-markdown", role: "code", children: markdownTableSyntax }) })] })] }));
18617
18633
  };
18618
- var generateMarkdownTableSyntax = function (_a) {
18619
- var inputData = _a.inputData, hasHeader = _a.hasHeader, columnAlignments = _a.columnAlignments, adjustColumnWidths = _a.adjustColumnWidths, hasTabs = _a.hasTabs, hasPadding = _a.hasPadding, canReplaceNewlines = _a.canReplaceNewlines;
18620
- if (inputData === null) {
18621
- return 'Error: No data provided for the table.';
18622
- }
18623
- if (!Array.isArray(inputData) || inputData.length === 0) {
18624
- throw new MarkdownTableError("The 'inputData' prop must be a non-empty two-dimensional array.");
18625
- }
18626
- var _b = hasHeader
18627
- ? {
18628
- inputDataHeader: inputData[0],
18629
- inputDataBody: inputData.slice(1),
18630
- }
18631
- : {
18632
- inputDataHeader: generateAlphabetHeaders(inputData[0].length),
18633
- inputDataBody: inputData,
18634
- }, inputDataHeader = _b.inputDataHeader, inputDataBody = _b.inputDataBody;
18635
- return generateMarkdownTableString({
18636
- inputData: { inputDataHeader: inputDataHeader, inputDataBody: inputDataBody },
18637
- columnAlignments: columnAlignments,
18638
- canAdjustColumnWidths: adjustColumnWidths,
18639
- useTabs: hasTabs,
18640
- replaceNewlines: canReplaceNewlines,
18641
- hasPadding: hasPadding,
18642
- });
18643
- };
18644
- var usePrismHighlight = function (markdownTableSyntax, preElementRef) {
18645
- React.useEffect(function () {
18646
- var _a;
18647
- var codeElement = (_a = preElementRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('code');
18648
- if (codeElement) {
18649
- requestAnimationFrame(function () {
18650
- Prism$1.highlightElement(codeElement);
18651
- });
18652
- }
18653
- }, [markdownTableSyntax]);
18654
- };
18655
18634
 
18656
18635
  exports.MarkdownTable = MarkdownTable;
18657
18636
  //# sourceMappingURL=index.cjs.js.map