@mobile-reality/mdma-renderer-vue 0.2.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.
Files changed (92) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/components/ApprovalGateRenderer.d.ts +40 -0
  4. package/dist/components/ApprovalGateRenderer.d.ts.map +1 -0
  5. package/dist/components/ApprovalGateRenderer.js +48 -0
  6. package/dist/components/ApprovalGateRenderer.js.map +1 -0
  7. package/dist/components/ButtonRenderer.d.ts +40 -0
  8. package/dist/components/ButtonRenderer.d.ts.map +1 -0
  9. package/dist/components/ButtonRenderer.js +28 -0
  10. package/dist/components/ButtonRenderer.js.map +1 -0
  11. package/dist/components/CalloutRenderer.d.ts +40 -0
  12. package/dist/components/CalloutRenderer.d.ts.map +1 -0
  13. package/dist/components/CalloutRenderer.js +39 -0
  14. package/dist/components/CalloutRenderer.js.map +1 -0
  15. package/dist/components/ChartRenderer.d.ts +45 -0
  16. package/dist/components/ChartRenderer.d.ts.map +1 -0
  17. package/dist/components/ChartRenderer.js +66 -0
  18. package/dist/components/ChartRenderer.js.map +1 -0
  19. package/dist/components/CustomRenderer.d.ts +45 -0
  20. package/dist/components/CustomRenderer.d.ts.map +1 -0
  21. package/dist/components/CustomRenderer.js +32 -0
  22. package/dist/components/CustomRenderer.js.map +1 -0
  23. package/dist/components/FormRenderer.d.ts +41 -0
  24. package/dist/components/FormRenderer.d.ts.map +1 -0
  25. package/dist/components/FormRenderer.js +291 -0
  26. package/dist/components/FormRenderer.js.map +1 -0
  27. package/dist/components/MdastRenderer.d.ts +37 -0
  28. package/dist/components/MdastRenderer.d.ts.map +1 -0
  29. package/dist/components/MdastRenderer.js +102 -0
  30. package/dist/components/MdastRenderer.js.map +1 -0
  31. package/dist/components/MdmaBlock.d.ts +36 -0
  32. package/dist/components/MdmaBlock.d.ts.map +1 -0
  33. package/dist/components/MdmaBlock.js +40 -0
  34. package/dist/components/MdmaBlock.js.map +1 -0
  35. package/dist/components/MdmaBlockLoading.d.ts +29 -0
  36. package/dist/components/MdmaBlockLoading.d.ts.map +1 -0
  37. package/dist/components/MdmaBlockLoading.js +30 -0
  38. package/dist/components/MdmaBlockLoading.js.map +1 -0
  39. package/dist/components/MdmaDocument.d.ts +109 -0
  40. package/dist/components/MdmaDocument.d.ts.map +1 -0
  41. package/dist/components/MdmaDocument.js +190 -0
  42. package/dist/components/MdmaDocument.js.map +1 -0
  43. package/dist/components/TableRenderer.d.ts +40 -0
  44. package/dist/components/TableRenderer.d.ts.map +1 -0
  45. package/dist/components/TableRenderer.js +65 -0
  46. package/dist/components/TableRenderer.js.map +1 -0
  47. package/dist/components/TasklistRenderer.d.ts +40 -0
  48. package/dist/components/TasklistRenderer.d.ts.map +1 -0
  49. package/dist/components/TasklistRenderer.js +49 -0
  50. package/dist/components/TasklistRenderer.js.map +1 -0
  51. package/dist/components/ThinkingRenderer.d.ts +45 -0
  52. package/dist/components/ThinkingRenderer.d.ts.map +1 -0
  53. package/dist/components/ThinkingRenderer.js +48 -0
  54. package/dist/components/ThinkingRenderer.js.map +1 -0
  55. package/dist/components/WebhookRenderer.d.ts +40 -0
  56. package/dist/components/WebhookRenderer.d.ts.map +1 -0
  57. package/dist/components/WebhookRenderer.js +41 -0
  58. package/dist/components/WebhookRenderer.js.map +1 -0
  59. package/dist/composables/use-document-store.d.ts +22 -0
  60. package/dist/composables/use-document-store.d.ts.map +1 -0
  61. package/dist/composables/use-document-store.js +84 -0
  62. package/dist/composables/use-document-store.js.map +1 -0
  63. package/dist/context/CustomVariantContext.d.ts +41 -0
  64. package/dist/context/CustomVariantContext.d.ts.map +1 -0
  65. package/dist/context/CustomVariantContext.js +17 -0
  66. package/dist/context/CustomVariantContext.js.map +1 -0
  67. package/dist/context/ElementOverridesContext.d.ts +111 -0
  68. package/dist/context/ElementOverridesContext.d.ts.map +1 -0
  69. package/dist/context/ElementOverridesContext.js +31 -0
  70. package/dist/context/ElementOverridesContext.js.map +1 -0
  71. package/dist/context/MdmaProvider.d.ts +50 -0
  72. package/dist/context/MdmaProvider.d.ts.map +1 -0
  73. package/dist/context/MdmaProvider.js +35 -0
  74. package/dist/context/MdmaProvider.js.map +1 -0
  75. package/dist/index.d.ts +21 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +21 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/renderers/renderer-props.d.ts +51 -0
  80. package/dist/renderers/renderer-props.d.ts.map +1 -0
  81. package/dist/renderers/renderer-props.js +30 -0
  82. package/dist/renderers/renderer-props.js.map +1 -0
  83. package/dist/renderers/renderer-registry.d.ts +18 -0
  84. package/dist/renderers/renderer-registry.d.ts.map +1 -0
  85. package/dist/renderers/renderer-registry.js +52 -0
  86. package/dist/renderers/renderer-registry.js.map +1 -0
  87. package/dist/theme/MdmaThemeProvider.d.ts +152 -0
  88. package/dist/theme/MdmaThemeProvider.d.ts.map +1 -0
  89. package/dist/theme/MdmaThemeProvider.js +169 -0
  90. package/dist/theme/MdmaThemeProvider.js.map +1 -0
  91. package/package.json +60 -0
  92. package/styles.css +1045 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Marcin Sadowski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # @mobile-reality/mdma-renderer-vue
2
+
3
+ Vue 3 renderer for [MDMA](https://github.com/MobileReality/mdma) documents — the Vue sibling of
4
+ [`@mobile-reality/mdma-renderer-react`](../renderer-react). Renders all 10 MDMA component types
5
+ plus inline Markdown, emitting the same `.mdma-*` class names and shipping the same
6
+ `styles.css`, so a theme is portable between the two renderers.
7
+
8
+ It reuses MDMA's headless stack unchanged — `spec`, `parser`, `runtime`, and (registered at the
9
+ app layer) `attachables-core` — and reimplements only the view layer. The document store,
10
+ binding graph, policy, audit log, PII redaction, and streaming state-preservation all come from
11
+ `runtime`; each Vue component emits the same store actions its React counterpart does.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ npm install @mobile-reality/mdma-renderer-vue \
17
+ @mobile-reality/mdma-spec @mobile-reality/mdma-runtime vue
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```ts
23
+ import { createDocumentStore } from '@mobile-reality/mdma-runtime';
24
+ import { MdmaDocument } from '@mobile-reality/mdma-renderer-vue';
25
+ import '@mobile-reality/mdma-renderer-vue/styles.css';
26
+ ```
27
+
28
+ ```vue
29
+ <script setup lang="ts">
30
+ import { MdmaDocument } from '@mobile-reality/mdma-renderer-vue';
31
+
32
+ // `ast` comes from @mobile-reality/mdma-parser; `store` is created from it.
33
+ const props = defineProps<{ ast: MdmaRoot; store: DocumentStore }>();
34
+ </script>
35
+
36
+ <template>
37
+ <MdmaDocument :ast="props.ast" :store="props.store" theme="dark" />
38
+ </template>
39
+ ```
40
+
41
+ ### Theming
42
+
43
+ Pass `theme="light" | "dark" | "auto"` (`"auto"` follows the OS color scheme) or a full
44
+ `MdmaTheme` token object; omit it for the default light palette. Built-in palettes are applied
45
+ as a `data-theme` attribute, a custom theme as inline `--mdma-*` CSS variables. To theme
46
+ components rendered outside a `MdmaDocument` (a lone `MdmaBlock`, say), wrap them in
47
+ `MdmaThemeProvider`.
48
+
49
+ The `MdmaTheme` token shape is shared with the React and React Native renderers, so a theme
50
+ object is portable across all three. See the repo [Theming guide](../../docs/guides/theming.md)
51
+ for the full token reference.
52
+
53
+ ### Customizations
54
+
55
+ Override a whole component renderer, or just a sub-element inside one:
56
+
57
+ ```ts
58
+ <MdmaDocument
59
+ :ast="ast"
60
+ :store="store"
61
+ :customizations="{
62
+ components: {
63
+ chart: MyChartRenderer, // full renderer
64
+ form: { elements: { input: GlassInput } }, // sub-element only
65
+ },
66
+ customVariants: { 'signature-pad': SignaturePad },
67
+ dataSources: { countries: [{ label: 'Poland', value: 'PL' }] },
68
+ }"
69
+ />
70
+ ```
71
+
72
+ Element overrides resolve scope-specific → global (`'*'`) → built-in. Custom component types
73
+ also need a Zod schema registered with the parser via `customSchemas`.
74
+
75
+ A custom renderer should spread the exported prop declaration so Vue passes the props through
76
+ rather than dropping them on the root element as attributes:
77
+
78
+ ```ts
79
+ import { defineComponent, h } from 'vue';
80
+ import { blockRendererProps } from '@mobile-reality/mdma-renderer-vue';
81
+
82
+ export const MyChartRenderer = defineComponent({
83
+ props: blockRendererProps,
84
+ setup(props) {
85
+ return () => h('div', props.component.id);
86
+ },
87
+ });
88
+ ```
89
+
90
+ ## Differences from the React renderer
91
+
92
+ The public API mirrors `renderer-react` name for name (a test asserts every value export
93
+ exists here too), with these deliberate differences:
94
+
95
+ | | React | Vue |
96
+ |---|---|---|
97
+ | Composables | `useMdmaTheme()`, `useComponentState()` … return plain values | return `ComputedRef`s, so they stay reactive — read `.value` |
98
+ | Context | `createContext` / `useContext` | `provide` / `inject` with exported `InjectionKey`s |
99
+ | Renderer props | type-only `MdmaBlockRendererProps` | plus the runtime declaration `blockRendererProps` |
100
+ | Element overrides | components receive `onChange` props | same — an override may declare an `onChange` prop *or* `emits: ['change']` |
101
+ | Memoization | `memo` + `useCallback` | none needed; Vue caches renders itself |
102
+
103
+ Components are authored as `defineComponent` + `h()` render functions in plain `.ts` — no
104
+ `.vue` SFCs — so the package builds with the workspace's `tsc` and needs no bundler.
105
+
106
+ ## What's shared vs. reimplemented
107
+
108
+ | Shared (headless, verbatim) | Reimplemented (Vue view layer) |
109
+ |---|---|
110
+ | `createDocumentStore`, reducer, bindings | 10 component renderers |
111
+ | policy, audit log, PII redaction | inline Markdown → vnodes |
112
+ | streaming `updateAst` state preservation | `styles.css` (mirrored from the web renderer) |
113
+ | binding resolution | store subscription → Vue reactivity bridge |
114
+
115
+ ## License
116
+
117
+ Apache-2.0
@@ -0,0 +1,40 @@
1
+ export declare const ApprovalGateRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ component: {
3
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
4
+ required: true;
5
+ };
6
+ componentState: {
7
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
8
+ default: undefined;
9
+ };
10
+ dispatch: {
11
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
12
+ required: true;
13
+ };
14
+ resolveBinding: {
15
+ type: import("vue").PropType<(expr: string) => unknown>;
16
+ required: true;
17
+ };
18
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
19
+ [key: string]: any;
20
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
+ component: {
22
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
23
+ required: true;
24
+ };
25
+ componentState: {
26
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
27
+ default: undefined;
28
+ };
29
+ dispatch: {
30
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
31
+ required: true;
32
+ };
33
+ resolveBinding: {
34
+ type: import("vue").PropType<(expr: string) => unknown>;
35
+ required: true;
36
+ };
37
+ }>> & Readonly<{}>, {
38
+ componentState: import("@mobile-reality/mdma-runtime").ComponentState;
39
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
40
+ //# sourceMappingURL=ApprovalGateRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalGateRenderer.d.ts","sourceRoot":"","sources":["../../src/components/ApprovalGateRenderer.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA2D/B,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ export const ApprovalGateRenderer = defineComponent({
4
+ name: 'ApprovalGateRenderer',
5
+ props: blockRendererProps,
6
+ setup(props) {
7
+ return () => {
8
+ const component = props.component;
9
+ if (component.type !== 'approval-gate')
10
+ return null;
11
+ const status = props.componentState?.values.status ?? 'pending';
12
+ return h('div', {
13
+ class: `mdma-approval-gate mdma-approval-gate--${status}`,
14
+ 'data-component-id': component.id,
15
+ }, [
16
+ h('h3', { class: 'mdma-approval-gate-title' }, component.title),
17
+ component.description
18
+ ? h('p', { class: 'mdma-approval-gate-description' }, component.description)
19
+ : null,
20
+ h('div', { class: 'mdma-approval-gate-status' }, ['Status: ', h('strong', status)]),
21
+ status === 'pending'
22
+ ? h('div', { class: 'mdma-approval-gate-actions' }, [
23
+ h('button', {
24
+ type: 'button',
25
+ class: 'mdma-button mdma-button--primary',
26
+ onClick: () => props.dispatch({
27
+ type: 'APPROVAL_GRANTED',
28
+ componentId: component.id,
29
+ actor: { id: 'current-user' },
30
+ }),
31
+ }, 'Approve'),
32
+ h('button', {
33
+ type: 'button',
34
+ class: 'mdma-button mdma-button--danger',
35
+ onClick: () => props.dispatch({
36
+ type: 'APPROVAL_DENIED',
37
+ componentId: component.id,
38
+ actor: { id: 'current-user' },
39
+ reason: '',
40
+ }),
41
+ }, 'Deny'),
42
+ ])
43
+ : null,
44
+ ]);
45
+ };
46
+ },
47
+ });
48
+ //# sourceMappingURL=ApprovalGateRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApprovalGateRenderer.js","sourceRoot":"","sources":["../../src/components/ApprovalGateRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC;IAClD,IAAI,EAAE,sBAAsB;IAC5B,KAAK,EAAE,kBAAkB;IACzB,KAAK,CAAC,KAAK;QACT,OAAO,GAAG,EAAE;YACV,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YAClC,IAAI,SAAS,CAAC,IAAI,KAAK,eAAe;gBAAE,OAAO,IAAI,CAAC;YAEpD,MAAM,MAAM,GAAI,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC,MAAiB,IAAI,SAAS,CAAC;YAE5E,OAAO,CAAC,CACN,KAAK,EACL;gBACE,KAAK,EAAE,0CAA0C,MAAM,EAAE;gBACzD,mBAAmB,EAAE,SAAS,CAAC,EAAE;aAClC,EACD;gBACE,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,0BAA0B,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC;gBAC/D,SAAS,CAAC,WAAW;oBACnB,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,gCAAgC,EAAE,EAAE,SAAS,CAAC,WAAW,CAAC;oBAC5E,CAAC,CAAC,IAAI;gBACR,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,2BAA2B,EAAE,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;gBACnF,MAAM,KAAK,SAAS;oBAClB,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,4BAA4B,EAAE,EAAE;wBAChD,CAAC,CACC,QAAQ,EACR;4BACE,IAAI,EAAE,QAAQ;4BACd,KAAK,EAAE,kCAAkC;4BACzC,OAAO,EAAE,GAAG,EAAE,CACZ,KAAK,CAAC,QAAQ,CAAC;gCACb,IAAI,EAAE,kBAAkB;gCACxB,WAAW,EAAE,SAAS,CAAC,EAAE;gCACzB,KAAK,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE;6BAC9B,CAAC;yBACL,EACD,SAAS,CACV;wBACD,CAAC,CACC,QAAQ,EACR;4BACE,IAAI,EAAE,QAAQ;4BACd,KAAK,EAAE,iCAAiC;4BACxC,OAAO,EAAE,GAAG,EAAE,CACZ,KAAK,CAAC,QAAQ,CAAC;gCACb,IAAI,EAAE,iBAAiB;gCACvB,WAAW,EAAE,SAAS,CAAC,EAAE;gCACzB,KAAK,EAAE,EAAE,EAAE,EAAE,cAAc,EAAE;gCAC7B,MAAM,EAAE,EAAE;6BACX,CAAC;yBACL,EACD,MAAM,CACP;qBACF,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ export declare const ButtonRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ component: {
3
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
4
+ required: true;
5
+ };
6
+ componentState: {
7
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
8
+ default: undefined;
9
+ };
10
+ dispatch: {
11
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
12
+ required: true;
13
+ };
14
+ resolveBinding: {
15
+ type: import("vue").PropType<(expr: string) => unknown>;
16
+ required: true;
17
+ };
18
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
19
+ [key: string]: any;
20
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
+ component: {
22
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
23
+ required: true;
24
+ };
25
+ componentState: {
26
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
27
+ default: undefined;
28
+ };
29
+ dispatch: {
30
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
31
+ required: true;
32
+ };
33
+ resolveBinding: {
34
+ type: import("vue").PropType<(expr: string) => unknown>;
35
+ required: true;
36
+ };
37
+ }>> & Readonly<{}>, {
38
+ componentState: import("@mobile-reality/mdma-runtime").ComponentState;
39
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
40
+ //# sourceMappingURL=ButtonRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonRenderer.d.ts","sourceRoot":"","sources":["../../src/components/ButtonRenderer.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA4BzB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ export const ButtonRenderer = defineComponent({
4
+ name: 'ButtonRenderer',
5
+ props: blockRendererProps,
6
+ setup(props) {
7
+ return () => {
8
+ const component = props.component;
9
+ if (component.type !== 'button')
10
+ return null;
11
+ return h('button', {
12
+ type: 'button',
13
+ class: `mdma-button mdma-button--${component.variant ?? 'primary'}`,
14
+ 'data-component-id': component.id,
15
+ onClick: () => {
16
+ if (component.onAction) {
17
+ props.dispatch({
18
+ type: 'ACTION_TRIGGERED',
19
+ componentId: component.id,
20
+ actionId: component.onAction,
21
+ });
22
+ }
23
+ },
24
+ }, component.text);
25
+ };
26
+ },
27
+ });
28
+ //# sourceMappingURL=ButtonRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonRenderer.js","sourceRoot":"","sources":["../../src/components/ButtonRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;IAC5C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,kBAAkB;IACzB,KAAK,CAAC,KAAK;QACT,OAAO,GAAG,EAAE;YACV,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YAClC,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC;YAE7C,OAAO,CAAC,CACN,QAAQ,EACR;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,4BAA4B,SAAS,CAAC,OAAO,IAAI,SAAS,EAAE;gBACnE,mBAAmB,EAAE,SAAS,CAAC,EAAE;gBACjC,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;wBACvB,KAAK,CAAC,QAAQ,CAAC;4BACb,IAAI,EAAE,kBAAkB;4BACxB,WAAW,EAAE,SAAS,CAAC,EAAE;4BACzB,QAAQ,EAAE,SAAS,CAAC,QAAQ;yBAC7B,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;aACF,EACD,SAAS,CAAC,IAAI,CACf,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ export declare const CalloutRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ component: {
3
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
4
+ required: true;
5
+ };
6
+ componentState: {
7
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
8
+ default: undefined;
9
+ };
10
+ dispatch: {
11
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
12
+ required: true;
13
+ };
14
+ resolveBinding: {
15
+ type: import("vue").PropType<(expr: string) => unknown>;
16
+ required: true;
17
+ };
18
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
19
+ [key: string]: any;
20
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
21
+ component: {
22
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
23
+ required: true;
24
+ };
25
+ componentState: {
26
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
27
+ default: undefined;
28
+ };
29
+ dispatch: {
30
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
31
+ required: true;
32
+ };
33
+ resolveBinding: {
34
+ type: import("vue").PropType<(expr: string) => unknown>;
35
+ required: true;
36
+ };
37
+ }>> & Readonly<{}>, {
38
+ componentState: import("@mobile-reality/mdma-runtime").ComponentState;
39
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
40
+ //# sourceMappingURL=CalloutRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalloutRenderer.d.ts","sourceRoot":"","sources":["../../src/components/CalloutRenderer.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA4C1B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ export const CalloutRenderer = defineComponent({
4
+ name: 'CalloutRenderer',
5
+ props: blockRendererProps,
6
+ setup(props) {
7
+ return () => {
8
+ const component = props.component;
9
+ if (component.type !== 'callout')
10
+ return null;
11
+ // Dismissal is document state, so a dismissed callout stays dismissed
12
+ // across a re-parse of the same document.
13
+ if (props.componentState?.values.dismissed)
14
+ return null;
15
+ return h('div', {
16
+ class: `mdma-callout mdma-callout--${component.variant ?? 'info'}`,
17
+ 'data-component-id': component.id,
18
+ role: 'alert',
19
+ }, [
20
+ component.title ? h('strong', { class: 'mdma-callout-title' }, component.title) : null,
21
+ h('p', { class: 'mdma-callout-content' }, component.content),
22
+ component.dismissible
23
+ ? h('button', {
24
+ type: 'button',
25
+ class: 'mdma-callout-dismiss',
26
+ 'aria-label': 'Dismiss',
27
+ onClick: () => props.dispatch({
28
+ type: 'FIELD_CHANGED',
29
+ componentId: component.id,
30
+ field: 'dismissed',
31
+ value: true,
32
+ }),
33
+ }, '×')
34
+ : null,
35
+ ]);
36
+ };
37
+ },
38
+ });
39
+ //# sourceMappingURL=CalloutRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalloutRenderer.js","sourceRoot":"","sources":["../../src/components/CalloutRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;IAC7C,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,kBAAkB;IACzB,KAAK,CAAC,KAAK;QACT,OAAO,GAAG,EAAE;YACV,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YAClC,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YAE9C,sEAAsE;YACtE,0CAA0C;YAC1C,IAAI,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC,SAAS;gBAAE,OAAO,IAAI,CAAC;YAExD,OAAO,CAAC,CACN,KAAK,EACL;gBACE,KAAK,EAAE,8BAA8B,SAAS,CAAC,OAAO,IAAI,MAAM,EAAE;gBAClE,mBAAmB,EAAE,SAAS,CAAC,EAAE;gBACjC,IAAI,EAAE,OAAO;aACd,EACD;gBACE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;gBACtF,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,EAAE,SAAS,CAAC,OAAO,CAAC;gBAC5D,SAAS,CAAC,WAAW;oBACnB,CAAC,CAAC,CAAC,CACC,QAAQ,EACR;wBACE,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,sBAAsB;wBAC7B,YAAY,EAAE,SAAS;wBACvB,OAAO,EAAE,GAAG,EAAE,CACZ,KAAK,CAAC,QAAQ,CAAC;4BACb,IAAI,EAAE,eAAe;4BACrB,WAAW,EAAE,SAAS,CAAC,EAAE;4BACzB,KAAK,EAAE,WAAW;4BAClB,KAAK,EAAE,IAAI;yBACZ,CAAC;qBACL,EACD,GAAG,CACJ;oBACH,CAAC,CAAC,IAAI;aACT,CACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Basic built-in chart renderer.
3
+ * Renders chart data as a simple HTML table.
4
+ * Override with a richer renderer (e.g. a charting library) via customizations.
5
+ */
6
+ export declare const ChartRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
+ component: {
8
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
9
+ required: true;
10
+ };
11
+ componentState: {
12
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
13
+ default: undefined;
14
+ };
15
+ dispatch: {
16
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
17
+ required: true;
18
+ };
19
+ resolveBinding: {
20
+ type: import("vue").PropType<(expr: string) => unknown>;
21
+ required: true;
22
+ };
23
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
24
+ [key: string]: any;
25
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
26
+ component: {
27
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
28
+ required: true;
29
+ };
30
+ componentState: {
31
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
32
+ default: undefined;
33
+ };
34
+ dispatch: {
35
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
36
+ required: true;
37
+ };
38
+ resolveBinding: {
39
+ type: import("vue").PropType<(expr: string) => unknown>;
40
+ required: true;
41
+ };
42
+ }>> & Readonly<{}>, {
43
+ componentState: import("@mobile-reality/mdma-runtime").ComponentState;
44
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
45
+ //# sourceMappingURL=ChartRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChartRenderer.d.ts","sourceRoot":"","sources":["../../src/components/ChartRenderer.ts"],"names":[],"mappings":"AA8BA;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAyDxB,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { computed, defineComponent, h } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ function parseCsvData(raw) {
4
+ const lines = raw
5
+ .trim()
6
+ .split('\n')
7
+ .filter((l) => l.trim() !== '');
8
+ if (lines.length === 0)
9
+ return { headers: [], rows: [] };
10
+ const headers = lines[0].split(',').map((h) => h.trim());
11
+ const rows = lines.slice(1).map((line) => {
12
+ const values = line.split(',').map((v) => v.trim());
13
+ const row = {};
14
+ headers.forEach((header, i) => {
15
+ const val = values[i] ?? '';
16
+ const num = Number(val);
17
+ row[header] = val !== '' && !Number.isNaN(num) ? num : val;
18
+ });
19
+ return row;
20
+ });
21
+ return { headers, rows };
22
+ }
23
+ /**
24
+ * Basic built-in chart renderer.
25
+ * Renders chart data as a simple HTML table.
26
+ * Override with a richer renderer (e.g. a charting library) via customizations.
27
+ */
28
+ export const ChartRenderer = defineComponent({
29
+ name: 'ChartRenderer',
30
+ props: blockRendererProps,
31
+ setup(props) {
32
+ const data = computed(() => {
33
+ const component = props.component;
34
+ if (component.type !== 'chart')
35
+ return { headers: [], rows: [] };
36
+ const raw = component.data;
37
+ if (typeof raw === 'string' && raw.startsWith('{{')) {
38
+ const resolved = props.resolveBinding(raw);
39
+ return typeof resolved === 'string' ? parseCsvData(resolved) : { headers: [], rows: [] };
40
+ }
41
+ return parseCsvData(raw);
42
+ });
43
+ return () => {
44
+ const component = props.component;
45
+ if (component.type !== 'chart')
46
+ return null;
47
+ if (data.value.rows.length === 0) {
48
+ return h('div', { class: 'mdma-chart mdma-chart--empty', 'data-component-id': component.id }, [
49
+ component.label ? h('div', { class: 'mdma-chart-label' }, component.label) : null,
50
+ h('div', { class: 'mdma-chart-empty' }, 'No chart data'),
51
+ ]);
52
+ }
53
+ return h('div', { class: 'mdma-chart', 'data-component-id': component.id }, [
54
+ component.label ? h('div', { class: 'mdma-chart-label' }, component.label) : null,
55
+ h('div', { class: 'mdma-chart-variant' }, `${component.variant ?? 'line'} chart`),
56
+ h('table', { class: 'mdma-chart-data' }, [
57
+ h('thead', [
58
+ h('tr', data.value.headers.map((header) => h('th', { key: header }, header))),
59
+ ]),
60
+ h('tbody', data.value.rows.map((row, i) => h('tr', { key: i }, data.value.headers.map((header) => h('td', { key: header }, String(row[header] ?? '')))))),
61
+ ]),
62
+ ]);
63
+ };
64
+ },
65
+ });
66
+ //# sourceMappingURL=ChartRenderer.js.map
@@ -0,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G,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAChC,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CACpD,CACF,CACF,CACF;iBACF,CAAC;aACH,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Renders a `custom` component by dispatching to the variant registered under
3
+ * its `name`. Unknown names degrade to an inline fallback rather than crashing,
4
+ * mirroring how unknown component types are handled.
5
+ */
6
+ export declare const CustomRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
7
+ component: {
8
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
9
+ required: true;
10
+ };
11
+ componentState: {
12
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
13
+ default: undefined;
14
+ };
15
+ dispatch: {
16
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
17
+ required: true;
18
+ };
19
+ resolveBinding: {
20
+ type: import("vue").PropType<(expr: string) => unknown>;
21
+ required: true;
22
+ };
23
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
24
+ [key: string]: any;
25
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
26
+ component: {
27
+ type: import("vue").PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
28
+ required: true;
29
+ };
30
+ componentState: {
31
+ type: import("vue").PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
32
+ default: undefined;
33
+ };
34
+ dispatch: {
35
+ type: import("vue").PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
36
+ required: true;
37
+ };
38
+ resolveBinding: {
39
+ type: import("vue").PropType<(expr: string) => unknown>;
40
+ required: true;
41
+ };
42
+ }>> & Readonly<{}>, {
43
+ componentState: import("@mobile-reality/mdma-runtime").ComponentState;
44
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
45
+ //# sourceMappingURL=CustomRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomRenderer.d.ts","sourceRoot":"","sources":["../../src/components/CustomRenderer.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA6BzB,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ import { useCustomVariants } from '../context/CustomVariantContext.js';
4
+ /**
5
+ * Renders a `custom` component by dispatching to the variant registered under
6
+ * its `name`. Unknown names degrade to an inline fallback rather than crashing,
7
+ * mirroring how unknown component types are handled.
8
+ */
9
+ export const CustomRenderer = defineComponent({
10
+ name: 'CustomRenderer',
11
+ props: blockRendererProps,
12
+ setup(props) {
13
+ const variants = useCustomVariants();
14
+ return () => {
15
+ const component = props.component;
16
+ if (component.type !== 'custom')
17
+ return null;
18
+ const Variant = variants.value[component.name];
19
+ if (!Variant) {
20
+ return h('div', { class: 'mdma-unknown-component', 'data-component-id': component.id }, `Unknown custom component: ${component.name}`);
21
+ }
22
+ return h(Variant, {
23
+ component,
24
+ props: component.props,
25
+ componentState: props.componentState,
26
+ dispatch: props.dispatch,
27
+ resolveBinding: props.resolveBinding,
28
+ });
29
+ };
30
+ },
31
+ });
32
+ //# sourceMappingURL=CustomRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomRenderer.js","sourceRoot":"","sources":["../../src/components/CustomRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;IAC5C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,kBAAkB;IACzB,KAAK,CAAC,KAAK;QACT,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;QAErC,OAAO,GAAG,EAAE;YACV,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YAClC,IAAI,SAAS,CAAC,IAAI,KAAK,QAAQ;gBAAE,OAAO,IAAI,CAAC;YAE7C,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAE/C,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO,CAAC,CACN,KAAK,EACL,EAAE,KAAK,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,SAAS,CAAC,EAAE,EAAE,EACtE,6BAA6B,SAAS,CAAC,IAAI,EAAE,CAC9C,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,CAAC,OAAO,EAAE;gBAChB,SAAS;gBACT,KAAK,EAAE,SAAS,CAAC,KAAK;gBACtB,cAAc,EAAE,KAAK,CAAC,cAAc;gBACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,cAAc,EAAE,KAAK,CAAC,cAAc;aACrC,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}