@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
@@ -0,0 +1,41 @@
1
+ import { type PropType } from 'vue';
2
+ export declare const FormRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
+ component: {
4
+ type: PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
5
+ required: true;
6
+ };
7
+ componentState: {
8
+ type: PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
9
+ default: undefined;
10
+ };
11
+ dispatch: {
12
+ type: PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
13
+ required: true;
14
+ };
15
+ resolveBinding: {
16
+ type: PropType<(expr: string) => unknown>;
17
+ required: true;
18
+ };
19
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
20
+ [key: string]: any;
21
+ }> | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
22
+ component: {
23
+ type: PropType<import("@mobile-reality/mdma-spec").MdmaComponent>;
24
+ required: true;
25
+ };
26
+ componentState: {
27
+ type: PropType<import("@mobile-reality/mdma-runtime").ComponentState>;
28
+ default: undefined;
29
+ };
30
+ dispatch: {
31
+ type: PropType<(action: import("@mobile-reality/mdma-spec").StoreAction) => void>;
32
+ required: true;
33
+ };
34
+ resolveBinding: {
35
+ type: PropType<(expr: string) => unknown>;
36
+ required: true;
37
+ };
38
+ }>> & Readonly<{}>, {
39
+ componentState: import("@mobile-reality/mdma-runtime").ComponentState;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
41
+ //# sourceMappingURL=FormRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormRenderer.d.ts","sourceRoot":"","sources":["../../src/components/FormRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAmB,MAAM,KAAK,CAAC;AAiO9E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAuIvB,CAAC"}
@@ -0,0 +1,291 @@
1
+ import { defineComponent, h, ref } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ import { useMdmaContext } from '../context/MdmaProvider.js';
4
+ import { useElementOverride, } from '../context/ElementOverridesContext.js';
5
+ // ─── Sensitive field indicator ──────────────────────────────────────────────
6
+ const DefaultSensitiveIndicator = defineComponent({
7
+ name: 'MdmaSensitiveIndicator',
8
+ props: {
9
+ name: { type: String, required: true },
10
+ label: { type: String, required: true },
11
+ },
12
+ setup(props) {
13
+ return () => h('span', {
14
+ class: 'mdma-sensitive-badge',
15
+ title: `${props.label} contains sensitive data (PII)`,
16
+ }, '\u{1F512}');
17
+ },
18
+ });
19
+ // ─── Default sub-elements ────────────────────────────────────────────────────
20
+ /** Props shared by the text-ish inputs; `onChange` is a plain callback prop. */
21
+ const baseElementProps = {
22
+ id: { type: String, required: true },
23
+ name: { type: String, required: true },
24
+ label: { type: String, required: true },
25
+ onChange: { type: Function, required: true },
26
+ required: { type: Boolean, default: undefined },
27
+ sensitive: { type: Boolean, default: undefined },
28
+ };
29
+ const DefaultInput = defineComponent({
30
+ name: 'MdmaInput',
31
+ props: {
32
+ ...baseElementProps,
33
+ type: { type: String, required: true },
34
+ value: { type: String, required: true },
35
+ },
36
+ setup(props) {
37
+ // A sensitive field starts masked; the toggle is per-field UI state, not
38
+ // document state, so it never reaches the store.
39
+ const masked = ref(props.sensitive === true);
40
+ return () => h('span', { class: `mdma-input-wrapper ${props.sensitive ? 'mdma-input--sensitive' : ''}` }, [
41
+ h('input', {
42
+ id: props.id,
43
+ type: masked.value ? 'password' : props.type,
44
+ value: props.value,
45
+ required: props.required,
46
+ placeholder: props.sensitive ? `Enter ${props.type}...` : undefined,
47
+ onInput: (e) => props.onChange(e.target.value),
48
+ }),
49
+ props.sensitive && props.value
50
+ ? h('button', {
51
+ type: 'button',
52
+ class: 'mdma-sensitive-toggle',
53
+ title: masked.value ? 'Reveal value' : 'Mask value',
54
+ onClick: () => {
55
+ masked.value = !masked.value;
56
+ },
57
+ }, masked.value ? '👁' : '🔒')
58
+ : null,
59
+ ]);
60
+ },
61
+ });
62
+ const DefaultSelect = defineComponent({
63
+ name: 'MdmaSelect',
64
+ props: {
65
+ ...baseElementProps,
66
+ type: { type: String, required: true },
67
+ value: { type: String, required: true },
68
+ options: {
69
+ type: Array,
70
+ required: true,
71
+ },
72
+ },
73
+ setup(props) {
74
+ return () => h('select', {
75
+ id: props.id,
76
+ value: props.value,
77
+ required: props.required,
78
+ onChange: (e) => props.onChange(e.target.value),
79
+ }, [
80
+ h('option', { value: '' }, 'Select...'),
81
+ ...props.options.map((opt) => h('option', { key: opt.value, value: opt.value }, opt.label)),
82
+ ]);
83
+ },
84
+ });
85
+ const DefaultCheckbox = defineComponent({
86
+ name: 'MdmaCheckbox',
87
+ props: {
88
+ id: { type: String, required: true },
89
+ name: { type: String, required: true },
90
+ label: { type: String, required: true },
91
+ checked: { type: Boolean, required: true },
92
+ onChange: { type: Function, required: true },
93
+ sensitive: { type: Boolean, default: undefined },
94
+ },
95
+ setup(props) {
96
+ return () => h('input', {
97
+ id: props.id,
98
+ type: 'checkbox',
99
+ checked: props.checked,
100
+ onChange: (e) => props.onChange(e.target.checked),
101
+ });
102
+ },
103
+ });
104
+ const DefaultTextarea = defineComponent({
105
+ name: 'MdmaTextarea',
106
+ props: {
107
+ ...baseElementProps,
108
+ value: { type: String, required: true },
109
+ },
110
+ setup(props) {
111
+ return () => h('span', { class: `mdma-input-wrapper ${props.sensitive ? 'mdma-input--sensitive' : ''}` }, [
112
+ h('textarea', {
113
+ id: props.id,
114
+ value: props.value,
115
+ required: props.required,
116
+ placeholder: props.sensitive ? 'Enter sensitive data...' : undefined,
117
+ onInput: (e) => props.onChange(e.target.value),
118
+ }),
119
+ ]);
120
+ },
121
+ });
122
+ const DefaultFile = defineComponent({
123
+ name: 'MdmaFileInput',
124
+ props: {
125
+ id: { type: String, required: true },
126
+ name: { type: String, required: true },
127
+ label: { type: String, required: true },
128
+ value: { type: Array, required: true },
129
+ onChange: { type: Function, required: true },
130
+ required: { type: Boolean, default: undefined },
131
+ sensitive: { type: Boolean, default: undefined },
132
+ },
133
+ setup(props) {
134
+ return () => h('span', {
135
+ class: `mdma-input-wrapper mdma-input--file ${props.sensitive ? 'mdma-input--sensitive' : ''}`,
136
+ }, [
137
+ h('input', {
138
+ id: props.id,
139
+ type: 'file',
140
+ required: props.required,
141
+ onChange: (e) => {
142
+ const files = e.target.files;
143
+ props.onChange(files ? Array.from(files) : []);
144
+ },
145
+ }),
146
+ props.value.length > 0
147
+ ? h('ul', { class: 'mdma-file-list' }, props.value.map((file) => h('li', { key: `${file.name}-${file.lastModified}-${file.size}` }, [
148
+ props.sensitive ? '•••' : file.name,
149
+ ' ',
150
+ h('span', { class: 'mdma-file-size' }, `(${file.size} B)`),
151
+ ])))
152
+ : null,
153
+ ]);
154
+ },
155
+ });
156
+ const DefaultSubmitButton = defineComponent({
157
+ name: 'MdmaSubmitButton',
158
+ props: {
159
+ onClick: { type: Function, required: true },
160
+ label: { type: String, required: true },
161
+ },
162
+ setup(props) {
163
+ return () => h('button', { type: 'button', class: 'mdma-form-submit', onClick: props.onClick }, props.label);
164
+ },
165
+ });
166
+ // ─── FormRenderer ────────────────────────────────────────────────────────────
167
+ export const FormRenderer = defineComponent({
168
+ name: 'FormRenderer',
169
+ props: blockRendererProps,
170
+ setup(props) {
171
+ const ctx = useMdmaContext();
172
+ // Overrides resolve to refs, so a document whose customizations change swaps
173
+ // the sub-elements without remounting the form.
174
+ const Input = useElementOverride('form', 'input');
175
+ const Select = useElementOverride('form', 'select');
176
+ const Checkbox = useElementOverride('form', 'checkbox');
177
+ const Textarea = useElementOverride('form', 'textarea');
178
+ const FileInput = useElementOverride('form', 'file');
179
+ const SubmitButton = useElementOverride('form', 'submitButton');
180
+ const SensitiveMark = useElementOverride('form', 'sensitiveIndicator');
181
+ return () => {
182
+ const component = props.component;
183
+ if (component.type !== 'form')
184
+ return null;
185
+ const values = props.componentState?.values ?? {};
186
+ const fields = component.fields.map((field) => {
187
+ const fieldId = `${component.id}-${field.name}`;
188
+ const fieldValue = String(values[field.name] ?? '');
189
+ const handleChange = (value) => props.dispatch({
190
+ type: 'FIELD_CHANGED',
191
+ componentId: component.id,
192
+ field: field.name,
193
+ value,
194
+ });
195
+ const handleChecked = (checked) => props.dispatch({
196
+ type: 'FIELD_CHANGED',
197
+ componentId: component.id,
198
+ field: field.name,
199
+ value: checked,
200
+ });
201
+ const handleFiles = (files) => props.dispatch({
202
+ type: 'FIELD_CHANGED',
203
+ componentId: component.id,
204
+ field: field.name,
205
+ value: files,
206
+ });
207
+ const shared = {
208
+ id: fieldId,
209
+ name: field.name,
210
+ label: field.label,
211
+ required: field.required,
212
+ sensitive: field.sensitive,
213
+ };
214
+ let control;
215
+ if (field.type === 'select') {
216
+ control = h(Select.value ?? DefaultSelect, {
217
+ ...shared,
218
+ type: 'select',
219
+ value: fieldValue,
220
+ onChange: handleChange,
221
+ options: typeof field.options === 'string'
222
+ ? (ctx.value.dataSources?.[field.options] ?? [])
223
+ : (field.options ?? []),
224
+ });
225
+ }
226
+ else if (field.type === 'checkbox') {
227
+ control = h(Checkbox.value ?? DefaultCheckbox, {
228
+ id: fieldId,
229
+ name: field.name,
230
+ label: field.label,
231
+ checked: Boolean(values[field.name]),
232
+ onChange: handleChecked,
233
+ sensitive: field.sensitive,
234
+ });
235
+ }
236
+ else if (field.type === 'textarea') {
237
+ control = h(Textarea.value ?? DefaultTextarea, {
238
+ ...shared,
239
+ value: fieldValue,
240
+ onChange: handleChange,
241
+ });
242
+ }
243
+ else if (field.type === 'file') {
244
+ control = h(FileInput.value ?? DefaultFile, {
245
+ ...shared,
246
+ value: Array.isArray(values[field.name]) ? values[field.name] : [],
247
+ onChange: handleFiles,
248
+ });
249
+ }
250
+ else {
251
+ control = h(Input.value ?? DefaultInput, {
252
+ ...shared,
253
+ type: field.type,
254
+ value: fieldValue,
255
+ onChange: handleChange,
256
+ });
257
+ }
258
+ return h('div', {
259
+ key: field.name,
260
+ class: `mdma-form-field ${field.sensitive ? 'mdma-form-field--sensitive' : ''}`,
261
+ }, [
262
+ h('label', { for: fieldId }, [
263
+ field.label,
264
+ field.sensitive
265
+ ? h(SensitiveMark.value ?? DefaultSensitiveIndicator, {
266
+ name: field.name,
267
+ label: field.label,
268
+ })
269
+ : null,
270
+ ]),
271
+ control,
272
+ ]);
273
+ });
274
+ return h('div', { class: 'mdma-form', 'data-component-id': component.id }, [
275
+ component.label ? h('h3', { class: 'mdma-form-label' }, component.label) : null,
276
+ ...fields,
277
+ component.onSubmit
278
+ ? h(SubmitButton.value ?? DefaultSubmitButton, {
279
+ label: 'Submit',
280
+ onClick: () => props.dispatch({
281
+ type: 'ACTION_TRIGGERED',
282
+ componentId: component.id,
283
+ actionId: component.onSubmit,
284
+ }),
285
+ })
286
+ : null,
287
+ ]);
288
+ };
289
+ },
290
+ });
291
+ //# sourceMappingURL=FormRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormRenderer.js","sourceRoot":"","sources":["../../src/components/FormRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,EAAkC,MAAM,KAAK,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,kBAAkB,GAQnB,MAAM,uCAAuC,CAAC;AAE/C,+EAA+E;AAE/E,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,EAAE,wBAAwB;IAC9B,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QACtC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;KACxC;IACD,KAAK,CAAC,KAAyC;QAC7C,OAAO,GAAG,EAAE,CACV,CAAC,CACC,MAAM,EACN;YACE,KAAK,EAAE,sBAAsB;YAC7B,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,gCAAgC;SACtD,EACD,WAAW,CACZ,CAAC;IACN,CAAC;CACF,CAAC,CAAC;AAEH,gFAAgF;AAEhF,gFAAgF;AAChF,MAAM,gBAAgB,GAAG;IACvB,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAa,EAAE;IAC7C,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAa,EAAE;IAC/C,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAa,EAAE;IAChD,QAAQ,EAAE,EAAE,IAAI,EAAE,QAA6C,EAAE,QAAQ,EAAE,IAAa,EAAE;IAC1F,QAAQ,EAAE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AC,IAAI;gBAC/E,GAAG,MAAM;gBACT,SAAS,CAAC,QAAQ;oBAChB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,IAAI,mBAAmB,EAAE;wBAC3C,KAAK,EAAE,QAAQ;wBACf,OAAO,EAAE,GAAG,EAAE,CACZ,KAAK,CAAC,QAAQ,CAAC;4BACb,IAAI,EAAE,kBAAkB;4BACxB,WAAW,EAAE,SAAS,CAAC,EAAE;4BACzB,QAAQ,EAAE,SAAS,CAAC,QAAkB;yBACvC,CAAC;qBACL,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Renders standard mdast (Markdown AST) nodes as Vue vnodes.
3
+ * Handles headings, paragraphs, lists, blockquotes, code blocks,
4
+ * tables, links, images, emphasis, strong, and other common Markdown constructs.
5
+ */
6
+ import { type PropType } from 'vue';
7
+ export interface MdastNode {
8
+ type: string;
9
+ children?: MdastNode[];
10
+ value?: string;
11
+ depth?: number;
12
+ ordered?: boolean;
13
+ start?: number;
14
+ checked?: boolean | null;
15
+ lang?: string;
16
+ url?: string;
17
+ title?: string;
18
+ alt?: string;
19
+ align?: (string | null)[];
20
+ }
21
+ export type MdastRendererProps = {
22
+ node: MdastNode;
23
+ };
24
+ export declare const MdastRenderer: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
25
+ node: {
26
+ type: PropType<MdastNode>;
27
+ required: true;
28
+ };
29
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
30
+ [key: string]: any;
31
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
32
+ node: {
33
+ type: PropType<MdastNode>;
34
+ required: true;
35
+ };
36
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
37
+ //# sourceMappingURL=MdastRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdastRenderer.d.ts","sourceRoot":"","sources":["../../src/components/MdastRenderer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAsB,KAAK,QAAQ,EAAmB,MAAM,KAAK,CAAC;AAIzE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC;CAC3B;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAqIF,eAAO,MAAM,aAAa;;cAGE,QAAQ,CAAC,SAAS,CAAC;;;;;;;cAAnB,QAAQ,CAAC,SAAS,CAAC;;;iGAK7C,CAAC"}
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Renders standard mdast (Markdown AST) nodes as Vue vnodes.
3
+ * Handles headings, paragraphs, lists, blockquotes, code blocks,
4
+ * tables, links, images, emphasis, strong, and other common Markdown constructs.
5
+ */
6
+ import { defineComponent, h } from 'vue';
7
+ function renderChildren(nodes) {
8
+ if (!nodes || nodes.length === 0)
9
+ return [];
10
+ return nodes.map((child) => renderNode(child));
11
+ }
12
+ /** Column alignment, when the table declares one. */
13
+ function alignStyle(align, index) {
14
+ const value = align?.[index];
15
+ return value ? { textAlign: value } : undefined;
16
+ }
17
+ function renderNode(node) {
18
+ switch (node.type) {
19
+ // ---- Block-level ----
20
+ case 'heading':
21
+ return h(`h${node.depth ?? 1}`, renderChildren(node.children));
22
+ case 'paragraph':
23
+ return h('p', renderChildren(node.children));
24
+ case 'blockquote':
25
+ return h('blockquote', renderChildren(node.children));
26
+ case 'list':
27
+ return h(node.ordered ? 'ol' : 'ul', { start: node.ordered ? (node.start ?? 1) : undefined }, renderChildren(node.children));
28
+ case 'listItem':
29
+ if (node.checked != null) {
30
+ return h('li', { class: 'mdast-task-item' }, [
31
+ h('input', { type: 'checkbox', checked: node.checked, readonly: true }),
32
+ ...renderChildren(node.children),
33
+ ]);
34
+ }
35
+ return h('li', renderChildren(node.children));
36
+ case 'code':
37
+ return h('pre', { class: 'mdast-code-block' }, [
38
+ h('code', { class: node.lang ? `language-${node.lang}` : undefined }, node.value),
39
+ ]);
40
+ case 'thematicBreak':
41
+ return h('hr');
42
+ case 'html':
43
+ // Render raw HTML as text for safety (never v-html)
44
+ return h('div', { class: 'mdast-raw-html' }, node.value);
45
+ // ---- Table ----
46
+ case 'table': {
47
+ const rows = node.children ?? [];
48
+ const headerRow = rows[0];
49
+ const bodyRows = rows.slice(1);
50
+ const sections = [];
51
+ if (headerRow) {
52
+ sections.push(h('thead', [
53
+ h('tr', (headerRow.children ?? []).map((cell, ci) => h('th', { style: alignStyle(node.align, ci) }, renderChildren(cell.children)))),
54
+ ]));
55
+ }
56
+ if (bodyRows.length > 0) {
57
+ sections.push(h('tbody', bodyRows.map((row) => h('tr', (row.children ?? []).map((cell, ci) => h('td', { style: alignStyle(node.align, ci) }, renderChildren(cell.children)))))));
58
+ }
59
+ return h('table', { class: 'mdast-table' }, sections);
60
+ }
61
+ // ---- Inline ----
62
+ case 'text':
63
+ return node.value;
64
+ case 'emphasis':
65
+ return h('em', renderChildren(node.children));
66
+ case 'strong':
67
+ return h('strong', renderChildren(node.children));
68
+ case 'delete':
69
+ return h('del', renderChildren(node.children));
70
+ case 'inlineCode':
71
+ return h('code', { class: 'mdast-inline-code' }, node.value);
72
+ case 'link':
73
+ return h('a', {
74
+ href: node.url,
75
+ title: node.title ?? undefined,
76
+ target: '_blank',
77
+ rel: 'noopener noreferrer',
78
+ }, renderChildren(node.children));
79
+ case 'image':
80
+ return h('img', { src: node.url, alt: node.alt ?? '', title: node.title ?? undefined });
81
+ case 'break':
82
+ return h('br');
83
+ // ---- Fallback ----
84
+ default:
85
+ // Attempt to render children for unknown container nodes
86
+ if (node.children)
87
+ return renderChildren(node.children);
88
+ if (node.value)
89
+ return node.value;
90
+ return null;
91
+ }
92
+ }
93
+ export const MdastRenderer = defineComponent({
94
+ name: 'MdastRenderer',
95
+ props: {
96
+ node: { type: Object, required: true },
97
+ },
98
+ setup(props) {
99
+ return () => h('div', { class: 'mdma-markdown-content' }, [renderNode(props.node)]);
100
+ },
101
+ });
102
+ //# sourceMappingURL=MdastRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdastRenderer.js","sourceRoot":"","sources":["../../src/components/MdastRenderer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAkC,MAAM,KAAK,CAAC;AAuBzE,SAAS,cAAc,CAAC,KAAmB;IACzC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5C,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,qDAAqD;AACrD,SAAS,UAAU,CAAC,KAAoC,EAAE,KAAa;IACrE,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAoC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC;AA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YACV,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS,EAAE,CAAC,CAAC;QAE1F,KAAK,OAAO;YACV,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;QAEjB,qBAAqB;QACrB;YACE,yDAAyD;YACzD,IAAI,IAAI,CAAC,QAAQ;gBAAE,OAAO,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACxD,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAO,IAAI,CAAC,KAAK,CAAC;YAClC,OAAO,IAAI,CAAC;IAChB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;IAC3C,IAAI,EAAE,eAAe;IACrB,KAAK,EAAE;QACL,IAAI,EAAE,EAAE,IAAI,EAAE,MAA6B,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC9D;IACD,KAAK,CAAC,KAAK;QACT,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type PropType } from 'vue';
2
+ import type { MdmaBlock as MdmaBlockType } from '@mobile-reality/mdma-spec';
3
+ import type { MdmaBlockRenderer } from '../renderers/renderer-props.js';
4
+ export type MdmaBlockProps = {
5
+ block: MdmaBlockType;
6
+ renderers?: Record<string, MdmaBlockRenderer>;
7
+ };
8
+ /**
9
+ * Renders one parsed MDMA block: looks up the renderer for its component type
10
+ * (caller-supplied first, then the built-ins) and hands it the component, its
11
+ * state, and the two store callbacks.
12
+ */
13
+ export declare const MdmaBlock: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
+ block: {
15
+ type: PropType<MdmaBlockType>;
16
+ required: true;
17
+ };
18
+ renderers: {
19
+ type: PropType<Record<string, MdmaBlockRenderer>>;
20
+ default: undefined;
21
+ };
22
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
23
+ [key: string]: any;
24
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
25
+ block: {
26
+ type: PropType<MdmaBlockType>;
27
+ required: true;
28
+ };
29
+ renderers: {
30
+ type: PropType<Record<string, MdmaBlockRenderer>>;
31
+ default: undefined;
32
+ };
33
+ }>> & Readonly<{}>, {
34
+ renderers: Record<string, MdmaBlockRenderer>;
35
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
36
+ //# sourceMappingURL=MdmaBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdmaBlock.d.ts","sourceRoot":"","sources":["../../src/components/MdmaBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,IAAI,aAAa,EAAe,MAAM,2BAA2B,CAAC;AAGzF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS;;cAGO,QAAQ,CAAC,aAAa,CAAC;;;;cAE9B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;;;;;;;cAFpC,QAAQ,CAAC,aAAa,CAAC;;;;cAE9B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;;;;;4EAiC/D,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { computed, defineComponent, h } from 'vue';
2
+ import { useComponentState, useDocumentStore } from '../composables/use-document-store.js';
3
+ import { defaultRenderers } from '../renderers/renderer-registry.js';
4
+ /**
5
+ * Renders one parsed MDMA block: looks up the renderer for its component type
6
+ * (caller-supplied first, then the built-ins) and hands it the component, its
7
+ * state, and the two store callbacks.
8
+ */
9
+ export const MdmaBlock = defineComponent({
10
+ name: 'MdmaBlock',
11
+ props: {
12
+ block: { type: Object, required: true },
13
+ renderers: {
14
+ type: Object,
15
+ default: undefined,
16
+ },
17
+ },
18
+ setup(props) {
19
+ const store = useDocumentStore();
20
+ const componentState = useComponentState(() => props.block.component.id);
21
+ const dispatch = (action) => store.value.dispatch(action);
22
+ const resolveBinding = (expr) => store.value.resolveBinding(expr);
23
+ const Renderer = computed(() => {
24
+ const type = props.block.component.type;
25
+ return props.renderers?.[type] ?? defaultRenderers[type];
26
+ });
27
+ return () => {
28
+ if (!Renderer.value) {
29
+ return h('div', { class: 'mdma-unknown-component' }, `Unknown component type: ${props.block.component.type}`);
30
+ }
31
+ return h(Renderer.value, {
32
+ component: props.block.component,
33
+ componentState: componentState.value,
34
+ dispatch,
35
+ resolveBinding,
36
+ });
37
+ };
38
+ },
39
+ });
40
+ //# sourceMappingURL=MdmaBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdmaBlock.js","sourceRoot":"","sources":["../../src/components/MdmaBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAiB,MAAM,KAAK,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAQrE;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,eAAe,CAAC;IACvC,IAAI,EAAE,WAAW;IACjB,KAA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AC;CACF,CAAC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { type PropType } from 'vue';
2
+ export type MdmaBlockLoadingProps = {
3
+ node: {
4
+ value?: string;
5
+ };
6
+ };
7
+ /**
8
+ * Skeleton shown for an `mdma` fence that hasn't finished streaming (or failed
9
+ * validation). The type hint comes from the partial YAML so the placeholder can
10
+ * name what is arriving instead of showing a generic spinner.
11
+ */
12
+ export declare const MdmaBlockLoading: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
13
+ node: {
14
+ type: PropType<{
15
+ value?: string;
16
+ }>;
17
+ required: true;
18
+ };
19
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
20
+ [key: string]: any;
21
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
22
+ node: {
23
+ type: PropType<{
24
+ value?: string;
25
+ }>;
26
+ required: true;
27
+ };
28
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
29
+ //# sourceMappingURL=MdmaBlockLoading.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdmaBlockLoading.d.ts","sourceRoot":"","sources":["../../src/components/MdmaBlockLoading.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,QAAQ,EAAE,MAAM,KAAK,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1B,CAAC;AASF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;cAGD,QAAQ,CAAC;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;;;;;;;cAA5B,QAAQ,CAAC;YAAE,KAAK,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;;;iGAkBtD,CAAC"}