react-markdown-table-ts 1.2.2 → 1.3.0

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.
@@ -0,0 +1,212 @@
1
+ /**
2
+ * @fileoverview Storybook stories for the MarkdownTable component, demonstrating
3
+ * various configurations and use cases for markdown table generation and display.
4
+ */
5
+
6
+ import type { Meta, StoryObj } from '@storybook/react';
7
+ import { MarkdownTable } from '../index'
8
+
9
+ const meta = {
10
+ title: 'Components/MarkdownTable',
11
+ component: MarkdownTable,
12
+ parameters: {
13
+ layout: 'centered'
14
+ },
15
+ tags: ['autodocs'],
16
+ args: {
17
+ inputData: null,
18
+ columnAlignments: [],
19
+ isCompact: false,
20
+ hasPadding: true,
21
+ hasTabs: false,
22
+ hasHeader: true,
23
+ convertLineBreaks: false,
24
+ topPadding: 16,
25
+ theme: 'light' as const,
26
+ showLineNumbers: true
27
+ },
28
+ argTypes: {
29
+ inputData: {
30
+ control: {
31
+ type: 'object'
32
+ },
33
+ description: 'The outer array represents rows. The inner array represent cells within each row.',
34
+ table: {
35
+ category: 'Core Data Props',
36
+ type: {
37
+ summary: 'string[][] | null'
38
+ }
39
+ }
40
+ },
41
+ columnAlignments: {
42
+ control: {
43
+ type: 'object'
44
+ },
45
+ description: 'An array specifying the alignment for each column.',
46
+ table: {
47
+ category: 'Core Data Props',
48
+ type: {
49
+ summary: 'readonly Alignment[]',
50
+ detail: 'export type Alignment = "left" | "right" | "center" | "none";'
51
+ }
52
+ }
53
+ },
54
+ isCompact: {
55
+ control: 'boolean',
56
+ description: 'Disables column width alignment to provide a more compact markdown table string.',
57
+ table: {
58
+ category: 'Configuration Props',
59
+ type: {
60
+ summary: 'boolean'
61
+ }
62
+ }
63
+ },
64
+ hasPadding: {
65
+ control: 'boolean',
66
+ description: 'Optional flag to add a single space around cell content in the markdown table.',
67
+ table: {
68
+ category: 'Configuration Props',
69
+ type: {
70
+ summary: 'boolean'
71
+ }
72
+ }
73
+ },
74
+ hasTabs: {
75
+ control: 'boolean',
76
+ description: 'Optional flag to add tabs as additional padding between column pipes.',
77
+ table: {
78
+ category: 'Configuration Props',
79
+ type: {
80
+ summary: 'boolean'
81
+ }
82
+ }
83
+ },
84
+ hasHeader: {
85
+ control: 'boolean',
86
+ description: 'Indicates whether the first row of `data` is a header.',
87
+ table: {
88
+ category: 'Configuration Props',
89
+ type: {
90
+ summary: 'boolean'
91
+ }
92
+ }
93
+ },
94
+ convertLineBreaks: {
95
+ control: 'boolean',
96
+ description: 'Optional flag to replace newlines with `<br>` tags in table cells.',
97
+ table: {
98
+ category: 'Configuration Props',
99
+ type: {
100
+ summary: 'boolean'
101
+ }
102
+ }
103
+ },
104
+ topPadding: {
105
+ control: {
106
+ type: 'number'
107
+ },
108
+ description: 'Controls the padding-top (in pixels) of the pre element display.',
109
+ table: {
110
+ category: 'Visual/UI Props',
111
+ type: {
112
+ summary: 'number'
113
+ }
114
+ }
115
+ },
116
+ theme: {
117
+ options: ['light', 'dark'],
118
+ control: { type: 'select' },
119
+ description: 'Switch between light and dark mode.',
120
+ table: {
121
+ category: 'Visual/UI Props',
122
+ type: {
123
+ summary: "'light' | 'dark'"
124
+ },
125
+ defaultValue: { summary: 'light' }
126
+ }
127
+ },
128
+ className: {
129
+ control: 'text',
130
+ description: 'Optional CSS class for styling the rendered Markdown table.',
131
+ table: {
132
+ category: 'Visual/UI Props',
133
+ type: {
134
+ summary: 'string'
135
+ }
136
+ }
137
+ },
138
+ preStyle: {
139
+ control: {
140
+ type: 'object'
141
+ },
142
+ description: 'Optional inline styles for the pre element.',
143
+ table: {
144
+ category: 'Visual/UI Props',
145
+ type: {
146
+ summary: 'React.CSSProperties'
147
+ }
148
+ }
149
+ },
150
+ minWidth: {
151
+ control: {
152
+ type: 'number'
153
+ },
154
+ description: 'Optional minimum width in pixels for the table container.',
155
+ table: {
156
+ category: 'Visual/UI Props',
157
+ type: {
158
+ summary: 'number'
159
+ }
160
+ }
161
+ },
162
+ showLineNumbers: {
163
+ control: 'boolean',
164
+ description: 'Optional flag to show or hide line numbers in the Prism syntax highlighting.',
165
+ table: {
166
+ category: 'Visual/UI Props',
167
+ type: {
168
+ summary: 'boolean'
169
+ },
170
+ defaultValue: { summary: 'true' }
171
+ }
172
+ },
173
+ onGenerate: {
174
+ description: 'Callback function that receives the generated Markdown table string.',
175
+ table: {
176
+ category: 'Callbacks',
177
+ type: {
178
+ summary: '(markdownTableString: string) => void'
179
+ }
180
+ }
181
+ }
182
+ }
183
+ } satisfies Meta<typeof MarkdownTable>
184
+
185
+ export default meta
186
+ type Story = StoryObj<typeof MarkdownTable>
187
+
188
+ // Move sample data before its usage
189
+ const sampleData = [
190
+ ['Package ID', 'Weight (kg)', 'Status', 'Destination'],
191
+ ['PKG-2024-001', '12.50', 'In Transit', 'Dublin, IE'],
192
+ ['PKG-2024-002', '3.75', 'Delivered', 'New York, US'],
193
+ ['PKG-2024-003', '8.20', 'Processing', 'Frankfurt, DE'],
194
+ ['PKG-2024-004', '5.60', 'In Transit', 'London, GB']
195
+ ]
196
+
197
+ export const Default: Story = {
198
+ args: {
199
+ inputData: sampleData,
200
+ columnAlignments: ['left', 'right', 'center', 'none'],
201
+ isCompact: false,
202
+ hasPadding: true,
203
+ hasTabs: false,
204
+ hasHeader: true,
205
+ convertLineBreaks: false,
206
+ topPadding: 16,
207
+ theme: 'light',
208
+ className: 'markdown-table-pre',
209
+ preStyle: {borderRadius: '8px'},
210
+ minWidth: 450
211
+ }
212
+ }
@@ -0,0 +1,2 @@
1
+ module.exports = {};
2
+