From ce513296cdd88a5110809c30994e1fe85c7b29ef Mon Sep 17 00:00:00 2001 From: LeighF Date: Tue, 27 Jan 2026 22:39:40 +0000 Subject: [PATCH] fix(calm-widgets): render primitive arrays inline with comma separator for MDX compatibility (#2080) --- calm-plugins/vscode/package.json | 2 +- calm-widgets/src/widgets.e2e.spec.ts | 9 +++++++ .../src/widgets/table/row-template.html | 2 +- .../src/widgets/table/table-vertical.html | 3 +-- .../comprehensive-documentation/expected.md | 8 +++---- .../metadata-primitive-array/context.json | 7 ++++++ .../metadata-primitive-array/expected.md | 24 +++++++++++++++++++ .../metadata-primitive-array/template.hbs | 1 + .../expected-output/widget-tests/sad-test.md | 4 ++-- .../widget-tests/table-test.md | 4 ++-- package-lock.json | 2 +- 11 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 calm-widgets/test-fixtures/table-widget/metadata-primitive-array/context.json create mode 100644 calm-widgets/test-fixtures/table-widget/metadata-primitive-array/expected.md create mode 100644 calm-widgets/test-fixtures/table-widget/metadata-primitive-array/template.hbs diff --git a/calm-plugins/vscode/package.json b/calm-plugins/vscode/package.json index 15c240efa..7fc68c5ef 100644 --- a/calm-plugins/vscode/package.json +++ b/calm-plugins/vscode/package.json @@ -2,7 +2,7 @@ "name": "calm-vscode-plugin", "displayName": "CALM", "description": "Live-visualize CALM architecture models, validate, and generate docs.", - "version": "0.4.1", + "version": "0.4.2", "publisher": "FINOS", "homepage": "https://calm.finos.org", "repository": { diff --git a/calm-widgets/src/widgets.e2e.spec.ts b/calm-widgets/src/widgets.e2e.spec.ts index 5113babf7..662ad9ed6 100644 --- a/calm-widgets/src/widgets.e2e.spec.ts +++ b/calm-widgets/src/widgets.e2e.spec.ts @@ -96,6 +96,15 @@ describe('Widgets E2E - Handlebars Integration', () => { expectToBeSameIgnoringLineEndings(result, expected); }); + + it('renders primitive arrays inline with comma separator (MDX-safe)', () => { + const { context, template, expected } = fixtures.loadFixture('table-widget', 'metadata-primitive-array'); + + const compiledTemplate = handlebars.compile(template); + const result = compiledTemplate(context); + + expectToBeSameIgnoringLineEndings(result, expected); + }); }); describe('List Widget', () => { diff --git a/calm-widgets/src/widgets/table/row-template.html b/calm-widgets/src/widgets/table/row-template.html index 539d1bf34..1de90e9be 100644 --- a/calm-widgets/src/widgets/table/row-template.html +++ b/calm-widgets/src/widgets/table/row-template.html @@ -18,7 +18,7 @@ {{> table-template.html rows=(objectEntries this) headers=false flatTable=false hasRows=true isNested=true}} {{else}} - {{this}} + {{this}}{{#unless @last}}, {{/unless}} {{/if}} {{/each}} {{else}} diff --git a/calm-widgets/src/widgets/table/table-vertical.html b/calm-widgets/src/widgets/table/table-vertical.html index 7c994ec75..bf08188c5 100644 --- a/calm-widgets/src/widgets/table/table-vertical.html +++ b/calm-widgets/src/widgets/table/table-vertical.html @@ -18,8 +18,7 @@ {{> table-template.html rows=(objectEntries cellValue) headers=false flatTable=false hasRows=true isNested=true}} {{else if (isArray cellValue)}}{{#each cellValue}}{{#if (isObject this)}} {{> table-template.html rows=(objectEntries this) headers=false flatTable=false hasRows=true isNested=true}} - {{else}}{{this}} - {{/if}}{{/each}}{{else}}{{cellValue}}{{/if}} + {{else}}{{this}}{{#unless @last}}, {{/unless}}{{/if}}{{/each}}{{else}}{{cellValue}}{{/if}} {{/with}} {{/with}} diff --git a/calm-widgets/test-fixtures/combined-widgets/comprehensive-documentation/expected.md b/calm-widgets/test-fixtures/combined-widgets/comprehensive-documentation/expected.md index 6eaca420d..2b89cb862 100644 --- a/calm-widgets/test-fixtures/combined-widgets/comprehensive-documentation/expected.md +++ b/calm-widgets/test-fixtures/combined-widgets/comprehensive-documentation/expected.md @@ -184,8 +184,8 @@ Value - Product Catalog - Inventory Management + Product Catalog, + Inventory Management, Price Calculation @@ -347,8 +347,8 @@ Value - Order Processing - Payment Integration + Order Processing, + Payment Integration, Order Tracking diff --git a/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/context.json b/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/context.json new file mode 100644 index 000000000..76d8d6ff6 --- /dev/null +++ b/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/context.json @@ -0,0 +1,7 @@ +{ + "metadata": { + "operations": ["add", "subtract", "multiply", "divide"], + "tags": ["payment", "financial", "api"], + "version": "1.0.0" + } +} \ No newline at end of file diff --git a/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/expected.md b/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/expected.md new file mode 100644 index 000000000..fa83147d9 --- /dev/null +++ b/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/expected.md @@ -0,0 +1,24 @@ +
+ + + + + + + + + + + + + + + + + + + + + +
KeyValue
Operationsadd, subtract, multiply, divide
Tagspayment, financial, api
Version1.0.0
+
\ No newline at end of file diff --git a/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/template.hbs b/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/template.hbs new file mode 100644 index 000000000..c256aaa64 --- /dev/null +++ b/calm-widgets/test-fixtures/table-widget/metadata-primitive-array/template.hbs @@ -0,0 +1 @@ +{{table metadata orientation="vertical"}} \ No newline at end of file diff --git a/cli/test_fixtures/template/expected-output/widget-tests/sad-test.md b/cli/test_fixtures/template/expected-output/widget-tests/sad-test.md index 7c9726a80..baf9319a5 100644 --- a/cli/test_fixtures/template/expected-output/widget-tests/sad-test.md +++ b/cli/test_fixtures/template/expected-output/widget-tests/sad-test.md @@ -942,8 +942,8 @@ The system follows a microservices architecture pattern deployed on Kubernetes, Nodes - load-balancer - attendees + load-balancer, + attendees, attendees-store diff --git a/cli/test_fixtures/template/expected-output/widget-tests/table-test.md b/cli/test_fixtures/template/expected-output/widget-tests/table-test.md index 286ffead7..b3ff61a7c 100644 --- a/cli/test_fixtures/template/expected-output/widget-tests/table-test.md +++ b/cli/test_fixtures/template/expected-output/widget-tests/table-test.md @@ -911,8 +911,8 @@ url-to-local-file-mapping: ../../../getting-started/url-to-local-file-mapping.js Nodes - load-balancer - attendees + load-balancer, + attendees, attendees-store diff --git a/package-lock.json b/package-lock.json index 5c05c61b5..c25e5a35e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -569,7 +569,7 @@ }, "calm-plugins/vscode": { "name": "calm-vscode-plugin", - "version": "0.4.0", + "version": "0.4.2", "dependencies": { "@finos/calm-models": "file:../../calm-models", "@finos/calm-shared": "file:../../shared",