|
1 | 1 | import type { Spec } from '@devframes/json-render' |
2 | 2 | import type { Meta, StoryObj } from '@storybook/vue3-vite' |
3 | 3 | import { h } from 'vue' |
| 4 | +import { baseRegistry } from './registry' |
4 | 5 | import { JsonRenderView } from './renderer' |
5 | 6 |
|
6 | 7 | // A no-op RPC — stories don't dispatch real actions. |
@@ -74,3 +75,31 @@ export const InvalidElement: StoryObj = story({ |
74 | 75 | bad: { type: 'Badge', props: { variant: 'purple' }, children: [] }, |
75 | 76 | }, |
76 | 77 | }) |
| 78 | + |
| 79 | +// An element whose `type` is absent from the registry renders behind the |
| 80 | +// unsupported placeholder (type + prop-keys gist), while its siblings render. |
| 81 | +export const UnsupportedComponent: StoryObj = story({ |
| 82 | + root: 'root', |
| 83 | + elements: { |
| 84 | + root: { type: 'Stack', props: { gap: 8 }, children: ['ok', 'chart', 'more'] }, |
| 85 | + ok: { type: 'Text', props: { text: 'This view uses a component the frontend does not ship.' }, children: [] }, |
| 86 | + chart: { type: 'Fancy3DChart', props: { data: [1, 2, 3], title: 'Revenue', animate: true }, children: [] }, |
| 87 | + more: { type: 'Badge', props: { text: 'still renders', variant: 'success' }, children: [] }, |
| 88 | + }, |
| 89 | +}) |
| 90 | + |
| 91 | +// A frontend that supports only a subset of the catalog: rendering with a |
| 92 | +// registry missing `DataTable` placeholders that element, everything else |
| 93 | +// renders normally. |
| 94 | +const { DataTable: _omitted, ...subsetRegistry } = baseRegistry as Record<string, unknown> |
| 95 | +export const SubsetRegistry: StoryObj = story( |
| 96 | + { |
| 97 | + root: 'root', |
| 98 | + elements: { |
| 99 | + root: { type: 'Stack', props: { gap: 8 }, children: ['title', 'table'] }, |
| 100 | + title: { type: 'Text', props: { text: 'Registry without DataTable', variant: 'heading' }, children: [] }, |
| 101 | + table: { type: 'DataTable', props: { rows: [{ id: 1, name: 'a' }], height: 120 }, children: [] }, |
| 102 | + }, |
| 103 | + }, |
| 104 | + { registry: subsetRegistry }, |
| 105 | +) |
0 commit comments