@onderwijsin/nuxt-loops-renderer 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 (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +144 -0
  3. package/dist/module.d.mts +18 -0
  4. package/dist/module.json +12 -0
  5. package/dist/module.mjs +123 -0
  6. package/dist/runtime/app/components/LoopsRenderer.d.vue.ts +11 -0
  7. package/dist/runtime/app/components/LoopsRenderer.vue +60 -0
  8. package/dist/runtime/app/components/LoopsRenderer.vue.d.ts +11 -0
  9. package/dist/runtime/app/components/nodes/LoopsAstCodeBlock.d.vue.ts +11 -0
  10. package/dist/runtime/app/components/nodes/LoopsAstCodeBlock.vue +23 -0
  11. package/dist/runtime/app/components/nodes/LoopsAstCodeBlock.vue.d.ts +11 -0
  12. package/dist/runtime/app/components/nodes/LoopsAstComponent.d.vue.ts +11 -0
  13. package/dist/runtime/app/components/nodes/LoopsAstComponent.vue +22 -0
  14. package/dist/runtime/app/components/nodes/LoopsAstComponent.vue.d.ts +11 -0
  15. package/dist/runtime/app/components/nodes/LoopsAstIcons.d.vue.ts +10 -0
  16. package/dist/runtime/app/components/nodes/LoopsAstIcons.vue +53 -0
  17. package/dist/runtime/app/components/nodes/LoopsAstIcons.vue.d.ts +10 -0
  18. package/dist/runtime/app/components/nodes/LoopsAstInline.d.vue.ts +12 -0
  19. package/dist/runtime/app/components/nodes/LoopsAstInline.vue +62 -0
  20. package/dist/runtime/app/components/nodes/LoopsAstInline.vue.d.ts +12 -0
  21. package/dist/runtime/app/components/nodes/LoopsAstLayout.d.vue.ts +10 -0
  22. package/dist/runtime/app/components/nodes/LoopsAstLayout.vue +60 -0
  23. package/dist/runtime/app/components/nodes/LoopsAstLayout.vue.d.ts +10 -0
  24. package/dist/runtime/app/components/nodes/LoopsAstList.d.vue.ts +12 -0
  25. package/dist/runtime/app/components/nodes/LoopsAstList.vue +39 -0
  26. package/dist/runtime/app/components/nodes/LoopsAstList.vue.d.ts +12 -0
  27. package/dist/runtime/app/components/nodes/LoopsAstMedia.d.vue.ts +10 -0
  28. package/dist/runtime/app/components/nodes/LoopsAstMedia.vue +52 -0
  29. package/dist/runtime/app/components/nodes/LoopsAstMedia.vue.d.ts +10 -0
  30. package/dist/runtime/app/components/nodes/LoopsAstNode.d.vue.ts +11 -0
  31. package/dist/runtime/app/components/nodes/LoopsAstNode.vue +113 -0
  32. package/dist/runtime/app/components/nodes/LoopsAstNode.vue.d.ts +11 -0
  33. package/dist/runtime/app/components/nodes/LoopsAstSection.d.vue.ts +11 -0
  34. package/dist/runtime/app/components/nodes/LoopsAstSection.vue +40 -0
  35. package/dist/runtime/app/components/nodes/LoopsAstSection.vue.d.ts +11 -0
  36. package/dist/runtime/app/components/nodes/LoopsAstTextBlock.d.vue.ts +10 -0
  37. package/dist/runtime/app/components/nodes/LoopsAstTextBlock.vue +44 -0
  38. package/dist/runtime/app/components/nodes/LoopsAstTextBlock.vue.d.ts +10 -0
  39. package/dist/runtime/app/components/nodes/LoopsAstUnsupportedNodes.d.vue.ts +10 -0
  40. package/dist/runtime/app/components/nodes/LoopsAstUnsupportedNodes.vue +12 -0
  41. package/dist/runtime/app/components/nodes/LoopsAstUnsupportedNodes.vue.d.ts +10 -0
  42. package/dist/runtime/app/utils/renderer.d.ts +18 -0
  43. package/dist/runtime/app/utils/renderer.js +16 -0
  44. package/dist/runtime/index.css +1 -0
  45. package/dist/runtime/types.d.ts +10 -0
  46. package/dist/runtime/types.js +0 -0
  47. package/dist/types.d.mts +7 -0
  48. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Stichting Onderwijs in
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,144 @@
1
+ ![Stichting Onderwijs in](https://raw.githubusercontent.com/onderwijsin/.github/main/banner.png)
2
+
3
+ # @onderwijsin/nuxt-loops-renderer
4
+
5
+ Render Loops LMX email content in a Nuxt 4 application. This module turns the
6
+ renderer-neutral AST produced by `@onderwijsin/loops-core` into safe, styled
7
+ Vue components that can be used in campaign archives, previews, and other
8
+ presentation surfaces.
9
+
10
+ The module is designed for content that has already been parsed on a trusted
11
+ server. It validates the AST again at the browser boundary, resolves supported
12
+ variables and URLs safely, and silently omits invalid or unsupported content.
13
+
14
+ ## Getting started
15
+
16
+ Install the module:
17
+
18
+ ```sh
19
+ pnpm add @onderwijsin/nuxt-loops-renderer @onderwijsin/loops-core
20
+ ```
21
+
22
+ Register it in `nuxt.config.ts`:
23
+
24
+ ```ts
25
+ export default defineNuxtConfig({
26
+ modules: ["@onderwijsin/nuxt-loops-renderer"]
27
+ });
28
+ ```
29
+
30
+ `@nuxt/ui` is registered as a Nuxt module dependency automatically. The
31
+ renderer uses its `UButton` and `UIcon` components.
32
+
33
+ Parse LMX with `@onderwijsin/loops-core` on the server, then pass the resulting
34
+ AST and variables to the auto-imported `LoopsRenderer` component:
35
+
36
+ ```vue
37
+ <script setup lang="ts">
38
+ import type { LoopsLmxVariables } from "@onderwijsin/loops-core";
39
+
40
+ const variables: LoopsLmxVariables = {
41
+ contact: { firstName: "Ada" },
42
+ event: {},
43
+ data: {}
44
+ };
45
+
46
+ const parsedAst = await getParsedCampaignAst();
47
+ </script>
48
+
49
+ <template>
50
+ <LoopsRenderer :data="parsedAst" :variables="variables" />
51
+ </template>
52
+ ```
53
+
54
+ ## `LoopsRenderer` component
55
+
56
+ The component accepts the following props:
57
+
58
+ | Prop | Required | Description |
59
+ | ----------- | -------- | -------------------------------------------------------------------------------- |
60
+ | `data` | Yes | A `LoopsLmxAst` root returned by `@onderwijsin/loops-core`. |
61
+ | `variables` | Yes | Values available to `{contact.*}`, `{event.*}`, and `{data.*}` merge tags. |
62
+ | `config` | No | Per-renderer overrides for debugging, inline styles, and conditional evaluation. |
63
+
64
+ ```vue
65
+ <LoopsRenderer :data="parsedAst" :variables="variables" :config="{ applyInlineStyles: false }" />
66
+ ```
67
+
68
+ The renderer supports the LMX presentation nodes used by Loops, including:
69
+
70
+ - headings, paragraphs, quotes, inline formatting, links, and line breaks;
71
+ - buttons, images, dividers, icons, and lazy-loaded media;
72
+ - ordered and unordered lists;
73
+ - sections, columns, reusable components, and conditional sections;
74
+ - safe URL handling, merge-tag resolution, and constrained inline styles.
75
+
76
+ Set `debug: true` during development to show unsupported nodes in the Nuxt
77
+ development overlay. Unsupported content is not rendered as raw HTML.
78
+
79
+ ```vue
80
+ <LoopsRenderer :data="parsedAst" :variables="variables" :config="{ debug: import.meta.dev }" />
81
+ ```
82
+
83
+ ## Configuration
84
+
85
+ Module defaults belong in `nuxt.config.ts` under `loopsRenderer`:
86
+
87
+ ```ts
88
+ export default defineNuxtConfig({
89
+ modules: ["@onderwijsin/nuxt-loops-renderer"],
90
+ loopsRenderer: {
91
+ applyInlineStyles: true,
92
+ evaluate: {
93
+ onMissingVariable: false,
94
+ onInvalidCondition: false,
95
+ onInvalidComparison: false
96
+ }
97
+ }
98
+ });
99
+ ```
100
+
101
+ Available module options are:
102
+
103
+ | Option | Default | Description |
104
+ | ------------------- | --------- | -------------------------------------------------------------- |
105
+ | `enabled` | `true` | Set to `false` to skip runtime registration. |
106
+ | `applyInlineStyles` | `true` | Apply validated LMX presentation attributes as inline styles. |
107
+ | `evaluate` | See above | Fallbacks for missing variables and invalid conditional rules. |
108
+
109
+ The same `applyInlineStyles` and `evaluate` options can be overridden for an
110
+ individual `LoopsRenderer` with its `config` prop. `debug` is a per-renderer
111
+ option and is intended for development diagnostics.
112
+
113
+ Conditional sections use LMX attributes such as `if`, `ifOperation`, and
114
+ `ifValue`. Evaluation never throws; missing variables and invalid conditions
115
+ use the configured fallbacks, which default to `false`.
116
+
117
+ ## Relationship with `@onderwijsin/loops-core`
118
+
119
+ `@onderwijsin/loops-core` is the framework-agnostic foundation. It parses LMX
120
+ into a JSON-serializable AST and provides the shared safety and interpretation
121
+ helpers for:
122
+
123
+ - parsing and component expansion;
124
+ - AST validation;
125
+ - merge-tag and URL resolution;
126
+ - conditional evaluation;
127
+ - supported-node detection and constrained style values.
128
+
129
+ `@onderwijsin/nuxt-loops-renderer` is the presentation layer. It does not
130
+ parse raw LMX, call the Loops API, or provide a general-purpose HTML renderer.
131
+ Instead, it maps a validated core AST to Nuxt/Vue components, applies the
132
+ application’s UI system, and chooses how supported LMX nodes appear on screen.
133
+
134
+ Keep API keys and raw-LMX parsing on a trusted server. Pass only the parsed AST
135
+ and the variables needed by the current presentation to the client renderer.
136
+
137
+ ## Compatibility
138
+
139
+ - Nuxt 4
140
+ - Node.js 22 or newer
141
+
142
+ ## License
143
+
144
+ MIT
@@ -0,0 +1,18 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ import { EvaluateLoopsLmxOptions } from '@onderwijsin/loops-core';
3
+
4
+ interface ModuleOptions {
5
+ /** Indicates whether the module should register its runtime features. */
6
+ enabled?: boolean;
7
+ /** Enables inline styles derived from LMX node attributes by default. */
8
+ applyInlineStyles?: boolean;
9
+ /** Fallbacks used when conditional Section rules cannot be evaluated. */
10
+ evaluate?: EvaluateLoopsLmxOptions;
11
+ }
12
+
13
+ /**
14
+ * Provides the Nuxt runtime foundation for rendering Loops LMX email content.
15
+ */
16
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
17
+
18
+ export { _default as default };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@onderwijsin/nuxt-loops-renderer",
3
+ "configKey": "loopsRenderer",
4
+ "version": "0.2.0",
5
+ "compatibility": {
6
+ "nuxt": "^4.0.0"
7
+ },
8
+ "builder": {
9
+ "@nuxt/module-builder": "1.0.3",
10
+ "unbuild": "3.6.1"
11
+ }
12
+ }
@@ -0,0 +1,123 @@
1
+ import { defineNuxtModule, useLogger, createResolver, addComponentsDir } from '@nuxt/kit';
2
+
3
+ var NUMBER_CHAR_RE = /\d/;
4
+ var STR_SPLITTERS = ["-", "_", "/", "."];
5
+ function isUppercase(char = "") {
6
+ if (NUMBER_CHAR_RE.test(char)) {
7
+ return void 0;
8
+ }
9
+ return char !== char.toLowerCase();
10
+ }
11
+ function splitByCase(str, separators) {
12
+ const splitters = STR_SPLITTERS;
13
+ const parts = [];
14
+ let buff = "";
15
+ let previousUpper;
16
+ let previousSplitter;
17
+ for (const char of str) {
18
+ const isSplitter = splitters.includes(char);
19
+ if (isSplitter === true) {
20
+ parts.push(buff);
21
+ buff = "";
22
+ previousUpper = void 0;
23
+ continue;
24
+ }
25
+ const isUpper = isUppercase(char);
26
+ if (previousSplitter === false) {
27
+ if (previousUpper === false && isUpper === true) {
28
+ parts.push(buff);
29
+ buff = char;
30
+ previousUpper = isUpper;
31
+ continue;
32
+ }
33
+ if (previousUpper === true && isUpper === false && buff.length > 1) {
34
+ const lastChar = buff.at(-1);
35
+ parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
36
+ buff = lastChar + char;
37
+ previousUpper = isUpper;
38
+ continue;
39
+ }
40
+ }
41
+ buff += char;
42
+ previousUpper = isUpper;
43
+ previousSplitter = isSplitter;
44
+ }
45
+ parts.push(buff);
46
+ return parts;
47
+ }
48
+ function kebabCase(str, joiner) {
49
+ return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join("-") : "";
50
+ }
51
+ function resolveModuleName(moduleKey) {
52
+ return `@onderwijsin/nuxt-${kebabCase(moduleKey)}`;
53
+ }
54
+ function resolveLoggerScope(moduleKey) {
55
+ return kebabCase(moduleKey);
56
+ }
57
+ function moduleSetup(MODULE_NAME, options, log) {
58
+ const start = () => {
59
+ log.start(`Loading module ${MODULE_NAME}`);
60
+ };
61
+ const end = () => {
62
+ log.success(`Module ${MODULE_NAME} Loaded`);
63
+ };
64
+ const isEnabled = () => {
65
+ if ("enabled" in options && options.enabled === false) {
66
+ log.info(`Module ${MODULE_NAME} is disabled. Skipping setup...`);
67
+ return false;
68
+ }
69
+ return true;
70
+ };
71
+ return {
72
+ start,
73
+ end,
74
+ isEnabled
75
+ };
76
+ }
77
+
78
+ const version = "0.2.0";
79
+
80
+ const MODULE_KEY = "loopsRenderer";
81
+ const MODULE_NAME = resolveModuleName(MODULE_KEY);
82
+ const module$1 = defineNuxtModule({
83
+ meta: {
84
+ name: MODULE_NAME,
85
+ configKey: MODULE_KEY,
86
+ version,
87
+ compatibility: {
88
+ nuxt: "^4.0.0"
89
+ }
90
+ },
91
+ defaults: {
92
+ applyInlineStyles: true
93
+ },
94
+ moduleDependencies: {
95
+ "@nuxt/ui": {
96
+ version: ">=4.0.0"
97
+ }
98
+ },
99
+ setup(options, nuxt) {
100
+ const log = useLogger(resolveLoggerScope(MODULE_KEY));
101
+ const { start, end, isEnabled } = moduleSetup(MODULE_NAME, options, log);
102
+ start();
103
+ if (!isEnabled()) {
104
+ return;
105
+ }
106
+ nuxt.options.appConfig.loopsRenderer = {
107
+ applyInlineStyles: options.applyInlineStyles ?? true
108
+ };
109
+ Object.assign(nuxt.options.appConfig.loopsRenderer, {
110
+ evaluate: options.evaluate
111
+ });
112
+ const resolver = createResolver(import.meta.url);
113
+ const runtimeDir = resolver.resolve("./runtime");
114
+ nuxt.options.build.transpile.push(runtimeDir);
115
+ addComponentsDir({
116
+ path: resolver.resolve(runtimeDir, "app", "components"),
117
+ pathPrefix: false
118
+ });
119
+ end();
120
+ }
121
+ });
122
+
123
+ export { module$1 as default };
@@ -0,0 +1,11 @@
1
+ import { type LoopsLmxAst, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../types.js";
3
+ type __VLS_Props = {
4
+ /** Parsed LMX component tree received from the public campaign-detail API. */
5
+ data: LoopsLmxAst;
6
+ variables: LoopsLmxVariables;
7
+ config?: LoopsRendererConfig;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,60 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import {
4
+ loopsLmxAstSchema,
5
+ getUnsupportedLoopsLmxNodes,
6
+ hasRenderableLoopsLmxNodes,
7
+ hasUnsupportedLoopsLmxNodes
8
+ } from "@onderwijsin/loops-core";
9
+ import { useAppConfig } from "nuxt/app";
10
+ import { createLoopsRendererConfig, hasRendererSpecificContent } from "../utils/renderer";
11
+ const props = defineProps({
12
+ data: { type: Object, required: true },
13
+ variables: { type: Object, required: true },
14
+ config: { type: Object, required: false }
15
+ });
16
+ const appConfig = useAppConfig();
17
+ const rendererConfig = computed(
18
+ () => createLoopsRendererConfig(props.config, appConfig.loopsRenderer)
19
+ );
20
+ const parsedContent = computed(() => loopsLmxAstSchema.safeParse(props.data));
21
+ const ast = computed(() => parsedContent.value.success ? parsedContent.value.data : null);
22
+ const hasRenderableContent = computed(
23
+ () => ast.value !== null && (hasRenderableLoopsLmxNodes(ast.value.children) || hasRendererSpecificContent(ast.value.children))
24
+ );
25
+ const hasUnsupportedContent = computed(
26
+ () => ast.value !== null && hasUnsupportedLoopsLmxNodes(ast.value.children)
27
+ );
28
+ const unsupportedNodes = computed(
29
+ () => ast.value === null ? [] : getUnsupportedLoopsLmxNodes(ast.value.children)
30
+ );
31
+ </script>
32
+
33
+ <template>
34
+ <div v-if="hasRenderableContent && ast" class="prose dark:prose-invert campaign-renderer">
35
+ <LoopsAstNode
36
+ v-for="(node, index) in ast.children"
37
+ :key="index"
38
+ :node="node"
39
+ :variables="variables"
40
+ :config="rendererConfig"
41
+ />
42
+ </div>
43
+ <DevOnly v-if="config?.debug">
44
+ <LoopsAstUnsupportedNodes
45
+ v-if="hasUnsupportedContent"
46
+ :nodes="unsupportedNodes"
47
+ :config="rendererConfig"
48
+ />
49
+ </DevOnly>
50
+ </template>
51
+
52
+ <style lang="postcss">
53
+ /* Remove margin top on first element */
54
+ .campaign-renderer > *:first-child {
55
+ margin-top: 0;
56
+ & > *:first-child {
57
+ margin-top: 0;
58
+ }
59
+ }
60
+ </style>
@@ -0,0 +1,11 @@
1
+ import { type LoopsLmxAst, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../types.js";
3
+ type __VLS_Props = {
4
+ /** Parsed LMX component tree received from the public campaign-detail API. */
5
+ data: LoopsLmxAst;
6
+ variables: LoopsLmxVariables;
7
+ config?: LoopsRendererConfig;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { type LoopsLmxElement, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../../types.js";
3
+ type __VLS_Props = {
4
+ /** Raw LMX code content; merge tags intentionally remain literal inside code blocks. */
5
+ node: LoopsLmxElement;
6
+ variables: LoopsLmxVariables;
7
+ config: LoopsRendererConfig;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ import {
3
+ applyInlineStyles
4
+ } from "@onderwijsin/loops-core";
5
+ defineProps({
6
+ node: { type: Object, required: true },
7
+ variables: { type: Object, required: true },
8
+ config: { type: Object, required: true }
9
+ });
10
+ </script>
11
+
12
+ <template>
13
+ <pre
14
+ :style="applyInlineStyles(node.attributes, config.applyInlineStyles !== false)"
15
+ ><code><LoopsAstInline
16
+ v-for="(child, index) in node.children"
17
+ :key="index"
18
+ :node="child"
19
+ :variables="variables"
20
+ :config="config"
21
+ :resolve-variables="false"
22
+ /></code></pre>
23
+ </template>
@@ -0,0 +1,11 @@
1
+ import { type LoopsLmxElement, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../../types.js";
3
+ type __VLS_Props = {
4
+ /** Raw LMX code content; merge tags intentionally remain literal inside code blocks. */
5
+ node: LoopsLmxElement;
6
+ variables: LoopsLmxVariables;
7
+ config: LoopsRendererConfig;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,11 @@
1
+ import { type LoopsLmxElement, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../../types.js";
3
+ type __VLS_Props = {
4
+ /** Component nodes contain already-expanded LMX children from the archival parser. */
5
+ node: LoopsLmxElement;
6
+ variables: LoopsLmxVariables;
7
+ config: LoopsRendererConfig;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,22 @@
1
+ <script setup>
2
+ import {
3
+ applyInlineStyles
4
+ } from "@onderwijsin/loops-core";
5
+ defineProps({
6
+ node: { type: Object, required: true },
7
+ variables: { type: Object, required: true },
8
+ config: { type: Object, required: true }
9
+ });
10
+ </script>
11
+
12
+ <template>
13
+ <div :style="applyInlineStyles(node.attributes, config.applyInlineStyles !== false)">
14
+ <LoopsAstNode
15
+ v-for="(child, index) in node.children"
16
+ :key="index"
17
+ :node="child"
18
+ :variables="variables"
19
+ :config="config"
20
+ />
21
+ </div>
22
+ </template>
@@ -0,0 +1,11 @@
1
+ import { type LoopsLmxElement, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../../types.js";
3
+ type __VLS_Props = {
4
+ /** Component nodes contain already-expanded LMX children from the archival parser. */
5
+ node: LoopsLmxElement;
6
+ variables: LoopsLmxVariables;
7
+ config: LoopsRendererConfig;
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { type LoopsLmxElement, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../../types.js";
3
+ type __VLS_Props = {
4
+ node: LoopsLmxElement;
5
+ variables: LoopsLmxVariables;
6
+ config: LoopsRendererConfig;
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,53 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import {
4
+ getLoopsLmxPixels,
5
+ resolveSafeLoopsLmxUrl,
6
+ applyInlineStyles
7
+ } from "@onderwijsin/loops-core";
8
+ const props = defineProps({
9
+ node: { type: Object, required: true },
10
+ variables: { type: Object, required: true },
11
+ config: { type: Object, required: true }
12
+ });
13
+ const icons = computed(
14
+ () => (props.node.name === "Icon" ? [props.node] : props.node.children).flatMap((node) => {
15
+ if (node.type !== "element" || node.name !== "Icon") return [];
16
+ const name = getIconName(node.attributes.name);
17
+ return name ? [{ name, href: resolveSafeLoopsLmxUrl(node.attributes.href, props.variables, "link") }] : [];
18
+ })
19
+ );
20
+ const style = computed(() => ({
21
+ display: "flex",
22
+ gap: `${getLoopsLmxPixels(props.node.attributes.gap, 0, 200) ?? 16}px`,
23
+ fontSize: `${getLoopsLmxPixels(props.node.attributes.size, 18, 48) ?? 24}px`,
24
+ ...applyInlineStyles(props.node.attributes, props.config.applyInlineStyles !== false)
25
+ }));
26
+ function getIconName(name) {
27
+ return {
28
+ "square-facebook": "i-simple-icons-facebook",
29
+ facebook: "i-simple-icons-facebook",
30
+ "square-x-twitter": "i-simple-icons-x",
31
+ twitter: "i-simple-icons-x",
32
+ linkedin: "i-simple-icons-linkedin",
33
+ instagram: "i-simple-icons-instagram",
34
+ youtube: "i-simple-icons-youtube",
35
+ github: "i-simple-icons-github",
36
+ discord: "i-simple-icons-discord",
37
+ envelope: "i-lucide-mail",
38
+ link: "i-lucide-link",
39
+ phone: "i-lucide-phone"
40
+ }[name ?? ""] ?? null;
41
+ }
42
+ </script>
43
+
44
+ <template>
45
+ <div v-if="icons.length" :style="style">
46
+ <template v-for="(icon, index) in icons" :key="index">
47
+ <a v-if="icon.href" :href="icon.href">
48
+ <UIcon :name="icon.name" />
49
+ </a>
50
+ <UIcon v-else :name="icon.name" />
51
+ </template>
52
+ </div>
53
+ </template>
@@ -0,0 +1,10 @@
1
+ import { type LoopsLmxElement, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../../types.js";
3
+ type __VLS_Props = {
4
+ node: LoopsLmxElement;
5
+ variables: LoopsLmxVariables;
6
+ config: LoopsRendererConfig;
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { type LoopsLmxNode, type LoopsLmxVariables } from "@onderwijsin/loops-core";
2
+ import type { LoopsRendererConfig } from "../../../types.js";
3
+ type __VLS_Props = {
4
+ node: LoopsLmxNode;
5
+ variables: LoopsLmxVariables;
6
+ config: LoopsRendererConfig;
7
+ /** Code blocks treat merge tags literally, as required by the LMX specification. */
8
+ resolveVariables?: boolean;
9
+ };
10
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
+ declare const _default: typeof __VLS_export;
12
+ export default _default;
@@ -0,0 +1,62 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import {
4
+ resolveSafeLoopsLmxUrl,
5
+ resolveLoopsLmxVariables,
6
+ applyInlineStyles
7
+ } from "@onderwijsin/loops-core";
8
+ const props = defineProps({
9
+ node: { type: Object, required: true },
10
+ variables: { type: Object, required: true },
11
+ config: { type: Object, required: true },
12
+ resolveVariables: { type: Boolean, required: false }
13
+ });
14
+ const resolvedText = computed(
15
+ () => props.node.type === "text" ? props.resolveVariables === false ? props.node.value : resolveLoopsLmxVariables(props.node.value, props.variables) : ""
16
+ );
17
+ const link = computed(
18
+ () => props.node.type === "element" ? resolveSafeLoopsLmxUrl(props.node.attributes.href, props.variables, "link") : null
19
+ );
20
+ const inlineTag = computed(() => {
21
+ if (props.node.type !== "element") return null;
22
+ return {
23
+ Strong: "strong",
24
+ Em: "em",
25
+ Underline: "u",
26
+ Strike: "s",
27
+ Code: "code",
28
+ Text: "span"
29
+ }[props.node.name];
30
+ });
31
+ const style = computed(
32
+ () => applyInlineStyles(
33
+ props.node.type === "element" ? props.node.attributes : {},
34
+ props.config.applyInlineStyles !== false
35
+ )
36
+ );
37
+ </script>
38
+
39
+ <template>
40
+ <template v-if="node.type === 'text'">{{ resolvedText }}</template>
41
+ <br v-else-if="node.type === 'element' && node.name === 'Br'" />
42
+ <a v-else-if="node.name === 'Link' && link" :href="link" rel="noopener noreferrer" :style="style">
43
+ <LoopsAstNode
44
+ v-for="(child, index) in node.children"
45
+ :key="index"
46
+ :node="child"
47
+ :variables="variables"
48
+ :config="config"
49
+ :resolve-variables="resolveVariables"
50
+ />
51
+ </a>
52
+ <component v-else-if="inlineTag" :is="inlineTag" :style="style">
53
+ <LoopsAstNode
54
+ v-for="(child, index) in node.children"
55
+ :key="index"
56
+ :node="child"
57
+ :variables="variables"
58
+ :config="config"
59
+ :resolve-variables="resolveVariables"
60
+ />
61
+ </component>
62
+ </template>