@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,48 @@
1
+ import { defineComponent, h } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ /**
4
+ * Basic built-in thinking renderer.
5
+ * Uses native <details>/<summary> for a zero-dependency collapsible.
6
+ * Override with a richer renderer via customizations.
7
+ */
8
+ export const ThinkingRenderer = defineComponent({
9
+ name: 'ThinkingRenderer',
10
+ props: blockRendererProps,
11
+ setup(props) {
12
+ return () => {
13
+ const component = props.component;
14
+ if (component.type !== 'thinking')
15
+ return null;
16
+ const collapsed = props.componentState?.values.collapsed ??
17
+ component.collapsed ??
18
+ true;
19
+ const status = component.status ?? 'done';
20
+ const label = component.label ?? 'Thinking';
21
+ return h('details', {
22
+ class: `mdma-thinking mdma-thinking--${status}`,
23
+ 'data-component-id': component.id,
24
+ open: !collapsed,
25
+ }, [
26
+ h('summary', {
27
+ class: 'mdma-thinking-summary',
28
+ // The open/closed state lives in the store, so the native toggle is
29
+ // suppressed and the dispatch drives it instead.
30
+ onClick: (e) => {
31
+ e.preventDefault();
32
+ props.dispatch({
33
+ type: 'FIELD_CHANGED',
34
+ componentId: component.id,
35
+ field: 'collapsed',
36
+ value: !collapsed,
37
+ });
38
+ },
39
+ }, [
40
+ status === 'thinking' ? h('span', { class: 'mdma-thinking-indicator' }) : null,
41
+ h('span', { class: 'mdma-thinking-label' }, label),
42
+ ]),
43
+ h('div', { class: 'mdma-thinking-content' }, component.content),
44
+ ]);
45
+ };
46
+ },
47
+ });
48
+ //# sourceMappingURL=ThinkingRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThinkingRenderer.js","sourceRoot":"","sources":["../../src/components/ThinkingRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;IAC9C,IAAI,EAAE,kBAAkB;IACxB,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,UAAU;gBAAE,OAAO,IAAI,CAAC;YAE/C,MAAM,SAAS,GACZ,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC,SAAiC;gBAC/D,SAAS,CAAC,SAAS;gBACnB,IAAI,CAAC;YACP,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,IAAI,MAAM,CAAC;YAC1C,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,IAAI,UAAU,CAAC;YAE5C,OAAO,CAAC,CACN,SAAS,EACT;gBACE,KAAK,EAAE,gCAAgC,MAAM,EAAE;gBAC/C,mBAAmB,EAAE,SAAS,CAAC,EAAE;gBACjC,IAAI,EAAE,CAAC,SAAS;aACjB,EACD;gBACE,CAAC,CACC,SAAS,EACT;oBACE,KAAK,EAAE,uBAAuB;oBAC9B,oEAAoE;oBACpE,iDAAiD;oBACjD,OAAO,EAAE,CAAC,CAAQ,EAAE,EAAE;wBACpB,CAAC,CAAC,cAAc,EAAE,CAAC;wBACnB,KAAK,CAAC,QAAQ,CAAC;4BACb,IAAI,EAAE,eAAe;4BACrB,WAAW,EAAE,SAAS,CAAC,EAAE;4BACzB,KAAK,EAAE,WAAW;4BAClB,KAAK,EAAE,CAAC,SAAS;yBAClB,CAAC,CAAC;oBACL,CAAC;iBACF,EACD;oBACE,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,yBAAyB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;oBAC9E,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,qBAAqB,EAAE,EAAE,KAAK,CAAC;iBACnD,CACF;gBACD,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,EAAE,SAAS,CAAC,OAAO,CAAC;aAChE,CACF,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,40 @@
1
+ export declare const WebhookRenderer: 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=WebhookRenderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebhookRenderer.d.ts","sourceRoot":"","sources":["../../src/components/WebhookRenderer.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA+C1B,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { defineComponent, h, ref } from 'vue';
2
+ import { blockRendererProps } from '../renderers/renderer-props.js';
3
+ export const WebhookRenderer = defineComponent({
4
+ name: 'WebhookRenderer',
5
+ props: blockRendererProps,
6
+ setup(props) {
7
+ const triggered = ref(false);
8
+ return () => {
9
+ const component = props.component;
10
+ if (component.type !== 'webhook')
11
+ return null;
12
+ const status = props.componentState?.values.status ?? 'idle';
13
+ return h('div', { class: 'mdma-webhook', 'data-component-id': component.id }, [
14
+ component.label ? h('span', { class: 'mdma-webhook-label' }, component.label) : null,
15
+ h('span', { class: `mdma-webhook-status mdma-webhook-status--${status}` }, `Webhook: ${triggered.value ? 'triggered' : status}`),
16
+ !triggered.value && status === 'idle'
17
+ ? h('button', {
18
+ type: 'button',
19
+ class: 'mdma-webhook-trigger',
20
+ onClick: () => {
21
+ triggered.value = true;
22
+ // Signals the user fired the webhook. Real HTTP execution is the (unbuilt) webhook
23
+ // engine; this routes the trigger + request shape so an agent/host can act on it.
24
+ props.dispatch({
25
+ type: 'INTEGRATION_CALLED',
26
+ componentId: component.id,
27
+ integrationId: 'webhook',
28
+ result: {
29
+ status: 'triggered',
30
+ url: component.url,
31
+ method: component.method,
32
+ },
33
+ });
34
+ },
35
+ }, 'Trigger webhook')
36
+ : null,
37
+ ]);
38
+ };
39
+ },
40
+ });
41
+ //# sourceMappingURL=WebhookRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WebhookRenderer.js","sourceRoot":"","sources":["../../src/components/WebhookRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC9C,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,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC;QAE7B,OAAO,GAAG,EAAE;YACV,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;YAClC,IAAI,SAAS,CAAC,IAAI,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YAE9C,MAAM,MAAM,GAAI,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC,MAAiB,IAAI,MAAM,CAAC;YAEzE,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE;gBAC5E,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI;gBACpF,CAAC,CACC,MAAM,EACN,EAAE,KAAK,EAAE,4CAA4C,MAAM,EAAE,EAAE,EAC/D,YAAY,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,EAAE,CACrD;gBACD,CAAC,SAAS,CAAC,KAAK,IAAI,MAAM,KAAK,MAAM;oBACnC,CAAC,CAAC,CAAC,CACC,QAAQ,EACR;wBACE,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,sBAAsB;wBAC7B,OAAO,EAAE,GAAG,EAAE;4BACZ,SAAS,CAAC,KAAK,GAAG,IAAI,CAAC;4BACvB,mFAAmF;4BACnF,kFAAkF;4BAClF,KAAK,CAAC,QAAQ,CAAC;gCACb,IAAI,EAAE,oBAAoB;gCAC1B,WAAW,EAAE,SAAS,CAAC,EAAE;gCACzB,aAAa,EAAE,SAAS;gCACxB,MAAM,EAAE;oCACN,MAAM,EAAE,WAAW;oCACnB,GAAG,EAAE,SAAS,CAAC,GAAG;oCAClB,MAAM,EAAE,SAAS,CAAC,MAAM;iCACzB;6BACF,CAAC,CAAC;wBACL,CAAC;qBACF,EACD,iBAAiB,CAClB;oBACH,CAAC,CAAC,IAAI;aACT,CAAC,CAAC;QACL,CAAC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { type ComputedRef, type MaybeRefOrGetter } from 'vue';
2
+ import type { ComponentState, DocumentState, DocumentStore } from '@mobile-reality/mdma-runtime';
3
+ /** The document store provided by the nearest `MdmaProvider` / `MdmaDocument`. */
4
+ export declare function useDocumentStore(): ComputedRef<DocumentStore>;
5
+ /**
6
+ * The whole document state, recomputed on every store notification.
7
+ *
8
+ * The returned object is a fresh shallow wrapper each time: the store mutates
9
+ * its state in place, so handing back the same reference would make the computed
10
+ * look unchanged and consumers would never re-render.
11
+ */
12
+ export declare function useDocumentState(): ComputedRef<DocumentState>;
13
+ /**
14
+ * A component's state, as a snapshot whose identity only changes when that
15
+ * component's own fields change. Without this, every store notification — a
16
+ * keystroke in an unrelated form — would hand every renderer a new object and
17
+ * defeat Vue's render caching.
18
+ */
19
+ export declare function useComponentState(componentId: MaybeRefOrGetter<string>): ComputedRef<ComponentState | undefined>;
20
+ /** Resolve a `{{binding}}` expression, kept current as the document changes. */
21
+ export declare function useBinding<T = unknown>(expression: MaybeRefOrGetter<string>): ComputedRef<T>;
22
+ //# sourceMappingURL=use-document-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-document-store.d.ts","sourceRoot":"","sources":["../../src/composables/use-document-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAEtB,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAuBjG,kFAAkF;AAClF,wBAAgB,gBAAgB,IAAI,WAAW,CAAC,aAAa,CAAC,CAG7D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAAC,aAAa,CAAC,CAO7D;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,gBAAgB,CAAC,MAAM,CAAC,GACpC,WAAW,CAAC,cAAc,GAAG,SAAS,CAAC,CA6BzC;AAED,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EAAE,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAO5F"}
@@ -0,0 +1,84 @@
1
+ import { computed, shallowRef, toValue, watchEffect, } from 'vue';
2
+ import { useMdmaContext } from '../context/MdmaProvider.js';
3
+ /**
4
+ * A counter bumped on every store notification. The store mutates its state in
5
+ * place, so there is nothing for Vue's reactivity to track — this is the bridge
6
+ * between `store.subscribe` and the reactive graph, and every composable below
7
+ * reads it to declare "recompute when the document changes".
8
+ *
9
+ * Re-subscribes if the provided store is swapped (which the AG-UI bridge does on
10
+ * re-parse), and unsubscribes with the owning effect scope.
11
+ */
12
+ function useStoreTick(ctx) {
13
+ const tick = shallowRef(0);
14
+ watchEffect((onCleanup) => {
15
+ const unsubscribe = ctx.value.store.subscribe(() => {
16
+ tick.value++;
17
+ });
18
+ onCleanup(unsubscribe);
19
+ });
20
+ return tick;
21
+ }
22
+ /** The document store provided by the nearest `MdmaProvider` / `MdmaDocument`. */
23
+ export function useDocumentStore() {
24
+ const ctx = useMdmaContext();
25
+ return computed(() => ctx.value.store);
26
+ }
27
+ /**
28
+ * The whole document state, recomputed on every store notification.
29
+ *
30
+ * The returned object is a fresh shallow wrapper each time: the store mutates
31
+ * its state in place, so handing back the same reference would make the computed
32
+ * look unchanged and consumers would never re-render.
33
+ */
34
+ export function useDocumentState() {
35
+ const ctx = useMdmaContext();
36
+ const tick = useStoreTick(ctx);
37
+ return computed(() => {
38
+ tick.value;
39
+ return { ...ctx.value.store.getState() };
40
+ });
41
+ }
42
+ /**
43
+ * A component's state, as a snapshot whose identity only changes when that
44
+ * component's own fields change. Without this, every store notification — a
45
+ * keystroke in an unrelated form — would hand every renderer a new object and
46
+ * defeat Vue's render caching.
47
+ */
48
+ export function useComponentState(componentId) {
49
+ const ctx = useMdmaContext();
50
+ const tick = useStoreTick(ctx);
51
+ let cached;
52
+ return computed(() => {
53
+ tick.value;
54
+ const current = ctx.value.store.getComponentState(toValue(componentId));
55
+ if (!current) {
56
+ cached = undefined;
57
+ return undefined;
58
+ }
59
+ // Only mint a new snapshot when this component's values actually changed.
60
+ const prev = cached;
61
+ if (prev &&
62
+ prev.id === current.id &&
63
+ prev.touched === current.touched &&
64
+ prev.visible === current.visible &&
65
+ prev.disabled === current.disabled &&
66
+ prev.values === current.values &&
67
+ prev.errors === current.errors) {
68
+ return prev;
69
+ }
70
+ const snapshot = { ...current };
71
+ cached = snapshot;
72
+ return snapshot;
73
+ });
74
+ }
75
+ /** Resolve a `{{binding}}` expression, kept current as the document changes. */
76
+ export function useBinding(expression) {
77
+ const ctx = useMdmaContext();
78
+ const tick = useStoreTick(ctx);
79
+ return computed(() => {
80
+ tick.value;
81
+ return ctx.value.store.resolveBinding(toValue(expression));
82
+ });
83
+ }
84
+ //# sourceMappingURL=use-document-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-document-store.js","sourceRoot":"","sources":["../../src/composables/use-document-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,UAAU,EACV,OAAO,EACP,WAAW,GAIZ,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,cAAc,EAAyB,MAAM,4BAA4B,CAAC;AAEnF;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,GAAkC;IACtD,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IAC3B,WAAW,CAAC,CAAC,SAAS,EAAE,EAAE;QACxB,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;YACjD,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,CAAC;QACH,SAAS,CAAC,WAAW,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,GAAG,GAAG,cAAc,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,QAAQ,CAAC,GAAG,EAAE;QACnB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cAAc,EAAE,CAAC;IAC7B,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,QAAQ,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,KAAK,CAAC;QACX,OAAO,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,CAAM,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type Component, type ComputedRef, type InjectionKey, type PropType } from 'vue';
2
+ import type { CustomComponent, StoreAction } from '@mobile-reality/mdma-spec';
3
+ import type { ComponentState } from '@mobile-reality/mdma-runtime';
4
+ /**
5
+ * Props passed to a custom-component variant renderer. The envelope is narrowed
6
+ * to `custom`, and its `props` payload is surfaced directly for convenience.
7
+ * Presentation lives entirely here — the spec only carries intent.
8
+ */
9
+ export interface CustomVariantProps {
10
+ component: CustomComponent;
11
+ props: Record<string, unknown>;
12
+ componentState: ComponentState | undefined;
13
+ dispatch: (action: StoreAction) => void;
14
+ resolveBinding: (expr: string) => unknown;
15
+ }
16
+ /** A Vue component that accepts {@link CustomVariantProps}. */
17
+ export type CustomVariantRenderer = Component;
18
+ /** Map of custom-component `name` to the variant renderer that draws it. */
19
+ export type CustomVariants = Record<string, CustomVariantRenderer>;
20
+ export declare const CustomVariantsKey: InjectionKey<ComputedRef<CustomVariants>>;
21
+ export type CustomVariantProviderProps = {
22
+ value?: CustomVariants;
23
+ };
24
+ export declare const CustomVariantProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
25
+ value: {
26
+ type: PropType<CustomVariants>;
27
+ default: undefined;
28
+ };
29
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
30
+ [key: string]: any;
31
+ }>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
32
+ value: {
33
+ type: PropType<CustomVariants>;
34
+ default: undefined;
35
+ };
36
+ }>> & Readonly<{}>, {
37
+ value: CustomVariants;
38
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
39
+ /** Read the registered custom variants, then look up by name. */
40
+ export declare function useCustomVariants(): ComputedRef<CustomVariants>;
41
+ //# sourceMappingURL=CustomVariantContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomVariantContext.d.ts","sourceRoot":"","sources":["../../src/context/CustomVariantContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,eAAe,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IAC3C,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C;AAED,+DAA+D;AAC/D,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAE9C,4EAA4E;AAC5E,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAEnE,eAAO,MAAM,iBAAiB,EAAE,YAAY,CAAC,WAAW,CAAC,cAAc,CAAC,CACxC,CAAC;AAEjC,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,CAAC,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,qBAAqB;;cAGL,QAAQ,CAAC,cAAc,CAAC;;;;;;;cAAxB,QAAQ,CAAC,cAAc,CAAC;;;;;4EASnD,CAAC;AAEH,iEAAiE;AACjE,wBAAgB,iBAAiB,IAAI,WAAW,CAAC,cAAc,CAAC,CAK/D"}
@@ -0,0 +1,17 @@
1
+ import { computed, defineComponent, inject, provide, } from 'vue';
2
+ export const CustomVariantsKey = Symbol('mdma-custom-variants');
3
+ export const CustomVariantProvider = defineComponent({
4
+ name: 'CustomVariantProvider',
5
+ props: {
6
+ value: { type: Object, default: undefined },
7
+ },
8
+ setup(props, { slots }) {
9
+ provide(CustomVariantsKey, computed(() => props.value ?? {}));
10
+ return () => slots.default?.();
11
+ },
12
+ });
13
+ /** Read the registered custom variants, then look up by name. */
14
+ export function useCustomVariants() {
15
+ return inject(CustomVariantsKey, computed(() => ({})));
16
+ }
17
+ //# sourceMappingURL=CustomVariantContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomVariantContext.js","sourceRoot":"","sources":["../../src/context/CustomVariantContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,MAAM,EACN,OAAO,GAKR,MAAM,KAAK,CAAC;AAuBb,MAAM,CAAC,MAAM,iBAAiB,GAC5B,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAMjC,MAAM,CAAC,MAAM,qBAAqB,GAAG,eAAe,CAAC;IACnD,IAAI,EAAE,uBAAuB;IAC7B,KAAK,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,MAAkC,EAAE,OAAO,EAAE,SAAS,EAAE;KACxE;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,CACL,iBAAiB,EACjB,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAClC,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,UAAU,iBAAiB;IAC/B,OAAO,MAAM,CACX,iBAAiB,EACjB,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,111 @@
1
+ import { type Component, type ComputedRef, type InjectionKey, type PropType } from 'vue';
2
+ export interface FormInputElementProps {
3
+ id: string;
4
+ name: string;
5
+ label: string;
6
+ type: string;
7
+ value: string;
8
+ onChange: (value: string) => void;
9
+ required?: boolean;
10
+ /** When true, the field contains PII and should be visually marked / masked. */
11
+ sensitive?: boolean;
12
+ }
13
+ export interface FormSelectElementProps extends FormInputElementProps {
14
+ options: {
15
+ label: string;
16
+ value: string;
17
+ }[];
18
+ }
19
+ export interface FormCheckboxElementProps {
20
+ id: string;
21
+ name: string;
22
+ label: string;
23
+ checked: boolean;
24
+ onChange: (checked: boolean) => void;
25
+ /** When true, the field contains PII and should be visually marked / masked. */
26
+ sensitive?: boolean;
27
+ }
28
+ export interface FormTextareaElementProps {
29
+ id: string;
30
+ name: string;
31
+ label: string;
32
+ value: string;
33
+ onChange: (value: string) => void;
34
+ required?: boolean;
35
+ /** When true, the field contains PII and should be visually marked / masked. */
36
+ sensitive?: boolean;
37
+ }
38
+ export interface FormFileElementProps {
39
+ id: string;
40
+ name: string;
41
+ label: string;
42
+ /** Files currently selected for this field. */
43
+ value: File[];
44
+ onChange: (files: File[]) => void;
45
+ required?: boolean;
46
+ /** When true, the field contains PII and should be visually marked / masked. */
47
+ sensitive?: boolean;
48
+ }
49
+ export interface FormSubmitElementProps {
50
+ onClick: () => void;
51
+ label: string;
52
+ }
53
+ /**
54
+ * Props for the marker rendered next to a sensitive (PII) field's label.
55
+ * Override the `sensitiveIndicator` element to restyle the badge — or render
56
+ * nothing to opt out of it entirely for a given scope.
57
+ */
58
+ export interface FormSensitiveIndicatorElementProps {
59
+ /** Machine name of the field this indicator marks. */
60
+ name: string;
61
+ /** Display label of the field this indicator marks. */
62
+ label: string;
63
+ }
64
+ /**
65
+ * Scoped element overrides. Keys are scope names (`'*'` for global,
66
+ * `'form'` for form-only, etc.). Values map element type names to
67
+ * Vue components.
68
+ *
69
+ * Resolution order: scope-specific → `'*'` (global) → built-in default.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * const overrides: ElementOverrides = {
74
+ * '*': { input: GlassInput }, // global fallback
75
+ * form: {
76
+ * checkbox: ToggleSwitch, // only inside forms
77
+ * sensitiveIndicator: () => null, // opt out of the PII badge
78
+ * },
79
+ * };
80
+ * ```
81
+ */
82
+ export type ElementOverrides = Record<string, Record<string, Component>>;
83
+ export declare const ElementOverridesKey: InjectionKey<ComputedRef<ElementOverrides | null>>;
84
+ export type ElementOverridesProviderProps = {
85
+ value?: ElementOverrides;
86
+ };
87
+ export declare const ElementOverridesProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
88
+ value: {
89
+ type: PropType<ElementOverrides>;
90
+ default: undefined;
91
+ };
92
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
93
+ [key: string]: any;
94
+ }>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
95
+ value: {
96
+ type: PropType<ElementOverrides>;
97
+ default: undefined;
98
+ };
99
+ }>> & Readonly<{}>, {
100
+ value: ElementOverrides;
101
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
102
+ /**
103
+ * Resolve an element override for the given scope and element type.
104
+ *
105
+ * Fallback chain: `overrides[scope][elementType]` → `overrides['*'][elementType]` → `undefined`.
106
+ *
107
+ * Returns a `ComputedRef` so a renderer resolving overrides once in `setup` still
108
+ * picks up a later change to the document's `customizations`.
109
+ */
110
+ export declare function useElementOverride(scope: string, elementType: string): ComputedRef<Component | undefined>;
111
+ //# sourceMappingURL=ElementOverridesContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"El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,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gFAAgF;IAChF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,kCAAkC;IACjD,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAIzE,eAAO,MAAM,mBAAmB,EAAE,YAAY,CAAC,WAAW,CAAC,gBAAgB,GAAG,IAAI,CAAC,CACjD,CAAC;AAEnC,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,CAAC,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,wBAAwB;;cAGR,QAAQ,CAAC,gBAAgB,CAAC;;;;;;;cAA1B,QAAQ,CAAC,gBAAgB,CAAC;;;;;4EASrD,CAAC;AAEH;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC,CAUpC"}
@@ -0,0 +1,31 @@
1
+ import { computed, defineComponent, inject, provide, } from 'vue';
2
+ // ─── Context ─────────────────────────────────────────────────────────────────
3
+ export const ElementOverridesKey = Symbol('mdma-element-overrides');
4
+ export const ElementOverridesProvider = defineComponent({
5
+ name: 'ElementOverridesProvider',
6
+ props: {
7
+ value: { type: Object, default: undefined },
8
+ },
9
+ setup(props, { slots }) {
10
+ provide(ElementOverridesKey, computed(() => props.value ?? null));
11
+ return () => slots.default?.();
12
+ },
13
+ });
14
+ /**
15
+ * Resolve an element override for the given scope and element type.
16
+ *
17
+ * Fallback chain: `overrides[scope][elementType]` → `overrides['*'][elementType]` → `undefined`.
18
+ *
19
+ * Returns a `ComputedRef` so a renderer resolving overrides once in `setup` still
20
+ * picks up a later change to the document's `customizations`.
21
+ */
22
+ export function useElementOverride(scope, elementType) {
23
+ const overrides = inject(ElementOverridesKey, computed(() => null));
24
+ return computed(() => {
25
+ const map = overrides.value;
26
+ if (!map)
27
+ return undefined;
28
+ return map[scope]?.[elementType] ?? map['*']?.[elementType];
29
+ });
30
+ }
31
+ //# sourceMappingURL=ElementOverridesContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ElementOverridesContext.js","sourceRoot":"","sources":["../../src/context/ElementOverridesContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,MAAM,EACN,OAAO,GAKR,MAAM,KAAK,CAAC;AA4Fb,gFAAgF;AAEhF,MAAM,CAAC,MAAM,mBAAmB,GAC9B,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAMnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;IACtD,IAAI,EAAE,0BAA0B;IAChC,KAAK,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,MAAoC,EAAE,OAAO,EAAE,SAAS,EAAE;KAC1E;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,CACL,mBAAmB,EACnB,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC,CACpC,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,KAAa,EACb,WAAmB;IAEnB,MAAM,SAAS,GAAG,MAAM,CACtB,mBAAmB,EACnB,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CACrB,CAAC;IACF,OAAO,QAAQ,CAAC,GAAG,EAAE;QACnB,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,GAAG;YAAE,OAAO,SAAS,CAAC;QAC3B,OAAO,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type ComputedRef, type InjectionKey, type PropType } from 'vue';
2
+ import type { DocumentStore } from '@mobile-reality/mdma-runtime';
3
+ /** Named collections of select options that form fields can reference by string. */
4
+ export type DataSources = Record<string, Array<{
5
+ label: string;
6
+ value: string;
7
+ }>>;
8
+ export interface MdmaContextValue {
9
+ store: DocumentStore;
10
+ dataSources?: DataSources;
11
+ }
12
+ export declare const MdmaContextKey: InjectionKey<ComputedRef<MdmaContextValue>>;
13
+ /**
14
+ * The nearest provided store + data sources. Throws when called outside a
15
+ * `MdmaProvider` (or a `MdmaDocument`, which provides one itself) — a missing
16
+ * store is a wiring bug, not a state a renderer should try to draw around.
17
+ */
18
+ export declare function useMdmaContext(): ComputedRef<MdmaContextValue>;
19
+ export type MdmaProviderProps = {
20
+ store: DocumentStore;
21
+ dataSources?: DataSources;
22
+ };
23
+ /**
24
+ * Provides the document store to every MDMA renderer below it. Renders its
25
+ * default slot untouched — no wrapper element, so it can sit anywhere in a tree.
26
+ */
27
+ export declare const MdmaProvider: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
28
+ store: {
29
+ type: PropType<DocumentStore>;
30
+ required: true;
31
+ };
32
+ dataSources: {
33
+ type: PropType<DataSources>;
34
+ default: undefined;
35
+ };
36
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
37
+ [key: string]: any;
38
+ }>[] | undefined, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
39
+ store: {
40
+ type: PropType<DocumentStore>;
41
+ required: true;
42
+ };
43
+ dataSources: {
44
+ type: PropType<DataSources>;
45
+ default: undefined;
46
+ };
47
+ }>> & Readonly<{}>, {
48
+ dataSources: DataSources;
49
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
50
+ //# sourceMappingURL=MdmaProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdmaProvider.d.ts","sourceRoot":"","sources":["../../src/context/MdmaProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,oFAAoF;AACpF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAAC;AAElF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAA0B,CAAC;AAElG;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,WAAW,CAAC,gBAAgB,CAAC,CAM9D;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,aAAa,CAAC;IACrB,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY;;cAGI,QAAQ,CAAC,aAAa,CAAC;;;;cACjB,QAAQ,CAAC,WAAW,CAAC;;;;;;;cAD3B,QAAQ,CAAC,aAAa,CAAC;;;;cACjB,QAAQ,CAAC,WAAW,CAAC;;;;;4EAatD,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { computed, defineComponent, inject, provide, toRaw, } from 'vue';
2
+ export const MdmaContextKey = Symbol('mdma-context');
3
+ /**
4
+ * The nearest provided store + data sources. Throws when called outside a
5
+ * `MdmaProvider` (or a `MdmaDocument`, which provides one itself) — a missing
6
+ * store is a wiring bug, not a state a renderer should try to draw around.
7
+ */
8
+ export function useMdmaContext() {
9
+ const ctx = inject(MdmaContextKey, null);
10
+ if (!ctx) {
11
+ throw new Error('useMdmaContext must be used within a MdmaProvider');
12
+ }
13
+ return ctx;
14
+ }
15
+ /**
16
+ * Provides the document store to every MDMA renderer below it. Renders its
17
+ * default slot untouched — no wrapper element, so it can sit anywhere in a tree.
18
+ */
19
+ export const MdmaProvider = defineComponent({
20
+ name: 'MdmaProvider',
21
+ props: {
22
+ store: { type: Object, required: true },
23
+ dataSources: { type: Object, default: undefined },
24
+ },
25
+ setup(props, { slots }) {
26
+ provide(MdmaContextKey,
27
+ // `toRaw` because the store is an external mutable service, not reactive
28
+ // data: a parent holding it in a `reactive()` would hand down a proxy,
29
+ // which breaks identity comparisons and lets Vue instrument the store's
30
+ // internal Map on every read. Its updates reach us via `subscribe`.
31
+ computed(() => ({ store: toRaw(props.store), dataSources: props.dataSources })));
32
+ return () => slots.default?.();
33
+ },
34
+ });
35
+ //# sourceMappingURL=MdmaProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MdmaProvider.js","sourceRoot":"","sources":["../../src/context/MdmaProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,MAAM,EACN,OAAO,EACP,KAAK,GAIN,MAAM,KAAK,CAAC;AAWb,MAAM,CAAC,MAAM,cAAc,GAAgD,MAAM,CAAC,cAAc,CAAC,CAAC;AAElG;;;;GAIG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,GAAG,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAOD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;IAC1C,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE;QACL,KAAK,EAAE,EAAE,IAAI,EAAE,MAAiC,EAAE,QAAQ,EAAE,IAAI,EAAE;QAClE,WAAW,EAAE,EAAE,IAAI,EAAE,MAA+B,EAAE,OAAO,EAAE,SAAS,EAAE;KAC3E;IACD,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QACpB,OAAO,CACL,cAAc;QACd,yEAAyE;QACzE,uEAAuE;QACvE,wEAAwE;QACxE,oEAAoE;QACpE,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAChF,CAAC;QACF,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ export { MdmaDocument, type MdmaDocumentProps, type MdmaRenderCustomizations, type ComponentEntry, } from './components/MdmaDocument.js';
2
+ export { MdmaBlock, type MdmaBlockProps } from './components/MdmaBlock.js';
3
+ export { MdastRenderer, type MdastRendererProps } from './components/MdastRenderer.js';
4
+ export { MdmaBlockLoading, type MdmaBlockLoadingProps } from './components/MdmaBlockLoading.js';
5
+ export { MdmaProvider, useMdmaContext, type MdmaProviderProps, type DataSources, } from './context/MdmaProvider.js';
6
+ export { MdmaThemeProvider, useMdmaTheme, resolveThemeProps, themeToCssVars, lightTheme, darkTheme, type MdmaTheme, type MdmaThemeInput, type MdmaThemeProviderProps, type ResolvedThemeProps, } from './theme/MdmaThemeProvider.js';
7
+ export { ElementOverridesProvider, useElementOverride, type ElementOverrides, type ElementOverridesProviderProps, type FormInputElementProps, type FormSelectElementProps, type FormCheckboxElementProps, type FormTextareaElementProps, type FormFileElementProps, type FormSubmitElementProps, type FormSensitiveIndicatorElementProps, } from './context/ElementOverridesContext.js';
8
+ export { useDocumentStore, useDocumentState, useComponentState, useBinding, } from './composables/use-document-store.js';
9
+ export { RendererRegistry, createRendererRegistry, defaultRenderers, blockRendererProps, type MdmaBlockRenderer, type MdmaBlockRendererProps, } from './renderers/renderer-registry.js';
10
+ export { FormRenderer } from './components/FormRenderer.js';
11
+ export { ButtonRenderer } from './components/ButtonRenderer.js';
12
+ export { TasklistRenderer } from './components/TasklistRenderer.js';
13
+ export { TableRenderer } from './components/TableRenderer.js';
14
+ export { CalloutRenderer } from './components/CalloutRenderer.js';
15
+ export { ApprovalGateRenderer } from './components/ApprovalGateRenderer.js';
16
+ export { WebhookRenderer } from './components/WebhookRenderer.js';
17
+ export { ChartRenderer } from './components/ChartRenderer.js';
18
+ export { ThinkingRenderer } from './components/ThinkingRenderer.js';
19
+ export { CustomRenderer } from './components/CustomRenderer.js';
20
+ export { CustomVariantProvider, useCustomVariants, type CustomVariantProps, type CustomVariantRenderer, type CustomVariants, type CustomVariantProviderProps, } from './context/CustomVariantContext.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,GACpB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAA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AClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,0BAA0B,GAChC,MAAM,mCAAmC,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ export { MdmaDocument, } from './components/MdmaDocument.js';
2
+ export { MdmaBlock } from './components/MdmaBlock.js';
3
+ export { MdastRenderer } from './components/MdastRenderer.js';
4
+ export { MdmaBlockLoading } from './components/MdmaBlockLoading.js';
5
+ export { MdmaProvider, useMdmaContext, } from './context/MdmaProvider.js';
6
+ export { MdmaThemeProvider, useMdmaTheme, resolveThemeProps, themeToCssVars, lightTheme, darkTheme, } from './theme/MdmaThemeProvider.js';
7
+ export { ElementOverridesProvider, useElementOverride, } from './context/ElementOverridesContext.js';
8
+ export { useDocumentStore, useDocumentState, useComponentState, useBinding, } from './composables/use-document-store.js';
9
+ export { RendererRegistry, createRendererRegistry, defaultRenderers, blockRendererProps, } from './renderers/renderer-registry.js';
10
+ export { FormRenderer } from './components/FormRenderer.js';
11
+ export { ButtonRenderer } from './components/ButtonRenderer.js';
12
+ export { TasklistRenderer } from './components/TasklistRenderer.js';
13
+ export { TableRenderer } from './components/TableRenderer.js';
14
+ export { CalloutRenderer } from './components/CalloutRenderer.js';
15
+ export { ApprovalGateRenderer } from './components/ApprovalGateRenderer.js';
16
+ export { WebhookRenderer } from './components/WebhookRenderer.js';
17
+ export { ChartRenderer } from './components/ChartRenderer.js';
18
+ export { ThinkingRenderer } from './components/ThinkingRenderer.js';
19
+ export { CustomRenderer } from './components/CustomRenderer.js';
20
+ export { CustomVariantProvider, useCustomVariants, } from './context/CustomVariantContext.js';
21
+ //# sourceMappingURL=index.js.map