@c2-markdown-ui/react 0.0.0-stage → 0.4.3
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 +111 -2
- package/dist/index.js +10085 -0
- package/package.json +44 -4
- package/src/index.ts +1 -0
- package/src/lib/MarkdownUI.tsx +111 -0
- package/src/lib/index.ts +3 -0
- package/src/lib/widgets.css +2189 -0
- package/src/widgets/Button.tsx +39 -0
- package/src/widgets/ButtonGroup.tsx +47 -0
- package/src/widgets/Cascader.tsx +400 -0
- package/src/widgets/Chart.tsx +238 -0
- package/src/widgets/DatePicker.tsx +451 -0
- package/src/widgets/Form.tsx +512 -0
- package/src/widgets/Incomplete.tsx +55 -0
- package/src/widgets/MultipleChoiceQuestion.tsx +82 -0
- package/src/widgets/NumberInput.tsx +169 -0
- package/src/widgets/Quiz.tsx +320 -0
- package/src/widgets/Radio.tsx +177 -0
- package/src/widgets/Select.tsx +178 -0
- package/src/widgets/SelectMulti.tsx +105 -0
- package/src/widgets/ShortAnswerQuestion.tsx +101 -0
- package/src/widgets/Slider.tsx +71 -0
- package/src/widgets/Switch.tsx +68 -0
- package/src/widgets/TextInput.tsx +76 -0
- package/src/widgets/TreeSelect.tsx +649 -0
- package/src/widgets/Widget.tsx +131 -0
- package/src/widgets/chartRemoteData.ts +84 -0
- package/src/widgets/choiceUtils.ts +90 -0
- package/src/widgets/index.ts +18 -0
package/README.md
CHANGED
|
@@ -1,3 +1,112 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @c2-markdown-ui/react
|
|
2
|
+
**Transform Markdown into interactive React components—instantly.**
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
Turn static docs into live experiences users can click, select, and submit.
|
|
5
|
+
|
|
6
|
+
✨ [Try the live demo](https://markdown-ui.com/) ✨
|
|
7
|
+
|
|
8
|
+
## Get started in 30 seconds
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @c2-markdown-ui/react @c2-markdown-ui/marked-ext marked
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { MarkdownUI } from '@c2-markdown-ui/react';
|
|
16
|
+
import '@c2-markdown-ui/react/widgets.css';
|
|
17
|
+
import { Marked } from 'marked';
|
|
18
|
+
import { markedUiExtension } from '@c2-markdown-ui/marked-ext';
|
|
19
|
+
|
|
20
|
+
const marked = new Marked();
|
|
21
|
+
marked.use(markedUiExtension);
|
|
22
|
+
|
|
23
|
+
const markdown = `
|
|
24
|
+
\`\`\`markdown-ui-widget
|
|
25
|
+
select env [dev staging prod]
|
|
26
|
+
\`\`\`
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
function App() {
|
|
30
|
+
const handleWidgetEvent = (event) => {
|
|
31
|
+
console.log('User selected:', event.detail);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<MarkdownUI
|
|
36
|
+
html={marked.parse(markdown)}
|
|
37
|
+
onWidgetEvent={handleWidgetEvent}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## What you can build
|
|
44
|
+
|
|
45
|
+
**Quick inputs**
|
|
46
|
+
```tsx
|
|
47
|
+
text-input username "Username" "Enter name"
|
|
48
|
+
button-group env [dev staging prod] dev
|
|
49
|
+
select region [us-east us-west] us-east
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Complex forms**
|
|
53
|
+
```tsx
|
|
54
|
+
form deploy "Launch"
|
|
55
|
+
text-input name "App Name"
|
|
56
|
+
slider replicas 1 10 1 3
|
|
57
|
+
select env [dev prod] dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Interactive charts**
|
|
61
|
+
```tsx
|
|
62
|
+
chart-line
|
|
63
|
+
title: Monthly Revenue
|
|
64
|
+
height: 300
|
|
65
|
+
Month,Sales,Target
|
|
66
|
+
Jan,45000,50000
|
|
67
|
+
Feb,52000,50000
|
|
68
|
+
Mar,48000,55000
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Events made simple**
|
|
72
|
+
```tsx
|
|
73
|
+
const handleWidgetEvent = (event) => {
|
|
74
|
+
const { id, value } = event.detail;
|
|
75
|
+
// That's it - perfect event data
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Form submit (fires after validation passes)
|
|
79
|
+
const handleSubmit = (event) => {
|
|
80
|
+
const { id, value } = event.detail; // value = full form data (visible fields only)
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Form field stats (fires on every field change)
|
|
84
|
+
const handleFormChange = (event) => {
|
|
85
|
+
const { visibleCount, filledCount, values } = event.detail.stats;
|
|
86
|
+
// e.g. "3/5 fields filled" - perfect for progress indicators
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
<MarkdownUI
|
|
90
|
+
html={html}
|
|
91
|
+
onWidgetEvent={handleWidgetEvent}
|
|
92
|
+
onSubmit={handleSubmit}
|
|
93
|
+
onFormChange={handleFormChange}
|
|
94
|
+
/>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## TypeScript ready
|
|
98
|
+
|
|
99
|
+
Full type safety out of the box. All components and events are properly typed for the best developer experience.
|
|
100
|
+
|
|
101
|
+
## Works everywhere
|
|
102
|
+
|
|
103
|
+
**SSR-safe by design.** No special setup needed for Next.js, Remix, or any React framework.
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
// Just import and use - SSR handled automatically
|
|
107
|
+
import { MarkdownUI } from '@c2-markdown-ui/react';
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Compatibility:** React 18+, Next.js, Remix, Create React App, Vite, and all modern React frameworks.
|
|
111
|
+
|
|
112
|
+
MIT © 2025
|