Hey @sdirix ,
Iām trying to create stories for each of my custom renderers. Iām starting with a very basic custom renderer that is only a text field. I created a base template that would be the wrapper for each story:
import type { JsonFormsProps, JsonFormsRendererRegistryEntry } from '@jsonforms/core'
import { JsonForms } from '@jsonforms/vue';
import { markRaw } from 'vue';
import { StoryObj } from '@storybook/vue3'
// various imports of custom renderers
export type JsonFormsTemplateProps = JsonFormsProps & {
data: Record<string, unknown> | Array<unknown>;
onChange: (ev: { data: Record<string, unknown> }) => void;
};
export type JsonFormsTemplate = StoryObj<JsonFormsTemplateProps>;
const renderers: JsonFormsRendererRegistryEntry[] = markRaw([
// ...rendererList
])
export const jsonFormsTemplate: JsonFormsTemplate = (args: any) => ({
render: (args: any) => ({
components: { JsonForms },
setup () {
args.renderers = markRaw(renderers);
return { args }
},
template: '<json-forms v-bind="args" />',
}),
});
Then I have the story for the custom renderer:
import type { Meta, StoryObj } from '@storybook/vue3'
import { jsonFormsTemplate } from '~/.storybook/jsonFormsTemplate'
// More on how to set up stories at: https://storybook.js.org/docs/vue/writing-stories/introduction
const meta: Meta = {
// This component will have an automatically generated docsPage
// entry: https://storybook.js.org/docs/vue/writing-docs/autodocs
tags: ['autodocs'],
args: {
schema: {
type: 'object',
unevaluatedProperties: false,
properties: {
'/personal/email': { title: 'Email', description: 'Email address', type: 'string', format: 'email' },
},
required: ['/personal/email'],
},
uischema: { type: 'Control', scope: '#/properties/~1personal~1email', options: {} },
path: '',
}, // default value
} satisfies Meta
export default meta
/*
*š Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/vue/api/csf
* to learn how to use render functions.
*/
export const Primary: StoryObj = jsonFormsTemplate.bind({})
Primary.args = {
schema: {
type: 'object',
unevaluatedProperties: false,
properties: {
'/personal/email': { title: 'Email', description: 'Email address', type: 'string', format: 'email' },
},
required: ['/personal/email'],
},
uischema: { type: 'Control', scope: '#/properties/~1personal~1email', options: {} },
path: '',
}
Iām getting the following error when opening Storybook and trying to view to story:
TypeError: Failed to fetch dynamically imported module: http://localhost:6006/components/renderers/RenderText.stories.ts?t=1693226780278