Skip to content

Commit 33c9eab

Browse files
Copilothotlong
andcommitted
Fix SchemaRendererProvider missing in data-table stories
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 5830eff commit 33c9eab

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

packages/components/src/stories-json/data-table.stories.tsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 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

46
const meta: Meta = {
57
title: 'Components/Table',
@@ -13,6 +15,15 @@ const meta: Meta = {
1315
export default meta;
1416
type 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+
1627
export 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

3546
export 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

6273
export 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

89100
export 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

Comments
 (0)