11import type { Meta , StoryObj } from '@storybook/react' ;
2- import { SchemaRenderer } from '../SchemaRenderer' ;
2+ import { SchemaRenderer , SchemaRendererProvider } from '@object-ui/react' ;
3+ import type { BaseSchema } from '@object-ui/types' ;
4+ import { createStorybookDataSource } from '@storybook-config/datasource' ;
35
46const meta : Meta = {
57 title : 'Components/Table' ,
@@ -13,6 +15,15 @@ const meta: Meta = {
1315export default meta ;
1416type Story = StoryObj < typeof meta > ;
1517
18+ // Create a DataSource instance that connects to MSW
19+ const dataSource = createStorybookDataSource ( ) ;
20+
21+ const renderStory = ( args : any ) => (
22+ < SchemaRendererProvider dataSource = { dataSource } >
23+ < SchemaRenderer schema = { args as unknown as BaseSchema } />
24+ </ SchemaRendererProvider >
25+ ) ;
26+
1627export const DataTable : Story = {
1728 args : {
1829 type : 'data-table' ,
@@ -29,7 +40,7 @@ export const DataTable: Story = {
2940 { id : 3 , name : 'Bob Johnson' , email : 'bob@example.com' , role : 'User' }
3041 ]
3142 } ,
32- render : ( args ) => < SchemaRenderer schema = { args } />
43+ render : renderStory
3344} ;
3445
3546export const FullFeatures : Story = {
@@ -56,7 +67,7 @@ export const FullFeatures: Story = {
5667 method : i % 2 === 0 ? 'Credit Card' : 'PayPal'
5768 } ) )
5869 } ,
59- render : ( args ) => < SchemaRenderer schema = { args } />
70+ render : renderStory
6071 } ;
6172
6273export const EditableTable : Story = {
@@ -83,7 +94,7 @@ export const EditableTable: Story = {
8394 alert ( `Updated ${ columnKey } to "${ newValue } " for ${ row . name } ` ) ;
8495 }
8596 } ,
86- render : ( args ) => < SchemaRenderer schema = { args } />
97+ render : renderStory
8798 } ;
8899
89100export const BatchEditTable : Story = {
@@ -120,6 +131,6 @@ export const BatchEditTable: Story = {
120131 alert ( `✓ Batch saved ${ allChanges . length } rows:\n\n${ summary } ` ) ;
121132 }
122133 } ,
123- render : ( args ) => < SchemaRenderer schema = { args } />
134+ render : renderStory
124135 } ;
125136
0 commit comments