-
Notifications
You must be signed in to change notification settings - Fork 600
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: React config component composition (#27899)
Co-authored-by: alexlavrov <[email protected]>
- Loading branch information
1 parent
c58ae9a
commit 7c8dee5
Showing
95 changed files
with
16,581 additions
and
12,264 deletions.
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
apps/react-storybook/stories/examples/common/CustomConfigurationComponents.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import React from "react"; | ||
|
||
import DataGrid, { | ||
Column, | ||
Grouping, | ||
GroupPanel, | ||
Pager, | ||
Paging, | ||
SearchPanel | ||
} from "devextreme-react/data-grid"; | ||
import TabPanel, { Item } from "devextreme-react/tab-panel"; | ||
import ODataStore from "devextreme/data/odata/store"; | ||
|
||
const meta: Meta<typeof DataGrid> = { | ||
title: 'Example/Common/Custom Configuration Components', | ||
component: DataGrid, | ||
parameters: { | ||
// More on Story layout: https://storybook.js.org/docs/configure/story-layout | ||
layout: 'padded', | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof DataGrid>; | ||
|
||
const pageSizes = [10, 25, 50, 100]; | ||
|
||
const dataSourceOptions = { | ||
store: new ODataStore({ | ||
version: 2, | ||
url: 'https://js.devexpress.com/Demos/SalesViewer/odata/DaySaleDtoes', | ||
key: 'Id', | ||
beforeSend(request) { | ||
const year = new Date().getFullYear() - 1; | ||
request.params.startDate = `${year}-05-10`; | ||
request.params.endDate = `${year}-5-15`; | ||
}, | ||
}), | ||
}; | ||
|
||
const CustomerData = () => ( | ||
<> | ||
<Column dataField="Region" dataType="string" /> | ||
<Column dataField="Customer" dataType="string" width={150} /> | ||
</> | ||
); | ||
|
||
const CommonSettings = () => ( | ||
<> | ||
<GroupPanel visible={true} /> | ||
<SearchPanel visible={true} highlightCaseSensitive={true} /> | ||
<Grouping autoExpandAll={false} /> | ||
<Pager allowedPageSizes={pageSizes} showPageSizeSelector={true} /> | ||
<Paging defaultPageSize={10} /> | ||
</> | ||
); | ||
|
||
const CommonColumns = () => ( | ||
<> | ||
<Column dataField="SaleDate" dataType="date" /> | ||
<Column dataField="Product" /> | ||
</> | ||
); | ||
|
||
const BriefGrid = () => ( | ||
<DataGrid | ||
dataSource={dataSourceOptions} | ||
style={{ padding: '10px' }} | ||
> | ||
<CommonSettings /> | ||
<CommonColumns /> | ||
<CustomerData /> | ||
</DataGrid> | ||
); | ||
|
||
const DetailGrid = () => ( | ||
<DataGrid | ||
dataSource={dataSourceOptions} | ||
style={{ padding: '10px' }} | ||
> | ||
<CommonSettings /> | ||
<CommonColumns /> | ||
<Column | ||
dataField="Amount" | ||
caption="Sale Amount" | ||
dataType="number" | ||
format="currency" | ||
alignment="right" | ||
/> | ||
<Column | ||
dataField="Discount" | ||
caption="Discount %" | ||
dataType="number" | ||
format="percent" | ||
alignment="right" | ||
allowGrouping={false} | ||
cssClass="bullet" | ||
/> | ||
<Column caption='Customer Data'> | ||
<CustomerData /> | ||
<Column dataField="Sector" dataType="string" /> | ||
<Column dataField="Channel" dataType="string" /> | ||
</Column> | ||
</DataGrid> | ||
); | ||
|
||
export const Overview: Story = { | ||
render: () => { | ||
return ( | ||
<TabPanel> | ||
<Item title="Brief"> | ||
<BriefGrid /> | ||
</Item> | ||
<Item title="Detailed"> | ||
<DetailGrid /> | ||
</Item> | ||
</TabPanel> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.