reactive-md 0.4.0 → 0.4.1

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.
Files changed (49) hide show
  1. package/CHANGELOG-ch.md +113 -96
  2. package/CHANGELOG.md +113 -96
  3. package/LICENSE +21 -21
  4. package/README-ch.md +123 -122
  5. package/README-en.md +147 -146
  6. package/README.md +147 -146
  7. package/bin/reactive-md.mjs +1 -1
  8. package/dist-library/reactive-md-react.js +199 -103
  9. package/dist-library/reactive-md.css +1 -1
  10. package/dist-library/reactive-md.js +1 -1
  11. package/dist-library/{runtime-DtjdPXxJ.js → runtime-D3QTVYaz.js} +122 -122
  12. package/dist-standalone/reactive-md-standalone.css +1 -1
  13. package/dist-standalone/reactive-md-standalone.js +1 -1
  14. package/docs/compatibility-ch.md +3 -3
  15. package/docs/compatibility-en.md +3 -3
  16. package/docs/release-0.4.0-ch.md +4 -4
  17. package/docs/release-0.4.0-en.md +4 -4
  18. package/docs/release-0.4.1-ch.md +23 -0
  19. package/docs/release-0.4.1-en.md +23 -0
  20. package/docs/releasing-ch.md +101 -101
  21. package/docs/releasing-en.md +101 -101
  22. package/examples/integration/core/package.json +7 -7
  23. package/examples/integration/react/index.html +12 -12
  24. package/examples/integration/react/main.jsx +21 -21
  25. package/examples/integration/react/package.json +9 -9
  26. package/examples/local/catalog.reactive.md +20 -20
  27. package/examples/local/checklist.reactive.md +32 -32
  28. package/examples/local/comparison.reactive.md +47 -47
  29. package/examples/local/components.reactive.md +44 -44
  30. package/examples/local/counter.reactive.md +7 -7
  31. package/examples/local/diagnostics.reactive.md +54 -54
  32. package/examples/local/diagram.reactive.md +44 -44
  33. package/examples/local/gallery.reactive.md +61 -61
  34. package/examples/local/parameters.reactive.md +36 -36
  35. package/examples/local/planning.reactive.md +24 -24
  36. package/examples/local/pricing.reactive.md +20 -20
  37. package/examples/local/zh/catalog.reactive.md +20 -20
  38. package/examples/local/zh/charts.reactive.md +73 -73
  39. package/examples/local/zh/checklist.reactive.md +32 -32
  40. package/examples/local/zh/comparison.reactive.md +47 -47
  41. package/examples/local/zh/components.reactive.md +44 -44
  42. package/examples/local/zh/counter.reactive.md +7 -7
  43. package/examples/local/zh/diagnostics.reactive.md +54 -54
  44. package/examples/local/zh/diagram.reactive.md +44 -44
  45. package/examples/local/zh/gallery.reactive.md +61 -61
  46. package/examples/local/zh/parameters.reactive.md +36 -36
  47. package/examples/local/zh/planning.reactive.md +24 -24
  48. package/examples/local/zh/pricing.reactive.md +20 -20
  49. package/package.json +91 -90
@@ -1,21 +1,21 @@
1
- import React from 'react';
2
- import { createRoot } from 'react-dom/client';
3
- import { LocalReactiveDocument } from 'reactive-md/react';
4
- import 'reactive-md/styles.css';
5
-
6
- const source = `# Cost estimate
7
-
8
- <panel title="Adjust the plan">
9
- <slider bind="people" label="People" initial="2" min="1" max="20">
10
- <toggle bind="annual" label="Annual billing">
11
- </panel>
12
-
13
- Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.`;
14
-
15
- createRoot(document.getElementById('root')).render(
16
- <React.StrictMode>
17
- <main style={{ padding: 24 }}>
18
- <LocalReactiveDocument source={source} />
19
- </main>
20
- </React.StrictMode>,
21
- );
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { LocalReactiveDocument } from 'reactive-md/react';
4
+ import 'reactive-md/styles.css';
5
+
6
+ const source = `# Cost estimate
7
+
8
+ <panel title="Adjust the plan">
9
+ <slider bind="people" label="People" initial="2" min="1" max="20">
10
+ <toggle bind="annual" label="Annual billing">
11
+ </panel>
12
+
13
+ Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.`;
14
+
15
+ createRoot(document.getElementById('root')).render(
16
+ <React.StrictMode>
17
+ <main style={{ padding: 24 }}>
18
+ <LocalReactiveDocument source={source} />
19
+ </main>
20
+ </React.StrictMode>,
21
+ );
@@ -1,9 +1,9 @@
1
- {
2
- "name": "reactive-md-react-example",
3
- "private": true,
4
- "type": "module",
5
- "engines": { "node": ">=22.12.0" },
6
- "scripts": { "dev": "vite --host 127.0.0.1", "build": "vite build" },
7
- "dependencies": { "react": "^19.0.0", "react-dom": "^19.0.0" },
8
- "devDependencies": { "vite": "^8.3.5" }
9
- }
1
+ {
2
+ "name": "reactive-md-react-example",
3
+ "private": true,
4
+ "type": "module",
5
+ "engines": { "node": ">=22.12.0" },
6
+ "scripts": { "dev": "vite --host 127.0.0.1", "build": "vite build" },
7
+ "dependencies": { "react": "^19.0.0", "react-dom": "^19.0.0" },
8
+ "devDependencies": { "vite": "^8.3.5" }
9
+ }
@@ -1,20 +1,20 @@
1
- # Find components in the document
2
-
3
- Type "visual", "input" or another keyword into the search box above the table. Click a column name to sort, and use the paging controls to move between pages.
4
-
5
- <panel title="Local component catalog">
6
- <table label="Component catalog" page-size="4">
7
- | Name | Category | Purpose |
8
- | --- | --- | --- |
9
- | slider | Input | Drag to adjust a number |
10
- | toggle | Input | Flip a switch |
11
- | choices | Input | Pick from a few options |
12
- | chart | Visual | Turn a Markdown table into a chart |
13
- | plot | Visual | Draw a function with LaTeX |
14
- | diagram | Visual | Select nodes to explore explanations |
15
- | checklist | Content | Tick off completed items |
16
- | timer | Utility | Start, pause and reset a countdown |
17
- </table>
18
- </panel>
19
-
20
- The catalog data lives in this document. Searching filters the table directly, and restoring the defaults clears the query and returns to the original order.
1
+ # Find components in the document
2
+
3
+ Type "visual", "input" or another keyword into the search box above the table. Click a column name to sort, and use the paging controls to move between pages.
4
+
5
+ <panel title="Local component catalog">
6
+ <table label="Component catalog" page-size="4">
7
+ | Name | Category | Purpose |
8
+ | --- | --- | --- |
9
+ | slider | Input | Drag to adjust a number |
10
+ | toggle | Input | Flip a switch |
11
+ | choices | Input | Pick from a few options |
12
+ | chart | Visual | Turn a Markdown table into a chart |
13
+ | plot | Visual | Draw a function with LaTeX |
14
+ | diagram | Visual | Select nodes to explore explanations |
15
+ | checklist | Content | Tick off completed items |
16
+ | timer | Utility | Start, pause and reset a countdown |
17
+ </table>
18
+ </panel>
19
+
20
+ The catalog data lives in this document. Searching filters the table directly, and restoring the defaults clears the query and returns to the original order.
@@ -1,32 +1,32 @@
1
- # Organize a walkthrough with a checklist
2
-
3
- <panel title="Walkthrough checklist">
4
- <checklist bind="done" label="Complete these steps">
5
- - [x] Read the source document
6
- - [ ] Adjust parameters and watch the results
7
- - [ ] Try it at phone width
8
- </checklist>
9
-
10
- Done: **{{ len(done) }} / 3**.
11
-
12
- <progress label="Completion" value="{{ len(done) / 3 * 100 }}">
13
-
14
- <if when="{{ len(done) == 3 }}">
15
- <alert tone="success" title="Walkthrough complete">
16
- You have read the source, tried the interactions and checked the narrow layout.
17
- </alert>
18
- </if>
19
- </panel>
20
-
21
- ## Search, sorting and paging
22
-
23
- <table label="Component price examples" page-size="3">
24
- | Name | Category | Price |
25
- | --- | --- | ---: |
26
- | Document | Basic | 20 |
27
- | Parameter panel | Input | 45 |
28
- | Chart | Visual | 80 |
29
- | Diagram | Visual | 65 |
30
- | Checklist | Basic | 30 |
31
- | Plan | Utility | 35 |
32
- </table>
1
+ # Organize a walkthrough with a checklist
2
+
3
+ <panel title="Walkthrough checklist">
4
+ <checklist bind="done" label="Complete these steps">
5
+ - [x] Read the source document
6
+ - [ ] Adjust parameters and watch the results
7
+ - [ ] Try it at phone width
8
+ </checklist>
9
+
10
+ Done: **{{ len(done) }} / 3**.
11
+
12
+ <progress label="Completion" value="{{ len(done) / 3 * 100 }}">
13
+
14
+ <if when="{{ len(done) == 3 }}">
15
+ <alert tone="success" title="Walkthrough complete">
16
+ You have read the source, tried the interactions and checked the narrow layout.
17
+ </alert>
18
+ </if>
19
+ </panel>
20
+
21
+ ## Search, sorting and paging
22
+
23
+ <table label="Component price examples" page-size="3">
24
+ | Name | Category | Price |
25
+ | --- | --- | ---: |
26
+ | Document | Basic | 20 |
27
+ | Parameter panel | Input | 45 |
28
+ | Chart | Visual | 80 |
29
+ | Diagram | Visual | 65 |
30
+ | Checklist | Basic | 30 |
31
+ | Plan | Utility | 35 |
32
+ </table>
@@ -1,47 +1,47 @@
1
- # Side by side, easier to compare
2
-
3
- <panel title="Payment method">
4
- <toggle bind="annual" label="Pay annually and save 20%">
5
- </panel>
6
-
7
- <grid>
8
- <card title="Basic plan">
9
- For individuals and small projects.
10
-
11
- **{{ annual ? 80 : 100 }} USD per month**.
12
-
13
- <badge>Local documents</badge>
14
- </card>
15
-
16
- <card title="Pro plan">
17
- For teams that need collaboration and room to grow.
18
-
19
- **{{ annual ? 160 : 200 }} USD per month**.
20
-
21
- <badge tone="success">More components</badge>
22
- </card>
23
- </grid>
24
-
25
- <tabs label="Plan details">
26
- <tab label="Feature comparison">
27
- | Capability | Basic plan | Pro plan |
28
- | --- | --- | --- |
29
- | Parameter adjustment | Included | Included |
30
- | Text binding | Included | Included |
31
- | Content organization | Basic layout | Charts and diagrams |
32
- </tab>
33
-
34
- <tab label="Buying advice">
35
- Choose a plan for what you need, then compare how the billing cycle changes the cost.
36
- </tab>
37
- </tabs>
38
-
39
- <accordion>
40
- <disclosure label="How is the cost calculated?">
41
- Annual billing applies a 20% discount to the monthly list price, and the equivalent monthly cost is shown above.
42
- </disclosure>
43
-
44
- <disclosure label="Can I switch at any time?">
45
- Toggle the switch above to compare the two billing cycles. This is a local calculation example.
46
- </disclosure>
47
- </accordion>
1
+ # Side by side, easier to compare
2
+
3
+ <panel title="Payment method">
4
+ <toggle bind="annual" label="Pay annually and save 20%">
5
+ </panel>
6
+
7
+ <grid>
8
+ <card title="Basic plan">
9
+ For individuals and small projects.
10
+
11
+ **{{ annual ? 80 : 100 }} USD per month**.
12
+
13
+ <badge>Local documents</badge>
14
+ </card>
15
+
16
+ <card title="Pro plan">
17
+ For teams that need collaboration and room to grow.
18
+
19
+ **{{ annual ? 160 : 200 }} USD per month**.
20
+
21
+ <badge tone="success">More components</badge>
22
+ </card>
23
+ </grid>
24
+
25
+ <tabs label="Plan details">
26
+ <tab label="Feature comparison">
27
+ | Capability | Basic plan | Pro plan |
28
+ | --- | --- | --- |
29
+ | Parameter adjustment | Included | Included |
30
+ | Text binding | Included | Included |
31
+ | Content organization | Basic layout | Charts and diagrams |
32
+ </tab>
33
+
34
+ <tab label="Buying advice">
35
+ Choose a plan for what you need, then compare how the billing cycle changes the cost.
36
+ </tab>
37
+ </tabs>
38
+
39
+ <accordion>
40
+ <disclosure label="How is the cost calculated?">
41
+ Annual billing applies a 20% discount to the monthly list price, and the equivalent monthly cost is shown above.
42
+ </disclosure>
43
+
44
+ <disclosure label="Can I switch at any time?">
45
+ Toggle the switch above to compare the two billing cycles. This is a local calculation example.
46
+ </disclosure>
47
+ </accordion>
@@ -1,44 +1,44 @@
1
- # Organize interactions with content
2
-
3
- Hover over <tooltip text="When an input changes, the related text and charts update automatically.">reactive bindings</tooltip>, or focus it with the keyboard to read the explanation.
4
-
5
- <panel title="Reading preferences">
6
- <radio-group bind="preference" label="Explanation style">
7
- <option value="concise">Concise</option>
8
- <option value="detailed">Detailed</option>
9
- </radio-group>
10
- </panel>
11
-
12
- <if when="{{ preference == 'concise' }}">
13
- Name the input and reference it in the prose.
14
- </if>
15
-
16
- <if when="{{ preference == 'detailed' }}">
17
- Name an input parameter with `bind` and read it with `{{ }}` to compute results. When readers adjust a control, the related content updates immediately.
18
- </if>
19
-
20
- ## Read at your own pace
21
-
22
- <accordion label="Reading order">
23
- <disclosure label="Understand the parameters" open>
24
- Find what readers can change, such as headcount, unit price or amplitude.
25
- </disclosure>
26
-
27
- <disclosure label="Write down the relationship">
28
- Connect inputs and results with an expression, for example `{{ people * 100 }}`.
29
- </disclosure>
30
-
31
- <disclosure label="Choose how to present it">
32
- Use prose for a single result, charts for comparisons, and function curves for mathematical relationships.
33
- </disclosure>
34
- </accordion>
35
-
36
- <alert title="Keep exploring">
37
- Switch the option above and watch the explanation change.
38
- </alert>
39
-
40
- <badge tone="success">Local interaction</badge>
41
-
42
- ---
43
-
44
- > Headings, blockquotes, links and images still follow Markdown. Components only handle the parts that need interaction.
1
+ # Organize interactions with content
2
+
3
+ Hover over <tooltip text="When an input changes, the related text and charts update automatically.">reactive bindings</tooltip>, or focus it with the keyboard to read the explanation.
4
+
5
+ <panel title="Reading preferences">
6
+ <radio-group bind="preference" label="Explanation style">
7
+ <option value="concise">Concise</option>
8
+ <option value="detailed">Detailed</option>
9
+ </radio-group>
10
+ </panel>
11
+
12
+ <if when="{{ preference == 'concise' }}">
13
+ Name the input and reference it in the prose.
14
+ </if>
15
+
16
+ <if when="{{ preference == 'detailed' }}">
17
+ Name an input parameter with `bind` and read it with `{{ }}` to compute results. When readers adjust a control, the related content updates immediately.
18
+ </if>
19
+
20
+ ## Read at your own pace
21
+
22
+ <accordion label="Reading order">
23
+ <disclosure label="Understand the parameters" open>
24
+ Find what readers can change, such as headcount, unit price or amplitude.
25
+ </disclosure>
26
+
27
+ <disclosure label="Write down the relationship">
28
+ Connect inputs and results with an expression, for example `{{ people * 100 }}`.
29
+ </disclosure>
30
+
31
+ <disclosure label="Choose how to present it">
32
+ Use prose for a single result, charts for comparisons, and function curves for mathematical relationships.
33
+ </disclosure>
34
+ </accordion>
35
+
36
+ <alert title="Keep exploring">
37
+ Switch the option above and watch the explanation change.
38
+ </alert>
39
+
40
+ <badge tone="success">Local interaction</badge>
41
+
42
+ ---
43
+
44
+ > Headings, blockquotes, links and images still follow Markdown. Components only handle the parts that need interaction.
@@ -1,7 +1,7 @@
1
- # Counter
2
-
3
- <counter bind="count" label="Current value">
4
-
5
- The prose can read it too: **{{ count }}**.
6
-
7
- Use the component's own plus, minus and reset buttons.
1
+ # Counter
2
+
3
+ <counter bind="count" label="Current value">
4
+
5
+ The prose can read it too: **{{ count }}**.
6
+
7
+ Use the component's own plus, minus and reset buttons.
@@ -1,54 +1,54 @@
1
- # Diagnostics example
2
-
3
- This document intentionally keeps errors to exercise the diagnostic messages. Start with the other documents in this folder for correct examples.
4
-
5
- ## Reference to a misspelled parameter name
6
-
7
- <slider bind="seats" label="People" initial="2" min="1" max="20">
8
-
9
- Current headcount: {{ seat }}.
10
-
11
- ## Duplicate initial declaration
12
-
13
- <number bind="seats" label="Another headcount input" initial="3" min="1" max="20">
14
-
15
- ## Initial value out of range
16
-
17
- <slider bind="ratio" label="Ratio" initial="12" min="0" max="10">
18
-
19
- ## Condition type error
20
-
21
- <if when="{{ seats }}">
22
- This needs a boolean condition, such as seats greater than 5.
23
- </if>
24
-
25
- ## Unknown tag
26
-
27
- <slidr label="Misspelled slider" />
28
-
29
- ## Event outside the local interaction language
30
-
31
- <counter label="Counter" on-click="increment">
32
-
33
- ## Missing node
34
-
35
- <diagram label="Broken edge">
36
- <node id="input" label="Input">
37
- This is the only node.
38
- </node>
39
- <edge from="input" to="missing">
40
- </diagram>
41
-
42
- ## Unsupported math structure
43
-
44
- <plot label="Integrals are not part of the plot grammar">
45
- $$ y = \int_0^x t^2\,dt $$
46
- </plot>
47
-
48
- ## Invalid chart data
49
-
50
- <chart title="Units mixed into a numeric column">
51
- | Item | Cost |
52
- | --- | ---: |
53
- | Content | 20 USD |
54
- </chart>
1
+ # Diagnostics example
2
+
3
+ This document intentionally keeps errors to exercise the diagnostic messages. Start with the other documents in this folder for correct examples.
4
+
5
+ ## Reference to a misspelled parameter name
6
+
7
+ <slider bind="seats" label="People" initial="2" min="1" max="20">
8
+
9
+ Current headcount: {{ seat }}.
10
+
11
+ ## Duplicate initial declaration
12
+
13
+ <number bind="seats" label="Another headcount input" initial="3" min="1" max="20">
14
+
15
+ ## Initial value out of range
16
+
17
+ <slider bind="ratio" label="Ratio" initial="12" min="0" max="10">
18
+
19
+ ## Condition type error
20
+
21
+ <if when="{{ seats }}">
22
+ This needs a boolean condition, such as seats greater than 5.
23
+ </if>
24
+
25
+ ## Unknown tag
26
+
27
+ <slidr label="Misspelled slider" />
28
+
29
+ ## Event outside the local interaction language
30
+
31
+ <counter label="Counter" on-click="increment">
32
+
33
+ ## Missing node
34
+
35
+ <diagram label="Broken edge">
36
+ <node id="input" label="Input">
37
+ This is the only node.
38
+ </node>
39
+ <edge from="input" to="missing">
40
+ </diagram>
41
+
42
+ ## Unsupported math structure
43
+
44
+ <plot label="Integrals are not part of the plot grammar">
45
+ $$ y = \int_0^x t^2\,dt $$
46
+ </plot>
47
+
48
+ ## Invalid chart data
49
+
50
+ <chart title="Units mixed into a numeric column">
51
+ | Item | Cost |
52
+ | --- | ---: |
53
+ | Content | 20 USD |
54
+ </chart>
@@ -1,44 +1,44 @@
1
- # Make explanations explorable
2
-
3
- Click a node or use the keyboard to select a step and read its description.
4
-
5
- <diagram bind="selected" initial="input" label="Reactive state flow">
6
- <node id="input" label="Input">
7
- Readers change parameters with sliders, switches and text fields.
8
- </node>
9
-
10
- <node id="compute" label="Compute">
11
- Formulas that depend on those parameters are recalculated.
12
- </node>
13
-
14
- <node id="view" label="View">
15
- Prose, charts and hints update with the result.
16
- </node>
17
-
18
- <edge from="input" to="compute" label="Parameter change">
19
- <edge from="compute" to="view" label="Updated result">
20
- </diagram>
21
-
22
- Current step: {{ selected == 'input' ? 'Input' : selected == 'compute' ? 'Compute' : 'View' }}.
23
-
24
- ## Change parameters and watch the curve
25
-
26
- <panel title="Sine wave parameters">
27
- <slider bind="a" label="Amplitude" initial="1" min="0" max="3" step="0.5">
28
- <slider bind="f" label="Frequency parameter" initial="1" min="0.5" max="3" step="0.5">
29
- </panel>
30
-
31
- <plot min="0" max="12.56" label="Sine wave" x-label="x" y-label="Displacement">
32
- $$ y = a\sin(fx) $$
33
- </plot>
34
-
35
- <if when="{{ a == 0 }}">
36
- The amplitude is zero, so the curve lies flat on the horizontal axis.
37
- </if>
38
-
39
- ## Overlay two curves
40
-
41
- <plot min="-5" max="5" label="Parabola and line">
42
- $$ y = x^2 $$
43
- $$ y = 2x + 1 $$
44
- </plot>
1
+ # Make explanations explorable
2
+
3
+ Click a node or use the keyboard to select a step and read its description.
4
+
5
+ <diagram bind="selected" initial="input" label="Reactive state flow">
6
+ <node id="input" label="Input">
7
+ Readers change parameters with sliders, switches and text fields.
8
+ </node>
9
+
10
+ <node id="compute" label="Compute">
11
+ Formulas that depend on those parameters are recalculated.
12
+ </node>
13
+
14
+ <node id="view" label="View">
15
+ Prose, charts and hints update with the result.
16
+ </node>
17
+
18
+ <edge from="input" to="compute" label="Parameter change">
19
+ <edge from="compute" to="view" label="Updated result">
20
+ </diagram>
21
+
22
+ Current step: {{ selected == 'input' ? 'Input' : selected == 'compute' ? 'Compute' : 'View' }}.
23
+
24
+ ## Change parameters and watch the curve
25
+
26
+ <panel title="Sine wave parameters">
27
+ <slider bind="a" label="Amplitude" initial="1" min="0" max="3" step="0.5">
28
+ <slider bind="f" label="Frequency parameter" initial="1" min="0.5" max="3" step="0.5">
29
+ </panel>
30
+
31
+ <plot min="0" max="12.56" label="Sine wave" x-label="x" y-label="Displacement">
32
+ $$ y = a\sin(fx) $$
33
+ </plot>
34
+
35
+ <if when="{{ a == 0 }}">
36
+ The amplitude is zero, so the curve lies flat on the horizontal axis.
37
+ </if>
38
+
39
+ ## Overlay two curves
40
+
41
+ <plot min="-5" max="5" label="Parabola and line">
42
+ $$ y = x^2 $$
43
+ $$ y = 2x + 1 $$
44
+ </plot>