reactive-md 0.5.3 → 0.6.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.
- package/CHANGELOG-ch.md +195 -165
- package/CHANGELOG.md +195 -165
- package/CONTRIBUTING-ch.md +67 -62
- package/CONTRIBUTING.md +69 -64
- package/README-ch.md +157 -155
- package/README-en.md +184 -181
- package/README.md +184 -181
- package/SECURITY-ch.md +81 -81
- package/SECURITY.md +81 -81
- package/THIRD_PARTY_NOTICES.md +585 -1
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +181 -181
- package/cli/assets.mjs +390 -390
- package/cli/build.mjs +268 -268
- package/cli/document.mjs +130 -130
- package/cli/errors.mjs +61 -61
- package/cli/fs-utils.mjs +133 -133
- package/cli/glob.mjs +203 -203
- package/cli/help.mjs +138 -138
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +55 -55
- package/cli/migrate.mjs +368 -368
- package/cli/package.mjs +210 -210
- package/dist-library/{authoring-DJJjKYg9.js → authoring-BEVyth5X.js} +58 -58
- package/dist-library/compiler-Cm3ppMxG.js +46044 -0
- package/dist-library/react-Bh7_oxZp.js +59655 -0
- package/dist-library/reactive-md-authoring.js +2 -2
- package/dist-library/reactive-md-editor.js +13 -0
- package/dist-library/reactive-md-print.css +284 -284
- package/dist-library/reactive-md-react-unstyled.js +1 -1
- package/dist-library/reactive-md-react.js +1 -1
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +123 -123
- package/dist-library/{runtime-DXtle_6c.js → runtime-DlFYQ4s_.js} +151 -151
- package/dist-library/types/editor/types.d.ts +2 -0
- package/dist-library/types/local/code-block.d.ts +3 -1
- package/dist-library/types/local/code-languages.d.ts +7 -0
- package/dist-library/types/local/compiled-data.d.ts +6 -0
- package/dist-library/types/local/compiler.d.ts +1 -0
- package/dist-library/types/local/diagnostics.d.ts +31 -0
- package/dist-library/types/local/diagram-layout.d.ts +69 -0
- package/dist-library/types/local/html-names.d.ts +6 -0
- package/dist-library/types/local/html-table.d.ts +25 -0
- package/dist-library/types/local/math-display.d.ts +22 -22
- package/dist-library/types/local/math-view.d.ts +6 -7
- package/dist-library/types/local/table-surface.d.ts +10 -0
- package/dist-library/types/local/types.d.ts +2 -0
- package/dist-library/types/local/visuals.d.ts +9 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +331 -51
- package/docs/README.md +84 -0
- package/docs/{compatibility-ch.md → compatibility/compatibility-ch.md} +121 -109
- package/docs/{compatibility-en.md → compatibility/compatibility-en.md} +121 -109
- package/docs/{source-versioning-ch.md → compatibility/source-versioning-ch.md} +159 -159
- package/docs/{source-versioning-en.md → compatibility/source-versioning-en.md} +159 -159
- package/docs/{component-development-ch.md → development/component-development-ch.md} +210 -210
- package/docs/{component-development-en.md → development/component-development-en.md} +210 -210
- package/docs/{component-protocol-ch.md → development/component-protocol-ch.md} +747 -747
- package/docs/{component-protocol-en.md → development/component-protocol-en.md} +747 -747
- package/docs/{performance-ch.md → development/performance-ch.md} +76 -76
- package/docs/{performance-en.md → development/performance-en.md} +76 -76
- package/docs/{releasing-ch.md → development/releasing-ch.md} +108 -108
- package/docs/{releasing-en.md → development/releasing-en.md} +108 -108
- package/docs/guides/local-guide-ch.md +513 -0
- package/docs/guides/local-guide-en.md +513 -0
- package/docs/{author-tools-ch.md → integration/author-tools-ch.md} +57 -57
- package/docs/{author-tools-en.md → integration/author-tools-en.md} +57 -57
- package/docs/{editor-ch.md → integration/editor-ch.md} +7 -6
- package/docs/{editor-en.md → integration/editor-en.md} +7 -6
- package/docs/{local-integration-ch.md → integration/local-integration-ch.md} +33 -15
- package/docs/{local-integration-en.md → integration/local-integration-en.md} +33 -15
- package/docs/{shareable-export-ch.md → integration/shareable-export-ch.md} +221 -209
- package/docs/{shareable-export-en.md → integration/shareable-export-en.md} +223 -211
- package/docs/{computations-formatting-ch.md → reference/computations-formatting-ch.md} +87 -87
- package/docs/{computations-formatting-en.md → reference/computations-formatting-en.md} +87 -87
- package/docs/{constraints-collections-ch.md → reference/constraints-collections-ch.md} +84 -84
- package/docs/{constraints-collections-en.md → reference/constraints-collections-en.md} +84 -84
- package/docs/{diagnostics-counting-ch.md → reference/diagnostics-counting-ch.md} +104 -84
- package/docs/{diagnostics-counting-en.md → reference/diagnostics-counting-en.md} +104 -84
- package/docs/{html-compatibility-ch.md → reference/html-compatibility-ch.md} +42 -4
- package/docs/{html-compatibility-en.md → reference/html-compatibility-en.md} +42 -4
- package/docs/{local-components-v2-ch.md → reference/local-components-v2-ch.md} +138 -138
- package/docs/{local-components-v2-en.md → reference/local-components-v2-en.md} +104 -104
- package/docs/{local-interaction-syntax-ch.md → reference/local-interaction-syntax-ch.md} +515 -492
- package/docs/{local-interaction-syntax-en.md → reference/local-interaction-syntax-en.md} +511 -488
- package/docs/{theme-protocol-ch.md → reference/theme-protocol-ch.md} +107 -107
- package/docs/{theme-protocol-en.md → reference/theme-protocol-en.md} +107 -107
- package/docs/{release-0.4.0-ch.md → releases/release-0.4.0-ch.md} +89 -89
- package/docs/{release-0.4.0-en.md → releases/release-0.4.0-en.md} +89 -89
- package/docs/{release-0.4.1-ch.md → releases/release-0.4.1-ch.md} +23 -23
- package/docs/{release-0.4.1-en.md → releases/release-0.4.1-en.md} +23 -23
- package/docs/{release-0.5.0-ch.md → releases/release-0.5.0-ch.md} +4 -4
- package/docs/{release-0.5.0-en.md → releases/release-0.5.0-en.md} +4 -4
- package/docs/{release-0.5.1-ch.md → releases/release-0.5.1-ch.md} +4 -4
- package/docs/{release-0.5.1-en.md → releases/release-0.5.1-en.md} +4 -4
- package/docs/{release-0.5.2-ch.md → releases/release-0.5.2-ch.md} +3 -3
- package/docs/{release-0.5.2-en.md → releases/release-0.5.2-en.md} +3 -3
- package/docs/{release-0.5.3-ch.md → releases/release-0.5.3-ch.md} +1 -1
- package/docs/{release-0.5.3-en.md → releases/release-0.5.3-en.md} +1 -1
- package/docs/releases/release-0.6.0-ch.md +57 -0
- package/docs/releases/release-0.6.0-en.md +57 -0
- package/docs/releases/release-0.6.1-ch.md +27 -0
- package/docs/releases/release-0.6.1-en.md +27 -0
- package/examples/conformance/README.md +53 -53
- package/examples/conformance/component-protocol-1.json +482 -482
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/local-draft-1.json +50 -50
- package/examples/conformance/local-draft-2.json +212 -212
- package/examples/integration/README.md +47 -45
- package/examples/integration/core/index.mjs +32 -32
- package/examples/integration/worker/index.html +19 -19
- package/examples/integration/worker/main.js +61 -61
- package/examples/integration/worker/package.json +13 -13
- package/examples/integration/worker/worker.js +3 -3
- package/examples/local/README.md +74 -74
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/html-compat.reactive.md +19 -0
- package/examples/local/recipes/invoice-zh.reactive.md +36 -36
- package/examples/local/recipes/invoice.reactive.md +36 -36
- package/examples/local/recipes/workshop-zh.reactive.md +33 -33
- package/examples/local/recipes/workshop.reactive.md +33 -33
- package/examples/local/showcase/README.md +25 -25
- package/examples/local/showcase/explore.reactive.md +102 -102
- package/examples/local/showcase/flow.reactive.md +86 -86
- package/examples/local/showcase/forms.reactive.md +126 -126
- package/examples/local/showcase/functions.reactive.md +119 -119
- package/examples/local/showcase/layout.reactive.md +100 -100
- package/examples/local/showcase/statistics.reactive.md +108 -108
- package/examples/local/showcase/tasks.reactive.md +89 -89
- package/examples/local/showcase/zh/explore.reactive.md +102 -102
- package/examples/local/showcase/zh/flow.reactive.md +86 -86
- package/examples/local/showcase/zh/forms.reactive.md +126 -126
- package/examples/local/showcase/zh/functions.reactive.md +119 -119
- package/examples/local/showcase/zh/layout.reactive.md +100 -100
- package/examples/local/showcase/zh/statistics.reactive.md +108 -108
- package/examples/local/showcase/zh/tasks.reactive.md +89 -89
- package/package.json +152 -145
- package/dist-library/compiler-UyPwGzJZ.js +0 -22109
- package/dist-library/react-fizgU3i8.js +0 -12764
- package/docs/local-guide-ch.md +0 -967
- package/docs/local-guide-en.md +0 -967
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { LocalCompileScheduler } from 'reactive-md';
|
|
2
|
-
|
|
3
|
-
const editor = document.getElementById('source');
|
|
4
|
-
const status = document.getElementById('status');
|
|
5
|
-
const diagnostics = document.getElementById('diagnostics');
|
|
6
|
-
const preview = document.getElementById('preview');
|
|
7
|
-
|
|
8
|
-
const initialSource = `# Compile in a Worker
|
|
9
|
-
|
|
10
|
-
Edits are compiled off the main thread after a short debounce. Keep typing and the status below updates.
|
|
11
|
-
|
|
12
|
-
<slider bind="people" label="People" min="1" max="20">`;
|
|
13
|
-
|
|
14
|
-
editor.value = initialSource;
|
|
15
|
-
|
|
16
|
-
function createWorker() {
|
|
17
|
-
return new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function formatDiagnostics(list) {
|
|
21
|
-
return list.length
|
|
22
|
-
? list.map((diagnostic) => `${diagnostic.line}:${diagnostic.column} ${diagnostic.code}: ${diagnostic.message}`).join('\n')
|
|
23
|
-
: 'No diagnostics.';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function showResult(outcome) {
|
|
27
|
-
const { result, duration, mode } = outcome;
|
|
28
|
-
status.textContent = `Compiled in ${duration} ms (${mode})`;
|
|
29
|
-
diagnostics.textContent = formatDiagnostics(result.diagnostics);
|
|
30
|
-
if (!result.ok) {
|
|
31
|
-
preview.textContent = 'No document';
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const heading = result.document.nodes.find((node) => node.type === 'heading');
|
|
35
|
-
const title = heading
|
|
36
|
-
? (heading.children ?? []).map((child) => child.value ?? '').join('') || 'Untitled'
|
|
37
|
-
: 'Untitled';
|
|
38
|
-
const bindings = Object.keys(result.document.bindings);
|
|
39
|
-
preview.textContent = [
|
|
40
|
-
`Title: ${title}`,
|
|
41
|
-
`Nodes: ${result.document.nodes.length}`,
|
|
42
|
-
`Bindings: ${bindings.length ? bindings.join(', ') : 'none'}`,
|
|
43
|
-
].join('\n');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const scheduler = new LocalCompileScheduler({
|
|
47
|
-
createWorker,
|
|
48
|
-
onResult: showResult,
|
|
49
|
-
onPendingChange: (pending) => {
|
|
50
|
-
if (pending) status.textContent = 'Compiling...';
|
|
51
|
-
},
|
|
52
|
-
onModeChange: (mode, detail) => {
|
|
53
|
-
status.textContent = mode === 'worker'
|
|
54
|
-
? 'Compiling in a Worker...'
|
|
55
|
-
: `Compiling on the main thread${detail ? ` (${detail})` : ''}`;
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
editor.addEventListener('input', () => scheduler.schedule(editor.value));
|
|
60
|
-
window.addEventListener('beforeunload', () => scheduler.dispose());
|
|
61
|
-
scheduler.schedule(editor.value);
|
|
1
|
+
import { LocalCompileScheduler } from 'reactive-md';
|
|
2
|
+
|
|
3
|
+
const editor = document.getElementById('source');
|
|
4
|
+
const status = document.getElementById('status');
|
|
5
|
+
const diagnostics = document.getElementById('diagnostics');
|
|
6
|
+
const preview = document.getElementById('preview');
|
|
7
|
+
|
|
8
|
+
const initialSource = `# Compile in a Worker
|
|
9
|
+
|
|
10
|
+
Edits are compiled off the main thread after a short debounce. Keep typing and the status below updates.
|
|
11
|
+
|
|
12
|
+
<slider bind="people" label="People" min="1" max="20">`;
|
|
13
|
+
|
|
14
|
+
editor.value = initialSource;
|
|
15
|
+
|
|
16
|
+
function createWorker() {
|
|
17
|
+
return new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function formatDiagnostics(list) {
|
|
21
|
+
return list.length
|
|
22
|
+
? list.map((diagnostic) => `${diagnostic.line}:${diagnostic.column} ${diagnostic.code}: ${diagnostic.message}`).join('\n')
|
|
23
|
+
: 'No diagnostics.';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function showResult(outcome) {
|
|
27
|
+
const { result, duration, mode } = outcome;
|
|
28
|
+
status.textContent = `Compiled in ${duration} ms (${mode})`;
|
|
29
|
+
diagnostics.textContent = formatDiagnostics(result.diagnostics);
|
|
30
|
+
if (!result.ok) {
|
|
31
|
+
preview.textContent = 'No document';
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const heading = result.document.nodes.find((node) => node.type === 'heading');
|
|
35
|
+
const title = heading
|
|
36
|
+
? (heading.children ?? []).map((child) => child.value ?? '').join('') || 'Untitled'
|
|
37
|
+
: 'Untitled';
|
|
38
|
+
const bindings = Object.keys(result.document.bindings);
|
|
39
|
+
preview.textContent = [
|
|
40
|
+
`Title: ${title}`,
|
|
41
|
+
`Nodes: ${result.document.nodes.length}`,
|
|
42
|
+
`Bindings: ${bindings.length ? bindings.join(', ') : 'none'}`,
|
|
43
|
+
].join('\n');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const scheduler = new LocalCompileScheduler({
|
|
47
|
+
createWorker,
|
|
48
|
+
onResult: showResult,
|
|
49
|
+
onPendingChange: (pending) => {
|
|
50
|
+
if (pending) status.textContent = 'Compiling...';
|
|
51
|
+
},
|
|
52
|
+
onModeChange: (mode, detail) => {
|
|
53
|
+
status.textContent = mode === 'worker'
|
|
54
|
+
? 'Compiling in a Worker...'
|
|
55
|
+
: `Compiling on the main thread${detail ? ` (${detail})` : ''}`;
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
editor.addEventListener('input', () => scheduler.schedule(editor.value));
|
|
60
|
+
window.addEventListener('beforeunload', () => scheduler.dispose());
|
|
61
|
+
scheduler.schedule(editor.value);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "reactive-md-worker-example",
|
|
3
|
-
"private": true,
|
|
4
|
-
"type": "module",
|
|
5
|
-
"engines": { "node": ">=22.12.0" },
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite --host 127.0.0.1",
|
|
8
|
-
"build": "vite build",
|
|
9
|
-
"preview": "vite preview --host 127.0.0.1"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": { "reactive-md": "
|
|
12
|
-
"devDependencies": { "vite": "^8.3.5" }
|
|
13
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "reactive-md-worker-example",
|
|
3
|
+
"private": true,
|
|
4
|
+
"type": "module",
|
|
5
|
+
"engines": { "node": ">=22.12.0" },
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 127.0.0.1",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview --host 127.0.0.1"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": { "reactive-md": "0.6.0" },
|
|
12
|
+
"devDependencies": { "vite": "^8.3.5" }
|
|
13
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { startLocalCompileWorker } from 'reactive-md';
|
|
2
|
-
|
|
3
|
-
startLocalCompileWorker();
|
|
1
|
+
import { startLocalCompileWorker } from 'reactive-md';
|
|
2
|
+
|
|
3
|
+
startLocalCompileWorker();
|
package/examples/local/README.md
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
# Local interaction syntax demo
|
|
2
|
-
|
|
3
|
-
These are standalone authoring examples for `local-draft-2`, described in the [local interaction syntax specification](../../docs/local-interaction-syntax-en.md). The Playground starts with a [quick calculator](pricing.reactive.md), followed by six focused [feature tours](showcase/README.md). Components are distributed across these six scenarios; diagnostics has an auxiliary menu. Hosts can compile and render every document through the [local mode API](../../docs/local-integration-en.md).
|
|
4
|
-
|
|
5
|
-
The original eleven working examples and one intentionally broken diagnostics document remain in this directory, with Chinese versions in [zh/](zh/). The six feature tours live in [showcase/](showcase/README.md), with Chinese sources in [showcase/zh/](showcase/zh/). Each file runs independently. Controls, expressions and visualizations use local state.
|
|
6
|
-
|
|
7
|
-
The new [HTML compatibility example](html-compat.reactive.md) combines rich disclosures, Markdown and a bound counter. See the [temporary HTML routing policy](../../docs/html-compatibility-en.md) before enabling author CSS, JavaScript or extended HTML.
|
|
8
|
-
|
|
9
|
-
## Start with the short examples
|
|
10
|
-
|
|
11
|
-
The [workshop recipe](recipes/workshop.reactive.md) ([中文](recipes/workshop-zh.reactive.md)) combines cross-field validation, conditional tones, numeric aggregates and generated table rows. See the [constraints and collections reference](../../docs/constraints-collections-en.md) for rules and budgets.
|
|
12
|
-
|
|
13
|
-
The [invoice recipe](recipes/invoice.reactive.md) ([中文](recipes/invoice-zh.reactive.md)) demonstrates shared calculations, constants, formatting and UTC date differences. The [calculation reference](../../docs/computations-formatting-en.md) explains its rules.
|
|
14
|
-
|
|
15
|
-
Start with the [plan calculator](pricing.reactive.md), then choose a [feature tour](showcase/README.md). For the smallest possible state example, read the original [counter](counter.reactive.md). If you are new to the syntax, read the [new user guide](../../docs/local-guide-en.md).
|
|
16
|
-
|
|
17
|
-
## Original standalone catalog
|
|
18
|
-
|
|
19
|
-
| File | Contents |
|
|
20
|
-
| --- | --- |
|
|
21
|
-
| [counter.reactive.md](counter.reactive.md) | One-line counter with built-in plus, minus and reset |
|
|
22
|
-
| [pricing.reactive.md](pricing.reactive.md) | Plan calculator with parameters linked inside a panel |
|
|
23
|
-
| [comparison.reactive.md](comparison.reactive.md) | Side-by-side comparison, a switch declared in place, tabs that manage their own selection |
|
|
24
|
-
| [parameters.reactive.md](parameters.reactive.md) | Live parameter panel with text, date and choice inputs |
|
|
25
|
-
| [checklist.reactive.md](checklist.reactive.md) | Fixed checkable list and an enhanced table |
|
|
26
|
-
| [charts.reactive.md](charts.reactive.md) | Charts built from tables, with a compound-interest formula in LaTeX |
|
|
27
|
-
| [diagram.reactive.md](diagram.reactive.md) | Auto-laid-out interactive diagram and curves |
|
|
28
|
-
| [catalog.reactive.md](catalog.reactive.md) | Local catalog search, sorting and paging |
|
|
29
|
-
| [planning.reactive.md](planning.reactive.md) | Timeline, timer and bill-splitting calculation |
|
|
30
|
-
| [components.reactive.md](components.reactive.md) | Content cards, disclosures, tabs and hint components |
|
|
31
|
-
| [gallery.reactive.md](gallery.reactive.md) | Common inputs, standalone components and code shown as-is |
|
|
32
|
-
| [diagnostics.reactive.md](diagnostics.reactive.md) | Intentionally broken diagnostics example |
|
|
33
|
-
|
|
34
|
-
The Playground example index is maintained in the repository's demo application.
|
|
35
|
-
|
|
36
|
-
## Expected behavior of the working examples
|
|
37
|
-
|
|
38
|
-
The table below lists the initial values and interaction checkpoints for each document. Numbers follow the formulas in the prose.
|
|
39
|
-
|
|
40
|
-
| Example | Initial display | Interaction checks |
|
|
41
|
-
| --- | --- | --- |
|
|
42
|
-
| comparison | Basic 100 USD, Pro 200 USD | Annual billing changes them to 80/160; switching tabs needs no declared variable; reset returns to monthly billing |
|
|
43
|
-
| parameters | Date 2026-10-22, personal use, name empty | Entering a name updates the card; selecting team use updates the description; checking the switch shows the preparation checklist; panel reset restores fields and switches |
|
|
44
|
-
| checklist | 1/3 items, progress about 33.33% | Selecting all shows the completion notice; reset restores only the first item; the table sorts by price, searches and pages |
|
|
45
|
-
| charts | 4 budget comparisons; savings parameters 10000, 500, 5%, 20 years; plan bars 40/70 | With the rate at 0 the end-of-curve readout is 130000; the default compound readout is about 232643.24; with 5 people the bars are 100/175 |
|
|
46
|
-
| diagram | Input node selected, a=1, f=1 | Clicking the compute node updates the details and prose; at a=0 the curve flattens and a notice appears; both fixed curves are shown together |
|
|
47
|
-
| catalog | 8 catalog rows, 4 rows per page | Searching for "visual" returns chart/plot/diagram; no match shows the empty state; reset clears the query, sorting and page |
|
|
48
|
-
| planning | 45-minute timeline, countdown paused at 60 seconds, 88 USD per person | timer start/pause/reset; with the extra charge at 0 each person pays 80 USD; the reference task starting at 15 overlaps the main section |
|
|
49
|
-
| components | Concise explanation, first disclosure open | Selecting detailed switches the prose; the tooltip is keyboard-focusable; other disclosures open independently |
|
|
50
|
-
| pricing | 2 people, 100 USD each, 200 USD total | Annual billing gives 160 USD; annual billing for 5 people is 400 USD and shows the team notice; reset returns to 200 USD |
|
|
51
|
-
| counter | 0 | Three increments show 3; three decrements return to 0 and disable minus; reset returns to 0 |
|
|
52
|
-
| gallery | Alex, quantity 3, Pro, monthly billing, cost 240 USD | Annual billing gives 192 USD; hiding and showing the express section keeps its checks; the standalone counter and timer need no bind; `example` in the code block creates no variable |
|
|
53
|
-
|
|
54
|
-
In parameters, the conditional checklist sits outside the panel: its existing checks survive hiding and are outside that panel's reset scope. The standalone counter and timer in gallery also sit outside the input panel, so resetting the input panel does not affect them.
|
|
55
|
-
|
|
56
|
-
## Expected results of the diagnostics example
|
|
57
|
-
|
|
58
|
-
[diagnostics.reactive.md](diagnostics.reactive.md) intentionally contains the following 9 error classes. The editor should collect recoverable, independent diagnostics, and the document as a whole must not activate interactions.
|
|
59
|
-
|
|
60
|
-
1. `seat` is not declared; the message can suggest the existing parameter `seats`.
|
|
61
|
-
2. `seats` has a duplicate explicit initial; both sources are reported.
|
|
62
|
-
3. `ratio` has initial value 12, above the maximum 10.
|
|
63
|
-
4. if.when receives `seats`, a number, where a boolean is required.
|
|
64
|
-
5. `slidr` is an unknown component; the message can suggest `slider`.
|
|
65
|
-
6. `on-click` is not part of counter or the local interaction event syntax.
|
|
66
|
-
7. The edge target `missing` does not exist.
|
|
67
|
-
8. The integral can be displayed but is not a computable structure in the first plot version.
|
|
68
|
-
9. The chart's cost column contains `20 USD`, text where a plain number is required.
|
|
69
|
-
|
|
70
|
-
## Check entry points
|
|
71
|
-
|
|
72
|
-
`npm test` checks parsing, bindings, expressions, LaTeX, the runtime and examples; `npm run test:demo` checks the Playground index; `npm run verify:release` runs the complete Node-side and browser gate, including real-tarball consumption and HTML export. See the [contributing guide](../../CONTRIBUTING.md) for individual commands.
|
|
73
|
-
|
|
74
|
-
The [six scenarios](showcase/README.md) include all 48 tag names: intervals, coordinates and numeric questions in Functions; input choices in Forms; linked selection in Data; jumps and prose colors in Layout; guided steps and choice questions in Flow; todos and timing in Checklists. The standalone gallery and interaction-tour sources remain available as authoring examples.
|
|
1
|
+
# Local interaction syntax demo
|
|
2
|
+
|
|
3
|
+
These are standalone authoring examples for `local-draft-2`, described in the [local interaction syntax specification](../../docs/reference/local-interaction-syntax-en.md). The Playground starts with a [quick calculator](pricing.reactive.md), followed by six focused [feature tours](showcase/README.md). Components are distributed across these six scenarios; diagnostics has an auxiliary menu. Hosts can compile and render every document through the [local mode API](../../docs/integration/local-integration-en.md).
|
|
4
|
+
|
|
5
|
+
The original eleven working examples and one intentionally broken diagnostics document remain in this directory, with Chinese versions in [zh/](zh/). The six feature tours live in [showcase/](showcase/README.md), with Chinese sources in [showcase/zh/](showcase/zh/). Each file runs independently. Controls, expressions and visualizations use local state.
|
|
6
|
+
|
|
7
|
+
The new [HTML compatibility example](html-compat.reactive.md) combines rich disclosures, Markdown and a bound counter. See the [temporary HTML routing policy](../../docs/reference/html-compatibility-en.md) before enabling author CSS, JavaScript or extended HTML.
|
|
8
|
+
|
|
9
|
+
## Start with the short examples
|
|
10
|
+
|
|
11
|
+
The [workshop recipe](recipes/workshop.reactive.md) ([中文](recipes/workshop-zh.reactive.md)) combines cross-field validation, conditional tones, numeric aggregates and generated table rows. See the [constraints and collections reference](../../docs/reference/constraints-collections-en.md) for rules and budgets.
|
|
12
|
+
|
|
13
|
+
The [invoice recipe](recipes/invoice.reactive.md) ([中文](recipes/invoice-zh.reactive.md)) demonstrates shared calculations, constants, formatting and UTC date differences. The [calculation reference](../../docs/reference/computations-formatting-en.md) explains its rules.
|
|
14
|
+
|
|
15
|
+
Start with the [plan calculator](pricing.reactive.md), then choose a [feature tour](showcase/README.md). For the smallest possible state example, read the original [counter](counter.reactive.md). If you are new to the syntax, read the [new user guide](../../docs/guides/local-guide-en.md).
|
|
16
|
+
|
|
17
|
+
## Original standalone catalog
|
|
18
|
+
|
|
19
|
+
| File | Contents |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| [counter.reactive.md](counter.reactive.md) | One-line counter with built-in plus, minus and reset |
|
|
22
|
+
| [pricing.reactive.md](pricing.reactive.md) | Plan calculator with parameters linked inside a panel |
|
|
23
|
+
| [comparison.reactive.md](comparison.reactive.md) | Side-by-side comparison, a switch declared in place, tabs that manage their own selection |
|
|
24
|
+
| [parameters.reactive.md](parameters.reactive.md) | Live parameter panel with text, date and choice inputs |
|
|
25
|
+
| [checklist.reactive.md](checklist.reactive.md) | Fixed checkable list and an enhanced table |
|
|
26
|
+
| [charts.reactive.md](charts.reactive.md) | Charts built from tables, with a compound-interest formula in LaTeX |
|
|
27
|
+
| [diagram.reactive.md](diagram.reactive.md) | Auto-laid-out interactive diagram and curves |
|
|
28
|
+
| [catalog.reactive.md](catalog.reactive.md) | Local catalog search, sorting and paging |
|
|
29
|
+
| [planning.reactive.md](planning.reactive.md) | Timeline, timer and bill-splitting calculation |
|
|
30
|
+
| [components.reactive.md](components.reactive.md) | Content cards, disclosures, tabs and hint components |
|
|
31
|
+
| [gallery.reactive.md](gallery.reactive.md) | Common inputs, standalone components and code shown as-is |
|
|
32
|
+
| [diagnostics.reactive.md](diagnostics.reactive.md) | Intentionally broken diagnostics example |
|
|
33
|
+
|
|
34
|
+
The Playground example index is maintained in the repository's demo application.
|
|
35
|
+
|
|
36
|
+
## Expected behavior of the working examples
|
|
37
|
+
|
|
38
|
+
The table below lists the initial values and interaction checkpoints for each document. Numbers follow the formulas in the prose.
|
|
39
|
+
|
|
40
|
+
| Example | Initial display | Interaction checks |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| comparison | Basic 100 USD, Pro 200 USD | Annual billing changes them to 80/160; switching tabs needs no declared variable; reset returns to monthly billing |
|
|
43
|
+
| parameters | Date 2026-10-22, personal use, name empty | Entering a name updates the card; selecting team use updates the description; checking the switch shows the preparation checklist; panel reset restores fields and switches |
|
|
44
|
+
| checklist | 1/3 items, progress about 33.33% | Selecting all shows the completion notice; reset restores only the first item; the table sorts by price, searches and pages |
|
|
45
|
+
| charts | 4 budget comparisons; savings parameters 10000, 500, 5%, 20 years; plan bars 40/70 | With the rate at 0 the end-of-curve readout is 130000; the default compound readout is about 232643.24; with 5 people the bars are 100/175 |
|
|
46
|
+
| diagram | Input node selected, a=1, f=1 | Clicking the compute node updates the details and prose; at a=0 the curve flattens and a notice appears; both fixed curves are shown together |
|
|
47
|
+
| catalog | 8 catalog rows, 4 rows per page | Searching for "visual" returns chart/plot/diagram; no match shows the empty state; reset clears the query, sorting and page |
|
|
48
|
+
| planning | 45-minute timeline, countdown paused at 60 seconds, 88 USD per person | timer start/pause/reset; with the extra charge at 0 each person pays 80 USD; the reference task starting at 15 overlaps the main section |
|
|
49
|
+
| components | Concise explanation, first disclosure open | Selecting detailed switches the prose; the tooltip is keyboard-focusable; other disclosures open independently |
|
|
50
|
+
| pricing | 2 people, 100 USD each, 200 USD total | Annual billing gives 160 USD; annual billing for 5 people is 400 USD and shows the team notice; reset returns to 200 USD |
|
|
51
|
+
| counter | 0 | Three increments show 3; three decrements return to 0 and disable minus; reset returns to 0 |
|
|
52
|
+
| gallery | Alex, quantity 3, Pro, monthly billing, cost 240 USD | Annual billing gives 192 USD; hiding and showing the express section keeps its checks; the standalone counter and timer need no bind; `example` in the code block creates no variable |
|
|
53
|
+
|
|
54
|
+
In parameters, the conditional checklist sits outside the panel: its existing checks survive hiding and are outside that panel's reset scope. The standalone counter and timer in gallery also sit outside the input panel, so resetting the input panel does not affect them.
|
|
55
|
+
|
|
56
|
+
## Expected results of the diagnostics example
|
|
57
|
+
|
|
58
|
+
[diagnostics.reactive.md](diagnostics.reactive.md) intentionally contains the following 9 error classes. The editor should collect recoverable, independent diagnostics, and the document as a whole must not activate interactions.
|
|
59
|
+
|
|
60
|
+
1. `seat` is not declared; the message can suggest the existing parameter `seats`.
|
|
61
|
+
2. `seats` has a duplicate explicit initial; both sources are reported.
|
|
62
|
+
3. `ratio` has initial value 12, above the maximum 10.
|
|
63
|
+
4. if.when receives `seats`, a number, where a boolean is required.
|
|
64
|
+
5. `slidr` is an unknown component; the message can suggest `slider`.
|
|
65
|
+
6. `on-click` is not part of counter or the local interaction event syntax.
|
|
66
|
+
7. The edge target `missing` does not exist.
|
|
67
|
+
8. The integral can be displayed but is not a computable structure in the first plot version.
|
|
68
|
+
9. The chart's cost column contains `20 USD`, text where a plain number is required.
|
|
69
|
+
|
|
70
|
+
## Check entry points
|
|
71
|
+
|
|
72
|
+
`npm test` checks parsing, bindings, expressions, LaTeX, the runtime and examples; `npm run test:demo` checks the Playground index; `npm run verify:release` runs the complete Node-side and browser gate, including real-tarball consumption and HTML export. See the [contributing guide](../../CONTRIBUTING.md) for individual commands.
|
|
73
|
+
|
|
74
|
+
The [six scenarios](showcase/README.md) include all 48 tag names: intervals, coordinates and numeric questions in Functions; input choices in Forms; linked selection in Data; jumps and prose colors in Layout; guided steps and choice questions in Flow; todos and timing in Checklists. The standalone gallery and interaction-tour sources remain available as authoring examples.
|
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
# Charts follow their inputs
|
|
2
|
-
|
|
3
|
-
## Comparing several budget series
|
|
4
|
-
|
|
5
|
-
<chart title="Actual cost vs budget" y-label="USD">
|
|
6
|
-
| Category | Actual cost | Budget |
|
|
7
|
-
| --- | ---: | ---: |
|
|
8
|
-
| Content | 120 | 150 |
|
|
9
|
-
| Visual | 230 | 200 |
|
|
10
|
-
| Interaction | 180 | 220 |
|
|
11
|
-
| Testing | 90 | 120 |
|
|
12
|
-
</chart>
|
|
13
|
-
|
|
14
|
-
## Savings curve
|
|
15
|
-
|
|
16
|
-
Deposit a fixed amount at the end of every month, compounded monthly at a fixed annual rate. $P$ is the initial amount, $m$ is the monthly deposit, and $r$ is the annual rate in percent.
|
|
17
|
-
|
|
18
|
-
<panel title="Adjust savings parameters">
|
|
19
|
-
<number bind="P" label="Initial amount" initial="10000" min="0" step="100">
|
|
20
|
-
<number bind="m" label="Monthly deposit" initial="500" min="0" step="100">
|
|
21
|
-
<slider bind="r" label="Annual rate (%)" initial="5" min="0" max="10" step="0.5">
|
|
22
|
-
<slider bind="t" label="Years" initial="20" min="1" max="40">
|
|
23
|
-
</panel>
|
|
24
|
-
|
|
25
|
-
<plot min="0" max="{{ t }}" label="Savings growth" x-label="Years" y-label="Amount">
|
|
26
|
-
$$
|
|
27
|
-
y =
|
|
28
|
-
\begin{cases}
|
|
29
|
-
P + 12mx, & r = 0 \\
|
|
30
|
-
P\left(1+\frac{r}{1200}\right)^{12x}
|
|
31
|
-
+ m\frac{\left(1+\frac{r}{1200}\right)^{12x}-1}{r/1200}, & r \ne 0
|
|
32
|
-
\end{cases}
|
|
33
|
-
$$
|
|
34
|
-
</plot>
|
|
35
|
-
|
|
36
|
-
Move the pointer to the end of the curve to read the balance at the end of year {{ t }}. Set the annual rate to 0 to compare growth from deposits alone.
|
|
37
|
-
|
|
38
|
-
## Shares and scatter
|
|
39
|
-
|
|
40
|
-
<grid>
|
|
41
|
-
<card title="Cost share">
|
|
42
|
-
<chart kind="donut" title="Share of actual cost">
|
|
43
|
-
| Category | Actual cost |
|
|
44
|
-
| --- | ---: |
|
|
45
|
-
| Content | 120 |
|
|
46
|
-
| Visual | 230 |
|
|
47
|
-
| Interaction | 180 |
|
|
48
|
-
| Testing | 90 |
|
|
49
|
-
</chart>
|
|
50
|
-
</card>
|
|
51
|
-
|
|
52
|
-
<card title="Budget vs actual">
|
|
53
|
-
<chart kind="scatter" title="Budget scatter" x="Budget" y="Actual" x-label="Budget" y-label="Actual">
|
|
54
|
-
| Budget | Actual |
|
|
55
|
-
| ---: | ---: |
|
|
56
|
-
| 150 | 120 |
|
|
57
|
-
| 200 | 230 |
|
|
58
|
-
| 220 | 180 |
|
|
59
|
-
| 120 | 90 |
|
|
60
|
-
</chart>
|
|
61
|
-
</card>
|
|
62
|
-
</grid>
|
|
63
|
-
|
|
64
|
-
## Charts read the same parameters
|
|
65
|
-
|
|
66
|
-
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
67
|
-
|
|
68
|
-
<chart title="Plan cost by headcount" y-label="USD">
|
|
69
|
-
| Plan | Monthly cost |
|
|
70
|
-
| --- | ---: |
|
|
71
|
-
| Basic | {{ people * 20 }} |
|
|
72
|
-
| Pro | {{ people * 35 }} |
|
|
73
|
-
</chart>
|
|
1
|
+
# Charts follow their inputs
|
|
2
|
+
|
|
3
|
+
## Comparing several budget series
|
|
4
|
+
|
|
5
|
+
<chart title="Actual cost vs budget" y-label="USD">
|
|
6
|
+
| Category | Actual cost | Budget |
|
|
7
|
+
| --- | ---: | ---: |
|
|
8
|
+
| Content | 120 | 150 |
|
|
9
|
+
| Visual | 230 | 200 |
|
|
10
|
+
| Interaction | 180 | 220 |
|
|
11
|
+
| Testing | 90 | 120 |
|
|
12
|
+
</chart>
|
|
13
|
+
|
|
14
|
+
## Savings curve
|
|
15
|
+
|
|
16
|
+
Deposit a fixed amount at the end of every month, compounded monthly at a fixed annual rate. $P$ is the initial amount, $m$ is the monthly deposit, and $r$ is the annual rate in percent.
|
|
17
|
+
|
|
18
|
+
<panel title="Adjust savings parameters">
|
|
19
|
+
<number bind="P" label="Initial amount" initial="10000" min="0" step="100">
|
|
20
|
+
<number bind="m" label="Monthly deposit" initial="500" min="0" step="100">
|
|
21
|
+
<slider bind="r" label="Annual rate (%)" initial="5" min="0" max="10" step="0.5">
|
|
22
|
+
<slider bind="t" label="Years" initial="20" min="1" max="40">
|
|
23
|
+
</panel>
|
|
24
|
+
|
|
25
|
+
<plot min="0" max="{{ t }}" label="Savings growth" x-label="Years" y-label="Amount">
|
|
26
|
+
$$
|
|
27
|
+
y =
|
|
28
|
+
\begin{cases}
|
|
29
|
+
P + 12mx, & r = 0 \\
|
|
30
|
+
P\left(1+\frac{r}{1200}\right)^{12x}
|
|
31
|
+
+ m\frac{\left(1+\frac{r}{1200}\right)^{12x}-1}{r/1200}, & r \ne 0
|
|
32
|
+
\end{cases}
|
|
33
|
+
$$
|
|
34
|
+
</plot>
|
|
35
|
+
|
|
36
|
+
Move the pointer to the end of the curve to read the balance at the end of year {{ t }}. Set the annual rate to 0 to compare growth from deposits alone.
|
|
37
|
+
|
|
38
|
+
## Shares and scatter
|
|
39
|
+
|
|
40
|
+
<grid>
|
|
41
|
+
<card title="Cost share">
|
|
42
|
+
<chart kind="donut" title="Share of actual cost">
|
|
43
|
+
| Category | Actual cost |
|
|
44
|
+
| --- | ---: |
|
|
45
|
+
| Content | 120 |
|
|
46
|
+
| Visual | 230 |
|
|
47
|
+
| Interaction | 180 |
|
|
48
|
+
| Testing | 90 |
|
|
49
|
+
</chart>
|
|
50
|
+
</card>
|
|
51
|
+
|
|
52
|
+
<card title="Budget vs actual">
|
|
53
|
+
<chart kind="scatter" title="Budget scatter" x="Budget" y="Actual" x-label="Budget" y-label="Actual">
|
|
54
|
+
| Budget | Actual |
|
|
55
|
+
| ---: | ---: |
|
|
56
|
+
| 150 | 120 |
|
|
57
|
+
| 200 | 230 |
|
|
58
|
+
| 220 | 180 |
|
|
59
|
+
| 120 | 90 |
|
|
60
|
+
</chart>
|
|
61
|
+
</card>
|
|
62
|
+
</grid>
|
|
63
|
+
|
|
64
|
+
## Charts read the same parameters
|
|
65
|
+
|
|
66
|
+
<slider bind="people" label="People" initial="2" min="1" max="20">
|
|
67
|
+
|
|
68
|
+
<chart title="Plan cost by headcount" y-label="USD">
|
|
69
|
+
| Plan | Monthly cost |
|
|
70
|
+
| --- | ---: |
|
|
71
|
+
| Basic | {{ people * 20 }} |
|
|
72
|
+
| Pro | {{ people * 35 }} |
|
|
73
|
+
</chart>
|
|
@@ -17,8 +17,27 @@
|
|
|
17
17
|
</details>
|
|
18
18
|
</details>
|
|
19
19
|
|
|
20
|
+
<div align="center">你好,**居中内容**。</div>
|
|
21
|
+
|
|
22
|
+
<p align="right">右对齐段落。</p>
|
|
23
|
+
|
|
20
24
|
<blockquote>默认模式使用现有渲染器和主题。</blockquote>
|
|
21
25
|
|
|
22
26
|
<ol start="3"><li>支持 HTML 列表。</li><li>代码按原样显示。</li></ol>
|
|
23
27
|
|
|
24
28
|
<pre><code><counter label="这里是代码"> {{ count }}</code></pre>
|
|
29
|
+
|
|
30
|
+
<table label="Markdown 表格" searchable="false" sortable="false">
|
|
31
|
+
| 项目 | 数值 |
|
|
32
|
+
| --- | ---: |
|
|
33
|
+
| 当前次数 | {{ count }} |
|
|
34
|
+
| 固定值 | 10 |
|
|
35
|
+
</table>
|
|
36
|
+
|
|
37
|
+
<table>
|
|
38
|
+
<caption>原生 HTML 表格</caption>
|
|
39
|
+
<tr><th scope="col">项目</th><th scope="col">数值</th></tr>
|
|
40
|
+
<tr><td>当前次数</td><td>{{ count }}</td></tr>
|
|
41
|
+
<tr><td>固定值</td><td>10</td></tr>
|
|
42
|
+
<tr><td colspan="2">**合并单元格**也支持 Markdown 和公式:\(x^2\)。</td></tr>
|
|
43
|
+
</table>
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
<const name="unitPrice" value="{{ 12.5 }}">
|
|
2
|
-
<computed name="total" value="{{ quantity * unitPrice }}">
|
|
3
|
-
<computed name="invoice" value="{{ formatCurrency(total, 'CNY', 2, 'zh-CN') }}">
|
|
4
|
-
<computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
|
|
5
|
-
|
|
6
|
-
# 共享账单计算
|
|
7
|
-
|
|
8
|
-
<panel title="调整账单">
|
|
9
|
-
<number bind="quantity" label="数量" initial="2" min="0" max="100">
|
|
10
|
-
<date bind="startDate" label="开始日期" initial="2026-10-24">
|
|
11
|
-
<date bind="endDate" label="结束日期" initial="2026-10-26">
|
|
12
|
-
</panel>
|
|
13
|
-
|
|
14
|
-
账单:**{{ invoice }}**。单价:{{ formatCurrency(unitPrice, 'CNY', 2, 'zh-CN') }}。
|
|
15
|
-
|
|
16
|
-
天数:{{ days == null ? '请选择两个日期' : formatNumber(days, 0) }}。
|
|
17
|
-
|
|
18
|
-
<if when="{{ total >= 100 }}">
|
|
19
|
-
达到批量配送门槛。
|
|
20
|
-
</if>
|
|
21
|
-
|
|
22
|
-
<chart kind="bar" title="账单总额" x="项目" y="费用">
|
|
23
|
-
| 项目 | 费用 |
|
|
24
|
-
| --- | --- |
|
|
25
|
-
| 账单 | {{ total }} |
|
|
26
|
-
| 单件 | {{ unitPrice }} |
|
|
27
|
-
</chart>
|
|
28
|
-
|
|
29
|
-
<plot label="账单倍数" min="0" max="2" samples="21">
|
|
30
|
-
$$
|
|
31
|
-
y = \mathrm{total} x
|
|
32
|
-
$$
|
|
33
|
-
</plot>
|
|
34
|
-
|
|
35
|
-
同一数字的其他显示:{{ formatNumber(total, 0) }}、{{ formatScientific(total) }}。
|
|
36
|
-
比例 {{ formatPercent(0.125, 1) }} 的显示不随读者设备地区变化。
|
|
1
|
+
<const name="unitPrice" value="{{ 12.5 }}">
|
|
2
|
+
<computed name="total" value="{{ quantity * unitPrice }}">
|
|
3
|
+
<computed name="invoice" value="{{ formatCurrency(total, 'CNY', 2, 'zh-CN') }}">
|
|
4
|
+
<computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
|
|
5
|
+
|
|
6
|
+
# 共享账单计算
|
|
7
|
+
|
|
8
|
+
<panel title="调整账单">
|
|
9
|
+
<number bind="quantity" label="数量" initial="2" min="0" max="100">
|
|
10
|
+
<date bind="startDate" label="开始日期" initial="2026-10-24">
|
|
11
|
+
<date bind="endDate" label="结束日期" initial="2026-10-26">
|
|
12
|
+
</panel>
|
|
13
|
+
|
|
14
|
+
账单:**{{ invoice }}**。单价:{{ formatCurrency(unitPrice, 'CNY', 2, 'zh-CN') }}。
|
|
15
|
+
|
|
16
|
+
天数:{{ days == null ? '请选择两个日期' : formatNumber(days, 0) }}。
|
|
17
|
+
|
|
18
|
+
<if when="{{ total >= 100 }}">
|
|
19
|
+
达到批量配送门槛。
|
|
20
|
+
</if>
|
|
21
|
+
|
|
22
|
+
<chart kind="bar" title="账单总额" x="项目" y="费用">
|
|
23
|
+
| 项目 | 费用 |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| 账单 | {{ total }} |
|
|
26
|
+
| 单件 | {{ unitPrice }} |
|
|
27
|
+
</chart>
|
|
28
|
+
|
|
29
|
+
<plot label="账单倍数" min="0" max="2" samples="21">
|
|
30
|
+
$$
|
|
31
|
+
y = \mathrm{total} x
|
|
32
|
+
$$
|
|
33
|
+
</plot>
|
|
34
|
+
|
|
35
|
+
同一数字的其他显示:{{ formatNumber(total, 0) }}、{{ formatScientific(total) }}。
|
|
36
|
+
比例 {{ formatPercent(0.125, 1) }} 的显示不随读者设备地区变化。
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
<const name="unitPrice" value="{{ 12.5 }}">
|
|
2
|
-
<computed name="total" value="{{ quantity * unitPrice }}">
|
|
3
|
-
<computed name="invoice" value="{{ formatCurrency(total) }}">
|
|
4
|
-
<computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
|
|
5
|
-
|
|
6
|
-
# Shared invoice calculations
|
|
7
|
-
|
|
8
|
-
<panel title="Adjust the invoice">
|
|
9
|
-
<number bind="quantity" label="Quantity" initial="2" min="0" max="100">
|
|
10
|
-
<date bind="startDate" label="Start" initial="2026-10-24">
|
|
11
|
-
<date bind="endDate" label="End" initial="2026-10-26">
|
|
12
|
-
</panel>
|
|
13
|
-
|
|
14
|
-
Invoice: **{{ invoice }}**. Per item: {{ formatCurrency(unitPrice) }}.
|
|
15
|
-
|
|
16
|
-
Days: {{ days == null ? 'Choose both dates' : formatNumber(days, 0) }}.
|
|
17
|
-
|
|
18
|
-
<if when="{{ total >= 100 }}">
|
|
19
|
-
Eligible for bulk delivery.
|
|
20
|
-
</if>
|
|
21
|
-
|
|
22
|
-
<chart kind="bar" title="Invoice total" x="Item" y="Cost">
|
|
23
|
-
| Item | Cost |
|
|
24
|
-
| --- | --- |
|
|
25
|
-
| Invoice | {{ total }} |
|
|
26
|
-
| One item | {{ unitPrice }} |
|
|
27
|
-
</chart>
|
|
28
|
-
|
|
29
|
-
<plot label="Scaled invoice" min="0" max="2" samples="21">
|
|
30
|
-
$$
|
|
31
|
-
y = \mathrm{total} x
|
|
32
|
-
$$
|
|
33
|
-
</plot>
|
|
34
|
-
|
|
35
|
-
Other displays of the same number: {{ formatNumber(total, 0) }}, {{ formatScientific(total) }}.
|
|
36
|
-
The fraction {{ formatPercent(0.125, 1) }} is independent of the reader's device locale.
|
|
1
|
+
<const name="unitPrice" value="{{ 12.5 }}">
|
|
2
|
+
<computed name="total" value="{{ quantity * unitPrice }}">
|
|
3
|
+
<computed name="invoice" value="{{ formatCurrency(total) }}">
|
|
4
|
+
<computed name="days" value="{{ startDate == '' || endDate == '' ? null : dateDiff(endDate, startDate) }}">
|
|
5
|
+
|
|
6
|
+
# Shared invoice calculations
|
|
7
|
+
|
|
8
|
+
<panel title="Adjust the invoice">
|
|
9
|
+
<number bind="quantity" label="Quantity" initial="2" min="0" max="100">
|
|
10
|
+
<date bind="startDate" label="Start" initial="2026-10-24">
|
|
11
|
+
<date bind="endDate" label="End" initial="2026-10-26">
|
|
12
|
+
</panel>
|
|
13
|
+
|
|
14
|
+
Invoice: **{{ invoice }}**. Per item: {{ formatCurrency(unitPrice) }}.
|
|
15
|
+
|
|
16
|
+
Days: {{ days == null ? 'Choose both dates' : formatNumber(days, 0) }}.
|
|
17
|
+
|
|
18
|
+
<if when="{{ total >= 100 }}">
|
|
19
|
+
Eligible for bulk delivery.
|
|
20
|
+
</if>
|
|
21
|
+
|
|
22
|
+
<chart kind="bar" title="Invoice total" x="Item" y="Cost">
|
|
23
|
+
| Item | Cost |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| Invoice | {{ total }} |
|
|
26
|
+
| One item | {{ unitPrice }} |
|
|
27
|
+
</chart>
|
|
28
|
+
|
|
29
|
+
<plot label="Scaled invoice" min="0" max="2" samples="21">
|
|
30
|
+
$$
|
|
31
|
+
y = \mathrm{total} x
|
|
32
|
+
$$
|
|
33
|
+
</plot>
|
|
34
|
+
|
|
35
|
+
Other displays of the same number: {{ formatNumber(total, 0) }}, {{ formatScientific(total) }}.
|
|
36
|
+
The fraction {{ formatPercent(0.125, 1) }} is independent of the reader's device locale.
|